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)≈1log⁡x.

That is, an integer chosen uniformly in a neighbourhood of x is prime with probability ∼1/log⁡x. The primes thin out — but slowly, since log⁡x 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)=∑k≥1⌊npk⌋.

Bounding the floors, np−1≤vp(n)≤np−1, so vp(n)≈n/p. Taking logarithms of n!=∏p≤npvp(n):

log⁡(n!)=∑p≤nvp(n)log⁡p≈n∑p≤nlog⁡pp.

2. Via calculus (analytic)

log⁡(n!)=∑j=1nlog⁡j, which is a Riemann sum for the integral of log⁡t:

log⁡(n!)≈∫1nlog⁡tdt=nlog⁡n−n+1≈nlog⁡n−n.

3. Equating both estimates

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

n∑p≤nlog⁡pp≈nlog⁡n−n⟹∑p≤nlog⁡pp≈log⁡n−1.

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)⋅log⁡xx,

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

δ(x)log⁡xx=1x⟹δ(x)=1log⁡x.

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