[plt-dev] Inexact integers

From: Jos Koot (jos.koot at telefonica.net)
Date: Tue May 25 15:22:39 EDT 2010

My remarks: see ===

-----Original Message-----
From: eval.apply at gmail.com [mailto:eval.apply at gmail.com] On Behalf Of Joe
Sent: 25 May 2010 20:46
To: Jos Koot
Cc: Michael Sperber; plt-dev at list.cs.brown.edu
Subject: Re: [plt-dev] Inexact integers

On Tue, May 25, 2010 at 10:59 AM, Jos Koot <jos.koot at telefonica.net> wrote:
> My 2 cents,
> The word 'real' means quite another thing in mathematics than in a
> programming language. That may be unlucky, but as a programmer you soon
> out the distinction.

So true.

> Whatever presentation you select, all machine presentable numbers
> are exact, in principle.

I don't know what this could mean.  You're not suggesting that we could
not represent inexact numbers, I hope.

=== This is a matter of definition of exact an inexact. Within the hardware
everything is exact as long as not exceeding limits of memory. This does not
imply that the things represented by the hardware are exact. This decision
is to be made y the programmer.

> We adorn a number with the
> predicate 'inexact' if it was fed into the program as inexact (for example
> datum retrieved from inexact measurements) or if it is the result of a
> function (such as log) that can at best produce an (internally exact)
> close the exact value.

What about log2 of 65536?

=== That depends on representation of numbers and the implementation of

> In PLT Scheme, now Racket, all reals are rationals.
> This is a reasonable choice, I think. But let's not forget that it is
> possible to represent sets of numbers that in meaning (not in cardinality,
> for each representation is necessarily countably finite and in practice
> finite) may be approximations of irrational numbers. It is possible to
> represents sets of numbers that include non rational reals (in
> sense), for example by representing a number by a sign followed by a
> list of exponents of the prime factors of the square of the number (as can
> be useful in group theory) Also notice that number like pi gamma and e can
> be represented exactly (just by their names) In general computations with
> these numbers cannot be exact, although I can imagine a system in which
> (expt e (* 2 pi)) -> the exact integer 1 and (log e) -> exact 1.

There are ways of representing pi, e, and other computable reals `exactly'.
One method is to use continued fractions.

> I can think of three reasons of adorning the representation of a number
> the predicate inexact:
> 1: it was produced by a function that cannot compute the exact value in
> any available representation within finite memory.

What do you do in the case that a function that can in many but not all
produce an exact value in finite memory?

=== That is a very good question. I am afraid this is an unsolvable
question. We already know that some questions cannot consistently be
answered by mathematics.

> 2: it was entered in the program as an approximation (for example a
> measurement)

Why would this matter?  Why would I treat an input approximation
any differently from other numbers?

=== Because in this case two entries that consist of the same characters
figures cannot be trusted to be equal in exact sense.

> 3: There is an approximate inexact representation that allows enough
> precision but enhances speed by using floating point hardware.

What do you do if the floating point hardware can in fact produce correct
exact answers fast?  How can you tell if rounding did or did not occur?

=== This is a non issue I think. Where we can, we should within practical
limits compute exactly, but once leaving exactness, the question whether or
not a result is exact is  not relevant. The representation of the result
should indicate whether or not he answer is certainly exact or may be

> I must say I am rather satisfied with the two (exact and inexact) towers
> numeric types in PLT/Racket. It gives you choice between exactness against
> speed.

Yes, but those are orthogonal issues (and not associated with the arguments,
but the operation).

=== True!!!!


Posted on the dev mailing list.