Chebyshev's Bounds for π(n)

lean4-proofnumber-theoryvisualization
n2lnn<π(n)<2nlnn\frac{n}{2\ln n} < \pi(n) < \frac{2n}{\ln n}

Statement

Chebyshev's bounds (1852): there exist explicit constants c1,c2>0c_1, c_2 > 0 such that for all sufficiently large nn,

c1nlnnπ(n)c2nlnn,c_1 \cdot \frac{n}{\ln n} \le \pi(n) \le c_2 \cdot \frac{n}{\ln n},

where π(n)\pi(n) is the number of primes up to nn. Chebyshev's constants are c1=ln2c_1 = \ln 2 and c2=ln4=2ln2c_2 = \ln 4 = 2 \ln 2, giving

ln2nlnnπ(n)2ln2nlnn.\frac{\ln 2 \cdot n}{\ln n} \le \pi(n) \le \frac{2\ln 2 \cdot n}{\ln n}.

This implies π(n)n/lnn\pi(n) \sim n/\ln n up to a constant factor, a precursor to the Prime Number Theorem (which gives π(n)Li(n)\pi(n) \sim \mathrm{Li}(n)).

Visualization

Comparison of π(n)\pi(n) (exact count), the Chebyshev lower bound ln(2)n/ln(n)\lfloor \ln(2)\cdot n / \ln(n) \rfloor, and the asymptotic approximation n/ln(n)\lfloor n / \ln(n) \rfloor:

nnπ(n)\pi(n)n/lnn\lfloor n/\ln n \rfloorratio π(n)/(n/lnn)\pi(n)/(n/\ln n)
10441.00
10025211.19
10001681441.17
10000122910851.13
100000959286851.10

The ratio π(n)/(n/lnn)\pi(n) / (n/\ln n) converges to 11 as nn \to \infty, which is the content of the Prime Number Theorem. Chebyshev's weaker result shows the ratio is bounded between ln20.693\ln 2 \approx 0.693 and ln41.386\ln 4 \approx 1.386.

Proof Sketch

  1. Upper bound via (2nn)\binom{2n}{n}. The product of all primes in (n,2n](n, 2n] divides (2nn)<4n\binom{2n}{n} < 4^n. Taking logarithms gives the Chebyshev ψ\psi-function bound ϑ(n)nln4\vartheta(n) \le n \ln 4.
  2. Lower bound from Bertrand. By Bertrand's PostulateBertrand's Postulaten1,  p prime,  n<p2n\forall n \ge 1,\; \exists p \text{ prime},\; n < p \le 2nFor every positive integer n there is always a prime p with n < p ≤ 2nRead more →, there is always a prime in (n,2n](n, 2n]. Iterating: primes >n/2> n/2, >n/4> n/4, ... give at least log2(n)1\log_2(n) - 1 primes up to nn. A tighter argument using (2nn)\binom{2n}{n} gives π(n)(ln2)n/lnn\pi(n) \ge (\ln 2)\, n/\ln n.
  3. Counting argument. Primes pnp \le n each appear in (2nn)\binom{2n}{n} to a bounded power; summing and comparing with 4n/(2n)4^n / (2n) closes the bound.

Connections

Chebyshev's bounds are a direct consequence of Bertrand's PostulateBertrand's Postulaten1,  p prime,  n<p2n\forall n \ge 1,\; \exists p \text{ prime},\; n < p \le 2nFor every positive integer n there is always a prime p with n < p ≤ 2nRead more → and a precursor to the Prime Counting Function π(n)Prime Counting Function π(n)π(n)=#{pn:p prime}\pi(n) = \#\{p \le n : p \text{ prime}\}π(n) counts primes up to n and satisfies π(n) ~ n/ln(n) by the Prime Number TheoremRead more → asymptotics. The central binomial coefficient argument also appears in Lagrange's Four-Square TheoremLagrange's Four-Square Theoremn=a2+b2+c2+d2n = a^2 + b^2 + c^2 + d^2Every natural number is the sum of four perfect squaresRead more → and in the Binomial TheoremBinomial Theorem(x+y)n=k=0n(nk)xkynk(x+y)^n = \sum_{k=0}^{n} \binom{n}{k} x^k y^{n-k}Expanding powers of a sum via binomial coefficientsRead more →.

Lean4 Proof

import Mathlib.Data.Nat.Prime.Basic
import Mathlib.Data.Finset.Basic

/-- There are at least 4 primes ≤ 10: {2, 3, 5, 7}. -/
theorem at_least_4_primes_le_10 :
    (Finset.filter Nat.Prime (Finset.range 11)).card  4 := by decide

/-- There are exactly 4 primes ≤ 10. -/
theorem exactly_4_primes_le_10 :
    (Finset.filter Nat.Prime (Finset.range 11)).card = 4 := by decide

/-- There are exactly 25 primes ≤ 100. -/
theorem exactly_25_primes_le_100 :
    (Finset.filter Nat.Prime (Finset.range 101)).card = 25 := by decide