Mertens' second theorem with explicit error term
ProvedMertensTheorems.mertens_secondMertens' second theorem gives the asymptotic for the sum of reciprocals of the primes, with an explicit error term.
The sum runs over primes , and is the Meissel–Mertens constant, approximately . The statement asserts the existence of such an together with an absolute constant for which the bound holds for every .
That diverges is Euler's theorem, and already shows the primes are infinite and not too sparse. Mertens' refinement pins the rate: the divergence is exactly , and the approach to it is . This is one of the foundational estimates of analytic number theory. It is what makes sieve methods quantitative — the Brun and Selberg sieves both need it — and it is the input to the Hardy–Ramanujan and Turán–Kubilius theorems on the normal order of the number of prime factors. Notably, the result predates the prime number theorem and does not depend on it.
Formalization note. The primes up to are enumerated as
(Finset.range (n+1)).filter Nat.Prime, so the sum is over a finite set of naturals cast to ℝ.
Both and are existentially quantified, with required only to be nonnegative. Only
Mathlib is needed.
import Mathlib
namespace MertensTheorems
/-- Mertens' second theorem, in sharp form: the sum of reciprocals of the primes up to `n`
equals `log log n + M` up to an error `O(1 / log n)`. -/
theorem mertens_second :
∃ M : ℝ, ∃ C : ℝ, 0 ≤ C ∧ ∀ n : ℕ, 2 ≤ n →
|(∑ p ∈ (Finset.range (n+1)).filter Nat.Prime, (1:ℝ)/p)
- (Real.log (Real.log n) + M)| ≤ C / Real.log n := by
sorry
end MertensTheorems