Main Content

igamma

Incomplete gamma function

Description

example

g = igamma(nu,z) returns the upper incomplete gamma function.

igamma uses the definition of the upper incomplete gamma function. However, the default MATLAB® gammainc function uses the definition of the regularized lower incomplete gamma function, where gammainc(z,nu) = 1 - igamma(nu,z)/gamma(nu). The order of input arguments differs between these functions.

Examples

collapse all

Depending on its arguments, igamma returns floating-point or exact symbolic results.

Compute the upper incomplete gamma function for these numbers. Because these numbers are not symbolic objects, you get floating-point results.

g = [igamma(0,1), igamma(3,sqrt(2)), igamma(pi,exp(1)), igamma(3,Inf)]
g = 1×4

    0.2194    1.6601    1.1979         0

Compute the upper incomplete gamma function for the numbers converted to symbolic objects.

symg = [igamma(sym(0),1), igamma(3,sqrt(sym(2))), ...
igamma(sym(pi),exp(sym(1))), igamma(3,sym(Inf))]
symg = (-ei(-1)e-222+4Γigamma(π,e)0)

Use vpa to approximate symbolic results with floating-point numbers.

vpag = vpa(symg)
vpag = (0.219383934395520273677163775460121.66010490389030441048265643735761.19793020813308281968655484717690)

igamma is implemented according to the definition of the upper incomplete gamma function. If you want to compute the lower incomplete gamma function, convert results returned by igamma as follows.

Compute the upper incomplete gamma function for these arguments using igamma.

z = [-5/3, -1/2, 0, 1/3];
gupper = igamma(1/3,z)
gupper = 1×4 complex

  -0.3900 - 5.3156i   1.3156 - 2.3614i   2.6789 + 0.0000i   0.7569 + 0.0000i

Subtract these results out of the gamma function to obtain the lower incomplete gamma function.

glower = gamma(1/3) - gupper
glower = 1×4 complex

   3.0689 + 5.3156i   1.3634 + 2.3614i   0.0000 + 0.0000i   1.9220 + 0.0000i

For comparison, you can also calculate the regularized lower incomplete gamma function by using the MATLAB gammainc function. The regularized definition differs by the gamma function factor.

glower2 = gammainc(z,1/3)*gamma(1/3)
glower2 = 1×4 complex

   3.0689 + 5.3156i   1.3634 + 2.3614i   0.0000 + 0.0000i   1.9220 + 0.0000i

Because gammainc does not accept complex arguments, if one or both arguments are complex numbers, use igamma to compute the regularized lower incomplete gamma function.

gcomplex = 1 - igamma(1/2,1i)/gamma(1/2)
gcomplex = 0.9693 + 0.4741i

Input Arguments

collapse all

Input, specified as a symbolic number, variable, expression, or function, or as a vector or matrix of symbolic numbers, variables, expressions, or functions.

Input, specified as a symbolic number, variable, expression, or function, or as a vector or matrix of symbolic numbers, variables, expressions, or functions.

More About

collapse all

Upper Incomplete Gamma Function

The following integral defines the upper incomplete gamma function:

Γ(η,z)=ztη1etdt

Regularized Lower Incomplete Gamma Function

The following integral defines the regularized lower incomplete gamma function:

γ(z,η)=1Γ(η)0ztη1etdt,

where the gamma function Γ(η) is defined by

Γ(η)=0tη1etdt.

Tips

  • The MATLAB gammainc function does not accept complex arguments. For complex arguments, use igamma.

  • gammainc(z,nu) = 1 - igamma(nu,z)/gamma(nu) represents the regularized lower incomplete gamma function in terms of the upper incomplete gamma function.

  • igamma(nu,z) = gamma(nu)*(1 - gammainc(z,nu)) represents the upper incomplete gamma function in terms of the regularized lower incomplete gamma function.

  • gammainc(z,nu,"upper") = igamma(nu,z)/gamma(nu).

Version History

Introduced in R2014a

See Also

| | | | |