Gamma Function Calculator

Enter a real number x to compute the gamma function Γ(x) using the Lanczos approximation, along with its natural log, sign, and factorial equivalent.

Quick Facts

Recurrence
Γ(x+1) = x · Γ(x)
Lets you build any Γ(x) from a value in a smaller range.
Factorial link
Γ(n) = (n-1)!
For positive integers n, e.g. Γ(6) = 5! = 120.
Known value
Γ(1/2) = √π ≈ 1.772454
Comes from the Gaussian integral.
Poles
Undefined at x = 0, -1, -2, …
Γ(x) blows up at every non-positive integer.

Your Results

Calculated
Γ(x)
-
Gamma function value
ln|Γ(x)|
-
Natural log of |Γ(x)|, useful for large x
Sign of Γ(x)
-
Positive or negative
Factorial equivalent
-
(x-1)! when x is a positive integer

Ready

Enter a value for x, then press Calculate.

How the Gamma Function Works

The gamma function Γ(x) generalizes the factorial to real (and complex) numbers. For a positive integer n, Γ(n) equals (n-1)!, but Γ(x) is also defined for fractional and negative non-integer x, giving a smooth curve that passes through every factorial value. This calculator evaluates Γ(x) using the Lanczos approximation, a fast numerical method that reproduces the true value of the gamma function to about 15 significant digits.

The integral definition

For x > 0, the gamma function is defined by the improper integral Γ(x) = ∫₀^∞ t^(x-1) e^(-t) dt. This integral converges for every positive x. Because direct numerical integration is slow and loses precision for large x, this calculator instead uses the Lanczos approximation — a rational-function formula tuned to match Γ(x) to double-precision accuracy without evaluating the integral directly.

Recurrence relation and factorials

The gamma function satisfies the recurrence Γ(x+1) = x · Γ(x). Applying this repeatedly to a positive integer n shows Γ(n+1) = n · (n-1) · … · 1 · Γ(1) = n!, since Γ(1) = 1. So Γ(6) = 5! = 120, Γ(1) = 0! = 1, and so on — the factorial you learned in school is just the gamma function evaluated at integer-plus-one arguments.

Reflection formula and negative arguments

For non-integer x < 0.5, this calculator uses the reflection formula Γ(x) · Γ(1-x) = π / sin(πx) to compute Γ(x) from Γ(1-x), which lies in the well-behaved positive range. This is also why Γ(x) is undefined at x = 0, -1, -2, -3, …: sin(πx) = 0 at every integer, so the reflection formula would require dividing by zero, producing a pole (the function value shoots to ±infinity as x approaches these points from either side).

Frequently Asked Questions

What is the gamma function?
The gamma function is defined for x > 0 by the integral Γ(x) = ∫₀^∞ t^(x-1) e^(-t) dt. It extends the factorial to non-integer, negative, and complex values, and satisfies Γ(n) = (n-1)! for positive integers n.
How does the gamma function relate to factorials?
For a non-negative integer n, Γ(n+1) = n!. For example, Γ(5) = 4! = 24 and Γ(1) = 0! = 1. The gamma function fills in the gaps between factorial values with a smooth curve.
Why is the gamma function undefined at 0, -1, -2, and other negative integers?
Γ(x) has simple poles at x = 0, -1, -2, -3, … From the recurrence Γ(x+1) = xΓ(x), evaluating at these points would require dividing by zero, so the function is undefined (it approaches ±infinity near each pole).
What is Γ(1/2)?
Γ(1/2) = √π ≈ 1.772454. This follows from the Gaussian integral ∫₀^∞ t^(-1/2) e^(-t) dt = √π, and it is the basis for half-integer values like Γ(3/2) = (1/2)√π ≈ 0.886227.