Gamma Function Calculator — Γ(x)
Compute Γ(x) for any real number using the Lanczos approximation
Quick Examples
Any real number except 0, −1, −2, −3, ...
Key Formulas
Step-by-Step Solution
Special Values of Γ(x)
| x | Γ(x) | Exact Form | Notes |
|---|---|---|---|
| 1/2 | 1.7724538509 | √π | Half-integer, Gaussian integral |
| 1 | 1 | 0! = 1 | Γ(1) = 1 by definition |
| 3/2 | 0.8862269255 | √π / 2 | ½ · Γ(1/2) |
| 2 | 1 | 1! = 1 | Γ(2) = 1 |
| 5/2 | 1.3293403882 | 3√π / 4 | Double factorial form |
| 3 | 2 | 2! = 2 | Γ(3) = 2 |
| 4 | 6 | 3! = 6 | Γ(4) = 6 |
| 5 | 24 | 4! = 24 | Γ(5) = 24 |
| 6 | 120 | 5! = 120 | Γ(6) = 120 |
| −1/2 | −3.5449077018 | −2√π | Negative half-integer |
| −3/2 | 2.3632718012 | 4√π / 3 | Alternating sign pattern |
Γ(x) Graph — x ∈ [−4, 5]
Hover/touch the chart to see exact Γ(x) values. Dashed red lines mark poles at x = 0, −1, −2, −3. Values outside [−10, 10] are clipped.
Γ(x) Values — x from 0.1 to 10 (step 0.1)
Highlighted (yellow) rows are positive integers where Γ(n) = (n−1)!. Purple values indicate negative Γ(x).
| x | Γ(x) | ln|Γ(x)| | Note |
|---|
What is the Gamma Function Γ(x)?
The Gamma function, denoted Γ(x) (capital Greek letter Gamma), is one of the most important special functions in mathematics. It was introduced by the Swiss mathematician Leonhard Euler in 1729 as a generalization of the factorial function to all real and complex numbers. While the factorial n! is defined only for non-negative integers, the Gamma function extends this concept smoothly across the entire real line (and beyond, into the complex plane), except at the non-positive integers 0, −1, −2, −3, ...
The formal definition is an improper integral known as the Euler integral of the second kind:
Γ(x) = ∫₀^∞ t^(x−1) · e^(−t) dt (valid for x > 0)
This integral converges for all real numbers with positive real part. For negative non-integer values, Γ(x) is defined via analytic continuation using the recurrence relation.
The Factorial Connection: Γ(n) = (n−1)!
The most celebrated property of the Gamma function is its relationship to factorials. For any positive integer n:
Γ(n) = (n − 1)! → Γ(1)=1, Γ(2)=1, Γ(3)=2, Γ(4)=6, Γ(5)=24
This means the Gamma function is the unique meromorphic function that interpolates the factorials and satisfies the recurrence Γ(x+1) = x·Γ(x) with Γ(1) = 1. Numerically, you can think of Γ as a smooth curve that passes through the points (1, 1), (2, 1), (3, 2), (4, 6), (5, 24), (6, 120), ... — connecting the factorial dots.
Recurrence Relation: Γ(x+1) = x·Γ(x)
The fundamental recurrence relation is:
Γ(x + 1) = x · Γ(x)
This mirrors the factorial identity (n+1)! = (n+1)·n! and can be proven by integration by parts in the defining integral. It means that once you know Γ(x) in any interval of length 1, you can extend it to the entire positive real line. This recurrence also allows the function to be extended to negative non-integer values by rearranging to Γ(x) = Γ(x+1)/x.
Euler's Reflection Formula
Euler discovered a beautiful symmetry linking Γ(x) and Γ(1−x):
Γ(x) · Γ(1 − x) = π / sin(πx)
This remarkable formula connects the Gamma function to trigonometry. At x = 1/2, it gives Γ(1/2)² = π/sin(π/2) = π, confirming Γ(1/2) = √π. The reflection formula is also used algorithmically: to compute Γ(x) for x < 0.5, compute Γ(1−x) and apply the formula, reducing the problem to a region where numerical methods are most stable.
The Special Value Γ(1/2) = √π
The most famous special value of the Gamma function is Γ(1/2) = √π ≈ 1.7724538509. This result is derived from the Gaussian integral:
∫₋∞^∞ e^(−t²) dt = √π ⟹ Γ(1/2) = √π
By substituting u = t² in the Gamma integral, we get Γ(1/2) = 2∫₀^∞ e^(−u²) du = √π. The half-integer values more generally satisfy Γ(n + 1/2) = (2n)!·√π / (4^n · n!), giving the sequence: Γ(1/2)=√π, Γ(3/2)=√π/2, Γ(5/2)=3√π/4, and so on.
Poles at Non-Positive Integers
The Gamma function has simple poles (vertical asymptotes) at x = 0, −1, −2, −3, ... At each of these points, |Γ(x)| → ∞. The function alternates sign between consecutive poles: it is positive on (0, +∞) and on (−2, −1), (−4, −3), ... and negative on (−1, 0), (−3, −2), ...
The residue at each pole x = −n (for n = 0, 1, 2, ...) is (−1)^n / n!. These poles are visible as sharp vertical lines on the Gamma function chart. This is why x = 0, −1, −2, −3, ... are excluded from the calculator's domain.
The Lanczos Approximation
For numerical computation, the Lanczos approximation (introduced by Cornelius Lanczos in 1964) is the most widely used algorithm. It approximates Γ(z) for z with positive real part as:
Γ(z+1) ≈ √(2π) · (z + g + 0.5)^(z+0.5) · e^(−(z+g+0.5)) · A_g(z)
where A_g(z) is a rational function whose coefficients depend on the parameter g. This calculator uses g = 7 with 9 Lanczos coefficients, providing about 15 digits of accuracy for all real inputs. For x < 0.5, Euler's reflection formula is applied first, then the approximation is used.
The Log-Gamma Function and Stirling's Approximation
For large values of x, Γ(x) grows extremely rapidly (faster than any exponential). The log-gamma function ln(Γ(x)) is therefore more useful numerically, as it grows only as x·ln(x). Stirling's approximation gives:
ln(Γ(x)) ≈ (x − 0.5)·ln(x) − x + 0.5·ln(2π) [for large x]
Log-gamma is used extensively in statistical computing: log-likelihoods, log-probabilities, and normalizing constants are computed in log-space to avoid overflow. This calculator always shows both Γ(x) and ln|Γ(x)|.
Relationship to the Beta Function
The Gamma function is intimately related to the Beta function B(a, b), which appears in probability and statistics:
B(a, b) = Γ(a) · Γ(b) / Γ(a + b)
This identity connects the two fundamental Euler integrals and is used to evaluate the normalizing constants for the Beta distribution, the Dirichlet distribution, and many others. The beta function can also be written as B(a,b) = ∫₀¹ t^(a−1)·(1−t)^(b−1) dt.
Applications of the Gamma Function
- Statistics: Gamma distribution PDF, chi-squared distribution, Student's t-distribution, F-distribution all involve Γ(x). The incomplete gamma function defines their CDFs.
- Combinatorics: Generalizing binomial coefficients to non-integer arguments: C(n,k) = Γ(n+1) / (Γ(k+1)·Γ(n−k+1)).
- Quantum Physics: Feynman path integrals, dimensional regularization in quantum field theory, and calculations in statistical mechanics use the Gamma function.
- String Theory: The Veneziano amplitude and dual resonance models are expressed in terms of the beta/gamma function.
- Number Theory: The Riemann zeta function satisfies the functional equation ξ(s) = π^(−s/2)·Γ(s/2)·ζ(s), linking it to the Gamma function.
- Engineering: Signal processing (fractional calculus), control theory, and fluid dynamics problems involving Bessel functions.
- Computer Science: Log-gamma is used in computing log-probabilities for machine learning, natural language processing, and Bayesian inference.
The Digamma Function
The digamma function ψ(x) is the logarithmic derivative of the Gamma function: ψ(x) = d/dx[ln(Γ(x))] = Γ'(x)/Γ(x). It appears in problems involving harmonic numbers, polygamma functions, and regularization in quantum field theory. For positive integers n, ψ(n) = −γ + H(n−1), where γ ≈ 0.5772156649 is the Euler–Mascheroni constant and H(n) is the nth harmonic number.