Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* A way to restore sanity to IEEE FP math.
@ 1999-09-05 23:52 David McClain
  0 siblings, 0 replies; only message in thread
From: David McClain @ 1999-09-05 23:52 UTC (permalink / raw)
  To: caml-list

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





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-09-06 16:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-05 23:52 A way to restore sanity to IEEE FP math David McClain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox