[GHC] #8532: Hyperbolic arc cosine fails on (-1) :: Complex r.

GHC ghc-devs at haskell.org
Fri Nov 15 12:49:02 UTC 2013


#8532: Hyperbolic arc cosine fails on (-1) :: Complex r.
-------------------------------------+-------------------------------------
        Reporter:  leftaroundabout   |            Owner:
            Type:  bug               |           Status:  new
        Priority:  low               |        Milestone:
       Component:  libraries/base    |          Version:  7.6.3
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  Incorrect result  |       Difficulty:  Easy (less than 1
  at runtime                         |  hour)
       Test Case:  acosh(-1) ::      |       Blocked By:
  Complex Double                     |  Related Tickets:
        Blocking:                    |
-------------------------------------+-------------------------------------

Comment (by leftaroundabout):

 Replying to [comment:1 carter]:
 > does this behave as expected in the a small radius around -1? (worth at
 least plotting it out)

 For real arguments, it sure enough works.

 {{{
 GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.
 Prelude> :m +Data.Complex
 Prelude Data.Complex> :m +Graphics.Rendering.Chart.Simple
 Prelude Data.Complex Graphics.Rendering.Chart.Simple> :set prompt "> "
 > let re f = realPart . f . realToFrac
 > let im f = imagPart . f . realToFrac
 > plotPNG "acosh-on-reals.png" [-2, -1.99 .. 2] (re acosh) (im acosh)
 }}}

 If you put in complex numbers, there's a problem anyway: the imaginary
 part jumps from {{{+π}}} to {{{-π}}} as {{{Im z}}} becomes negative.
 Still, ([http://www.wolframalpha.com/input/?i=acosh]) it's apparently
 convention that for {{{Im z = 0}}}, we always have {{{Im (acosh(z)) ≥
 0)}}}, including {{{z = -1}}}. At any rate, the real part is 0 there; but
 in the current implementation that is also {{{NaN}}}.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8532#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list