Hyperbolic arc cosine fails on (-1) :: Complex r.
When allowing for complex results, the hyperbolic arc cosine is continuously defined on all ℝ.
In the (x < (-1))
real ray of the complex plane, acosh
equals \z -> i * pi + acosh(abs z)
, which works fine for almost all arguments. Thus, acosh (-1)
should equal i * pi
; however due to the implementation as
acosh z = log (z + (z+1) * sqrt ((z-1)/(z+1)))
where the denominator in the root becomes zero at z = -1
, this comes out as NaN :+ NaN
.
Could be fixed trivially by adding a special case
acosh ((-1):+0) = 0:+pi
to the instance (RealFloat a) => Floating (Complex a)
in Data.Complex
.
Trac metadata
Trac field | Value |
---|---|
Version | 7.6.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | low |
Resolution | Unresolved |
Component | libraries/base |
Test case | acosh(-1) :: Complex Double |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |