[issue3366] Add gamma function, error functions and other C99 math.h functions to math module
Mark Dickinson
report at bugs.python.org
Fri Sep 18 22:43:54 CEST 2009
Mark Dickinson <dickinsm at gmail.com> added the comment:
Here's a more careful patch for just the gamma function. It's a fairly
direct implementation of Lanczos' formula, with the choice of parameters
(N=13, g=6.024680040776729583740234375) taken from the Boost library. In
testing of random values and known difficult values, it's consistently
giving errors of < 5ulps across its domain. This is considerably better
than the error from the exp(lgamma(x)) method, since the exp call alone
can easily introduce errors of hundreds of ulps for larger values of x.
I'd appreciate any feedback, especially if anyone has the chance to test
on Windows: I'd like to know whether I got the build modifications right.
This patch *doesn't* use the system gamma function, even when available.
At least on OS X 10.5.8, the supplied gamma function has pretty terrible
accuracy, and some severe numerical problems near negative integers. I
don't imagine Linux is much better.
Once this is working, I'll concentrate on lgamma. Then erf and erfc.
----------
Added file: http://bugs.python.org/file14927/gamma3.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3366>
_______________________________________
More information about the Python-bugs-list
mailing list