Proposal: Add log1p and expm1 to GHC.Float.Floating
Daniel Trstenjak
daniel.trstenjak at gmail.com
Mon Apr 21 08:34:38 UTC 2014
On Sun, Apr 20, 2014 at 11:25:36PM -0400, Edward Kmett wrote:
> I use log1p as a better log (1 + x).
>
> It lets me pick up a few decimal places worth of accuracy opportunistically.
But isn't it a bit unfortunate to take a function name that is known and
used in numercial circles to get a higher accuracy and in the Haskell
world it only might give you a higher accuracy?
I'm not that much into numerics, but are you really using log1p without
also really needing it?
If you're using log1p to possibly get a higher accuracy but don't really
need it, why you're using it in the first place?
Both solutions - a log1p without a higher accuracy and throwing an error - seem
to be somehow unsatisfactory. It might be nice to be able to define a warning
for default implementations that might not do what you expect, but this also just
seems like another workaround.
Is it completely out of question to have another type class for these
higher accuracy functions?
Sure, if you're having some code that's generic on Floating, which
should just work with and without these higher accuracy funtions, then
this is out of question.
But then at least IMHO the function names should somehow indicate that
you can't be sure that they return a higher accuracy.
Greetings,
Daniel
More information about the Libraries
mailing list