Possible std.math.exp() bug
anthony.difranco at yale.edu-
anthony.difranco at yale.edu-
Wed Apr 12 06:27:48 PDT 2006
Thanks for the view from within, but it ended up being something else causing
the overflow, and regular lgamma is fine in the correct context. I'll file that
away for forays into the combinatorics of ridiculous quantities.
>
>For x > 1e10, it looks as though this is all lgamma() is doing:
>
>const real LOGSQRT2PI = 0.91893853320467274178L;
>
>return ( x - 0.5L ) * log(x) - x + LOGSQRT2PI;
>
>Disturbing. This doesn't look very accurate, although Stirling's
>approximation is probably very good by then.
>
>So for large a, b
>lgamma(a) - lgamma(b)
>= a*(log(a)-1) - b*(log(b)-1) - 0.5 * (log(a) - log(b));
>So overflows can be avoided quite easily ... but is any accuracy left?
More information about the Digitalmars-d-bugs
mailing list