On Tue, Dec 9, 2008 at 9:21 AM, Raymond Toy <raymond.toy at ericsson.com>wrote:
> Stavros> ...I compared its results to results from cf(rationalize(...)),
> which are the exact answers. A little experimentation
>
> Note that maxima's rationalize doesn't call ration1.
Exactly. Rationalize(.23) and rat(.23) are two different things -- by
design. Rationalize is the exact binary fraction corresponding to a
floating-point number, whereas rat is the simplest rational within
ratepsilon of the argument.
It seems we shouldn't ever be more than 1 ulp off.
That would be nice, and could fairly easily be accomplished by doing all the
arithmetic with exact numbers (integers/rationals). However, the whole
point of ratepsilon is to give some non-zero play. Of course, *rationalize*
is by definition exact i.e. 0 ulp off.
> Could we not just set ratepsilon to 0 instead of 2e-15 or so?
>
That would be a bad idea. The whole point of ratepsilon is to allow some
"slop" in the float-to-rational conversion so that even after a few
arithmetic operations (with their associated rounding errors), round numbers
stay round. For example, sum((-1)^i/float(i),i,1,n) is exactly the rational
result when converted using ratepsilon = 2.0e-15 up to n=18, while
rationalize (unsurprisingly, since it's a binary fraction) is only exact for
n=1,2.
But given that rationalize doesn't seem to call ration1 it's no longer
> clear to me what we should do. Should maxima-rationalize be changed?
Rationalize and rat (ration1) have different functions. Neither should
change.
-s