


Gamma and Beta Functions
========================

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

.. index:
  Gamma function
  Beta function

.. _gamma-functions:

Gamma Functions
---------------

The :index:`Gamma function` is defined by the following integral,

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

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

.. function:: gsl_sf_gamma(x)

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

.. function:: gsl_sf_lngamma(x)

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

.. function:: gsl_sf_gammastar(x)

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

 .. math::
   \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.

.. function:: gsl_sf_gammainv(x)

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

Pochhammer Symbol
-----------------

.. function:: gsl_sf_poch(a, x)

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

.. function:: gsl_sf_lnpoch(a, x)

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

.. function:: gsl_sf_pochrel(a, x)

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

Incomplete Gamma Functions
--------------------------

.. function:: gsl_sf_gamma_inc(a, x)

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

.. function:: gsl_sf_gamma_inc_Q(a, x)

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

.. function:: gsl_sf_gamma_inc_P(a, x)

 This routine computes the complementary normalized incomplete
 Gamma Function

 .. math::
   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.

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

Beta Functions
--------------

.. function:: gsl_sf_beta(a, b)

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

.. function:: gsl_sf_lnbeta(a, b)

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

Incomplete Beta Function
------------------------

.. function:: gsl_sf_beta_inc(a, b, x)

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

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