Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Output Precision Exploration
Replies: 6   Last Post: Apr 29, 2011 6:55 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
ברק שושני

Posts: 8
Registered: 12/19/10
Re: Output Precision Exploration
Posted: Apr 28, 2011 5:43 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Apr 27, 12:39 pm, Rafael Dunn <worthless.trash.j...@gmail.com>
> Mathematica, Mac OSX x86
> In:=
> Log[173.5/173.5]
> Out:=
> -1.11022*10^-16
> I expect an output of exactly 0. Although 10^-16 is small, it turned
> out to be the largest factor in a chemical equation I was attempting to
> compute.
> I discovered this is because Mathematica does not actually evaluate
> 173.5/173.5 = 1. The output is actually some number 0.9999999999...
> However, for most decimal constants x/x produces an exact output of 1.
> By entering a few decimals off the top of my head I also found 1733.5,
> 26.44, and 27.44 do not produce an output of 1 when divided by
> themselves.
> Why? I understand Mathematica's algorithms for working with decimals
> must make approximations, but why is there so much variance among
> decimal calculations? 173.49/173.49 = 1, while 173.5/173.5 != 1.
> Furthermore, I find:
> x=173.49999999999999
> x/x = 173.5/173.5, with infinite precision. If you add or remove a
> single 9 to the end of x, this ceases to be true.
> Furthermore, this looks like a contradiction to me:
> In:=
> 173.5/173.5 = 1
> Log[1] = 0
> Log[173.5/173.5] = 0
> Out:=
> True
> True
> False
> I have learned a lot about Mathematica's precision and approximation through the help documentation, but I still can not explain this or see how I can expect Log[x/x] = 0 for the sake of calculations on the 10^-16 scale.

173.5 is a machine precision number, not an exact number. So it's only
know up to a certain precision. Try this:



So it's only *approximately* 1. Of course, you could specify the
numbers to be of arbitrary precision, for example 100 digits:



However, the answer will never be *exactly* 0 because it is only known
to a certain precision. This is what Chop was made for:



See tutorial/NumericalPrecision in the Mathematica documentation.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2015. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.