IEEE-ATAN-BRANCH-CUTIEEE 754 floating-point arithmetic, then slight adjustments in the branch cuts of transcendental functions are appropriate.
If there is a minus zero and a plus zero, then *no* complex number is actually "on the axis" whether real or imaginary. Instead, numbers of the form x+0i and x-0i straddle the real axis, and those of the form 0+xi and -0+xi straddle the imginary axis. Branch cuts that lie on the axes therefore run between such numbers, and directions of continuity are not an issue.
ATAN, covering the cases where there is or is not a minus zero, and then redefine *all* other functions that have branch cuts in terms of two-argument ATAN. Specifically, we first define PHASE in terms of two-argument ATAN, and complex ABS in terms of real SQRT (which has no branch cut problems); then define complex LOG in terms of PHASE, ABS, and real LOG; then define complex SQRT in terms of LOG; and then define all others in terms of these.
In this propoal Lisp expressions should be taken as mathematical formulas that actually are implemented in other ways for improved accuracy.
(1) If there is no minus zero, two-argument ATAN behaves as in CLtL. If there is a minus zero, then some cases are modified: Condition result y=+0 x>0 +0 y=-0 x>0 -0 y=+0 x<0 +pi y=-0 x<0 -pi y=+0 x=+0 +0 y=-0 x=+0 -0 y=+0 x=-0 +pi y=-0 x=-0 -pi The range of two-argument atan therefore includes -pi in this case.
Note that the case y=0 x=0 is an error in the absence of minus zero, but is defined in the presence of minus zero.
(2) (PHASE X) = (ATAN (IMAGPART X) (REALPART X)), as before, but now the range of PHASE may include -PI if there is a minus zero.
(3) (ABS X) = (SQRT (+ (* (REALPART X) (REALPART X)) (* (IMAGPART X) (IMAGPART X)))), as before
(4) (LOG X) = (COMPLEX (LOG (ABS X)) (PHASE X))
(5) (SQRT X) = (EXP (/ (LOG X) 2))
(6) For EXPT, ASIN, ACOS, ATAN, ASINH, ACOSH, ATANH use the formulas in CLtL pp. 211-213, but use the formulas (1-5) above as the definitions of LOG and SQRT in order to determine the branch cuts properly.
(LOG #c(-1.0 +0.0)) => #c(0.0 3.14159...) ;Current (LOG #c(-1.0 -0.0)) => #c(0.0 3.14159...) ;Current
(LOG #c(-1.0 +0.0)) => #c(0.0 3.14159...) ;Proposed (= current) (LOG #c(-1.0 -0.0)) => #c(0.0 -3.14159...) ;Proposed (conjugate)
IEEE floating-point arithmetic. The proposed specification produces results more natural to that arithmetic.CL 2.1.3 of 10-Nov-88 and Symbolics CL, all follow the current CLtL specification.
The IEEE trig library atan2 routine written by K.C. Ng (with the advice or supervision of W. Kahan, I believe), and distributed with BSD UNIX (it is file /usr/src/usr.lib/libm/IEEE/atan2.c on my machine) follows this proposal for treatment of minus zero.
ZEROP need to be rewritten to use FLOAT-SIGN instead.The compatibility note on p. 210 of CLtL gave users fair warning that a change of this kind might be adopted.
IEEE floating-point arithmetic.