MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

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

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 *)
> (* 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

  • Prev by Date: Re: Serious Bug in Mathematica 7 and (latest version)
  • Next by Date: Re: evaluating functions and displaying results numerically
  • Previous by thread: Re: Serious Bug in Mathematica 7 and (latest version)
  • Next by thread: Re: Serious Bug in Mathematica 7 and (latest version)