[Fwd: Two bugs in one (fwd)]



>  x^(2^.5) => x^1.414213562373095
> ...it shouldn't have converted 2^.5 to float

This results from three Maxima principles:

1) airthmetic between explicit numbers yields a single number: 2+3/2
=> 7/2, 5.0^(1/3))  => 1.70998....

2) arithmetic between an exact number (integer, rational) and an
approximate number (float, bfloat) yields an approximate number: 0.0+3
=> 3.0, 2/3-1.0 => -0.333...

3) a floating-point number denotes an approximate number: 0.5 is not
considered identical to 1/2: 0.5-1/2 => 0.0, not 0.

Do you disagree with these principles?

If you want to use exact arithmetic, do not use floats, but rationals,
e.g. x^(2^(1/2)).

> RAT replaced 1.414213562373095 by 8119//5741
> ... it certainly shouldn't convert the float to 8119/5741.

The conversion of floats to fractions is controlled by the global
parameter ratepsilon.  By default, this is 2.0e-8.  I have argued for
a long time that this should be much smaller, perhaps 1.0e-15 (5
ulps).  But you can always change it for your calculations in the
meantime:

   ratepsilon: 1.0e-15$
   rat(sqrt(2.0)) => 511643454094369/255821727047184

          -s