[GHC] #8539: Data.Complex shouldn't use default implementation of (**)

GHC ghc-devs at haskell.org
Sat Apr 26 15:07:55 UTC 2014


#8539: Data.Complex shouldn't use default implementation of (**)
-------------------------------------+-------------------------------------
        Reporter:  jjaredsimpson     |            Owner:
            Type:  bug               |           Status:  patch
        Priority:  low               |        Milestone:
       Component:  Prelude           |          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:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+-------------------------------------

Comment (by yalas):

 What about just adding check x>=0?
 {{{
 (x:+0) ** (y:+0)
   | x >= 0     =  (x ** y) :+ 0
 x ** y         =  exp (log x * y)
 }}}
 It will be more accurate when raising real numbers to real power:
 {{{
 Prelude Data.Complex> exp (log (2) * 4) :: Complex Double
 15.999999999999998 :+ 0.0
 Prelude Data.Complex> 2**4 :: Double
 16.0
 }}}

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


More information about the ghc-tickets mailing list