Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

Re: Low precision exponentiation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129853] Re: Low precision exponentiation
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Mon, 18 Feb 2013 06:05:03 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20130217090833.8CF776937@smc.vnet.net>

You are not doing anything "silly"; you're just being caught by two 
common traps for Mathematica beginners.

First, by default Mathematica treats 2.5 as a machine-precision number; 
no matter what you do with it as is, you won't get any more than 
machine-precision as result. You need to specify you mean exactly that 
number, to the desired precision, e.g.:

   2.5`30

Second, no matter what the precision of a number, by default Mathematica 
only _displays_ 6 significant digits. To get more digits, use NumberForm 
(or depending on the format you want, perhaps ScientificForm, 
EngineeringForm, or AccountingForm), with second argument the number of 
digits to display.

Thus:

   NumberForm[N[2.5`30^125, 30], 30]
5.527147875260444560247265192*10^(49)

Actually, in such an example you probably want to be more careful, since 
the calculation may lose precision. In fact:

   Precision[N[2.5`30^125, 30]]
27.9031

You've lost 2 to 3 digits of precision. So just increase the precision 
in the calculation:

   Precision[N[2.5`40^125, 40]]
37.9031

Which means that when you display 30 digits of N[2.5`40^125, 40] with 
NumberForm, all 30 digits will be correct.

On Feb 17, 2013, at 4:08 AM, Blaise F Egan <blaise at blaisefegan.me.uk> wrote:

> I am trying to evaluate 2.5^125 to high precision.
>
> R gives 5.527147875260445183346e+49 as the answer but Mathematica with N[2.5^125,30] gives 5.52715*10^49 and says that is to machine precision.
>
> I am inexperienced at Mathematica. Am I doing something silly?

---
Murray Eisenberg                                    murray at math.umass.edu
Mathematics & Statistics Dept.      
Lederle Graduate Research Tower            phone 413 549-1020 (H)
University of Massachusetts                               413 545-2838 (W)
710 North Pleasant Street                         fax   413 545-1801
Amherst, MA 01003-9305








  • Prev by Date: Re: Mathematica and Lisp
  • Next by Date: Re: Stephen Wolfram's recent blog
  • Previous by thread: Re: Low precision exponentiation
  • Next by thread: Re: Low precision exponentiation