Gamma Function Calculator: Γ(x) for Any Real Number, with Exact Half-Integer Values
Calculate the gamma function Γ(x) for any real x, including fractions and negatives, with ln Γ, 1/Γ, digamma, x! and exact √π forms for half-integers, plus the steps.
How it works
Γ(x) = ∫₀^∞ t^(x−1) e^(−t) dt (x > 0) · Γ(x + 1) = x·Γ(x) · Γ(n) = (n − 1)! · Γ(½) = √π · Γ(n + ½) = (2n)!/(4ⁿ n!)·√π · Γ(x)·Γ(1 − x) = π / sin(πx) · Lanczos: Γ(x) ≈ √(2π)·(x + g − ½)^(x − ½)·e^−(x + g − ½)·A_g(x)
The gamma function extends the factorial to every real number except 0 and the negative integers: Γ(n) = (n − 1)! for whole numbers, so Γ(5) = 4! = 24, and in between it is a smooth curve. Its key property is the recurrence Γ(x + 1) = x·Γ(x), which lets you step from any argument to its neighbours; Γ(½) = √π then gives exact values for every half-integer, such as Γ(4.5) = (105/16)√π. For negative non-integers Γ alternates in sign between the poles, and the reflection formula Γ(x)·Γ(1 − x) = π/sin(πx) links it to positive arguments. This calculator evaluates Γ with the Lanczos approximation (g = 7, nine coefficients), which is accurate to about 15 significant digits, and uses reflection below ½. Above x ≈ 171.6, Γ(x) no longer fits in a standard floating-point number, so it works with ln Γ(x) and shows the result as m × 10ⁿ (for example Γ(1000) = 4.02 × 10²⁵⁶⁴). You can type fractions like 1/3. Next to Γ(x) you also get ln|Γ(x)|, the reciprocal 1/Γ(x), x! = Γ(x + 1), the digamma function ψ(x), exact factorial or √π forms where they exist, and a table of neighbouring values. The factorial calculator handles whole numbers only, and the gamma distribution calculator gives probabilities of a statistical distribution; this page is for the function Γ(x) itself, as it appears in probability densities, physics and the beta function B(a, b) = Γ(a)Γ(b)/Γ(a + b).
Worked example
For the default x = 4.5, apply Γ(x + 1) = x·Γ(x) four times to reach 0.5: Γ(4.5) = 3.5 × 2.5 × 1.5 × 0.5 × Γ(0.5). The product of the factors is 6.5625 and Γ(0.5) = √π = 1.772453851, so Γ(4.5) = 6.5625 × 1.772453851 = 11.6317284, exactly (105/16)√π. Also ln Γ(4.5) = 2.453736571, 1/Γ(4.5) = 0.08597174606, 4.5! = Γ(5.5) = 52.34277778 and ψ(4.5) = 1.388870926.
Sources: NIST DLMF §5.4: Special values of the gamma function · Omni Calculator: Gamma function (Lanczos and Stirling, half-integer values) · Math is Fun: Gamma function (definition and recurrence) · Redcrab Software: Gamma function calculator (Γ(0.5), Γ(1.5), Γ(2.5))
Frequently asked questions
What is Γ(1/2)?
Γ(½) = √π = 1.7724538509. It comes from the Gaussian integral, and with Γ(x + 1) = x·Γ(x) it gives every half-integer: Γ(3/2) = ½√π = 0.8862269255, Γ(5/2) = ¾√π = 1.329340388 and Γ(−½) = −2√π = −3.544907702.
How is the gamma function related to the factorial?
For whole numbers Γ(n) = (n − 1)!, so Γ(1) = 0! = 1, Γ(4) = 3! = 6 and Γ(6) = 5! = 120. Equivalently x! = Γ(x + 1), which is how calculators find “factorials” of non-integers: 0.5! = Γ(1.5) = 0.8862.
Why is the gamma function undefined at 0 and negative integers?
Running the recurrence backwards, Γ(x) = Γ(x + 1)/x, means dividing by zero at x = 0, and the same happens at −1, −2, −3… These are poles: Γ shoots to ±∞ on either side. Between the poles Γ is finite and alternates in sign, e.g. Γ(−1.5) = 2.363 and Γ(−0.5) = −3.545. Γ itself is never zero.
What is the minimum of the gamma function?
For positive x, Γ has its minimum at x ≈ 1.461632145, where Γ(x) ≈ 0.8856031944. It equals 1 at x = 1 and x = 2 and rises steeply towards 0 and towards infinity.
How do I calculate the gamma function of a large number?
Use logarithms. Stirling’s formula ln Γ(x) ≈ (x − ½) ln x − x + ½ ln(2π) is already within about 1% of Γ at x = 10 and improves as x grows. This calculator switches to ln Γ automatically above 171.6, where Γ exceeds 1.8 × 10³⁰⁸, and still shows the full mantissa and exponent.
Can the gamma function take negative arguments?
Yes, any negative number that is not an integer. Use the reflection formula Γ(x) = π / (sin(πx)·Γ(1 − x)) or the backwards recurrence: Γ(−1.5) = Γ(0.5) ÷ (−1.5 × −0.5) = 1.7725 ÷ 0.75 = 2.3633, which is (4/3)√π.
Related calculators
This calculator is for educational purposes. Double-check important results before acting on them.