Gamma Function Calculator
Evaluate the Gamma function for any positive real x.
Returns Gamma(x) and log-gamma.
For positive integers, Gamma(n) equals (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. (The shift by one is a quirk of Euler’s original convention — it’s the price of admission.)
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 — Γ(3/2) = (1/2)·Γ(1/2) = √π / 2 ≈ 0.886, Γ(5/2) = (3/2)·Γ(3/2), and so on.
The gamma function has poles (infinite values) at 0 and all negative integers. Between the poles, it alternates sign for negative non-integer inputs. For positive x, it is always positive and grows extremely fast — Γ(171) already overflows double-precision floating point.
That overflow 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.
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) — Γ is what makes that formula work for all real n, not just 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, which computes Γ(x) to about 15 significant digits by evaluating a rational approximation — the standard algorithm in scientific computing libraries.
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.