MathGroup Archive 2004

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

Search the Archive

Re: Precision of output

  • To: mathgroup at
  • Subject: [mg48211] Re: Precision of output
  • From: "Peltio" <peltio at>
  • Date: Tue, 18 May 2004 04:16:23 -0400 (EDT)
  • References: <c89q2f$t51$>
  • Reply-to: "Peltio" <peltioNOSP at>
  • Sender: owner-wri-mathgroup at

"Per Rønne" wrote
>    N[4209/0.14,100] I get:
>        30064.3

You are using a machine precision number, here, so Mathemaitca answers with a
machine precision number. By default these numbers are displayed with 6
digits only: that is the value you see.
You can see up to 16 digits for this result but no more than that, by using


Which as far as I know should be equivalent to


This behavior is version dependant, though. (moreover, the actual digits you
could see is also machine dependant, but that's another matter altogether).

>But if I write
>    N[420900/14,100]
>        30064.28571428571428571428571428571...

In this case, you passed to N an exact number. It is then possible to
extract as many digits as you wish.

>Why the difference? I thought N determined the number of digitals shown

No longer. That is a job for NumberForm, now.
Machine precision numbers have (on a typical PC) 16 digits of which only 6
are shown (unless you invoke NumberForm to see more). Numbers with more that
16 digits show them all (to remember you are working in higher precision, I
guess). Exact numbers show all the digits you ask them to have (by invoking
N) or to show (by invoking NumberForm).

There have been _many_ changes to the way N works in subsequent
versions of mathematica [1]. You might want to look up to te "what's new"
part of the online help, as well as to the "Incompatible changes since
version x".[2]

Some notes and a question:

[1] I remember the pain it took to make the crystal morphology package
Crystal.m work on version 3 and(/or?) 4: one of the things that prevented a
part of the package to work properly was a change in the behavior of N form
one version to the other. I wonder if the modified version runs on version
5, by the way.

[2] My question to the group: is there a page where the changes in the
numerical functions are discussed thoroughly with respect to _all_ earlier
version of Mathematica? I have already read these fine tutorials:

     Significance Arithmetic,
          by Mark Sofroniu,
          in "Fast and Stable Algorithms"

    Significance Arithmetic,
         by Mark Sofroniu,
         in "History and Development of Numerical Computing in Mathematica"
        (it's a slightly different version from the one above)

    Numerics in Mathematica 3.0,
        by Mark Sofroniu,
        TMJ dontremembertheissue, but it's on the mathsource and in the help

    "Numerical Mathematica: Using Accuracy and Precision",
        by Rob Knapp

Plus many articles scattered in the Usenet, among which a few from the late
Jerry Keiper and many interesting posts by Daniel Lichtblau and Andrzej
Kozlowski. But...
....wouldn't a *unified* treatment of the changes occurred to N and to
related numerical procedures in *all* of the Mathematica versions be useful? It
seems to me that questions related to N, the number of digits displayed, the
precision and accuracy given as integers or real, the fact that N[0] be 0 or
0., come up quite often in the group.

I don't remember to have seen such a treatment in the FAQs or in the
Technical Notes. And somehow I feel that N, being so ubiquitos, deserves a
treatment different from the other procedures.
Just my thought, though...

(Every time I posed a question of the sort "why there is no such a thing?"
the answer was invariably "Why, there IS such a thing, and it's right under
your nose". I hope this is _again_ the case.)

  • Prev by Date: RE: Re: Kernel init.m File
  • Next by Date: Re: Uniform design
  • Previous by thread: Re: Precision of output
  • Next by thread: Re: Precision of output