# Gamma and Beta Functions¶

This following routines compute the gamma and beta functions in their full and incomplete forms.

## Gamma Functions¶

The Gamma function is defined by the following integral,

$\Gamma(x) = \int_0^\infty t^{x-1} \exp(-t) dt$

It is related to the factorial function by $$\Gamma(n)=(n-1)!$$ for positive integer $$n$$. Further information on the Gamma function can be found in Abramowitz & Stegun, Chapter 6.

gsl_sf_gamma(x)

This routine computes the Gamma function $$\Gamma(x)$$, subject to $$x$$ not being a negative integer or zero. The function is computed using the real Lanczos method. The maximum value of $$x$$ such that $$\Gamma(x)$$ is not considered an overflow is 171.0.

gsl_sf_lngamma(x)

This routine computes the logarithm of the Gamma function, $$\log(\Gamma(x))$$, subject to $$x$$ not being a negative integer or zero. For $$x<0$$ the real part of $$\log(\Gamma(x))$$ is returned, which is equivalent to $$\log(|\Gamma(x)|)$$. The function is computed using the real Lanczos method.

gsl_sf_gammastar(x)

This routine computes the regulated Gamma Function $$\Gamma^*(x)$$ for $$x > 0$$. The regulated gamma function is given by,

$\Gamma^*(x) = \Gamma(x)/(\sqrt{2\pi} x^{(x-1/2)} \exp(-x)) = (1 + (1/12x) + ...) \text{ for } x \to \infty$

and is a useful suggestion of Temme.

gsl_sf_gammainv(x)

This routine computes the reciprocal of the gamma function, $$1/\Gamma(x)$$ using the real Lanczos method.

## Pochhammer Symbol¶

gsl_sf_poch(a, x)

This routine computes the Pochhammer symbol $$(a)_x = \Gamma(a + x)/\Gamma(a)$$. The Pochhammer symbol is also known as the Apell symbol and sometimes written as $$(a,x)$$. When $$a$$ and $$a+x$$ are negative integers or zero, the limiting value of the ratio is returned.

gsl_sf_lnpoch(a, x)

This routine computes the logarithm of the Pochhammer symbol, $$\log((a)_x) = \log(\Gamma(a + x)/\Gamma(a))$$.

gsl_sf_pochrel(a, x)

This routine computes the relative Pochhammer symbol $$((a)_x - 1)/x$$ where $$(a)_x = \Gamma(a + x)/\Gamma(a)$$.

## Incomplete Gamma Functions¶

gsl_sf_gamma_inc(a, x)

This routine computes the unnormalized incomplete Gamma Function $$\Gamma(a,x) = \int_x^\infty t^{a-1} \exp(-t) dt$$ for a real and $$x \geq 0$$.

gsl_sf_gamma_inc_Q(a, x)

This routine computes the normalized incomplete Gamma Function $$Q(a,x) = 1/\Gamma(a) \int_x^\infty t^{a-1} \exp(-t) dt$$ for $$a > 0$$, $$x \geq 0$$.

gsl_sf_gamma_inc_P(a, x)

This routine computes the complementary normalized incomplete Gamma Function

$\begin{split}P(a,x) = 1 - Q(a,x) = 1/\Gamma(a) \int_0^x t^{a-1} \exp(-t) dt \text{ for } a > 0, x \geq 0.\end{split}$

Note that Abramowitz & Stegun call $$P(a,x)$$ the incomplete gamma function (section 6.5).

## Beta Functions¶

gsl_sf_beta(a, b)

This routine computes the Beta Function, $$\operatorname{B}(a,b) = \Gamma(a)\Gamma(b)/\Gamma(a+b)$$ subject to $$a$$ and $$b$$ not being negative integers.

gsl_sf_lnbeta(a, b)

This routine computes the logarithm of the Beta Function, $$\log(\operatorname{B}(a,b))$$ subject to $$a$$ and $$b$$ not being negative integers.

## Incomplete Beta Function¶

gsl_sf_beta_inc(a, b, x)

This routine computes the normalized incomplete Beta function $$I_x(a,b) = \operatorname{B}_x(a,b)/\operatorname{B}(a,b)$$ where $$\operatorname{B}_x(a,b) = \int_0^x t^{a-1} (1-t)^{b-1} dt$$ for $$0 \leq x \leq 1$$. For $$a > 0$$, $$b > 0$$ the value is computed using a continued fraction expansion. For all other values it is computed using the relation

$I_x(a,b) = (1/a) x^a {}_2F_1(a,1-b,a+1,x)/\operatorname{B}(a,b).$