Re: MachinePrecision vs. Arbitrary Precision
- To: mathgroup at smc.vnet.net
- Subject: [mg118438] Re: MachinePrecision vs. Arbitrary Precision
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Thu, 28 Apr 2011 06:34:55 -0400 (EDT)
On 4/27/11 at 5:39 AM, worthless.trash.junk at gmail.com (Rafael Dunn) wrote: >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, More specifically, this asks hardware to do the required computation. >it produces an incorrect result in this example. That is due to the limitations of floating point arithmetic as implemented in hardware. The actual result you get will vary according to what hardware is being used. >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? The key is whenever you use N[expr, n], you invoke Mathematica's arbitrary precision arithmetic and Mathematica does what is needed to get the desired precision. This often means the result returned is more accurate than what you get from N[expr] even when n is less than $MachinePrecision. And note, doing N[expr, $MachinePrecision] is quite different than doing either N[expr] or N[expr, MachinePrecision]