|
|
 |
|
|
|
 |
include machine.e
include math.e
?atom_to_float64(power(E,20.0))
?atom_to_float64
(485165195.409790277969106830541540558684638988944847254353610800315977996142709740165979850652747349447833789438961)
?atom_to_float64(power(E,12.0))
?atom_to_float64(
162754.7914190039208080052048984867831702092844787207704435562481385967708355437387292882419094316843)
?atom_to_float64(power(E,10.0))
?atom_to_float64(
22026.46579480671651695790064528424436635351261855678107423542635522520281857079257519912096816452590)
?atom_to_float64(power(E,8.0))
?atom_to_float64(
2980.957987041728274743592099452888673755967939132835702208963530387730725173367530157371871490018139)
?atom_to_float64(power(E,6.0))
?atom_to_float64(
403.4287934927351226083871805433882796058998973571292026139671883251511806339934983051788866512126648)
?atom_to_float64(power(E,5.0))
?atom_to_float64(
148.4131591025766034211155800405522796234876675938789890467528451109120648209585760796884094598990211)
?machine_func(26,0)
Results:
{253,231,104,139,8,235,188,65}
{3,232,104,139,8,235,188,65}
{152,124,211,84,22,222,3,65}
{154,124,211,84,22,222,3,65}
{93,5,149,207,157,130,213,64}
{97,5,149,207,157,130,213,64}
{108,12,71,125,234,73,167,64}
{110,12,71,125,234,73,167,64}
{141,192,144,86,220,54,121,64}
{142,192,144,86,220,54,121,64}
{142,51,112,153,56,141,98,64}
{142,51,112,153,56,141,98,64}
So, discrepancies start showing up for values of the argument as small as 6,
or even smaller.
The pasted strings in the code were obtained from Mathematica 5.5 asking for
100 decimal digits of precision. That's way more than hardware can hold.
Suggestion for a more proper implemntation:
exp(x)= (x<=5)
? power(x,E)
: a=log(2)
n=floor(x/a)
x=remainder(x,a)
return exp(x)*power(2,n)
Not tested yet, but must be better.
If you look at the past discussions about math.e (in 2006 or 2007), you'll see
that I had already warned against this problem. Also, some useful constants
were posted there, which may seem worth being included in math.e.
CChris