# [Maxima] Implementation of Gamma functions

Dieter Kaiser drdieterkaiser at web.de
Sat Sep 6 14:55:09 CDT 2008

```Thank very much for the feedback.

I like long names too. For use it is possible to define a short name via a
function definition or an alias. Second, I would like the convention that the
main name of the function is always at the beginning e.g. laguerre_generalized
and not gen_laguerre. The long names would look like:

gamma_incomplete(a,z)
gamma_incomplete_generalized(a,z1,z2)
gamma_incomplete_regularized(a,z)
gamma_incomplete_generalized_regularized(a,z1,z2)

Yes, gamma_greek is the most confusing name and perhaps we should avoid the use
of this function. The Maxima symbol gammagreek is only used in the code of
specint and perhaps could be completely eliminated.

The biggest problem is that it is not always clear what is meant by the
Incomplete Gamma function. A&S gives three different definitions with the
formulas 6.5.1, 6.5.2 and 6.5.3 but do not distinguish the definitions with
different names. The definitions are:

6.5.1: P(a,x)     = 1/Gamma(a) * integral(exp(-t)*t^(a-1),t,0,x) (lower tail)

6.5.2: gamma(a,x) = P(a,x)*Gamma(a)                  (lower case Greek gamma)

6.5.3: Gamma(a,x) = integral(exp(-t)*t^(a-1),t,x,inf)            (upper tail)
= Gamma(a)-gamma(a,x)              (upper case Greek gamma)

The Maxima symbol gammagreek follows the definition in A&S 6.5.2. The Maxima
symbol gammaincomplete means the definition 6.5.3.

The Numerical Recipes use the following conventions:

P(a,x) = Gamma(a,x)/gamma(a)   (Incomplete Gamma function)
Q(a,x) = gamma(a,x)/gamma(a)   (Complement of the Incomplete Gamma function)
= 1-Gamma(a,x)/Gamma(a)

That is opposite to A&S. Here P(a,x) is the upper tail and not the lower tail of
the integral and the function is divided by Gamma(a). The numerical Recipes do
not give extra names for Gamma(a,x) or gamma(a,x).

The names I have suggested follow the conventions of functions.wolfram.com.
There we have the following definition for the Incomplete Gamma function which
is equal to A&S 6.5.3:

Gamma(a,z) = (exp(-t)*t^(a-1),t,x,inf)   (upper tail, Upper case Greek gamma)

A very important feature of this definition is that the interconnections between
a lot of special functions can be expressed more easy and directly with this
definition of the Incomplete Gamma function.

functions.wolfram.com do not introduce a name for the complement of the
Incomplete Gamma function. For the Gamma Incomplete function divided by gamma(a)
the name Regularized Incomplete Gamma function is introduced and the symbol
Q(a,x).

Sorry, but I have not seen that we have numerical routines for the Gamma
functions in the code of numdistrib.lisp. I will have a look at the routines and
compare them against the routines I have written.

Dieter Kaiser

```