MathGroup Archive 2009

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

Search the Archive

Re: An arithmetic puzzle, equality of numbers.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103097] Re: An arithmetic puzzle, equality of numbers.
  • From: Richard Fateman <fateman at cs.berkeley.edu>
  • Date: Tue, 8 Sep 2009 05:56:14 -0400 (EDT)
  • References: <h829m8$3ue$1@smc.vnet.net> <4AA4BA87.3020500@gmail.com> <4AA5167F.8090105@cs.berkeley.edu> <f831b3d60909070809u7eed1eb8o6575b2e97bf8ba49@mail.gmail.com>

Szabolcs Horvát wrote:
> 2009/9/7 Richard Fateman <fateman at cs.berkeley.edu>:
>   
>> Szabolcs Horvát wrote:
>>     
>>> On 2009.09.07. 8:36, Richard Fateman wrote:
>>>       
>>>> For[i = 1.11111111111111111111, i>  0, Print[i = 2*i - i]]
>>>>
>>>> This came to my attention (again), and I thought it might amuse
>>>> current readers of this newsgroup.
>>>>
>>>> What looks like an infinite loop terminates with i==0 being true.  also
>>>> i==2 is true.  (Tested in Mathematica 6.0; I don't have access to 7 yet.)
>>>>
>>>>         
>>> It's because of precision loss:
>>>
>>> For[i = 1.11111111111111111111, i > 0,
>>>  Print[i = 2*i - i, "\t", Precision[i]]]
>>>
>>> For similar results to what C/Fortran/etc. would give (no high precision
>>> arithmetic with precision tracking), use machine precision numbers:
>>>
>>> For[i = 1.1111111111111111, i > 0,
>>>  Print[i = 2*i - i, "\t", Precision[i]]]
>>>       
>> Yes, I know.
>>     
>
> You should have mentioned it in your message then.  Otherwise you just
> confuse beginners/newcomers, and that is not nice.
>   
Actually, I mention this target group  (current readers) in my original 
message. My intention was to alert them to this odd phenomenon.
>   
>> I think a design that allows one to create objects such as i
>> that i==0 and i==2 simultaneously is problematical.  Do you agree?
>>     
>
> No, not really.  I don't see how a program that supports arbitrary
> precision arithmetic could avoid this, and still be convenient to use.
Numerous systems support arbitrary precision arithmetic, and they avoid 
this problem.
I think that what you mean to say is that Mathematica implements  
"significance arithmetic".
This is an idea abandoned by numerical analysts in the late 1960s, and 
either revived or re-invented by WRI.
>  (I suppose you were referring to the lack of transitivity.) 
Also that 0.==1. This a pretty damning defect in a system that is 
supposed to "do mathematics".
>  Suppose
> we have a system that works with decimals.  We have a=0.5 with one
> digit precision, and b=0.51 and c=0.50 with two digit precision.  Both
> b and c become 0.5 when rounded to 1 digit.  Which of the following
> comparisons should give true?  Which should give false?  Why?
>
> a == b, b == c, a == c
>   

If a= 0.5,  then you can treat it as 0.500000000000000000000000... in a 
binary system since that is exactly representable in binary.
and if b=0.51, then you can treat it as some (exact) number in your 
base, close to 0.51. Some binary float in some precision.
perhaps that would be printed as SetPrecision[0.51,40]= 
0.5100000000000000088817841970012523233891

If you want to round these numbers, you can instruct the computer to 
round them, and then it will be clear what
their exact values, after rounding, are.  As given,

a is equal to c.   a is not equal to b.  b is not equal to c.

Compare to

For[i = Interval[{1.1, 1.2}],   i > 0,
 Print[i = 2*i - i, "\t", Precision[i]]]

> P.S. I am not familiar with the topic of precision tracking on computers.
>   

google for "significance arithmetic".
 One useful discussion is 
http://www.av8n.com/physics/uncertainty.htm#sec-abomination
or see the Wikipedia article.
There is also
http://www.wolfram.com/technology/guide/SignificanceArithmetic/
which gives the WRI marketing blurb on the topic, but has no links to 
the literature.
 Wolfram|alpha doesn't know about significance arithmetic...


RJF



  • Prev by Date: Re: How does Eigensystem works ?
  • Next by Date: Re: Re: Re: Manipulate: How to
  • Previous by thread: Re: Re: An arithmetic puzzle, equality of numbers.
  • Next by thread: Re: Re: An arithmetic puzzle, equality of numbers.