MathGroup Archive 2011

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

Search the Archive

Re: N[] MachinePrecision vs. Arbitrary Precision

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118430] Re: N[] MachinePrecision vs. Arbitrary Precision
  • From: Sseziwa Mukasa <mukasa at gmail.com>
  • Date: Thu, 28 Apr 2011 06:33:29 -0400 (EDT)

On Apr 27, 2011, at 5:39 AM, Rafael Dunn wrote:

> Mathematica 8.0.1.0, Mac OSX x86
>
> In:=
> N[Sin[Exp[100]]]
> N[Sin[Exp[100]], 1]
> N[Sin[Exp[100]], 11]
>
> Out:=
> -0.999105
> 0.1
> 0.14219812366
>
> I realize that N[exp] = N[exp, MachinePrecision].  This indicates when
> N[] is asked to calculate to MachinePrecision, it produces an incorrect
> result in this example.  However, when I use N[exp,n] where n <
> MachinePrecision, I get a correct output.  Is this because N[exp,n] uses
> ExtraPrecision, while N[exp] does not? 

Not really, the behavior of N[e] and N[e,p] is different even if p == MachinePrecision, the relevant text in the help guide is:

>  N[e] typically works by replacing numbers with machine numbers and computing the result:


and

>  N[e,p] works adaptively using arbitrary-precision numbers when  p is not MachinePrecision:

So N[Sin[Exp[100]]] is equivalent to N[Sin[Exp[100.]]] but N[Sin[Exp[100]], p] evaluates Exp[100] arbitrary precision.  Consider:

In[41]:= N[Exp[100.]]
N[Exp[100]]
N[Exp[100], MachinePrecision]
N[Exp[100], $MachinePrecision]
Out[41]= 2.68812*10^43
Out[42]= 2.68812*10^43
Out[43]= 2.68812*10^43
Out[44]= 2.688117141816135*10^43
In[37]:= $MachinePrecision == MachinePrecision
Out[37]= True

Regards,
	Sseziwa


  • Prev by Date: Re: plot of nmaximized result
  • Next by Date: Workaround for Plot[ ] and color via PlotStyle
  • Previous by thread: N[] MachinePrecision vs. Arbitrary Precision
  • Next by thread: Re: N[] MachinePrecision vs. Arbitrary Precision