MathGroup Archive 2000

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

Search the Archive

Re: Error in Subtraction with V4.0??

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22547] Re: [mg22463] Error in Subtraction with V4.0??
  • From: "David Park" <djmp at earthlink.net>
  • Date: Thu, 9 Mar 2000 03:24:31 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

John,

Mathematica is using machine precision arithmetic, and the numbers are not
represented precisely when converted to binary form. Machine precision arithmetic is
usually 16 places of precision. You can specify the exact precision you want by using
the backquote and the number of places of precision. See the discusion in Section
3.1.4 Numerical Precision in the Mathematica Book. Thus:

1.`14 - .999999999999`14
1. x 10^-12

Or

SetPrecision[1. - .999999999999, 2]
1.0 x 10^-12

SetAccuracy[1. - .999999999999, 14]
1.0 x 10^-12

One of the nice features of Mathematica is that you can have extensive control over
the precision or accuracy of your calculations - but you have to bring in the tools
to exert that control any rely on software rather than floating point hardware.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



>Can someone please explain why
>
>1. - .999999999999
>
>results in
>9.999778782798785*10^-13
>
>The old way (by hand) gives me
>
>1x10^-12
>
>Is this an error or am I missing something?
>
>TIA,
>
>John Brooks
>
>



  • Prev by Date: Re: Problem with Integration
  • Next by Date: Re: Q: Rookie question ..
  • Previous by thread: Re: Error in Subtraction with V4.0??
  • Next by thread: Re: Error in Subtraction with V4.0??