Gamma, Beta and Related Functions


Function Library Home
Gamma, Beta and Related Functions

Gamma and Log Gamma Functions

The gamma function is defined as:
Γ(a) = ∫0t a-1e-tdt.
For complex a the gamma function, Γ(a), is meromorphic in the complex plane with simple poles at the nonpositive real integers. The gamma function is evaluated for real a using Lanczos's expression with a Lanczos error estimate of 8 x 10-15. This estimate should be valid except near a pole.
Note that for a > 0, the gamma function is positive while if a < 0, the sign of the gamma function alternates between adjacent poles.

Function List

    Functions:
  • double Gamma_Function( double x )
     
    This function returns Γ(x) for 0 < x ≤ Gamma_Function_Max_Arg() or if -Gamma_Function_Max_Arg() ≤ x < 0 and x is not a pole (nonpositive integer). If x > Gamma_Function_Max_Arg() or if x < -Gamma_Function_Max_Arg() and x is not a pole (nonpositive integer) then 0 is returned. If x is a pole, then DBL_MAX is returned, but note that the gamma function changes sign on either side of a pole.

  • long double xGamma_Function( long double x )
     
    This is the same as that for the Gamma_Function() except that a long double is returned.

  • double Gamma_Function_Max_Arg( void )
     
    This function returns the maximum argument x for which Γ(x) is representable as the type double.

  • long double xGamma_Function_Max_Arg( void )
     
    This function returns the maximum argument x for which Γ(x) is representable as the type long double.

  • double Ln_Gamma_Function( double x )
     
    This function returns ln(Γ(x)) for x > 0. The argument x must be positive. Note that for negative x, ln(Γ(x)) may be imaginary.

  • long double xLn_Gamma_Function( long double x )
     
    This is the same as that for the Ln_Gamma_Function() except that a long double is returned.

Incomplete Gamma Function

The incomplete gamma function is defined as:
γ(x,ν) = ∫0xt ν-1e-tdt.

Function List

    Functions:
  • double Incomplete_Gamma_Function(double x, double nu)
     
    This function returns γ(x,ν) = ∫0xt ν-1e-tdt.

  • long double xIncomplete_Gamma_Function(long double x, long double nu)
     
    This is the same as that for the Incomplete_Gamma_Function() except that the arguments are of type long double and the return value is of type long double.

Entire Incomplete Gamma Function

The entire incomplete gamma function is defined as:
γ*(x,ν) = (1 / Γ(ν) ) ∫0xt ν-1e-tdt.

Function List

    Function:
  • double Entire_Incomplete_Gamma_Function(double x, double nu)
     
    This function returns γ*(x,ν) = (1 / Γ(ν) ) ∫0xt ν-1e-tdt.

  • long double xEntire_Incomplete_Gamma_Function(long double x, long double nu)
     
    This is the same as that for the Entire_Incomplete_Gamma_Function() except that the arguments are of type long double and the return value is of type long double.

Digamma

The digamma function, also called the psi function, is defined as:
&psi(x)=(1/Γ(x)) dΓ(x)/dx.
The digamma function has positive slope throughout its domain of definition with infinite singularities at the nonpositive integers.

Function List

    Function:
  • double DiGamma_Function( double x )
     
    This function returns &psi(x) if x is not a nonpositive integer and DBL_MAX if x is a nonpositive integer.

  • long double xDiGamma_Function( long double x )
     
    This is the same as that for the DiGamma_Function() except that the argument is of type long double and the return value is of type long double.

Beta and Log Beta Functions

The beta function B(a,b) is defined as:
B(a,b) = ∫01t a-1(1-t) b-1dt = Γ(a) Γ(b) / Γ(a + b), where a > 0 and b > 0.

Function List

    Functions:
  • double Beta_Function( double a, double b)
     
    This function returns B(a,b) for positive a and b. If B(a,b) > DBL_MAX, then DBL_MAX is returned.

  • long double xBeta_Function( long double a, long double b)
     
    This is the same as that for the Beta_Function() except that the arguments are of type long double and a long double is returned.

  • double Ln_Beta_Function( double a, double b)
     
    This function returns ln(B(a,b)) for positive a and b.

  • long double xLn_Beta_Function( long double a, long double b)
     
    This is the same as that for the Ln_Beta_Function() except that the arguments are of type long double and a long double is returned.

Incomplete Beta Function

This function returns Ix(a,b) = ∫0xt a-1(1-t) b-1dt, where a > 0, b > 0. and 0 ≤ x ≤ 1.

Function List

    Functions:
  • double Incomplete_Beta_Function( double x, double a, double b )
     
    This function returns Ix(a,b). If Ix(a,b) > DBL_MAX, then DBL_MAX is returned.

  • long double xIncomplete_Beta_Function( long double x, long double a, long double b )
     
    This is the same as that for the Incomplete_Beta_Function() except that the arguments are of type long double and a long double is returned.