[Fwd: Two bugs in one (fwd)]



---------- Forwarded message ----------
Date: Tue, 22 Feb 2005 10:59:33 -0500 (EST)
From: George Gesslein II 
To: maxima@www.math.utexas.edu
Subject: Two bugs in one

Hello,

The following is problem that I had with version 5.9.0 of Maxima
and still with V5.9.1:

(%i1) x^(2^.5);
                                1.414213562373095
(%o1)                         x
(%i2) ratsimp(%);

RAT replaced 1.414213562373095 by 8119//5741 = 1.414213551646055
                                    8119/5741
(%o2)                             x
(%i3)

First, it shouldn't have converted 2^.5 to float, and it certainly
shouldn't convert the float to 8119/5741.

I can explain how to better validate floats to fractions,
by using an epsilon value.  Here is my C code:

        if (fabs(k3 - k4) > (small_epsilon * fabs(k3))) {
                return false;	/* fraction is too inaccurate */
        }

k3 = the original float;
k4 = the new float obtained by dividing out the fraction;
small_epsilon = 0.000000000000005; a good value for doubles.


 		Regards,
 		George

George John Gesslein II
http://www.mathomatic.com
"The light of souls is a warm, little glow."