MathGroup Archive 2002

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

Search the Archive

Re: Re: Accuracy and Precision

  • To: mathgroup at
  • Subject: [mg36949] Re: [mg36933] Re: Accuracy and Precision
  • From: Andrzej Kozlowski <andrzej at>
  • Date: Thu, 3 Oct 2002 00:16:26 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

The last part of my message you are quoting was completely wrong, as 
was pointed out by Allan Hayes. Mathematica does not track precision of 
machine arithmetic computations. In order for Mathematica to give 
reliable information about the precision of a computation you have to 
explicitly set the precision of all the numerical quantities.

Your own example at the bottom simply shows you have not understood the 
evaluation mechanism of Mathematica. What you are doing is this:

a = SetAccuracy[77617., Infinity];
b = SetAccuracy[33096., Infinity];

At this point you have converted a and be to have the following exact 





Next you evaluate:

f = SetAccuracy[333.75*b^6 +
     a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 +
     a/(2*b), Infinity]

but this is a two step process (which is what you seem not to have 
grasped). First Mathematica computes:

333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +
   5.5*b^8 + a/(2*b)


Now, because there were  machine floats in the formula (333.75 and 5.5 
) the whole expression was computed using machine arithmetic without 
keeping track of precision. The answer is therefore completely 
inacurate. Mathematica returns the purely formal accuracy:



But the second part of your evaluation tells it to take this inaccurate 
answer and convert it to an exact number.

SetAccuracy[%%, Infinity]




But of course doing this is meaningless, after converting an inexact 
answer  to an exact number does not make it a an exact answer!

Of course had you evaluated f before you assigned the values to a and b 
you would not have encountered the problem because no machine reals 
would have appeared in the computation. ALternatively you might have 

f = SetAccuracy[333.75, Infinity]*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 
- 2) +
      SetAccuracy[5.5, Infinity]*b^8 + a/(2*b)

Andrzej Kozlowski
Yokohama, Japan

On Wednesday, October 2, 2002, at 04:32 PM, Peter Kosta wrote:

> Andrzej Kozlowski <andrzej at> wrote in message 
> news:<anbofj$e7u$1 at>...
>> It seems clear to me that what Allan and what you mean by "succeeds"
>> here refer to quite different things and your objection is therefore
>> beside the point. There are obviously two ways in which one can
>> interpret the original posting. The first interpretation, which Allan
>> and myself adopted, was that the question concerned purely the
>> computational mechanism of Mathematica. Or, to put it in other words,
>> it was "why are the results of these two computations not the same?".
>> In this sense "success" means no more than making Mathematica return
>> the same answer using the two different routes the original poster 
>> used.
>> You on the other hand choose to assume that the posting shows that its
>> author does not understand not just the mechanism of significance
>> arithmetic used by Mathematica  but also computations with inexact
>> numbers in general. I do not think this is necessarily the correct
>> assumption. I also don't see that Mathematica is doing anything wrong.
>> After all, one can always check the accuracy of your answer:
>> In[1]:=
>> a = 77617.; b = 33096.;
>> In[2]:=
>> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +
>>     5.5*b^8 + a/(2*b)
>> In[3]:=
>> f
>> Out[3]=
>> -1.1805916207174113*^21
>> In[4]:=
>> Accuracy[%]
>> Out[4]=
>> -5
>> which tells you that it can't be very reliable. What more do you 
>> demand?
> As you are dealing here only with machine-precision numbers, your
> argument is valid. From the manual 3.1.6:
> "When you do calculations with arbitrary-precision numbers, as
> discussed in the previous section, Mathematica always keeps track of
> the precision of your results, and gives only those digits which are
> known to be correct, given the precision of your input. When you do
> calculations with machine-precision numbers, however, Mathematica
> always gives you a machine-¡Áprecision result, whether or not all the
> digits in the result can, in fact, be determined to be correct on the
> basis of your input. "
> In practice, to rely on a numerical result, you ALWAYS have to check
> its accuracy. How reliable is Accuracy anyway?
> In[1]:=
> a = SetAccuracy[77617., Infinity];
> b = SetAccuracy[33096., Infinity];
> In[3]:=
> f = SetAccuracy[333.75*b^6 +
>     a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 +
>     a/(2*b), Infinity]
> Out[3]=
> 1180591620717411303424
> In[4]:=
> Accuracy[f]
> Out[4]=
> Infinity
> We got completely wrong result with Infinite accuracy. In conclusion,
> one can not rely on Accuracy. Checking numerical results in
> Mathematica sounds like a tough task.:-)
> --PK
>> Andrzej
>> Andrzej Kozlowski
>> Yokohama, Japan
> [...]

  • Prev by Date: Re: Choosing between Mathematica for Windows and Linux
  • Next by Date: Re: RE: final results: creating adjacency matrices
  • Previous by thread: RE: Accuracy and Precision
  • Next by thread: Re: Accuracy and Precision