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

Barak A. Pearlmutter barak at pearlmutter.net
Fri Sep 17 20:54:13 UTC 2021

I suspect that most implementations of Common Lisp just call the C
standard library catan(3) etc, which are well tuned.

$ clisp
Welcome to GNU CLISP 2.49.92 (2018-02-18) <http://clisp.org/>
[1]> (atan #c(0 1d-40))
#C(0 1.0d-40)

In this particular case, the problem is that the Haskell Data.Complex
code has its own implementation of atan, which uses a log(1 + x) in
calculating the imaginary part. A foreign function call to the
appropriate libm routine would robustly address this, but that would
be difficult because it's trying to be generic over RealFloat a =>
Complex a, instead of special casing Complex Float / Complex Double.
Anyway, the Standard Prelude code for this is naïve: it should call
log1p, at the very least—which it actually goes to the trouble of
defining correctly, but not exporting.

More information about the Haskell-Cafe mailing list