The prime count π(x)

16/ 1,000,000
Loading…
Position · x
…
Exact
…
Reconstruction
…
Use the arrow keys to inspect values and Escape to return to the endpoint.

With s(x)=lnxx, black shows s(x)[π(x)−Li(x)] and blue shows s(x)[πk(x)−Li(x)]. This scaling preserves the sign of the error at every x.

Range of x
Method

From primes to waves

The exact count jumps by one at each prime. The reconstruction starts with a baseline, π₀(x), and adds one wave for each conjugate pair of zeros of the Riemann zeta function.

πk(x)=π0(x)+∑j=1kwj(x)

The slider sets k, the number of pairs. At a prime, the expansion approaches the midpoint of the jump. The close-up around 101 lets you watch the waves resolve a single step.

The baseline and one zero pair

Riemann’s formula counts prime powers. Möbius inversion uses the weights μ(n) to recover a count of primes. With the slider at zero, the smooth terms, the constant and the contribution from the trivial zeros give the baseline below. It is closely related to Riemann’s R function. Riemann’s R function and the explicit formula.

π0(x)=∑n≤log2xμ(n)nJ0(un)un=lnxn

In the smooth term J₀, Ei is the exponential integral. The final integral accounts for the trivial zeros.

J0(u)=Ei(u)−ln2+∫u∞dvv(e2v−1)

The jth pair consists of a zero ρⱼ and its complex conjugate. Their contributions combine into one real wave, wⱼ. The zero’s height γⱼ sets the pace of its oscillation along the logarithmic axis.

ρj=12+iγjwj(x)=−2∑n≤log2xμ(n)nReEi(ρjun)

Reading the error

Counting error subtracts Li(x) from both curves. Zero-pair baseline error subtracts π₀(x), so the black line shows the fluctuation the waves must explain and the blue line shows their sum.

Li(x)=∫2xdtlnts(x)=lnxx

Scaled error multiplies the counting error by s(x). This preserves its sign and brings the leading prime-square correction toward −1. Beyond a billion the explorer uses that bias plus the leading wave from each selected pair. The overview shows individual samples. The crossover close-up connects them on a finer grid.

The distant curve is approximate. The crossover proof uses the classical li(x), which exceeds the explorer’s Li(x) by about 1.045.

How the curves are computed

A segmented sieve indexes exact prime counts every 32,768 integers. Above one million the black overview retains the highest and lowest counting error in each log-grid interval. The blue curve joins sampled estimates. The last 1,000 integers before a billion are shown with every prime step.

The first 2,048 zero locations come from high-precision mpmath calculations. The rest use numerical Riemann–Siegel root approximations with zero-count checkpoints checked against mpmath. The slider then adds groups of 512 pairs, with 64 in the final group. Higher terms use an asymptotic approximation to Ei and quantized block sums. A standalone edition embeds the same tables for offline use. Odlyzko’s reference tables.