Documentation

lngamma

Log-gamma function

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

lngamma(x)

Description

lngamma(x) represents the logarithmic gamma function for positive real x.

The logarithmic gamma function is defined for all complex arguments apart from the singular points 0, - 1, - 2, ….

Along the positive real semi axis, the logarithmic gamma function coincides with the logarithm of the gamma function. For negative or general complex arguments x, however, one has with some integer valued function f(x). The integer multiples of 2 π i are chosen such that lngamma is analytic throughout the complex plane with a branch cut along the negative real semi axes. Cf. Example 4. For negative real x, the value coincides with the limit "from above".

If the argument x is a floating-point value, then lngamma(x) returns a floating-point value. For other values of x the call lngamma(x) returns ln(gamma(x)) whenever x is a positive real number and gamma(x) is not returned as a symbolic call. For negative or non-real complex values x a symbolic call lngamma(x) is returned.

The functional equations for gamma lead to various identities for lngamma which can be applied via expand. Cf. Example 3.

The logarithmic derivative of gamma is implemented by the digamma function psi.

Environment Interactions

When called with a floating-point argument, the functions are sensitive to the environment variable DIGITS which determines the numerical working precision.

Examples

Example 1

We demonstrate some calls with exact and symbolic input data:

gamma(15),
gamma(3/2),
gamma(-3/2),
gamma(sqrt(2)),
gamma(x + 1)

lngamma(15),
lngamma(3/2),
lngamma(-3/2),
lngamma(sqrt(2)),
lngamma(x + 1)

Floating point values are computed for floating-point arguments:

gamma(11.5),
gamma(2.0 + 10.0*I)

lngamma(11.5),
lngamma(2.0 + 10.0*I)

Example 2

gamma and lngamma are singular for nonpositive integers:

gamma(0)
Error: Singularity. [gamma]
lngamma(-2)
Error: Singularity. [lngamma]

Example 3

The functions diff, expand, float, limit, and series handle expressions involving gamma and lngamma:

diff(gamma(x^2 + 1), x), 
diff(lngamma(x^2 + 1), x)

float(ln(3 + gamma(sqrt(PI)))),
float(ln(3 + lngamma(sqrt(PI))))

expand(gamma(x + 2)),
expand(lngamma(x + 2))

expand(gamma(2*x)),
expand(lngamma(2*x))

expand(gamma(2*x - 1)),
expand(lngamma(2*x - 1))

limit(1/gamma(x), x = infinity),
limit(1/lngamma(x), x = infinity)

limit(gamma(x - 4)/gamma(x - 10), x = 0),
limit(lngamma(x - 4) - lngamma(x - 10), x = 0)

series(gamma(x), x = 0, 3),
series(lngamma(x), x = 0, 3)

The Stirling formula is obtained as an asymptotic series:

series(gamma(x), x = infinity, 4),
series(lngamma(x), x = infinity, 4)

Example 4

The logarithm function ln has a branch cut along the negative real semi axis, where the values jump by 2 π i when crossing the cut. In the following plot of the imaginary part of the logarithm of the gamma function the lines in the complex z plane with and are clearly visible as discontinuities:

plotfunc3d(Im(ln(gamma(x + I*y))), x = -10 .. 10, y = -10 .. 10, 
           Submesh = [2, 2], CameraDirection = [0, -1, 1000]):

The function lngamma(z), however, adds suitable integer multiples of 2 π i to ln(gamma(z)) making the function analytic throughout the complex plane with a branch cut along the negative real semi axis:

plotfunc3d(Im(lngamma(x + I*y)), x = -10 .. 10, y = -10 .. 10, 
           Submesh = [2, 2], CameraDirection = [0, -1, 1000]):

Parameters

x

An arithmetical expression

Return Values

Arithmetical expression or a floating-point interval.

Overloaded By

x

See Also

MuPAD Functions

Was this topic helpful?