The gamma function calculator above evaluates Γ(x) for any real argument, together with its logarithm, its reciprocal and the shifted value Γ(x+1) that gives the factorial reading. It handles negative arguments through the reflection formula, names the poles at zero and the negative integers instead of returning an infinity, and reports the logarithm where the value itself has overflowed.
The gamma function is the standard extension of the factorial to non-integer arguments, satisfying Γ(n+1) = n! for every non-negative integer n. Arb Digital publishes it as the continuous function across the whole real line. If your argument is a whole number and you want the exact integer, our factorial calculator is the right page — it returns exact values for whole numbers, whereas this one returns a double-precision value for any real number at all.
What This Gamma Function Calculator Does
It returns four related quantities. Γ(x) is the headline, computed by the Lanczos approximation for arguments above one half and by the reflection formula below it. ln |Γ(x)| is computed on its own path rather than by taking the logarithm of the value, so it stays finite and accurate for arguments where Γ(x) itself is far too large to represent. Γ(x+1) is the same function shifted, which for a whole number x is exactly x factorial. 1/Γ(x) is the reciprocal, which unlike Γ itself is an entire function with no poles at all — it simply passes through zero at every non-positive integer.
The poles are handled explicitly. At x = 0, −1, −2 and so on the function is undefined, with the limits from either side running off to opposite infinities. The tool says which pole you have landed on rather than printing an infinity, because a signed infinity here would be misleading: there is no consistent sign to report.
Where Stirling's approximation applies, its value and relative error are shown alongside. That comparison is the quickest way to develop a feel for how fast the approximation converges, and it is a genuine check on the main computation from an entirely independent formula.
How to Use It
- Enter any real argument. Positive, negative, integer or fractional; only zero and the negative integers are excluded.
- Read Γ(x) in the hero, with the logarithm in the grid for arguments where the value itself is enormous.
- Check the factorial reading — Γ(x+1) equals x factorial whenever x is a non-negative whole number.
- Look at the identities panel, which states the recurrence and the reflection formula evaluated at your argument.
- Turn on the Stirling comparison to see how the approximation's error falls away as the argument grows.
The Definition and How It Is Computed
For arguments with positive real part the gamma function is defined by Euler's integral
Γ(z) = ∫0∞ tz−1 e−t dt
and is extended to the rest of the plane by analytic continuation. The NIST Digital Library of Mathematical Functions states this and the equivalent limit and product definitions in §5.2 Definitions of its gamma function chapter. Integrating by parts gives the recurrence Γ(z+1) = zΓ(z), and since Γ(1) = 1 this immediately yields Γ(n+1) = n!.
The integral is not how anyone computes it. This tool uses the Lanczos approximation, a rational expression in the argument multiplied by a power and an exponential, which reaches about fifteen significant digits with a handful of coefficients. Below x = 0.5 it applies the reflection formula Γ(z)Γ(1−z) = π / sin(πz), which maps a small or negative argument to a large one where the approximation is at its most accurate. Wolfram MathWorld's page on the gamma function collects these identities and the special values.
Some reference values to check against: Γ(1) = 1, Γ(5) = 24, Γ(10) = 362,880, and Γ(½) = √π = 1.7724538509. The half-integers follow from the recurrence, so Γ(1.5) = √π/2 = 0.8862269255 and Γ(2.5) = 1.3293403882. Reflection gives the negatives: Γ(−0.5) = −2√π = −3.5449077018 and Γ(−1.5) = 4√π/3 = 2.3632718012. Enter each and confirm the digits.
Why Γ(n+1) = n! and Not Γ(n)
The off-by-one shift is the single most persistent source of confusion with this function, so it is worth being explicit. Γ(1) = 1 = 0!, Γ(2) = 1 = 1!, Γ(3) = 2 = 2!, Γ(4) = 6 = 3!. The factorial of n is Γ(n+1), not Γ(n).
The shift is an accident of history. Euler's original formulation used the integral above, and Legendre later chose the normalisation that produced it. Gauss used a function Π(z) = Γ(z+1) with no shift, which many people find more natural, but Legendre's convention won and every table, library and reference uses it. The grid above shows both readings side by side precisely so the shift is never in doubt.
A practical consequence: the binomial coefficient is written with gamma functions as Γ(n+1) ÷ (Γ(k+1)Γ(n−k+1)), and every one of those arguments carries a plus one. Our binomial coefficient calculator and permutation calculator handle the combinatorial forms directly, which avoids the issue entirely for whole numbers.
The Poles, the Reflection Formula and the Reciprocal
Γ(x) has a simple pole at every non-positive integer. Approach x = 0 from above and the function goes to plus infinity; from below, to minus infinity. The same alternation continues down the negative axis, which is why the function oscillates wildly between the poles rather than settling into a shape.
Those poles are exactly what the reflection formula predicts. Since Γ(z)Γ(1−z) = π / sin(πz), and the sine vanishes at every integer, one of the two gamma factors must blow up there. For a positive integer it is the Γ(1−z) factor; for zero and the negatives it is Γ(z) itself. Setting z = ½ makes the formula give Γ(½)² = π, which is the cleanest derivation of Γ(½) = √π.
The reciprocal is the well-behaved object. 1/Γ(z) is entire — analytic everywhere, with no poles at all — and simply has a zero at each non-positive integer. That is why numerical libraries and series expansions so often work with the reciprocal or with the logarithm rather than with the function itself. Our error function calculator is a case in point: erf is a scaled incomplete gamma function at the parameter one half, and the √π in its normalisation is exactly Γ(½).
Overflow, Logarithms and Stirling
Γ(171) is about 7.26 × 10³&sup0;&sup6;, and Γ(172) exceeds the largest double-precision number. So the function overflows at an argument most people would consider small, while ln Γ(172) is a perfectly ordinary 711.7. This is why serious code almost never computes Γ directly.
The standard practice is to work entirely in logarithms and exponentiate once, at the end, if at all. A binomial coefficient computed as exp(lnΓ(n+1) − lnΓ(k+1) − lnΓ(n−k+1)) is fine for n in the millions, whereas the same expression using Γ directly fails past n = 170. The logarithm in the grid is computed on its own path for exactly this reason, and our logarithm calculator handles the arithmetic that follows.
Stirling's approximation, Γ(x) ≈ √(2π/x) · (x/e)x, is the asymptotic story. It runs slightly low, with a relative error close to −1/(12x), so it is about 8% short at x = 1, under 1% by x = 10 and around one part in a million by x = 100. MathWorld's page on Stirling's approximation gives the full asymptotic series and its error terms. Turn the comparison on and watch the error fall as you raise the argument — the 1/(12x) rule is visible almost immediately.
Arb Digital builds free tools that compute the logarithm on its own path instead of taking the log of a number that no longer exists.
Browse All Free Tools Talk To Our TeamCommon Mistakes to Avoid
- Using Γ(n) where n factorial is meant — the factorial of n is Γ(n+1), and the shift catches almost everyone at least once.
- Computing large factorials through Γ directly — it overflows a double just past x = 171, while the logarithm remains finite for any argument you will ever use.
- Taking the logarithm of the computed value — if Γ(x) has already overflowed, its logarithm is infinite too. Compute ln Γ on its own path.
- Expecting a value at a negative integer — those are poles, and the two one-sided limits run to opposite infinities, so no signed value is correct.
- Trusting Stirling for small arguments — it is about eight per cent low at x = 1, which is fine for an order of magnitude and useless for a value.
Related Free Tools From Arb Digital
Get exact whole-number factorials with the factorial calculator, evaluate the closely related special function with the error function calculator, count selections with the binomial coefficient calculator or the permutation calculator, take logarithms with the logarithm calculator, or raise numbers to arbitrary powers with the exponent calculator. The full free online tools hub lists every mathematics tool we publish.
Frequently Asked Questions
It is the standard extension of the factorial to non-integer arguments, defined for positive arguments by Euler's integral and continued analytically to the rest of the real line except the poles.
Gamma of n plus one equals n factorial for every non-negative whole number n. The plus one is a historical convention from Legendre and is the most common source of confusion with the function.
The square root of pi, about 1.7724538509. It follows from the reflection formula at one half, and it is the constant that appears in the normalisation of the error function.
Those are simple poles. The limits from above and below run to opposite infinities, so no single signed value is correct and the tool names the pole instead.
By the Lanczos approximation above one half, and by the reflection formula below it, which maps small and negative arguments to large ones where the approximation is most accurate.
Because gamma of 172 exceeds the largest representable double-precision number. Its logarithm is only about 712, which is why serious computation works in logarithms throughout.
Because one over gamma is entire, with no poles anywhere. It simply passes through zero at each non-positive integer, which makes it far easier to expand in a series.
It runs low by close to one over twelve x, so roughly eight per cent at an argument of one, under one per cent by ten, and about one part in a million by a hundred.
This page evaluates a mathematical special function for educational purposes. Results are computed in double-precision floating point, so the final one or two displayed digits may differ from an arbitrary-precision reference.