Three related items, one of them a suggestion for a feature.
1. You can experiment with a nice Java applet to do constructive reals at
http://www.hpl.hp.com/personal/Hans_Boehm/crcalc/
But I think you have to be aware of a few things. Like computing even the
first digit of tan(pi/2) will not terminate. And asking a question like is
[some expression] greater than zero may also not terminate.
2.
Floating point numbers are not approximate. They are exact numbers. They
may not be the numbers that you think they are because you typed in some
decimal number and it was converted to a nearby binary number. Or the number
may have been computed in a way that produced a number different from the
correct one. But the floating point number is an exact number. It can be
converted to an exact rational number which is exactly equal to it (by
lisp's rational or a nearby "short" one by lisp's rationalize). It is not
true that all calculations starting from a float will be approximate. A
newton iteration can find an exact root of a polynomial starting from a less
accurate approximation to the root. Much of the point of numerical analysis
is to remove uncertainty from a result.
3. Yet another proposal, easy to implement, I think.
Any time the user types a number like 1.4,
there is an {optional} warning message like this:
Maxima is converting 1.4 to an binary hardware floating-point number. The
closest representable fp number is
Exactly 3152519739159347/2251799813685248 which is really more like
1.3999999999999999112.
If you really want exactly 7/5, please use that rational number.
....
Those numbers can be computed by
bfloat(1.4d0)
:lisp (rational 1.4d0)
:lisp (rationalize 1.4d0)
And of course if the user types in a number that has an exact binary
representation, like 5.0 or 0.5, or 0.125, the warning could be left out. It
would look foolish if printed :)
RJF
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Andrey G. Grozin
> Sent: Wednesday, April 11, 2007 1:05 PM
> To: Jay Belanger
> Cc: maxima at math.utexas.edu
> Subject: Re: [Maxima] strange behaviour with simple decimals
>
> On Wed, 11 Apr 2007, Jay Belanger wrote:
> > Base 10 most certainly does stand out.
> > While other bases have their uses, I would guess most people enter
> > data in base 10.
> How data are input is irrelevant for the choice of the best way to
> manipulate them.
>
> > It may well be the case that getting small errors when doing decimal
> > arithmetic is an acceptable cost, but it was previously implied that
> > it is a silly thing to talk about. I disagree. What's
> more, I think
> > that if getting small errors when computing 1.4^2 is the
> cost of using
> > Maxima, the manual should clearly state that.
> I think that everybody should know that when one writes any
> number with .
> in it (a floating-point number), all subsequent calculations will be
> approximate. Results which differ from each other by something of the
> order of the precision used for calculations are *equally*
> good. Saying
> that one result is better than the other is completely
> meaningless. And I
> think that seeing things like 0.9999999999999998 or
> 1.0000000000000001
> sometimes is a good thing: it is a healthy remainder to the
> user that,
> having input something with a dot in it (hence inexact), the user has
> accepted the consequences - that the result will be
> approximate. Hiding
> this fundamental fact only leads to unnecessary misunderstandings.
>
> And as for teaching junior school children, I am sure many
> things are done
> wrong. A classical example is x^(1/3). School children (and
> even teachers)
> beleive that it is real and negative for x<0. Maxima uses a more
> consistent definition - a cut along a negative real
> half-axis, with an
> additional rule that when we are exactly on the cut, the
> value from its
> upper side is used. So, for x<0 the result is complex. I'd
> say that here
> (as very often) maxima is right, and the school education is wrong.
>
> Andrey
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>