>>>>> "Robert" == Robert Dodier <robert.dodier at gmail.com> writes:
Robert> On 2/26/06, Richard Fateman <fateman at cs.berkeley.edu> wrote:
>> I haven't been following this branch cut discussion much,
>> but I participated in the negotiating between Guy Steele and
>> W. Kahan on the branch cut definitions in CL. The intention
>> was to use Kahan's branch cuts. If they have strayed, that
>> is too bad. One way of "fixing" these bugs is to take the
>> tests that depend on them out of the test suite!
Robert> Sure, but I don't think that's necessary now.
Robert> As to whether CLHS differs from Kahan's recommendations,
Robert> the only discrepancy that I know is that the description of
Robert> the branch cuts of atanh is at odds with the formula
Robert> (log(1 + x) - log(1 - x))/2.
In what way?
I think the issue is what to do when x is a real number on the branch
cuts.
Using the formula, we have:
x 2*atanh(x)
2 log(3)-log(-1)
2+0*%i log(3+0*%i) - log(-1-0*%i) = log(3) + %i*%pi
2-0*%i log(3-0*%i) - log(-1+0*%i) = log(3) - %i*%pi
-2 log(-1) - log(3)
-2+0*%i log(-1+0*%pi) - log(3-0*%i) = -log(3) + %i*%pi
-2-0*%i log(-1-0*%pi) - log(3+0*%i) = -log(3) - %i*%pi
I've used Kahan's convention that 1-z is 1-x-y*%i if z = x+%i*y.
(This is important so we don't lose the sign of zero.)
I think Kahan's convention and the CLHS note is trying to tell you
what value to assign when x is purely real. For x = 2, he wants
continuity with quadrant I, which would be log(3)+%i*%pi. For x =
-2, we want quadrant III or -log(3)-%i*%pi.
Interestingly, in CL, if we applied (complex 2.0) and (complex -2.0), we
would get the right answers because (complex 2.0) is #c(2.0 +0.0) but
(complex -2.0) is #c(-2.0 -0.0). Or was that (imagpart -2.0) is -0.0?
Anyway, CL is inconsistent here, and I'm pretty sure no Lisp gets this
all right.
I don't see how to easily make rectform agree with this, unless we
choose different branch cuts. Perhaps that is the right answer. In
that case, we might use APL's definition that Barton mentioned:
log((1+z)*sqrt(1/(1-z^2))). But note that maxima immediately
simplifies sqrt(1/(1-z^2)) to 1/sqrt(1-z^2). I'd have to check that
that still preserves the branch cuts.
I don't see why we need to be in a hurry to solve this. 5.9.3 gets
whatever we had, and the CVS HEAD will get the solution whenever we
find it.
Ray