fp equality

uunet!cwi.nl!Dik.Winter uunet!cwi.nl!Dik.Winter
Tue Nov 30 19:02:05 PST 1993


 > In the particular case of evaluating functions with a singularity, 
 > it's certainly appropriate to test the arguments
 > for exact equality with the singular point.   Elementary transcendental
 > function libraries do this all the time.   Any uncertainty in the argument
 > is irrelevant in this case; the standard library, not knowing all the
 > uses to which it will be put, must assume the arguments are exact and return
 > a result as close to the exact result as the set of representable numbers
 > and economics allow.

That is not entirely true and depends on the viewpoint you take.  There
are people that think that any result is allowable as long as it is the
exact function value for one of the arguments within the range the
precision allows.  I.e. if you call the cosine function with argument
(single precision) of 1.0, any result is valid that is consistent with
an argument in the range 1.0-2^-24 to 1.0+2^-24.  In this case it does
not matter very much, but for larger arguments it makes a lot of difference.

I know of one system where (on good mathematical grounds) the range
reduction was done by multiplication by the inverse of pi.  But not
the proper rounded value, but a bit tweaked, such that sin(k * pi)
would deliver 0.0 for every integer k and machine precision pi.  Some
hand-held calculators have something similar.  And I have heard numerical
analysts complain that sin(1000 * pi) was not zero on their system.

But of course, this issue is undecided (and will be forever).

There is however another problem if you allow fuzzy comparison only.
Which way you define that fuzzy comparison, there is a function f such
that x ~ y does not imply f(x) ~ f(y), and this is a much bigger problem
than allowing exact comparison.  (Moreover, if you do not have exact
comparison you can not build interval arithmetic, costly, but sometimes
very useful.)
--
dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland
home: bovenover 215, 1025 jn  amsterdam, nederland; e-mail: dikacwi.nl



More information about the Numeric-interest mailing list