From: Robert Dodier <robert.dodier@gm...>  20060227 14:07:10

On 2/22/06, Christophe Rhodes <csr21@...> wrote: > The question raised by your test script is: what does 2.5 mean in the > complex plane? Is it 2.5+0.0i, 2.50.0i or 2.5+<exactly 0>i? Does > 2.5 mean 2.5+0.0i, 2.50.0i or 2.5+<exactly 0>i? I suppose that > the simple view would be that these real floats are on the axis, but > unfortunately that's not what the rest of the spec says; (COMPLEX 2.5) > is #c(2.5 0.0), but while (complex 2.5) is #c(2.5 0.0), according to > the spec (IMAGPART 2.5) is 0.0. Well, the discrepancy between (imagpart (complex 2.5)) and (imagpart 2.5) is certainly disheartening ... From a broader perspective, that the CLHS allows implementations to return different results depending on the presence or absence of signed zero makes it very burdensome for a programmer to write portable code. Too bad about that I guess. > I think that the first thing to do is check whether or not the various > trig functions obey the branch cuts when given arguments of type > complex: that is, with an explicit positive or negative zero imaginary > part. After that, we can discuss what the most useful interpretation > of the real numbers in terms of the branch cuts are. OK, I've studied this problem some more and here's what I've come to. I believe the CLHS is OK wrt asin and acos. About atanh, the CLHS specifies behavior according to the formula atanh x =3D (log(1 + x)  log(1  x))/2 and then goes on to give a description of branch cuts which, to the best of my knowledge, is inconsistent with the formula. I'm assuming the formula is the spec and the stuff about branch cuts is just commentary. So (I've concluded) the branch cuts for asin, acos, and atanh should all (\infty, 1) continuous w/ 2nd quadrant, and (1, \infty) continuous w/ 4th quadrant. For arguments which are complex numbers, it appears that the SBCL asin, acos, and atanh have branch cuts which are continuous with 2nd and 1st quadrants, respectively. See the PS below. For the record, other CL implementations that I know about (GCL, Clisp, CMUCL) make differing choices of branch cuts, and no two of the four make the same choices on all three functions asin, acos, and atanh. For what it's worth, Robert Dodier PS. test script: (format t "~S~%~S~%~S~%~%" (cl:asin #C(2.5 0.01)) (cl:asin #C(2.5 0.0)) (cl:asin #C(2.5 0.01))) (format t "~S~%~S~%~S~%~%" (cl:asin #C(2.5 0.01)) (cl:asin #C(2.5 0.0)) (cl:asin #C(2.5 0.01))) (format t "~S~%~S~%~S~%~%" (cl:acos #C(2.5 0.01)) (cl:acos #C(2.5 0.0)) (cl:acos #C(2.5 0.01))) (format t "~S~%~S~%~S~%~%" (cl:acos #C(2.5 0.01)) (cl:acos #C(2.5 0.0)) (cl:acos #C(2.5 0.01))) (format t "~S~%~S~%~S~%~%" (cl:atanh #C(2.5 0.01)) (cl:atanh #C(2.5 0.0)) (cl:atanh #C(2.5 0.01))) (format t "~S~%~S~%~S~%~%" (cl:atanh #C(2.5 0.01)) (cl:atanh #C(2.5 0.0)) (cl:atanh #C(2.5 0.01))) output: #C(1.566432 1.5668098) #C(1.5707964 1.5667993) #C(1.566432 1.5668098) #C(1.566432 1.5668098) #C(1.5707964 1.5667993) #C(1.566432 1.5668098) #C(0.004364322 1.5668098) #C(0.0 1.5667993) #C(0.004364322 1.5668098) #C(3.1372283 1.5668098) #C(3.1415927 1.5667993) #C(3.1372283 1.5668098) #C(0.42363986 1.5688916) #C(0.42364892 1.5707964) #C(0.42363986 1.5688916) #C(0.42363986 1.5688916) #C(0.42364892 1.5707964) #C(0.42363986 1.5688916) 