# \(\Gamma\)¶

You can use the \(\Gamma\) function to calculate both the Gamma function and the upper incomplete gamma function. The calculated values depends on the number of supplied parameters.

You can use the `\gammafn`

backslash command to insert this function.

The following variants of this function are available:

\(\text{complex } \Gamma \left ( \text{<value>} \right )\)

\(\text{complex } \Gamma \left ( \text{<s>}, \text{<z>} \right )\)

Where \(\text{<value>}\), \(\text{<s>}\), and \(\text{<z>}\) can be
any basic type. The incomplete gamma function is defined over the range
\(\Re \left (s \right ) \geq 0\) and \(\Re \left ( z \right ) \geq 0\)
and will return `NaN`

or generate an error for which the values are not
defined.

Note that run-time type conversion allows the result of this function to be assigned to any basic type provided the returned value is compatible with that type.

The \(\Gamma\) function is defined by the integral:

The upper incomplete gamma function is defined by the integral:

*Aion* also included optimized versions of the gamma function for real and
for complex parameters. *Aion* will also automatically detect usage of the
gamma function or upper incomplete gamma function with \(\ln\) or
\(\log\) functions, as shown below, and will optimize the underlying
implementation to compute log-gamma or log-incomplete gamma directly.

For clarity, *Aion* also makes the \(\text{lnGamma}\) function
available.

The gamma function is calculated using Lanczos approximation [4]. The upper incomplete gamma function is calculated using continued fractions using the algorithm described in [7].

The examples below show how you can use the \(\Gamma\) function: