       RE: floor problems

• To: mathgroup at smc.vnet.net
• Subject: [mg8131] RE: [mg8113] floor problems
• Date: Fri, 15 Aug 1997 23:41:43 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```Tom De Vires wrote:

|I had a very frustrating time trying to debug some work I was doing in
|Mathematica.
|
|Floor[(.7 67 10)]
|
|469
|
|Floor[(67 10 .7)]
|
|468
|

Consider the following:

In:=     b=67*10*0.7
Out=  469.

0.7 is a machine precision number rather than an exact number such as an
Integer or Rational.  Arithmetic involving machine precision numbers
gives machine precision (imprecise) results.  Now lets see how far the
result
is from 469.

In:=    error=469-b
Out=  5.68434x10^-14

It turns out the result  (b)  is a tiny bit less than 469.  Hence the Floor
of this
value is 468.

It turns out we do have an idea how much error there can be in such a
result.  You should always find the magnatude of the error from any machine
precision calculation is less than the value times \$MachineEpsilon.
\$MachineEpsilon is explained below.

In:=    error<469 * \$MachineEpsilon
Out=  True

Sure enough the error is less than  (469)*\$MacineEpsilon.

In:=   ?\$MachineEpsilon
Out   \$MachineEpsilon gives the smallest machine-precision number
which can be added to 1.0 to give a result that is
distinguishable
from 1.0.

Now when the machine precision (imprecise) multiplication is computed in a
different order, the result is as close as you can get to 469.  It should be
no
surprise that the Floor of this result is 469.

In:=     a=0.7*67*10;
469-a

Out=  0.

However, I wouldn't read to much into the result above.  You will only have
things work out this good in special situations.

http://www.wolfram.com/support/Math/Numerics/NumericalError.html

Ted Ersek

```

• Prev by Date: Re: Mathematica question
• Next by Date: Limit a^n / n!
• Previous by thread: Re: floor problems
• Next by thread: Re: floor problems