MathGroup Archive 2004

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

Search the Archive

RE: 34.123*89 = 3036.95 (3036.947)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47919] RE: [mg47905] 34.123*89 = 3036.95 (3036.947)
  • From: "DrBob" <drbob at bigfoot.com>
  • Date: Fri, 30 Apr 2004 19:26:57 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

No, it's actually the following binary representation:

x = 34.123*89
RealDigits[x, 2]
Precision[x]
3036.9469999999997
{{1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 
   1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 
   1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1}, 12}
MachinePrecision

How that looks in decimal depends on how many digits you display, how the
conversion to decimal is done, whether it's rounded up or down, et cetera.
But the product IS that string of binary bits, in this case 0.10111(and so
forth) times 2^12.

Most rational numbers cannot be represented exactly in binary. They can be
ONLY if the denominator of the rational fraction, in reduced form, is a
power of 2.

But you can get as close as you want to, by specifying inputs to more
decimal places. You can control display with NumberForm. For instance,

x = 34.12300000000000000000000000000*89
RealDigits[x, 2]
Precision[x]
NumberForm[x, 20]

3036.947`30.533047206146456
{{1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 
   1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 
   1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 
   0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 
   0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 
   0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0}, 12}
30.533047206146456
3036.9470000000000000

I specified more than $MachinePrecision digits in the input; otherwise it
defaults to a machine precision number, like your original input.

But this is a tempest in a teacup. Unless you happen to know the first
multiplier is EXACTLY 34123/1000 because it's derived from an exact formula,
I doubt that you really know it even to machine precision, and that's what
Mathematica is assuming when you input 34.123. If you know the number
exactly, you can enter it as a rational number, and then there's no
approximation error at all.

If you don't know the number that exactly, just relax. The visible "error"
you think you're seeing is smaller than your actual uncertainty. In this
case, the original answer in your post is "off" by less than 10^-10. The
relative error is less than 10^-14. Does it really matter?

error = 3036.946999999970000000 - 34.123*89
error/3036.946999999970000000

-2.955857780762017*^-11
-9.732990996425178*^-15

DrBob

www.eclecticdreams.net


-----Original Message-----
From: Thomas Schulz [mailto:thomas-k-schulz at t-online.de] 
To: mathgroup at smc.vnet.net
Subject: [mg47919] [mg47905] 34.123*89 = 3036.95 (3036.947)

I am a NewBe - and i dont understand the Result.
Mathematica says that 34.123*89 = 3036.94699999997 but its 3036.947...
How can i change this?

i use a IBook (G4) with Mac OS X.
THX
Thomas




  • Prev by Date: Re: 34.123*89 = 3036.95 (3036.947)
  • Next by Date: Re: bug in IntegerPart ?
  • Previous by thread: Re: 34.123*89 = 3036.95 (3036.947)
  • Next by thread: Mathematica User Groups?