Mark Dickinson <dicki...@gmail.com> added the comment: A first attempt for lgamma, using Lanczos' formula.
In general, this gives very good accuracy. As the tests show, there's one big problem area, namely when gamma(x) is close to +-1, so that lgamma(x) is close to 0. This happens for x ~ 1.0, x ~ 2.0, and various negative values of x (mathematically, lgamma(x) hits zero twice in each interval (n-1, n) for n <= -2). In that case the accuracy is still good in absolute terms (around 1e-15 absolute error), but terrible in ulp terms. I think it's reasonable to allow an absolute error of a few times the machine epsilon in lgamma: for many uses, the lgamma result will be exponentiated at some point (often after adding or subtracting other lgamma results), and at that point this absolute error just becomes a small relative error. ---------- Added file: http://bugs.python.org/file15008/lgamma1.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue3366> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com