[Haskell-cafe] Numerics (was: Re: Trouble with asinh)

Barak A. Pearlmutter barak at pearlmutter.net
Fri Sep 17 16:13:01 UTC 2021


The numerics in Haskell have not been carefully vetted, for a variety
of reasons. Not just under MS Windows, even under Linux. Here's an
example: atan has drastic loss of precision in the imaginary direction
around zero in the complex domain.

$ ghci
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
Prelude> :m + Data.Complex

Prelude Data.Complex> tan (1e-20 :+ 0)
1.0e-20 :+ 0.0

Prelude Data.Complex> atan (1e-20 :+ 0)
1.0e-20 :+ (-0.0)

Prelude Data.Complex> tan (0 :+ 1e-20)
0.0 :+ 1.0e-20

Prelude Data.Complex> atan (0 :+ 1e-20)
0.0 :+ (-0.0)

Although there have been amazing efforts to use fancy PLT methods to
improve the numerics of programs using source-to-source
transformations and such, the boring janitorial work of checking and
fixing numeric issues in the standard library doesn't seem to attract
people. To be fair, it isn't my cup of tea either...


More information about the Haskell-Cafe mailing list