Prime density

The density of the primes near x, denoted δ(x), is the proportion of integers in a small window around x that are prime. For x large this quantity is remarkably well approximated by

δ(x)1logx.

That is, an integer chosen uniformly in a neighbourhood of x is prime with probability 1/logx. The primes thin out — but slowly, since logx grows slowly.

Heuristic derivation: two estimates of log(n!)

The idea (as in zetamath's video Factorials, prime numbers, and the Riemann Hypothesis) is to estimate log(n!) twice — once arithmetically using primes, once analytically using calculus — and force the answers to agree.

1. Via primes (number theory)

The exponent vp(n) of a prime p in n! is given by Legendre's formula:

vp(n)=k1npk.

Bounding the floors, np1vp(n)np1, so vp(n)n/p. Taking logarithms of n!=pnpvp(n):

log(n!)=pnvp(n)logpnpnlogpp.

2. Via calculus (analytic)

log(n!)=j=1nlogj, which is a Riemann sum for the integral of logt:

log(n!)1nlogtdt=nlognn+1nlognn.

3. Equating both estimates

Since both expressions approximate the same log(n!), they must be close:

npnlogppnlognnpnlogpplogn1.

4. Differentiating both sides

Viewing x as a continuous variable, the left side is a step function: when x increases by 1 we either add log(x)/x (if x is prime) or add nothing. Its "average slope" is therefore

δ(x)logxx,

where δ(x) is the proportion of the time we add a full term. The derivative of the right side is 1/x. Equating:

δ(x)logxx=1xδ(x)=1logx.

Related: prime counting function · prime number theorem · logarithmic integral · Chebyshev function · Riemann zeta function · Riemann hypothesis