Re: Using N function
- To: mathgroup at smc.vnet.net
- Subject: [mg76319] Re: Using N function
- From: Bill Rowe <readnewsciv at sbcglobal.net>
- Date: Sat, 19 May 2007 04:49:47 -0400 (EDT)
On 5/18/07 at 6:31 AM, kkwweett at hotmail.fr (kkwweett) wrote: >Can anyone tell me, please, which of a),b) or c) is wrong : >a) <MathematicaHelp> <quote> >N[expr] is equivalent to N[expr, MachinePrecision]. ></quote> </MathematicaHelp> >b) In[1]:=N[Exp[Sqrt[163 ]Pi] - 640320^3] Out[1]=256. >c) In[2]:=N[Exp[Sqrt[163 ]Pi] - 640320^3,$MachinePrecision] >Out[2]=743.9999999999993 a) and c) are correct. The problem with b is the order in which things are being done. In b, first all of the constants are made machine precision numbers then the expressions are evaluated. In c, the expression is being evaluated with the specified precision. This can be verified as follows: In[1]:= Exp[Sqrt[163.] Pi] - 640320^3 Out[2]= 256. which results since In[2]:= {Exp[Sqrt[163.] Pi], 640320^3.} Out[2]= {2.6253741264076826*^17, 2.62537412640768*^17} using arbitrary precision we get In[3]:= N[Exp[Sqrt[163] Pi] - 640320^3, 4] Out[3]= 744.0 which verifies c) is correct -- To reply via email subtract one hundred and four