Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

Gamma Function Γ(z)
24
Γ(5)
Input z 5
Method Lanczos approximation (g = 7)

What Is the Gamma Function?

The Gamma function, written \(\Gamma(z)\), is the continuous extension of the factorial. For any positive integer n it satisfies \(\Gamma(n) = (n - 1)!\), so \(\Gamma(5) = 4! = 24\). Unlike the ordinary factorial, the Gamma function is defined for all real and complex numbers except the non-positive integers (0, −1, −2, …), where it has poles. It appears throughout mathematics, statistics (the gamma, beta and chi-squared distributions), physics, and combinatorics.

Smooth curve of the Gamma function plotted against a horizontal axis, with the factorial integer points highlighted
The Gamma function extends the factorial to all real (and complex) numbers, with poles at non-positive integers.

How to Use This Calculator

Enter any value of z — it can be an integer, a fraction, or a negative number that is not a whole number — and the calculator returns \(\Gamma(z)\). For example, \(\Gamma(0.5) = \sqrt{\pi} \approx 1.772454\), and \(\Gamma(2.5) \approx 1.329340\). Avoid entering 0 or negative integers, where the function is undefined.

The Formula Explained

This tool uses the Lanczos approximation, a fast and highly accurate series with a constant \(g = 7\) and nine precomputed coefficients. The core identity is $$\Gamma(z) = \sqrt{2\pi}\,\left(z + g + \tfrac{1}{2}\right)^{z + \frac{1}{2}}\, e^{-\left(z + g + \frac{1}{2}\right)}\, A_g(z),$$ where \(A_g(z)\) is the weighted coefficient sum. For \(z < 0.5\) the calculator first applies the reflection formula $$\Gamma(z)\,\Gamma(1 - z) = \frac{\pi}{\sin(\pi z)},$$ which lets it evaluate small and negative arguments accurately.

Advertisement
Diagram showing the reflection formula mapping a negative argument to a positive one
The reflection formula lets the calculator evaluate Γ(z) for negative non-integer arguments.

Worked Example

To find \(\Gamma(5)\): since 5 is a positive integer, $$\Gamma(5) = (5 - 1)! = 4! = 4 \times 3 \times 2 \times 1 = 24.$$ The Lanczos approximation returns 24.0000 (to within rounding), confirming the factorial relationship.

FAQ

Why can't I compute \(\Gamma(0)\) or \(\Gamma(-2)\)? The Gamma function has poles at every non-positive integer, so it grows without bound there and is undefined.

How accurate is the result? The Lanczos approximation with \(g = 7\) is accurate to roughly 15 significant digits for typical inputs — well beyond what the display shows.

Is \(\Gamma(z)\) the same as factorial? They are closely related: \(\Gamma(n) = (n - 1)!\) for positive integers n. The Gamma function generalises the factorial to non-integer and negative arguments.

Last updated: