rtest_trig, atanh and Common Lisp



I've tried out Barton's nice work on double-float eval, and I've come
across an issue.  On clisp, all of the tests in rtest_trig pass.  But
with cmucl, one test fails.

The test is problem 64, which compares the double-float version with
the rectform version.  With cmucl,  atanh(2) is log(3)/2+%i*%pi/2.
However, if you evaluate the rectform of atanh(2) at 2, you get
log(3)/2-%i*%pi/2. 

I think cmucl (and probably sbcl) is right.  The CLHS says:

     a number with imaginary part equal to /2 is in the range if
     and only if its imaginary part is strictly positive.

With signed-zeroes that cmucl supports, 2 has a strictly positive
imaginary part, so %i*%pi/2 is the correct answer.  

Evaluation of the rectform eventually gives log(1-2), which is log(-1)
= +%i*%pi.  However, Kahan says 1-z = 1-(x+%i*y) = 1-x - %i*y, which
would give log(-1-0*%i) = -%i*%pi.

Getting this right is going to be tricky.  And it's bad that maxima
gives different answers depending on which underlying Lisp is used,
unless we can get them all to agree on one value.  Or implement them
ourselves.   (CMUCL has a fairly portable implementation of the
special functions for complex values.)

Ray