acos (may apply to other trigonometric functions) have inconsistent results across different build options
When ECL is build with complex float support, then
CL-USER> (acos 2) ;; #C(0.0 -1.316958)
Otherwise, when it is build without the complex float support then a function ported from cmucl is used (see numlib.lsp):
(defun complex-acos (z)
(declare (number z)
(si::c-local))
(let ((sqrt-1+z (sqrt (+ 1 z)))
(sqrt-1-z (sqrt (- 1 z))))
(complex (* 2 (atan (realpart sqrt-1-z) (realpart sqrt-1+z)))
(asinh (imagpart (* (conjugate sqrt-1+z)
sqrt-1-z))))))
CL-USER> (complex-acos 2) ;; #C(0.0 1.316958)
I'm not sure whether having the positive imaginary part is required by the spec, but the the discrepancy doesn't look good.
-
check whether the result using inlined cacos(2 + I*0.0)
is conforming -
think about how to make results consistent