float(sin(2^2048))?



On 5/11/10 9:59 AM, Robert Dodier wrote:
> On 5/11/10, Raymond Toy <toy.raymond at gmail.com> wrote:
>
>   
>> What should maxima do with float(sin(2^2048))?  It currently generates
>> an error because 2^2048 is too big to fit in a double float.
>>
>> We could do better than this by doing argument reduction of 2^2048.
>>
>> Or the easy way is to tell the user to do float(bfloat(sin(2^2048))).
>> Should maxima do that automatically?
>>     
> Well, to have a consistent effect for the float function,
> I think the answer is no.
>   

You mean not to do that automatically?  And it's inconsistent because it
doesn't float the 2^2048 first?
> At present float has (or should have; maybe there are already
> some special cases) a simple explanation: it changes any
> literal numbers or symbolic constants to floats
> (and, happily, that's what the reference manual says).
> A function which evaluates floats to floats will then yield a
> float. E.g. float(sin(1)) is equivalent to sin(float(1)), which
> yields a float.
>
> There is a different interpretation of the float function, which
> I think I would prefer, namely float(foo(x)) should return the
> floating point number closest to the numerical value of foo(x).
> Then argument reduction or whatever is necessary would be
> applied to sin(giant number) and floating point conversion
> later in the game.
>   

I think for most foo, it's very hard to get the FP value closest to
foo(x), unless foo(x) is some rational or you do the work in some kind
of extended precision or purely rational operations.  You can probably
get to within a few bits, though.

I also think foo(float(x)) is pretty good except for when x won't fit in
a float.

There are also some related issues like float(erf(2^2048)) and
float(tanh(2^2048)) which generate errors instead of returning 1.0.


> The latter is obviously more work, and the former already
> entrenched, but both, at least, are easily explained.
> I'm pretty sure I'm not in favor of mixing the two.
>   
I guess that I will have to remove the changes I made for float(log(x)),
then.

Ray