# [Python-3000] adding gamma and error functions to math module

nirinA raseliarison nirina at mail.blueline.mg
Tue Jul 15 10:10:30 CEST 2008

```gammas and errors functions are available from the C standard
library. it would be nice to have them in the math module.
or is there any reason not to include them?

diff -u1 /usr/local/src/Python-3.0b1/Modules/mathmodule.c mathmodule.c
<diff>
--- /usr/local/src/Python-3.0b1/Modules/mathmodule.c	2008-06-18 13:04:31.000000000 +0300
+++ mathmodule.c	2008-07-14 23:30:17.000000000 +0300
@@ -329,2 +329,7 @@
"cosh(x)\n\nReturn the hyperbolic cosine of x.")
+FUNC1(erf, erf, 0,
+      "erf(x)\n\nReturn the error function of x.")
+FUNC1(erfc, erfc, 0,
+      "erfc(x)\n\nReturn the complementary error function of x.\n\
+      A domain error may occur if x is too large.")
FUNC1(exp, exp, 1,
@@ -355,2 +360,6 @@

+FUNC1(lgamma, lgamma, 0,
+      "lgamma(x)\n\nReturn the natural logarithm of the absolute\n\
+      value of the gamma function of x.\n\
+      A domain error occurs if x is a negative integer or zero.")
FUNC1(log1p, log1p, 1,
@@ -368,2 +377,6 @@
"tanh(x)\n\nReturn the hyperbolic tangent of x.")
+FUNC1(tgamma, tgamma, 0,
+      "tgamma(x)\n\nReturn the gamma function of x.\n\
+      A domain error occurs if x is a negative integer or zero\n\
+      or if the magnitude of x is too large or too small.")

@@ -1075,2 +1088,4 @@
{"degrees",	math_degrees,	METH_O,		math_degrees_doc},
+        {"erf", math_erf,	METH_O,		math_erf_doc},
+        {"erfc",	math_erfc,	METH_O,		math_erfc_doc},
{"exp",		math_exp,	METH_O,		math_exp_doc},
@@ -1085,2 +1100,3 @@
{"ldexp",	math_ldexp,	METH_VARARGS,	math_ldexp_doc},
+        {"lgamma",	math_lgamma,	METH_O,		math_lgamma_doc},
{"log",		math_log,	METH_VARARGS,	math_log_doc},
@@ -1097,2 +1113,3 @@
{"tanh",	math_tanh,	METH_O,		math_tanh_doc},
+        {"tgamma",	math_tgamma,	METH_O,		math_tgamma_doc},
{"trunc",	math_trunc,	METH_O,		math_trunc_doc},

</diff>

nirinA

--

```