The Explicit Formula

Here is the single most astonishing identity in all of number theory. On the left, a jagged staircase that counts the primes — a purely arithmetic object, built by hand out of the whole numbers 2, 3, 4, 5, \dots. On the right, a smooth sweep x minus an infinite chord of waves, one wave for every zero of the Riemann zeta function. The two sides are not "approximately" equal, not equal "in the limit" — they are exactly, identically equal, for every real x > 1.

This is Riemann's explicit formula (1859), made rigorous by von Mangoldt (1895). It says the primes are literally played by the zeros of zeta, the way a chord is played by its overtones. If you ever wondered what the zeros of an obscure complex function have to do with the prime numbers, this is the answer, written out in full. It is the bridge the whole proof of the Prime Number Theorem walks across.

The object being counted: \psi(x)

We do not count the primes directly. The clean quantity is the Chebyshev function, the running sum of the von Mangoldt function \Lambda(n):

\psi(x) = \sum_{n \le x} \Lambda(n), \qquad \Lambda(n) = \begin{cases} \log p, & n = p^k \ (k \ge 1),\\ 0, & \text{otherwise.}\end{cases}

So \psi jumps by \log p at every prime p and by \log p again at every prime power p^k. Weighting each prime by its logarithm is exactly the weighting that makes the analysis come out clean: the Prime Number Theorem in this language is simply \psi(x) \sim x. The counting function \pi(x) can be recovered from \psi afterwards (that translation is the equivalence of the three prime functions).

One tiny bookkeeping fix. At a jump the staircase is discontinuous, so we use the midpoint value \psi_0(x), which averages the left and right limits:

\psi_0(x) = \tfrac12\big(\psi(x^-) + \psi(x^+)\big).

Away from jumps \psi_0 = \psi; at a jump it sits exactly halfway up the riser. This is the version the exact formula reproduces.

The formula itself

For every real x > 1,

\psi_0(x) = x \;-\; \sum_{\rho} \frac{x^{\rho}}{\rho} \;-\; \log(2\pi) \;-\; \tfrac12\log\!\left(1 - x^{-2}\right),

where the sum runs over all non-trivial zeros \rho of \zeta, taken in conjugate pairs and ordered by |\Im\rho|. Term by term:

Read it as a decomposition. The smooth prediction is x; every correction to it is a zero of zeta making itself heard. The two small tail terms (-\log(2\pi) \approx -1.838 and the log term, which \to 0 as x \to \infty) are fixed and harmless. All the drama is in the sum over \rho.

Where it comes from: Perron, then a contour shift

The engine is the logarithmic derivative of zeta. Its Dirichlet series is precisely the generating series of \Lambda:

-\frac{\zeta'(s)}{\zeta(s)} = \sum_{n \ge 1} \frac{\Lambda(n)}{n^{s}}, \qquad \Re(s) > 1.

Feed this into Perron's formula, which recovers a summatory function as a vertical contour integral:

\psi_0(x) = \frac{1}{2\pi i}\int_{c - i\infty}^{c + i\infty} \left(-\frac{\zeta'(s)}{\zeta(s)}\right)\frac{x^{s}}{s}\,ds, \qquad c > 1.

Now push the contour to the left, out toward \Re(s) = -\infty. By the residue theorem, the integral picks up 2\pi i times the residue at every pole of the integrand it sweeps across, and the integrand -\dfrac{\zeta'(s)}{\zeta(s)}\dfrac{x^s}{s} has a pole wherever something in it blows up. Bookkeeping the residues is the formula:

Pole atCauseResidue picked up
s = 1pole of \zeta (so of -\zeta'/\zeta)+\,x
s = \rhoeach non-trivial zero of \zeta-\,x^{\rho}/\rho
s = 0the 1/s in Perron-\,\log(2\pi)
s = -2,-4,\dotseach trivial zero of \zeta-\tfrac12\log(1-x^{-2})

A zero \rho of \zeta is a pole of \zeta'/\zeta with residue equal to its multiplicity; the factor x^s/s evaluated there gives x^\rho/\rho. Sum the trivial-zero residues \sum_{n\ge1} x^{-2n}/(2n) = -\tfrac12\log(1-x^{-2}) and every piece of the theorem is accounted for. (Making the shifted integral genuinely vanish takes real work — bounding \zeta'/\zeta along carefully chosen horizontal cuts — but the shape of the answer is just this residue count.)

Each zero is a musical note

The mysterious-looking term x^\rho/\rho becomes vivid once you pair a zero \rho = \beta + i\gamma with its mirror image \bar\rho = \beta - i\gamma (zeros always come in conjugate pairs, since \zeta is real on the real axis). Writing x^{\rho} = x^{\beta}e^{i\gamma\log x} and adding the pair, the imaginary parts cancel and you are left with a real oscillation:

\frac{x^{\rho}}{\rho} + \frac{x^{\bar\rho}}{\bar\rho} = \frac{2\,x^{\beta}}{|\rho|}\cos\!\big(\gamma\log x - \arg\rho\big).

Look at what each ingredient controls:

So \psi_0(x) = x - (\text{a sum of pure notes}). The primes are a chord; the zeros of zeta are its overtones. Riemann's insight, in one picture: the music of the primes is written on the zeros of zeta.

What the Riemann Hypothesis says here

Now the punchline. The amplitude of the \gamma-note is x^{\beta}/|\rho|. The non-trivial zeros all lie in the strip 0 < \beta < 1 — but where in the strip decides how loud they get. The Riemann Hypothesis is exactly the statement \beta = \tfrac12 for every zero, and in the explicit formula that reads:

No zero is allowed to shout above the others. Every note capped at amplitude \sqrt{x} is the precise musical meaning of "the primes hold no secret pattern."

Seeing it: a few zeros rebuild the staircase

This is the picture worth a thousand words. The faint grey staircase is the true \psi(x), jumping by \log p at each prime and prime power. The coloured curve is the explicit formula with the sum truncated to just the first seven pairs of zeros (imaginary parts \gamma \approx 14.13,\,21.02,\,25.01,\,30.42,\,32.94,\,37.59,\,40.92):

\psi_{\text{approx}}(x) = x - \sum_{k=1}^{7}\frac{2\sqrt{x}}{|\rho_k|}\cos\!\big(\gamma_k\log x - \arg\rho_k\big), \qquad \rho_k = \tfrac12 + i\gamma_k.

With only seven waves the curve already leans into every step, cresting just where a prime lands and dipping back between them. Each extra zero you add sharpens the corners a little more; the full infinite sum reproduces the staircase exactly, vertical risers and all. That the smooth line x, nudged by a few complex numbers, should know where the primes are — that is the whole magic of analytic number theory in one chart.

Riemann's original: counting \pi(x) directly

Riemann actually wrote his formula for the prime-counting function itself. Start from the smooth approximation not by \operatorname{Li}(x) alone but by the Riemann prime-counting function, a Möbius-weighted stack of logarithmic integrals:

R(x) = \sum_{n \ge 1} \frac{\mu(n)}{n}\,\operatorname{Li}\!\big(x^{1/n}\big) = \operatorname{Li}(x) - \tfrac12\operatorname{Li}(x^{1/2}) - \tfrac13\operatorname{Li}(x^{1/3}) - \cdots

R(x) is a strikingly better fit to \pi(x) than \operatorname{Li}(x) is (that -\tfrac12\operatorname{Li}(\sqrt x) correction accounts for the squares of primes). The exact formula then reads

\pi_0(x) = R(x) - \sum_{\rho} R\!\big(x^{\rho}\big),

with, again, one oscillating term per non-trivial zero. It is the same song as the \psi formula, rescored for \pi: a smooth lead line, corrected by a chorus of zeros. The \mu(n)/n coefficients are exactly the Möbius inversion of the relation \Pi(x) = \sum_k \tfrac1k \pi(x^{1/k}) that ties the prime-power count back to the prime count.

The series \sum_\rho x^\rho/\rho is only conditionally convergent — you may not reorder it freely. Its terms shrink like 1/|\rho| \sim 1/\gamma, and \sum 1/\gamma diverges, so absolute convergence fails. What rescues it is pairing each zero \rho with its conjugate \bar\rho and summing in order of increasing |\gamma|:

\sum_{\rho} \frac{x^{\rho}}{\rho} = \lim_{T\to\infty}\sum_{|\gamma| < T}\frac{x^{\rho}}{\rho}.

Within a conjugate pair the imaginary parts cancel to give the real cosine above, and the cancellation between successive pairs is what makes the whole thing converge. Grab the terms in the wrong order and you can make the "sum" converge to anything you like — a classic Riemann-rearrangement trap. And remember the left-hand side is \psi_0, the midpoint value: at a prime p the formula returns the value halfway up the jump, not the top or the bottom.

Take the explicit formula literally as sound. Each zero \rho = \tfrac12 + i\gamma contributes a pure tone of frequency proportional to \gamma and (under RH) the same amplitude order. The lowest zero, \gamma \approx 14.13, is the fundamental; the higher zeros are the overtones. Play them together and you literally hear the "music of the primes" — a surprisingly rich, bell-like timbre, because the frequencies (the zero heights) are not simple integer multiples of one another.

There is more than metaphor here. The Hilbert–Pólya conjecture guesses that the numbers \gamma are the eigenvalues of some self-adjoint operator — the resonant frequencies of some unknown quantum drum. Statistically, the spacings between consecutive \gamma's match the eigenvalue spacings of large random Hermitian matrices (the Montgomery–Odlyzko law) astonishingly well. If that operator were ever found, its self-adjointness would force every \gamma real — and the Riemann Hypothesis would fall out as a theorem about a vibrating object.

A worked check: reading a jump off the formula

Take x creeping up past the prime 7. The true staircase does nothing between 5 and 7, then leaps by \Lambda(7) = \log 7 \approx 1.946 exactly at x = 7. How does the smooth-plus-waves right-hand side manage a vertical jump?

It doesn't — no finite truncation can. The main term x rises steadily; the finitely many wave terms are each smooth. But as you throw in more and more zeros, the partial sums pile up an ever-steeper climb concentrated right at x = 7, converging to a genuine step of height exactly \log 7, centred on the midpoint value \psi_0(7) = \psi(7) - \tfrac12\log 7. Add zeros and the "corner" at 7 gets sharper and sharper (with a small Gibbs-style overshoot, the same ringing you see in a truncated Fourier series). The infinitely many zeros conspire, through their careful phase alignment at x = 7, to build a cliff out of nothing but cosines — which is exactly what the chart above is showing you in miniature.