[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sqrt(4/9) != 2/3



Thus spake Aaron Lehmann:
> Try typing something like:
> 
> a=.242342342342342342360728309470
> a+3
> In my experience it will tack on a lot of 9's to the end of 3.2423...

er, doesn't seem to on my system -- if it does on yours, file a bug.

> I think this is a related bug, am I right?

Well, it would be related insomuch as we have a bit of a problem
telling when a number is rational and when it is decimal.

For instance,
genius> 3/2 == 1.5
= 1
genius> is_rational(1.5)
= 0
genius> is_rational(3/2)
= 1

So is 3/2 equal to 1.5 or are they different?
We need to deal with this sometime.

This is a question that m9a (my name for mathematica, which is too
long and pompous to write repeatedly) flubs, IMNSHO.
Basically, it considers 1.5 to be a real number approximation with 2
digits of precision (I think...), and 3/2 to be an exact rational
number.

So........
I suggest that we (eventually) have a mechanism for precision
(volunteers?).

That is, every decimal number would come with a precision (possibly
infinite) attached.
Thus, if one had 1.5 with 4 digits of precision, then it would be
0.1500 x 10^1 +- 0.5 x 10^(-5), i.e., an approximate real number.
If we had 1.5 with Infinite precision, then it would be exactly 3/2
(and should probably be so converted).

We should also have a default precision; common values would be:
DefaultPrecision = 0 (only as much precision as you specify --
probably the best default, and good in any field where you care about
precision)
DefaultPrecision = 16 (or something like this, if people want
pseudo-machine precision or some default amount of precision).
DefaultPrecision = Infinity (probably best in elementary school and
for theoretical math)

Of course, this is non-trivial to implement, and we'd need to make
sure that basic arithmetic returned results with proper precision.

This would be a nice feature, and it'll probably be implemented
eventually, but it's pretty anal and hair-splitting for now (i.e., we
have more important things to do, and jiri is hacking at the engine
right now anyway so now isn't the best time).

> On Wed, 2 Feb 2000, Nils Barth wrote:
> 
> > Package: drgenius
> > Version: 0.5.0
> > 
> > The sqrt function doesn't work properly on rational numbers that are
> > perfect squares.
> > For example,
> > 
> > genius> sqrt(4/9)
> > = 0.66666666666666666666666666666666666666666666666666666666666666666666666666667
> > 
> > while it should return 2/3.

-- 
  -nils