Re: Serious Bug in Mathematica 7 and 8.0.4.0 (latest version)

*To*: mathgroup at smc.vnet.net*Subject*: [mg126188] Re: Serious Bug in Mathematica 7 and 8.0.4.0 (latest version)*From*: George Woodrow III <georgevw3 at mac.com>*Date*: Tue, 24 Apr 2012 05:31:51 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com

I don't think that this is a bug. When you set b to 6371.01, you tell Mathematica to use a machine precision number. As I recall from the IEEE-754 specification, this means that the number is accurate to 16 digits (more or less), but what is stored as 'garbage' is not specified. What you have done is to expose the 'slop' below the limits of the specified precision of the machine precision number. You can look at the specification to see how machine-precision numbers are actually stored if you want a more precise definition. When you add enough zeros, you tell Mathematica to use an arbitrary precision number, which *does* guarantee the precision to the number of digits specified. The trade off is that computations using arbitrary precision numbers is much slower. Unless you are using a lot of them, then you probably will not notice this, though. If maintaining 20 (or any number of digits > 16 or so) digit precision is important to you, then you will want to use arbitrary precision or exact numbers in your computations. Mathematica will then keep track of precision for you. If you are dealing with limited precision -- most real-world (measured) numbers have at best 6 significant digits -- then the machine precision numbers are sufficient most of the time. If you are graphing near singularities, you may need to carry the extra precision, as an example of a case where arbitrary precision may be important. hope this helps. george woodrow On Apr 23, 2012, at 5:41 AM, Alexander Mayer wrote: > In[1]:= (* This notebook produced by Mathematica 8.0.4.0 *) > (* Platform: OSX 10.6.8 on MacBook Pro *) > > In[1]:= b = 6371.01 (* We set the value of b to this real number. *) > > Out[1]= 6371.01 > > In[2]:= SetPrecision[a = b, 20] (* We test the actual value of b. *) > > Out[2]= 6371.0100000000002183 > > In[3]:= (* Mathematica has added a small constant! *) > > In[4]:= (* Adding zeros to the 16th place fixes the problem. *) > > In[5]:= c = 6371.0100000000000000 > > Out[5]= 6371.0100000000000000 > > In[6]:= SetPrecision[a = c, 20] > > Out[6]= 6371.0100000000000000 >