Gamma Function Calculator
Evaluate the Gamma function at any real x, positive or negative, with log-gamma and digamma.
Whole numbers give the exact factorial, Gamma(n) = (n-1) factorial.
The gamma function extends the factorial to non-integer and complex arguments. Leonhard Euler introduced it in the 1720s while looking for a smooth interpolation of the factorial. The defining property is the recurrence Γ(x+1) = x · Γ(x), which for positive integers gives Γ(n) = (n−1)!. So Γ(1) = 1, Γ(2) = 1, Γ(3) = 2, Γ(4) = 6, and so on. That shift by one catches everybody the first time. It is a quirk of Euler’s original convention, not a piece of mathematics, and Legendre is usually blamed for making it stick.
The integral definition for positive x is:
Γ(x) = ∫₀^∞ t^(x−1) · e^(−t) dt
Evaluating this integral at x = 1/2 gives the famously beautiful result Γ(1/2) = √π ≈ 1.77245. That identity shows up all over physics and statistics: it is essentially the reason the normalising constant of the Gaussian distribution is √(2π), and the reason the volume of an n-dimensional sphere has π in it. The half-integer values follow from there by the recurrence, so Γ(3/2) = (1/2)·Γ(1/2) = √π / 2 ≈ 0.886, then Γ(5/2) = (3/2)·Γ(3/2) ≈ 1.329, and so on up.
The gamma function has poles (infinite values) at 0 and all negative integers. Between the poles, it alternates sign for negative non-integer inputs, so Γ(−0.5) is negative, Γ(−1.5) is positive, Γ(−2.5) is negative again. This calculator handles those, reaching them through the reflection formula below. It cannot evaluate 0 or any negative whole number, because there is genuinely no value there.
For positive x the function is always positive and grows extremely fast. Γ(171) is about 7.26 × 10³⁰⁶, which a double still holds; Γ(172) is 171! and overflows to infinity. So the practical ceiling in a browser is x = 171.
That ceiling is why most numerical work uses the log-gamma function ln(Γ(x)) instead. Working in log space keeps the numbers manageable; you only exponentiate at the end if you actually need Γ rather than its logarithm. ln(Γ(1000)) is about 5,905, a perfectly ordinary number, while Γ(1000) itself has 2,565 digits.
The gamma function appears in:
- Probability distributions: the gamma, chi-squared, F, t, beta, and Dirichlet distributions all have Γ in their normalising constants.
- Physics: quantum mechanics, statistical mechanics, string theory.
- Number theory: the reflection formula Γ(x) · Γ(1−x) = π / sin(πx) ties Γ to trigonometry in a surprising way.
- Geometry: the volume of the unit n-ball is π^(n/2) / Γ(n/2 + 1), and Γ is what makes that formula work for all real n rather than just the integers.
- Engineering: signal processing, control theory.
The digamma function ψ(x) = Γ’(x) / Γ(x) is the logarithmic derivative and shows up in Bayesian statistics and special-function identities. For positive integers, ψ(n) = H(n−1) − γ, where H is the harmonic number and γ is the Euler-Mascheroni constant (≈ 0.5772).
This calculator uses the Lanczos approximation, a rational approximation good to roughly 15 significant digits and the standard algorithm in scientific computing libraries. One place it is deliberately overridden: when you enter a whole number, the panel prints the factorial computed exactly with big integers instead. Exponentiating a floating-point logarithm is accurate to about eleven digits, which is fine for Γ(4.5) and not fine for Γ(20), where it would report 121645100410059440 for a 19! that is really 121645100408832000.
How we build and check this calculator
This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.
SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.
More Math Calculators
- Geometric Distribution Calculator
- Golden Rectangle Calculator
- Gradient Calculator
- Hypergeometric Distribution Calculator
- Hypothesis Test Calculator
- Implicit Differentiation Calculator
- IQR Calculator (Interquartile Range)
- L'Hopital's Rule Calculator
- Lagrange Multiplier Calculator
- Linear Approximation Calculator
- Log-Normal Distribution Calculator
- LU Decomposition Calculator