A way to restore sanity to IEEE FP math.

From: David McClain (dmcclain@azstarnet.com)
Date: Mon Sep 06 1999 - 01:52:48 MET DST


From: "David McClain" <dmcclain@azstarnet.com>
To: <caml-list@inria.fr>
Subject: A way to restore sanity to IEEE FP math.
Date: Sun, 5 Sep 1999 16:52:48 -0700

All the recent difficulties I've had with IEEE FP math can be traced to the
bipolar nature of zero. Direct use of this means that although the two
compare as equal, they cause a situation where subtraction is no longer
anitcommutative. They manifest this difficulty most in complex arithmetic
when the function atan2 is used to compute the phase angle of a complex
number.

I recommend, instead, that complex arithmetic use the function phase,
defined as,

    phase re im = atan2 (im +. 0.0) (re +. 0.0)

Doing so preserves the affine infinities, and preserves the use of bipolar
zero for those who need it, but restores the sanity of our number system in
the complex plane.

The phase angle of (-1, 0-) and (-1, 0+) are thus on the same Riemann sheet,
addition retains its cummutative behavior, negation is still idempotent, and
subtraction is restored to anticommutativity.

The only way to detect which zero one might have is through the use of the
curious function atan2, which allows one to see ever so slightly beyond one
Riemann sheet by peeking under the principal sheet along the branch cut on
the negative real axis. But since this is a curious function, and since
complex arithmetic now uses phase to obtain its angles, we have a sensible
system.

Furthermore, the old identities (a + 0) = a are restored, as well as (0 -
a) = -a.
Hence the kinds of quick simplifications one is tempted to do are okay and
will not violate the arithmetic. Our faith can be restored in FP math, and
branch cuts are all properly preserved regardless of the number and kind of
quick simplifications we might be tempted to perform during translation from
algebra to computer code.

Those needing the bipolar zeros for interval arithmetic and for detecting
the sense of arithmetic rounding are still able to achieve their goals, by
means of the atan2 function.

- DM



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:25 MET