MathGroup Archive 2006

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

Search the Archive

Understanding N and Precision

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71147] Understanding N and Precision
  • From: Alain Cochard <alain at geophysik.uni-muenchen.de>
  • Date: Thu, 9 Nov 2006 03:38:25 -0500 (EST)
  • Reply-to: alain at geophysik.uni-muenchen.de

Hi.  I would like to understand the following behavior:

   Mathematica 5.2 for Linux
   Copyright 1988-2005 Wolfram Research, Inc.
    -- Motif graphics initialized -- 

   In[1]:= MatrixForm[{{exact1=Cos[3Pi/2+Pi/7], Precision[exact1]}, \
		       {exact2=Cos[40139127975 Pi/14], Precision[exact2]}}] 


   Out[1]//MatrixForm=     23 Pi
		       Cos[-----]
			    14               Infinity

			   40139127975 Pi
		       Cos[--------------]
				 14          Infinity

just checking:

   In[2]:= FullSimplify[exact1-exact2]    

   Out[2]= 0

   In[3]:= MatrixForm[{{float1=N[exact1], Precision[float1]},\
		       {float2=N[exact2], Precision[float2]}}]


   Out[3]//MatrixForm= 0.433884           MachinePrecision

		       0.433883           MachinePrecision

So the N of supposedly(?) 2 identical numbers is different (although
the precision is indeed the same). That's what I would like to
understand most.

Also, if I specify the precision for N, it now gives the same.  E.g.:

   In[4]:= MatrixForm[{{float1=N[exact1,3], Precision[float1]},\
		       {float2=N[exact2,3], Precision[float2]}}]


   Out[4]//MatrixForm= 0.434   3.

		       0.434   3.

including the case where the precision asked is MachinePrecision:


   In[5]:= MatrixForm[{{float1=N[exact1,$MachinePrecision], Precision[float1]},\
		       {float2=N[exact2,$MachinePrecision], Precision[float2]}}]

   Out[5]//MatrixForm= 0.4338837391175581   15.9546

		       0.4338837391175581   15.9546

Why in this case does it gives a precision of "15.9546" and not
"MachinePrecision", as above, especially since

   In[6]:= N[$MachinePrecision,Infinity]

   Out[6]:= 15.9546

Isn't N[x] equivalent to N[x,$MachinePrecision]?

Thanks in advance for any tip.

Alain


  • Prev by Date: RE: Option Inspector Window Font Size
  • Next by Date: Re: Plotting multi-column data
  • Previous by thread: Re: [Help Needed] Converting C++ program into Mathematica Function
  • Next by thread: Re: Understanding N and Precision