# Gamma Function

Wave · y = f(x, t)

`y = ∫₀^∞ u^(x − 1) · exp(−u) du`

[Open in the app](https://www.wavelace.com/app#p=106) · [This page](https://www.wavelace.com/presets/gamma-function)

### What it draws

The curve is an integral, computed at every point: `y = ∫₀^∞ u^(x−1) · e^(−u) du`. That is Euler's integral for the gamma function, `Γ(x)`, and nothing in it depends on the clock, so the curve stands still. Integrating by parts gives `Γ(x + 1) = x · Γ(x)`, and `Γ(1) = ∫₀^∞ e^(−u) du = 1`, so at the whole numbers `Γ(n) = (n − 1)!`. Read along the curve: `1, 1, 2, 6, 24` at `x = 1, 2, 3, 4, 5`. Between them it fills in the factorial for every real argument.

The integral is taken numerically out to a fixed reach, and `e^(−u)` makes sure the integrand has died away by then. To the left of `x = 1` the curve is blank: there `u^(x−1)` is infinite at `u = 0`, where the rule samples it, though the true integral converges down to `x = 0`. The lowest point of the curve lies between the first two integers, `Γ(1.4616) ≈ 0.8856`.

### Between the integers

Infinitely many smooth curves pass through `1, 1, 2, 6, 24`. The Bohr–Mollerup theorem singles out Euler's integral: it is the only one with `Γ(x + 1) = x · Γ(x)` whose logarithm is convex. The growth is faster than any exponential. `Γ(6) = 120` lies just off the right edge, and Stirling's approximation `Γ(x) ≈ √(2π/x) · (x/e)^x` tracks the curve from below, `23.6` against `24` at `x = 5`.

### History

Leonhard Euler found the integral in 1729, in letters to Christian Goldbach, answering the question of how to extend `n!` to fractions; Daniel Bernoulli had a product formula the same year. Adrien-Marie Legendre gave the function its name and the symbol `Γ` in 1811. Harald Bohr and Johannes Mollerup proved the uniqueness theorem in 1922, in a textbook.

### Try

- Shift by one, `integral(u^x·exp(−u), u, 0, inf)`: now `Γ(x + 1) = x!`, reading `1, 1, 2, 6, 24, 120` at `x = 0` to `5`, and the blank stretch ends at `x = 0`.
- Take the logarithm, `log(integral(u^(x − 1)·exp(−u), u, 0, inf))`: zero at `x = 1` and `x = 2`, `ln 24 ≈ 3.18` at `x = 5`, and convex throughout, as Bohr and Mollerup require.
- Compare with Stirling, `sqrt(2π/x)·x^x·exp(−x)`: the same rise, below the curve by `8%` at `x = 1` and under `2%` at `x = 5`, and drawn for every positive `x` since no integral can fail.
- Grow the upper limit with the clock, `integral(u^(x − 1)·exp(−u), u, 0, t)`, then `Rewind` and `Play`: the incomplete gamma function fills in from the left. After five seconds `x = 5` has reached only `13.4` of its `24`.

### Read more

- [Gamma function](https://en.wikipedia.org/wiki/Gamma_function)
- [Factorial](https://en.wikipedia.org/wiki/Factorial)
- [Bohr–Mollerup theorem](https://en.wikipedia.org/wiki/Bohr%E2%80%93Mollerup_theorem)
- [Stirling's approximation](https://en.wikipedia.org/wiki/Stirling%27s_approximation)
