MathGroup Archive 2011

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

Search the Archive

Re: Why Mathematica does not issue a warning when the calculations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117618] Re: Why Mathematica does not issue a warning when the calculations
  • From: Richard Fateman <fateman at eecs.berkeley.edu>
  • Date: Thu, 24 Mar 2011 06:31:45 -0500 (EST)

On 3/23/2011 6:48 PM, Barrie Stokes wrote:
> Hi Richard
>
> Intrigued, I tried
>
> 1.
> z = 1.11111111111111111111
> Table[  (z = 2*z - z), {42}]
>
> and
>
> 2.
> z = 1.11111111111111111111 // Rationalize
> Table[  (z = 2*z - z), {42}]
>
> Seeing the result from 2, I take it that the result from 1, and your input, has to do with the imprecise representation of such as 10/9 in binary arithmetic.

No. It does not have to do with the imprecise representation of a 
decimal number in binary
You can start with ANY "bigfloat" value for z, including one that is 
EXACTLY representable in binary
arithmetic.  You might be surprised by the fact that the same problem 
occurs here:

z = 1.0000000000000000000
Table[(z = 2*z - z), {42}]

That is, z is changed to zero.

Now if you start with a number that is not a floating point number but a 
rational number and is not
subject to Mathematica's "significance arithmetic",  then the logical, 
mathematical, exact result
will be computed.  Starting with z=1  or z= any exact rational, you get 
what a mathematician
would expect. That is, z does not change.


> What do other CAS's do with your original input, given that "... it is especially a problem with Mathematica because of its unusual arithmetic"?

If we just use Mathematica and ordinary hardware arithmetic, you can
see what would happen with a system that either uses hardware arithmetic,
or simply simulates hardware arithmetic "but with more bits".

start by setting z = N[1/3]
and notice that z remains the same.

For most systems, computing 2*z where z is a float,
simply increments the exponent by 1.




  • Prev by Date: Re: Chop in Mathematica 8.0.1
  • Next by Date: Re: Using Nearest on a group of points
  • Previous by thread: Re: Why Mathematica does not issue a warning when the calculations
  • Next by thread: Re: Why Mathematica does not issue a warning when the calculations