This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nirinA
Recipients mark.dickinson, nirinA, stutzbach, terry.reedy
Date 2008-07-21.13:10:27
SpamBayes Score 0.007359365
Marked as misclassified No
Message-id <1216645836.62.0.59473696163.issue3366@psf.upfronthosting.co.za>
In-reply-to
Content
here is an attempt to make erf, erfc, lgamma and tgamma
accessible from math module.
erf and erfc are crude translation of the code pointed
out by Daniel Stutbach.
lgamma is also taken from sourceware.org, but doesn't
use the reentrant call for the sign.

i tested only on gcc-4.3.1/linux-2.6.26.
i'll write a testsuite soon.

some results:

Python 3.0b2 (r30b2:65080, Jul 21 2008, 13:13:13) 
[GCC 4.3.1] on linux2

>>> print(math.tgamma(0.5))
1.77245385091
>>> print(math.sqrt(math.pi))
1.77245385091
>>> print(math.tgamma(1.5))
0.886226925453
>>> print(math.sqrt(math.pi)/2)
0.886226925453
>>> print(math.sqrt(math.pi)*3/4)
1.32934038818
>>> print(math.tgamma(2.5))
1.32934038818
>>> for i in range(14):
	print(i, math.lgamma(i), math.tgamma(i))
	
0 inf inf
1 0.0 1.0
2 0.0 1.0
3 0.69314718056 2.0
4 1.79175946923 6.0
5 3.17805383035 24.0
6 4.78749174278 120.0
7 6.57925121201 720.0
8 8.52516136107 5040.0
9 10.6046029027 40320.0
10 12.8018274801 362880.0
11 15.1044125731 3628800.0
12 17.5023078459 39916800.0
13 19.9872144957 479001600.0

>>> for i in range(-14,0):
	print(i/5, math.lgamma(i/5), math.tgamma(i/5))
	
-2.8 0.129801291662 -1.13860211111
-2.6 -0.118011632805 -0.888685714647
-2.4 0.102583615968 -1.10802994703
-2.2 0.790718673676 -2.20498051842
-2.0 inf inf
-1.8 1.15942070884 3.18808591111
-1.6 0.837499812222 2.31058285808
-1.4 0.978052353322 2.65927187288
-1.2 1.57917603404 4.85095714052
-1.0 inf -inf
-0.8 1.74720737374 -5.73855464
-0.6 1.30750344147 -3.69693257293
-0.4 1.31452458994 -3.72298062203
-0.2 1.76149759083 -5.82114856863

>>> math.erf(INF)
1.0
>>> math.erf(-INF)
-1.0
>>> math.erfc(INF)
0.0
>>> math.erfc(-INF)
2.0
>>> math.erf(0.6174)
0.61741074841139409
History
Date User Action Args
2008-07-21 13:10:37nirinAsetspambayes_score: 0.00735937 -> 0.007359365
recipients: + nirinA, terry.reedy, mark.dickinson, stutzbach
2008-07-21 13:10:36nirinAsetspambayes_score: 0.00735937 -> 0.00735937
messageid: <1216645836.62.0.59473696163.issue3366@psf.upfronthosting.co.za>
2008-07-21 13:10:34nirinAlinkissue3366 messages
2008-07-21 13:10:33nirinAcreate