MathGroup Archive 1990

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

Search the Archive

N

  • To: mathgroup at yoda.ncsa.uiuc.edu
  • Subject: N
  • From: uunet!cello.hpl.hp.com!jacobson
  • Date: Thu, 22 Mar 90 08:20:47 PST

There has been discussion recently about using N[...,30] around
everything.  It is been observed by Richard Fateman and confirmed by
Paul Abbott that this may not work because f[N[...,30]] and
N[f[...],30] are not the same.  However there is a much more important
reason why it won't work.  N only reduces the accuracy of its first
argument, it never increases it.  Note the following:

In[1]:= N[1.2,30]

Out[1]= 1.2

In[2]:= Precision[%]

Out[2]= 16

To get N to work right on decimal things I have to rewrite them as
rationals, or use lots of zeros, then apply N.

In[3]:= N[12/10,30]

Out[3]= 1.2

In[4]:= Precision[%]

Out[4]= 30

You can force the accuracy up by SetPrecision or SetAccuracy, but
beware, because the number was first converted to binary in low
precision form before SetPrecision or SetAccuracy got to it.  So you
are declaring an inaccurate value to be accurate.

In[8]:= SetPrecision[1.2,30]

Out[8]= 1.19999999999999995559107901499

In[9]:= Precision[%]

Out[9]= 30

I know of no way to make the Mathematica "reader" convert decimal
input to high accuracy other than appending a long string of zeros.
If anybody know of a way, please speak up.

  -- David Jacobson




  • Prev by Date: Tutorial Notes
  • Next by Date: D and Derivative - help please
  • Previous by thread: Tutorial Notes
  • Next by thread: Re: N