Re: Current implementation of exp() is faulty.
- Posted by CChris <christian.cuvier at agric?lture.gouv.fr> May 09, 2008
- 748 views
Matt Lewis wrote: > > CChris wrote: > > > > }}} <eucode> > > 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) > > </eucode> {{{ > > > > 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. > > Are you certain that it's the implementation of exp and not the parsing > of floating point? You're way beyond the precision that the current > floating point scanner can handle. Try changing to scientific notation. > I just added E+0 to all of your ridiculously precise numbers, and here's > what I got: > > {251,231,104,139,8,235,188,65} > {4,232,104,139,8,235,188,65} > {151,124,211,84,22,222,3,65} > {154,124,211,84,22,222,3,65} > {92,5,149,207,157,130,213,64} > {96,5,149,207,157,130,213,64} > {107,12,71,125,234,73,167,64} > {110,12,71,125,234,73,167,64} > {141,192,144,86,220,54,121,64} > {143,192,144,86,220,54,121,64} > {142,51,112,153,56,141,98,64} > {143,51,112,153,56,141,98,64} > > > Frankly, I have idea how close to Mathematica's result these are. You > never told us what those answers were. > > Matt I thought I did.... The pasted value for exp(x) is obtained by ealuating N[Exp[x],100] . When x is not an integer, it must be entered in fractional form. Otherwise, Mathematica is aware of the roundoff errors and only returns like 6 or 7 decimal places. exp(some fraction) can be computed at any precision as a rational approximation. The process is simply tedious by hand, so I didn't check directly. CChris