🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #133

Re: Trawl for debugging anecdotes

#133
From: Robert Bernecky
Date: Thu, 09 Apr 1992 16:34
50 lines
3047 bytes
In article <1992Apr3.221541.9682@thinkage.on.ca> atbowler@thinkage.on.ca (Alan Bowler) writes:
>In article <5766@charon.cwi.nl> dik@cwi.nl (Dik T. Winter) writes:
>>On the other hand, within algorithms fuzzy comparisons are frequently needed.
>>Some iterative root finders require at some stage division by the function
>>value found at that stage.  Of course division by 0 is not allowed, so we
>>have to stop (and have actually found a solution) if the function value is 0.
>>But: we must also stop if the function value is close to 0 in some sense,
>>otherwise the division might overflow.  So a fuzzy comparison is needed here.
>>But I see no way to implement fuzzy comparison in general such that this case
>>is covered.
>>-- 
>Thank you for pointing out that the exact form of fuzzy comparision is
>algorithm dependant, and also for the observation that with iterative
>algorithms converging on zero you need an absolute fuzz instead of
>a relative one. (I.e. the APL definition does you no good)
>When coding things like Newton root finders the test I use is
>
>            abs(x - y)
>     ------------------------   < eps1
>     max(abs(x), abs(y), eps2)
>
>Where eps1 and eps2 are chosen depending on the algorithm and the
>hardware.  "eps2" is the point at which you switch from a relative fuzz
>to ann absolute one.  (The APL algorithm is equivalent to having eps2
>equal to zero.

I think the absolute fuzz algorithms are highly non-portable:
The S/360, for example, uses a biased base-16 exponent for floating 
point, rather than IEEE (which didn't exist when S/360 was invented in
1964). This can cause VERY strange problems with comparisons when the
exponent is about to roll over. In particular, you can compare two
numbers, and as you increase one of them, you get not equal, equal 
equal, not equal, equal, equal, then not equal again. This is due to
the way the hardware does comparison. Most unpleasant. 

The APL algorithms are NOT a complete solution: There IS no complete
solution. However, they do work quite well for most problems, and in
thecases where they don't work, you can set the comparison tolerance
to zero, and use your own algorithm. Or, you can just compare against
zero, which has the same effect.

Bob



Robert Bernecky      rbe@yrloc.ipsa.reuter.com  bernecky@itrchq.itrc.on.ca 
Snake Island Research Inc  (416) 368-6944   FAX: (416) 360-4694 
18 Fifth Street, Ward's Island
Toronto, Ontario M5J 2B9 
Canada
Technical Details
Message-ID: <1992Apr9.163440.1921@yrloc.ipsa.reuter.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!news-server.csri.toronto.edu!torsqnt!jtsv16!itcyyz!yrloc!rbe
References: <920@engcon.marshall.ltv.com> <ROCKWELL.92Mar26074202@socrates.umd.edu> <5766@charon.cwi.nl> <1992Apr3.221541.9682@thinkage.on.ca>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!news-server.csri.toronto.edu!torsqnt!jtsv16!itcyyz!yrloc!rbe
From: rbe@yrloc.ipsa.reuter.COM (Robert Bernecky)
Subject: Re: Trawl for debugging anecdotes
Message-ID: <1992Apr9.163440.1921@yrloc.ipsa.reuter.COM>
Reply-To: rbe@yrloc.ipsa.reuter.COM (Robert Bernecky)
Organization: Snake Island Research Inc, Toronto
References: <920@engcon.marshall.ltv.com> <ROCKWELL.92Mar26074202@socrates.umd.edu> <5766@charon.cwi.nl> <1992Apr3.221541.9682@thinkage.on.ca>
Date: Thu, 9 Apr 92 16:34:40 GMT