Primes from Zeros

Each zero is a wave, and added together the waves build the staircase of primes exactly. Switch them on one at a time and hear what the primes are made of

Primes from Zeros

The primes and the zeros of the zeta function are two descriptions of the same thing, related the way a sound is related to its frequencies. Each zero contributes one wave. Add the waves up and the staircase of primes appears, step for step; listen to the primes instead and the zeros are the notes you hear.

Building the Staircase

Press Reset, then Play, and watch the fuchsia curve grow steps as zeros are added one at a time. Then widen the window and see how many zeros a sharp staircase costs further out.

finding zeros: 0 of 2,000
Window of x
0
pairs of zeros in the sum
—
height γ of the last zero used
2.45
largest error between jumps, at x = 40.5
—
formula / ψ: point at the chart
−1.8379
the constant term, −ln 2π
0.144
the trivial zeros’ term, −½ ln(1 − x−2), at x = 2
With no zeros the formula is the straight line x, lowered by ln 2π. It knows how many primes to expect and nothing about where they are. Press Play, or step in the first zero.
ψ(x), from a sieve: a jump of ln p at each power of a prime pthe explicit formula with K pairs of zerosthe main term xlargest error± 2√x/|ρ|, the size of one wave

The fuchsia curve is x − ∑ xρ/ρ − ln 2π − ½ ln(1 − x−2), with the sum taken over the first K zeros above the real axis and their mirror images below, in order of height. The zeros are found by this browser, to about ten decimal places, and each one costs two trigonometric evaluations for every point of the curve. The error is measured half-way between whole numbers, where ψ has no jump; on the widest window the curve is drawn at whole and half numbers only. The amber dots mark the midpoint of each jump. Switch off the two small terms to see what they are worth: the curve floats about 1.84 too high.

Go deeper:Von Mangoldt’s Explicit Formula

Chebyshev’s function ψ(x) adds up ln p over every prime power pk ≤ x. For x > 1, with ψ0 meaning ψ with each jump replaced by its midpoint,

ψ0(x) = x − ∑ρ xρ/ρ − ln 2π − ½ ln(1 − x−2)

where ρ runs over the non-trivial zeros of ζ. Riemann stated a formula of this kind in 1859; this version was proved by Hans von Mangoldt in 1895. The derivation has three steps. Taking the logarithmic derivative of Euler’s product gives −ζ′(s)/ζ(s) = ∑ Λ(n) n−s, where Λ(n) is ln p when n is a power of the prime p and zero otherwise. Hadamard’s product for ζ (1893) writes the same function as a sum of simple fractions, one for the pole at s = 1 and one for each zero. An inverse Mellin transform then turns each fraction 1/(s − ρ) into a power xρ/ρ, and the two sides become ψ and the formula above. The pole gives the main term x, the trivial zeros at −2, −4, … give the last term, and the constant is −ζ′(0)/ζ(0) = −ln 2π.

The sum over zeros does not converge absolutely: there are about (T/2π) ln T zeros up to height T and the terms shrink only like 1/|ρ|. It converges conditionally, so the order matters, and the theorem is about the order used in the demo: pair each zero with its mirror image below the real axis and add the pairs in order of height. No finite number of smooth waves can make a jump, which is why the partial sums overshoot beside each one (the Gibbs phenomenon) and pass through its midpoint.

A pair of zeros ρ = β ± iγ contributes −2xβ cos(γ ln x − arg ρ)/|ρ|. That is a wave which is periodic in ln x, with frequency γ, and whose amplitude grows like xβ. Every zero has β = ½: that is the Riemann hypothesis, proved in November 2026. So every wave grows like √x. A zero with β > ½ would have given a wave that eventually outgrows all the others. See also: What the Hypothesis Says.

Zeros from Primes

Slide X up and watch peaks rise out of a sum over primes, exactly where the fuchsia lines mark the zeros the browser found. Tap a peak to measure it, then switch to the second view to see and hear the waves.

finding zeros: 0 of 80
Window of heights t
10,000
X: the largest prime power used
0
prime powers in the sum
0.68
width of a peak, about 2π/ln X
13.809
highest peak near where you tapped
—
nearest zero from the search
—
peak − zero
Tap the chart near a peak to measure it against the nearest zero.
F(t), computed from primes alonezeros of ζ, found separately on the critical linethe predicted height of a peakthe peak you picked

F(t) = −∑ Λ(n) n−½ cos(t ln n) over the prime powers n = pk ≤ X, with Λ(n) = ln p. Tap or drag on the chart to pick a peak. The sharp cutoff gives the tallest, narrowest peaks, with ringing on either side of each; the taper halves their height and widens them a little, and in exchange every zero shows as a clean bump with no negative lobes. Either way two zeros closer together than about 2π/ln X merge into one peak: try the pair near t = 111 with X = 1,000, then raise X. “Take out the pole’s ripple” adds back −6.3 at t = 14.1: the known contribution of the pole at s = 1, which is not a zero. The sum is carried at 4,001 heights from 0 to 200, so the largest setting adds up about 300 million terms. Below t = 8 the raw sum plunges to −2√X at t = 0, and the chart lets that run off the bottom.

Go deeper:A Duality Between Primes and Zeros

The explicit formula can be read in either direction. Differentiate it and ask for the Dirichlet sum over prime powers up to X at the point s = ½ + it: each zero ρ contributes −(Xρ−s − 1)/(ρ − s), which at t = γ is exactly −ln X and elsewhere stays bounded. So F(t) = −∑ Λ(n) n−½ cos(t ln n) has a peak of height about ln X, and width about 2π/ln X, at each zero on the critical line. The pole of ζ contributes too: a ripple of size 2√X/t, which for large X is bigger than the peaks. It is known exactly, and the demo lets you subtract it. With the taper, each zero’s contribution becomes a squared sine-over-argument, which is never negative, and the peak height is ½ ln X.

This is a Fourier-type relation between two sets of numbers: the logarithms of the prime powers, ln pk, and the heights γ of the zeros. Its general form is André Weil’s explicit formula (1952), which holds for any suitable test function and puts a sum over primes on one side and a sum over zeros on the other; von Mangoldt’s formula and the sum in this demo are two choices of test function. Edmund Landau proved a particularly clean instance in 1911: for fixed x > 1,

∑0 < γ ≤ T xρ = −(T/2π) Λ(x) + O(ln T).

Summing xρ over zeros gives something that grows with T exactly when x is a prime power: the zeros detect the primes, just as the primes above detect the zeros.

None of this depends on the Riemann hypothesis. The hypothesis adds that every frequency γ is a real number and every wave is a pure oscillation in ln x, scaled by √x; since November 2026 that is a theorem. A zero off the critical line would have appeared in this picture as a wave with its own, faster rate of growth, and in the spectrum as a peak that grows like a power of X where ln X is predicted. The agreement in the demo is a double-precision computation at heights below 200; it illustrates the duality and proves nothing about zeros further up. See also: Fourier Analysis, for a signal and its spectrum, and The Riemann Zeta Function in Number Theory.

Riemann’s Formula for π(x)

Switch the ingredients on one at a time: li(x), the correction that turns it into R(x), then the zeros. Slide K up and watch a smooth curve learn to count primes.

finding zeros: 0 of 500
Ingredients of the formula (li(x) is always in; switch the others on and off)
Window of x
0
pairs of zeros in the sum
—
size of the last zero term
0.977
largest error between steps, at x = 96.5
—
formula / π: point at the chart
The whole formula, every ingredient on, with 0 pairs of zeros
xπ(x)R(x)R(x) − π(x)formulaformula − π(x)
2087.527−0.4737.488−0.512
501514.976−0.02414.894−0.106
1002525.6620.66225.6890.689
5009594.328−0.67294.304−0.696
1,000168168.3590.359168.3350.335
With no zeros the formula is Riemann’s smooth curve R(x), give or take the small terms. It runs through the middle of the staircase and has no steps of its own. Press Play to add the zeros.
π(x), from a sieveRiemann’s formula with the ingredients switched onli(x)R(x)

Riemann’s J(x) counts each prime power pk ≤ x with weight 1/k, and π(x) = ∑ μ(n)/n · J(x1/n) over the whole numbers n with x1/n ≥ 2: here n = 1, 2, 3, 5, 6 at x = 100. Each zero costs one complex exponential integral for every such n at every point of the curve. “The small terms” are the −ln 2 and the integral from the trivial zeros in each J, together with the difference between stopping the sum over n there and running it for ever, as R(x) does; that is why the K = 0 curve has a faint step at each power of 2. All of it is computed in double precision from zeros found to about ten decimal places: a demonstration that the formula works, not a rigorous count.

Go deeper:What the 1859 Paper Did

Bernhard Riemann’s only paper on number theory, published in November 1859, is fewer than ten pages long. In it he continued ζ to the whole plane, proved the functional equation, and wrote down a formula for the prime-counting function. He worked with J(x), which counts each prime power pk ≤ x with weight 1/k, because that is what the logarithm of Euler’s product produces:

J0(x) = li(x) − ∑ρ li(xρ) − ln 2 + ∫x∞ dt / (t (t² − 1) ln t)

and then π(x) = ∑ μ(n)/n · J(x1/n) by Möbius inversion, a finite sum because J is zero below 2. Here li(xρ) means Ei(ρ ln x), the exponential integral of a complex number, taken on the branch that tends to iπ far up the imaginary axis; the demo computes it with a power series, a continued fraction or an asymptotic series depending on where the argument lies. The integral is the contribution of the trivial zeros, and it is at most 0.14. Keeping only the li terms, for every n, gives the smooth curve R(x) = ∑ μ(n)/n · li(x1/n), which, apart from the small terms, is what the formula looks like with the zeros switched off.

Riemann did not prove this formula rigorously. He also made the remark that made the paper famous: that it is “very probable” that all the zeros have real part ½, that he had put the search for a proof aside after a few brief attempts, and that it was not needed for his immediate purpose. Von Mangoldt supplied the proof of the formula in 1895. A year later Jacques Hadamard and Charles-Jean de la Vallée Poussin independently proved the prime number theorem, π(x) ~ li(x), and what they needed was much less than the hypothesis: only that no zero has real part 1, so that every wave grows more slowly than the main term.

“The music of the primes” is the title of Marcus du Sautoy’s 2003 book. The idea underneath it, that the primes are a sum of waves with the zeros as their frequencies, is in Riemann’s paper. See also: The Prime Staircase, where li(x) and R(x) are measured against π(x) up to ten million.

Key Takeaways

  • The explicit formula rebuilds the staircase of primes exactly from the zeros of ζ: one wave, periodic in ln x, for each pair of zeros.
  • It runs backwards too: a cosine sum over prime powers up to X has a peak of height about ln X at every zero.
  • The real part of a zero sets how fast its wave grows; every zero has real part ½, and its wave grows like √x.
  • The formula is a theorem (von Mangoldt, 1895) and never depended on the Riemann hypothesis, which was open until it was proved in November 2026 by a machine-checked proof (See also: What Is Actually Known).

Spot a mistake or have an idea?

Search