TGAMMA Function
Description
The TGAMMA function computes the value of the Gamma function (Γ function). The mathematical definition of the Gamma function is:
Γ(x) = ∫₀∞ t(x-1) e(-t) dt
The Gamma function is the generalization of the factorial to the real and complex number domains. For positive integers n, Γ(n) = (n-1)!. This function is widely used in probability theory, statistics, combinatorics, and physics.
Syntax
tgamma(expr)
Parameters
expr: A numeric expression for which to compute the Gamma function value. Supports numeric types (implicitly castable to DOUBLE).
Returns
The return type is DOUBLE, representing the Gamma function value corresponding to the input.
Examples
-
Compute the Gamma value for a positive integer (Γ(5) = 4! = 24):
-
Compute Γ(1):
-
Compute the Gamma value for a non-integer argument (Γ(0.5) = √π):
-
When the input is NULL:
Notes
- When the input parameter is NULL, the result is NULL.
- For zero and negative integers (0, -1, -2, ...), the Gamma function is undefined, and the return value is Infinity or NaN (CASTing such results to decimal yields NULL).
- For positive integers n, Γ(n) = (n-1)!, e.g., Γ(5) = 24, Γ(1) = 1.
- Γ(0.5) = √π ≈ 1.7724538509, a classic special value of the Gamma function.
- When the input value is very large, the result may overflow to Infinity.
