The Gamma Function
You already know the factorial: 5! = 5\cdot4\cdot3\cdot2\cdot1 = 120.
It counts the ways to arrange things, and it shows up all over physics — in the number of ways to
share energy among the atoms of a gas, in the coefficients of a Taylor series, in the normalisation
of a quantum wavefunction. But factorials have a glaring limitation: n! is
only defined for a whole number n. What on earth is
\left(\tfrac{1}{2}\right)!?
That is not an idle question. When you count the quantum states of a particle in a box, or work out
the average speed of gas molecules, or evaluate the integrals that pour out of statistical mechanics
and quantum field theory, you keep meeting factorials of halves and other non-integers.
Physics needs a function that agrees with the factorial at the whole numbers but flows smoothly through
the gaps between them. That function is the Gamma function
\Gamma(z) — the single most important of the "special functions", and the
one idea this page is about.
The definition: an improper integral
Euler found the right object. For any z with a positive real part, the
Gamma function is defined by an improper
integral running all the way out to infinity:
\Gamma(z) = \int_0^{\infty} t^{\,z-1}\, e^{-t}\, dt.
The integrand is a tug-of-war: the power t^{z-1} pulls it up as
t grows, while the decaying exponential e^{-t}
crushes it back down. The exponential always wins in the end, so the area under the curve is finite —
that is exactly the kind of convergent improper integral you have already met. This one formula makes
sense for fractions, for irrationals, even (after a little more work) for complex numbers.
The magic is in what it does at the whole numbers. Watch the two anchor values fall straight out of
the integral:
\Gamma(1) = \int_0^{\infty} e^{-t}\, dt = 1, \qquad \Gamma(2) = \int_0^{\infty} t\, e^{-t}\, dt = 1.
The recursion that rebuilds the factorial
Everything about \Gamma hangs on one relationship. Apply
integration by parts
to the definition — differentiate the power, integrate the exponential — and the boundary term
vanishes, leaving a beautifully simple rule:
-
Step-up rule. For every z in the domain,
\Gamma(z+1) = z\,\Gamma(z).
-
Factorials recovered. Because \Gamma(1)=1, iterating
the step-up rule gives \Gamma(n) = (n-1)! for every positive integer
n.
Read that carefully — this is the trap that catches everyone. The Gamma function is the factorial
shifted by one: \Gamma(n) = (n-1)!, not
n!. So \Gamma(5) = 4! = 24, and
\Gamma(1) = 0! = 1. If you want plain n!, ask for
\Gamma(n+1).
The recursion is also a machine for extending \Gamma to negative arguments.
Rearranged as \Gamma(z) = \Gamma(z+1)/z, it lets you step
downward. But look what happens as z\to 0: you divide by zero.
\Gamma blows up to infinity at 0, -1, -2, -3, \dots
— it has a pole at every non-positive integer, and is finite and smooth everywhere else.
Seeing it: the factorial made smooth
The graph below plots \Gamma(x) for real
x>0. The marked dots sit at the integers, where the curve threads exactly
through the factorials 0!, 1!, 2!, 3!, \dots (remember the shift:
\Gamma(x) at x equals
(x-1)!). Between them the curve does not jump — it glides, dipping to a
gentle minimum near x \approx 1.46 before turning upward and rocketing away.
That soaring right-hand side is the factorial's famous explosive growth, now happening continuously.
The steep left-hand wall as x\to 0 is the first of the poles. Everything in
between is the new territory the Gamma function opens up: factorials of numbers that are not whole.
The half-integer that physics can't do without
The most quoted single value of the Gamma function is the one that isn't a factorial at all:
\Gamma\!\left(\tfrac{1}{2}\right) = \sqrt{\pi}\,.
Where does \pi come from? Put z=\tfrac12 in the
integral and substitute t=u^2. The
t^{-1/2} and the dt=2u\,du conspire to leave the
famous Gaussian integral:
\Gamma\!\left(\tfrac{1}{2}\right) = \int_0^{\infty} t^{-1/2} e^{-t}\, dt = 2\int_0^{\infty} e^{-u^2}\, du = \sqrt{\pi}.
This is why \sqrt{\pi} keeps appearing where you least expect it. Feed
\Gamma(\tfrac12)=\sqrt\pi into the step-up rule and you can climb the whole
ladder of half-integers:
\Gamma\!\left(\tfrac{3}{2}\right) = \tfrac{1}{2}\sqrt\pi, \qquad \Gamma\!\left(\tfrac{5}{2}\right) = \tfrac{3}{2}\cdot\tfrac{1}{2}\sqrt\pi = \tfrac{3}{4}\sqrt\pi.
Those exact half-integer values are precisely the constants that appear when you compute the volume of
a sphere in n dimensions, the density of states of a free quantum gas, or
the moments of the Maxwell–Boltzmann speed distribution. Statistical mechanics runs on Gamma functions.
Worked examples
Example 1 — a factorial in disguise. Evaluate \Gamma(6).
Use \Gamma(n)=(n-1)! with n=6:
\Gamma(6) = 5! = 5\cdot4\cdot3\cdot2\cdot1 = 120.
Example 2 — using the recursion. Given only that
\Gamma(4)=6, find \Gamma(5) without a new integral.
Step up: \Gamma(5) = 4\cdot\Gamma(4) = 4\cdot 6 = 24. (And indeed
24 = 4!.)
Example 3 — a half-integer. Evaluate \Gamma(\tfrac52).
Step down twice from \Gamma(\tfrac12)=\sqrt\pi using
\Gamma(z+1)=z\,\Gamma(z):
\Gamma\!\left(\tfrac{5}{2}\right) = \tfrac{3}{2}\,\Gamma\!\left(\tfrac{3}{2}\right) = \tfrac{3}{2}\cdot\tfrac{1}{2}\,\Gamma\!\left(\tfrac{1}{2}\right) = \tfrac{3}{4}\sqrt\pi \approx 1.329.
Example 4 — a physics integral. Many statistical-mechanics integrals reduce to
\int_0^\infty x^{n} e^{-x}\,dx. Compare with the definition: this is exactly
\Gamma(n+1)=n!. So \int_0^\infty x^{3} e^{-x}\,dx = 3! = 6
— no integration by parts required, once you recognise the Gamma function.
No — and this is the single most common Gamma mistake. The Gamma function carries a built-in shift of
one: \Gamma(n) = (n-1)!. So \Gamma(4)=3!=6, not
4!=24. If you actually want n!, you must write
\Gamma(n+1).
Why the awkward offset? Blame history. Euler and Legendre defined the notation before the modern
convention settled, and Legendre's placement of the z-1 in the exponent is
the one that stuck. Some mathematicians grumble that the "Pi function"
\Pi(z)=\Gamma(z+1)=z! would have been tidier — Gauss preferred it — but
Legendre's \Gamma won, shift and all. Learn to live with the
-1 and you will never be caught out.
It usually doesn't compute the integral at all. Two exact identities do the heavy lifting. The first
is the recursion \Gamma(z+1)=z\,\Gamma(z), which lets you shift any argument
into a convenient strip. The second is the gorgeous reflection formula
\Gamma(z)\,\Gamma(1-z) = \frac{\pi}{\sin(\pi z)}.
Set z=\tfrac12 and it reads \Gamma(\tfrac12)^2 = \pi/\sin(\pi/2) = \pi,
so \Gamma(\tfrac12)=\sqrt\pi instantly. The reflection formula also explains
the poles: \sin(\pi z) hits zero at every integer, forcing
\Gamma to infinity. Numerically, libraries lean on the razor-sharp
Lanczos approximation — a short weighted sum that nails
\Gamma to fifteen digits — rather than ever touching the improper integral.