
Hey Barak,
These are really good points. They seem worth submitting to the GHC issue
tracker. This would be a first step on the way to improve the current (not
ideal, as you say) state.
—
Best, Artem
On Fri, Sep 17, 2021 at 5:06 PM Barak A. Pearlmutter
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. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.