The Prime Number Theorem
We return to the question raised back in the
distribution of primes:
roughly how many primes are there below x? That earlier page only hinted that
primes thin out in a predictable way. The Prime Number Theorem (PNT) makes the hint
precise: it hands us a simple formula, accurate to within a shrinking percentage, for the count of
primes up to any x — and it does so by tunnelling through the
Riemann zeta function,
an object built from ordinary calculus that, remarkably, "knows" where every prime sits. It is one of the
great triumphs of mathematics: a statement purely about counting whole numbers, proved using the analysis of
continuous, complex-valued functions.
This isn't just idle curiosity. Every time you connect to a secure website, software somewhere has to find
a large prime number — often several hundred digits long — to build an encryption key. The PNT is what
guarantees such a search is even feasible: it tells you, on average, roughly how many candidates you'll
need to test before you strike a prime (about \ln x of them, near
x), so the hunt for a usable prime takes a predictable, practical amount of
computer time instead of an open-ended gamble.
The statement
The prime-counting function \pi(x) satisfies
\pi(x) \sim \frac{x}{\ln x}, \qquad\text{meaning}\qquad \lim_{x\to\infty} \frac{\pi(x)}{x/\ln x} = 1.
Equivalently, the n-th prime is about n \ln n,
and a random whole number near x has roughly a 1/\ln x
chance of being prime. That last phrasing is worth sitting with: near a trillion, only about one number
in twenty-eight is prime; near a million, it's about one in fourteen. Primes never vanish, but they get
rarer in a completely predictable way.
Why \ln x specifically, and not some other slowly growing function? One way to
see it: summing the "probability" 1/\ln t of hitting a prime near each integer
t from 2 up to x gives
almost exactly \operatorname{Li}(x) = \int_2^x dt/\ln t, and integrating by
parts shows that integral is, to a first approximation, just x/\ln x itself (the
next term is smaller by a further factor of \ln x). The logarithm shows up
because it is precisely the function that makes "one prime every \ln x integers,
on average" consistent with itself as x grows.
A worked example: how good is the guess?
The symbol \sim promises only that the ratio of the two sides tends to
1 — it says nothing about how close they are for any one particular
x. Let's check the formula against the truth at two scales.
At x = 1000: since \ln 1000 \approx 6.908,
\frac{x}{\ln x} = \frac{1000}{6.908} \approx 144.8.
The true count is \pi(1000) = 168. The estimate is off by about
14\% — a fairly loose guess.
Now push out to x = 1{,}000{,}000: since \ln 10^6 \approx 13.816,
\frac{x}{\ln x} = \frac{1{,}000{,}000}{13.816} \approx 72{,}382.
The true count is \pi(10^6) = 78{,}498, so now the estimate is off by only about
7.8\%. The absolute gap has actually grown — from
23 to over 6000 — but the relative error has
halved, exactly as the theorem promises.
One more step out, to x = 10^9: \ln 10^9 \approx 20.723,
so
\frac{x}{\ln x} = \frac{1{,}000{,}000{,}000}{20.723} \approx 48{,}254{,}952,
against the true \pi(10^9) = 50{,}847{,}534 — a relative error of about
5.1\%. The sequence of relative errors, 13.8\%,
7.8\%, 5.1\%, is heading toward
0, but notice how slowly: it takes a thousandfold jump in x
each time to knock only a few percentage points off the error. That sluggish convergence is itself a known
and studied feature of the theorem, not a flaw in the estimate.
A conjecture that waited a century
The theorem's history is a lovely lesson in the gap between spotting a pattern and proving it. Around
1792, a fifteen-year-old Carl Friedrich Gauss
was given a book of logarithms with prime tables in the back; for fun, he counted primes in successive
blocks of a thousand and noticed their density falling off like 1/\ln x. A few
years later, in 1798, Adrien-Marie Legendre independently published his own
empirical fit for \pi(x). Both were pattern-matching from data, with no proof in
sight — and neither could have proved it with the tools of their day, because the right tool didn't exist
yet.
A halfway house arrived in the 1850s: Pafnuty Chebyshev
proved, using purely elementary (if fiendishly clever) methods, that the ratio
\pi(x) / (x/\ln x) stays trapped between two fixed constants close to
1 for all large x — squeezing the truth into a narrow
band without quite pinning it down. He also showed that if the ratio converges to a limit at all,
that limit has to be exactly 1. The final "if" was the hard part.
The tool that finally removed it was Riemann's 1859 memoir connecting the zeta function to the primes. It
took another 37 years of hard analysis before Jacques
Hadamard and Charles Jean de la Vallée Poussin, working
independently and publishing within months of each other, finally nailed down a full rigorous proof in
1896 — almost exactly a century after Gauss's teenage guess.
How it was proven
The Hadamard–de la Vallée Poussin argument turns entirely on the
zeros of zeta.
The crucial step is showing
\zeta(s) \ne 0 \quad\text{on the line}\quad \Re(s) = 1.
A zero sitting on that line would inject a non-vanishing oscillation into the prime count, breaking the
asymptotic; ruling it out forces \pi(x) to follow x/\ln x.
The primes' large-scale regularity is, quite literally, a statement about where
\zeta cannot be zero.
Why should the primes care where a function of a complex variable vanishes? Because
\zeta(s) is built directly out of the primes via the Euler product, every zero
of \zeta secretly encodes a "wobble" — a correction term — in the prime count.
Zeros far to the left contribute only tiny, rapidly damped wobbles; a zero sitting right on
\Re(s)=1 would contribute a wobble that never damps out at all, which would wreck
the clean limit in the theorem's statement. Proving no such zero exists is, in effect, proving that every
correction term to x/\ln x eventually fades away. (Half a century later,
"elementary" proofs avoiding complex analysis altogether were found by Erdős and Selberg — a considerable
surprise at the time, since most mathematicians believed complex analysis was unavoidable — but the
analytic route remains the most illuminating way to see why the theorem is true.)
x/\ln x is an approximation, not a formula for the exact prime
count. It is tempting, once you've seen how well it performs at x = 10^6, to
plug in some x and expect the answer on the nose — it never is. The theorem only
guarantees that the relative error shrinks toward zero as x \to \infty;
for any single finite x, there is still a gap, and that gap can be a stubbornly
large number of primes even when it looks tiny as a percentage. Treat x/\ln x as
a dial that gets more trustworthy the further out you turn it, never as an exact prime-counting machine.
Much better, in fact. Swap in the logarithmic integral
\operatorname{Li}(x) = \int_2^x \frac{dt}{\ln t} and the fit tightens dramatically:
\operatorname{Li}(1000) \approx 178 against the true
\pi(1000) = 168, and \operatorname{Li}(10^6) \approx 78{,}628
against \pi(10^6) = 78{,}498 — an error of roughly
0.17\%, forty times tighter than the plain x/\ln x
estimate at the same scale.
So how good does \operatorname{Li}(x) ultimately get? Pinning down the exact size
of the gap between \pi(x) and \operatorname{Li}(x), for
every x, turns out to be equivalent to locating every zero of
\zeta precisely — which is exactly the content of the still-unsolved
Riemann Hypothesis.
A question a curious teenager could ask with a table of primes turns out to reach all the way to one of the
seven Millennium Prize Problems.
Here's a delicious sting in the tail. In every single case anyone had ever computed —
x = 1000, 10^6, 10^9, and
far beyond — \operatorname{Li}(x) comes out slightly larger than the
true \pi(x). It was tempting to guess that this was always true. It isn't. In
1914, J. E. Littlewood proved the inequality must flip infinitely often — somewhere out past
\pi(x) catches up and overtakes \operatorname{Li}(x),
then falls behind again, forever. The first place this is now known to happen is a number with hundreds of
digits, far beyond anything a computer could ever check term by term. A pattern that held for every number
humanity has ever tested can still be false — proof, not computation, is what settles the matter.