Re: Understanding N and Precision
- To: mathgroup at smc.vnet.net
- Subject: [mg71186] Re: [mg71147] Understanding N and Precision
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Fri, 10 Nov 2006 06:37:41 -0500 (EST)
- References: <200611090838.DAA15669@smc.vnet.net>
On 9 Nov 2006, at 17:38, Alain Cochard wrote: > 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. This is quite common in computations with MachiePrecision. Two mathematically equal expressions can give completely different answers; in fact the difference can be much greater than the one you got here. This is referred to as "conditioning" of the expressions and is explained in most modern books on numerical analysis. And by the way, mathematica has basically "nothing to do" with MachinePrecision computations and is nto "responsible' for the answers you get when you perform them. > > > 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]? > > Note the distinction between In[24]:= MachinePrecision Out[24]= MachinePrecision and In[25]:= $MachinePrecision Out[25]= 15.9546 In[26]:= Precision[N[2,MachinePrecision]] Out[26]= MachinePrecision In[27]:= Precision[N[2,$MachinePrecision]] Out[27]= 15.9546 N[2,$MachinePrecision] is not a MachinePrecision but an extended precision number! Andrzej Kozlowski
- References:
- Understanding N and Precision
- From: Alain Cochard <alain@geophysik.uni-muenchen.de>
- Understanding N and Precision