gamma -- the gamma function
Introductiongamma(x) represents the gamma function
int(exp(-t)*t^(x-1), t=0..infinity).
Call(s)gamma(x)
Parametersx |
- | an arithmetical expression |
Returnsan arithmetical expression.
x
Side
EffectsWhen called with a floating point argument, the function is
sensitive to the environment variable DIGITS which determines the numerical
working precision.
Related
Functions
Detailsgamma(x)=fact(x-1)=(x-1)! for all positive integers
x.x is a floating point value, then a floating point
value is returned. If x is a positive integer smaller than
1000, then an integer is returned. If x is a
rational number of domain type DOM_RAT satisfying
1<x<500, then the functional relation
gamma(x)=(x-1)*gamma(x-1) is applied to ``normalize'' the
result. The functional relation
gamma(x)*gamma(1-x)=PI*csc(PI*x) is applied if
x<1/2 is a rational number of domain type DOM_RAT that is an integer
multiple of 1/4 or 1/6. The call
gamma(1/2) yields sqrt(PI);
gamma(infinity) yields infinity.
For all other arguments, a symbolic function call is returned.
gamma is a kernel function,
i.e., floating point evaluation is fast.gamma is implemented by
the digamma function psi.
Example
1We demonstrate some calls with exact and symbolic input data:
>> gamma(15), gamma(23/2), gamma(sqrt(2)), gamma(x + 1)
1/2
13749310575 PI 1/2
87178291200, -----------------, gamma(2 ), gamma(x + 1)
2048
Floating point values are computed for floating point arguments:
>> gamma(11.5), gamma(2.0 + 10.0*I)
11899423.08, - 0.00001089258677 + 0.00000504737724 I
Example
2gamma is singular for nonpositive
integers:
>> gamma(-2)
Error: singularity [gamma]
Example
3The functions diff, expand, float, limit, and series handle expressions involving
gamma:
>> diff(gamma(x^2 + 1), x), float(ln(3 + gamma(sqrt(PI))))
2 2
2 x psi(x + 1) gamma(x + 1), 1.367203476
>> expand(gamma(3*x - 4))
gamma(3 x)
---------------------------------------
(3 x - 1) (3 x - 2) (3 x - 3) (3 x - 4)
>> limit(1/gamma(x), x = infinity), limit(gamma(x - 4)/gamma(x - 10), x = 0)
0, 151200
>> series(gamma(x), x = 0, 4)
/ 2 2 \
| PI EULER |
| - --- + ------ |
1 | PI 12 2 | 2
- - EULER + x PI | -- + -------------- | + O(x )
x \ 6 PI /
The Stirling formula is obtained as an asymptotic series:
>> series(gamma(x), x = infinity, 3)
x / 2 PI \1/2
x exp(-x) | ---- |
x / 2 PI \1/2 \ x /
x exp(-x) | ---- | + ---------------------- +
\ x / 12 x
x / 2 PI \1/2 / x / 2 PI \1/2 \
x exp(-x) | ---- | | x exp(-x) | ---- | |
\ x / | \ x / |
---------------------- + O| ---------------------- |
2 | 3 |
288 x \ x /