ζ · A Visual Journey

Level 2

Counting the Uncountable

The prime staircase, and the curve that shadows it.

Prerequisites: Comfort reading a graph. Logarithms introduced gently in-page.

Level 1 ended with a tension: primes look random one at a time, yet the Ulam spiral hints at hidden order. The way out of the paradox is a change of question. Stop asking “which numbers are prime?” and start asking “how many primes are there up to x?” Individuals are unpredictable; populations have statistics.

Mathematicians write the answer as π(x) — nothing to do with the circle constant; it is just the letter p for prime-counting. π(10) = 4, because 2, 3, 5, 7. π(100) = 25. Each new prime adds a step of height one. Plotted, π(x) is a staircase — and this staircase has a secret that only distance reveals. Drag the slider:

π(x): the prime-counting staircase
π(x) = 25

π(x) counts the primes up to x. Up close (x ≤ a few hundred) it is a jagged staircase, climbing one step at each prime, with no visible rhythm. Drag the slider right and watch the steps fuse into a smooth, confident curve. Nothing about the primes changed — only your distance from them.

At x ≤ 100 the staircase is all elbows: jerky, irregular, stubbornly local. By x = 1,000,000 it has become a single elegant sweep. This is the visual heart of the whole subject. The lawlessness is real, and so is the law — they live at different scales.

Gauss’s guess

Around 1792, a teenage Carl Friedrich Gauss spent idle quarter-hours counting primes in blocks of a thousand (he later claimed to have counted all primes below three million this way). He noticed the thinning was not chaotic at all: near a number x, roughly one in every ln(x) numbers is prime — where ln is the natural logarithm. Near 1,000 (ln ≈ 6.9) about one number in seven is prime; near 1,000,000 (ln ≈ 13.8) about one in fourteen. Each multiplication of x by ten just adds about 2.3 to ln(x). Slow, steady dilution.

Go deeperNever met ln? A two-minute introduction★★

The natural logarithm answers one question: how long does growth take? If something grows continuously at 100% per unit time, ln(x) is the time needed to grow from 1 to x. It undoes the exponential function: ln(et)=t\ln(e^t) = t, where e2.71828e \approx 2.71828.

The only properties we use: ln turns multiplication into addition (ln(ab)=lna+lnb\ln(ab) = \ln a + \ln b), and it grows very slowly — ln(10) ≈ 2.3, ln(1,000,000) ≈ 13.8, ln(a googol) ≈ 230. When you hear “one in ln(x) numbers near x is prime,” hear: primes thin out, but glacially.

If the density of primes near x is about 1/ln(x), then counting primes up to x should be like adding up that density — giving the estimate π(x)x/lnx\pi(x) \approx x/\ln x, or better, Gauss’s refined version: add up the density as it changes, the logarithmic integral

Li(x)=2xdtlnt.\operatorname{Li}(x) = \int_2^x \frac{dt}{\ln t}.

Two candidate laws, one truth. Let them race:

The great race: two formulas chase the primes
π(x) — the truthLi(x) — Gauss's refined guessx∕ln x — the first guess
π = 1,229Li off +1.31%x∕ln x off -11.66%

Both approximations are asymptotically right, but they are not equally good. x/ln x trails noticeably (about 8% low at one million), while Li(x) hugs the true count so closely you can barely separate the curves — off by just 0.16% at one million, and still improving. Keep an eye on the error readout as you drag.

The Prime Number Theorem

What the race suggests, a century of work confirmed. In plain words: the proportion of primes near x is 1/ln(x), exactly, in the long run. In symbols, this is the Prime Number Theorem, proved in 1896 by Jacques Hadamard and Charles de la Vallée Poussin (independently, both building on Riemann’s blueprint):

π(x)xlnxmeaninglimxπ(x)x/lnx=1.\pi(x) \sim \frac{x}{\ln x} \qquad\text{meaning}\qquad \lim_{x\to\infty}\frac{\pi(x)}{x/\ln x} = 1.

Pause on how strange this is. No one can tell you whether 286,243 − 1 is prime without serious computation — yet the census of primes obeys a law as clean as anything in physics. The atoms are anarchists; the population files tax returns.

The question that remains

The Prime Number Theorem says π(x) and Li(x) agree eventually, in ratio. It does not say how far apart they can drift along the way. Look back at the race: Li(x) ran ahead of π(x) by 129 at one million. Is that drift bounded by √x? By x0.9? The theorem alone won’t say.

The question is no longer “is there a pattern?” There is. The question is “how big is the error term?” — and that is exactly where the Riemann Hypothesis lives.

To attack the error term, mathematics had to leave the whole numbers entirely — for an infinite sum, discovered by Euler and weaponized by Riemann, that somehow knows everything about the primes. That is Level 3.

Go deeperChebyshev gets close (1850)★★

Before the full theorem, Pafnuty Chebyshev proved by elementary (if ingenious) counting that the answer has the right shape: for large x,

0.92xlnx  <  π(x)  <  1.11xlnx.0.92\,\frac{x}{\ln x} \;<\; \pi(x) \;<\; 1.11\,\frac{x}{\ln x}.

So π(x) is trapped at the scale x/ln x forever — but pinning the constant to exactly 1 resisted all elementary attack, and ultimately fell to complex analysis. A fully elementary proof of the Prime Number Theorem did eventually arrive (Selberg and Erdős, 1949) — nearly a century later, and famously harder, not easier, than the analytic one.

Go deeperSkewes' number: π(x) fights back★★★

In every range ever computed, Li(x)>π(x)\operatorname{Li}(x) > \pi(x) — the smooth curve runs slightly hot. Surely that’s a law? No. Littlewood proved in 1914 that π(x)Li(x)\pi(x) - \operatorname{Li}(x) changes sign infinitely often. The lead changes hands forever; we have simply never computed far enough to witness it. Skewes bounded the first crossover by the absurd 1010103410^{10^{10^{34}}} (assuming RH); the bound now stands near 1.39×103161.39 \times 10^{316} — still far beyond direct computation.

Remember this in Level 5: it is the canonical warning against trusting numerical evidence in number theory. A pattern can hold for the first 1030010^{300} cases and still be false.

What you now know

Counting primes instead of hunting them reveals a law: the staircase π(x) smooths into a curve tracked astonishingly well by Li(x), and the Prime Number Theorem makes the convergence exact — in the limit. What it leaves open is the size of the wobble between truth and law, and you have now seen that wobble with your own eyes. The next tool is unexpected: an infinite sum from analysis, Euler’s “golden key,” that converts statements about primes into statements about a smooth function — where calculus can finally get a grip.

Next — Level 3The Golden KeyAn infinite sum that secretly knows every prime.