Re: Re: An arithmetic puzzle, equality of numbers.
- To: mathgroup at smc.vnet.net
- Subject: [mg103137] Re: [mg103097] Re: An arithmetic puzzle, equality of numbers.
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Wed, 9 Sep 2009 04:42:10 -0400 (EDT)
- References: <h829m8$3ue$1@smc.vnet.net> <4AA4BA87.3020500@gmail.com> <4AA5167F.8090105@cs.berkeley.edu> <f831b3d60909070809u7eed1eb8o6575b2e97bf8ba49@mail.gmail.com> <200909080956.FAA26432@smc.vnet.net>
Richard Fateman wrote:
> 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.
With great success (assuming it was really abandoned; I don't know).
Interesting thing: with the emergence of hybrid computation, it seems
researchers are now trying to reinvent it yet again. This at least is my
observation, based on anecdotal evidence.
>> (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
One very good reference is
M. Sofroniou and G. Spaletta. Precise numerical computation.
The Journal of Logic and Algebraic Programming 64:113-134. 2005.
See the URLs below.
http://library.wolfram.com/infocenter/Articles/2044/
Newer version:
http://www.sciencedirect.com/science?_ob=ArticleURL&_udi=B6W8D-4FFGJ35-1&_user=10&_rdoc=1&_fmt=&_orig=search&_sort=d&_docanchor=&view=c&_searchStrId=1004527983&_rerunOrigin=google&_acct=C000050221&_version=1&_urlVersion=0&_userid=10&md5=f51b36da2c014952f2f2adfffca5edee
As for the example that began this thread, it's been raised several
times over the years. Here are links to a few of the responses; further
information can be found by spelunking their threads.
http://forums.wolfram.com/mathgroup/archive/2000/Jun/msg00256.html
http://forums.wolfram.com/mathgroup/archive/2000/Jun/msg00316.html
http://forums.wolfram.com/mathgroup/archive/2001/Nov/msg00119.html
(above has numerous further links, probably now dead...)
http://forums.wolfram.com/mathgroup/archive/2001/Nov/msg00192.html
For the record, I still think this is a waste of time (non-)issue.
Daniel Lichtblau
Wolfram Research
- References:
- Re: An arithmetic puzzle, equality of numbers.
- From: Richard Fateman <fateman@cs.berkeley.edu>
- Re: An arithmetic puzzle, equality of numbers.