Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #1942

Re: Output Precision Exploration

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!multikabel.net!newsfeed10.multikabel.net!feed.xsnews.nl!border-1.ams.xsnews.nl!206.55.64.80.MISMATCH!newspump.sol.net!posts.news.twtelecom.net!nnrp2.twtelecom.net!not-for-mail
From Sseziwa Mukasa <mukasa@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Output Precision Exploration
Date Thu, 28 Apr 2011 10:33:33 +0000 (UTC)
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <ipbfpt$ab5$1@smc.vnet.net> (permalink)
Lines 47
NNTP-Posting-Date 28 Apr 2011 09:34:18 GMT
NNTP-Posting-Host b65042e2.news.twtelecom.net
X-Trace DXC=LbfBN^Bd>kZjd=H^]FJ5\ZC_A=>8kQj6];[h;PUXBgbTAbB79SZHZ=\EFiONJ7[GoVeEj5RLM8W>\
X-Complaints-To abuse@twtelecom.net
Xref x330-a1.tempe.blueboxinc.net comp.soft-sys.math.mathematica:1942

Show key headers only | View raw


On Apr 27, 2011, at 5:39 AM, Rafael Dunn wrote:

> Mathematica 8.0.1.0, 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.

My advice is to use exact numbers for x where possible, which it is in this case.  Machine precision is only good to 16 digits, if you need more you need to specify it explicitly.  Alternatively, if you don't actually need the precision but are annoyed by extraneous small values you can use Chop.

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Output Precision Exploration Sseziwa Mukasa <mukasa@gmail.com> - 2011-04-28 10:33 +0000

csiph-web