Working notes on the primes

Grant Golland’s working notes on how the prime numbers are spread out. Every figure is computed here from a sieve of all 5 761 455 primes below 100 000 000, or with mpmath, and its caption says how. A sibling site, Zeta Zeros, covers the zeros that control these patterns.

Sentences carry a flag: Settled for proved theorems or computations on a stated range, Open for conjectures. A numerical match is never a proof.

Step 2

How many primes: the Prime Number Theorem

Write π(x) for the number of primes up to x. Near a large number x, about one number in log x is prime (natural logarithm). Adding that density up gives Gauss’s guess Li(x), and it is astonishingly good.

Counting function π(x) of primes (step curve, dark), Gauss's logarithmic integral Li(x) (gold), and x/log x (red), for x from 10 to 100000 on a linear scale. Li(x) hugs π(x); x/log x falls below it. At x = 100000: π = 9592, Li ≈ 9629, x/log x ≈ 8686.
Sieve: numpy boolean sieve of Eratosthenes to 108, 23 October 2026 PT, giving π(108) = 5 761 455 (matches the standard value). Li(x) is the integral of 1/log t from 2 to x, computed with mpmath. Motion is off if your system asks for reduced motion.

At this scale the counted staircase and Li(x) are almost one curve. The simpler x/log x has the right shape but runs about 10 percent low.

xπ(x), countedLi(x), roundedx/log xπ(x)/Li(x)
104540.80000
1002529220.86207
1 0001681771450.94915
10 0001 2291 2451 0860.98715
1059 5929 6298 6860.99616
10678 49878 62772 3820.99836
107664 579664 917620 4210.99949
1085 761 4555 762 2085 428 6810.99987

The theorem

Ratios π(x)/(x/log x) (red) and π(x)/Li(x) (gold) for x from 10 to 10^8 on a log axis, computed from a sieve of all 5761455 primes below 10^8. The first falls slowly toward 1 (1.0613 at 10^8); the second is already 0.99987 at 10^8.
Ratios from the same sieve at 300 points between 10 and 108. Motion is off if your system asks for reduced motion.
  • Settled The Prime Number Theorem: π(x) divided by x/log x tends to 1. Proved independently by Jacques Hadamard and Charles de la Vallée Poussin in 1896, both by showing that ζ(s) has no zeros on the line Re s = 1.
  • Settled Gauss (letter to Encke, 1849, recalling work from about 1792) and Legendre (1798, 1808) conjectured it from tables. Riemann’s 1859 memoir showed how the zeros of ζ control the error.
  • Settled de la Vallée Poussin (1899) proved the error π(x) − Li(x) is smaller than x·exp(−c√log x) for some constant c. Elementary proofs, without complex analysis, were found by Selberg and Erdős in 1949.
  • Open The Riemann Hypothesis is equivalent to the sharper error bound |π(x) − Li(x)| ≤ C√x log x (von Koch, 1901). It is unproved. See the Zeta Zeros site.
  • Settled Li(x) is larger than π(x) for every x in this table, but not forever: Littlewood (1914) proved the sign changes infinitely often. The first crossing is known only to lie below about 1.4 × 10316 (Bays and Hudson 2000; later refinements); none has been seen in any computed table.