MathGroup Archive 2009

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

Search the Archive

Re: Odd behavior?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101892] Re: Odd behavior?
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Mon, 20 Jul 2009 19:22:37 -0400 (EDT)
  • References: <h3uv8j$kcb$1@smc.vnet.net>

Hi,

> The expression 5.1 - 4.5 - 0.6 gives different answers depending on the version of 
> Mathematica. Version 6 says 0. (which is obviously what we expect) with an accuracy 
> of about 307. Version 7 says -3.33067x10^-16 with an accuracy of about
31. Also,
> in version 7, if the expression is changed to 5.1 - (4.5 + 0.6) the
answer it gives
> is 0. with an accuracy of about 307. Both versions were run on three
different
> computers.
> 
> Anybody know what changed or what I can do to prevent such poor solutions 
> (besides forcing a specific order of evaluation)? Thanks.

I think others have explained the background of your problem. I just
wanted to add that Mathematica indeed can do software emulated floating
point calculations to more than MachinePrecision if one tells it to.
Then the concept of Precision and Accuracy make more sense, since for
MachinePrecision alone it seems to have limited value, as Andrzej has
explained. This is how you can avoid MachinePrecision calculations:

5.1`300 - 4.5`300 - 0.6`300
5.1`300 - (4.5`300 + 0.6`300)

>From the result you can see that now the results are equal to a very
high precision. But be warned:

1) It is very easy to forget precision information in your input and so
make Mathematica fall back to MachinePrecision
2) the software emulated arbitrary precision calculations are of course
some orders of magnitude slower than machine precision calculations
handled more directly by the hardware.
3) some of the numerical functions might not work with or respect the
arbitrary precision floating point numbers.

hth,

albert


  • Prev by Date: Re: patterns
  • Next by Date: Re: patterns
  • Previous by thread: Re: Odd behavior?
  • Next by thread: Re: Different (real) solutions using Solve for same