Haskell 98 - Standard Prelude - Floating Class

Simon Peyton-Jones [email protected]
Mon, 15 Oct 2001 07:34:54 -0700

| > 1. Actually, I wouldn't even call that "default=20
| definitions". These ARE
| >    definitions of sinh and cosh.
| Mathematically, yes.  Numerically, no.  Even if 'exp' is=20
| implemented with high accuracy, the suggested defaults may=20
| return a very inaccurate (in ulps) result.  Take sinh near=20
| zero.  sinh(x) with x very close to 0 should return x.  With=20
| the above 'default' sinh(x) will return exactly 0 for a=20
| relatively wide interval around 0, which is the wrong result=20
| except for 0 itself.

Indeed.  The proposal is only to give "default declarations"
in the class defn for sinh, cosh, and perhaps as Lennart suggests
asinh, acosh, atanh.     They give a reasonable first cut if you
don't write definitions yourself.  But you can overrride them at will.
The only reason not to do this (which amounts to giving a default
decl of "error") is if the default decl is so awful that it's badly
to provide it.  Which doesn't look true in this case.

I don't propose to change any of the actual instance declarations,
because (as Lennart says) it's entirely possible that they have better
numerical properties than the default declarations.