Documentation

CslibFrontier.Foundations.Data.Nat.Totient

An elementary lower bound for Euler's totient function, and the totient of a square #

Euler's product formula φ n / n = ∏_{p ∣ n} (1 - 1/p) together with the fact that the i-th smallest prime factor of n is at least i + 1 gives φ n / n ≥ 1 / (ω n + 1), where ω n is the number of distinct prime factors; since 2 ^ ω n ≤ n, also φ n / n ≥ 1 / (log₂ n + 1). The bound is much weaker than the optimal order φ n / n ≫ 1 / log log n (Hardy and Wright's Theorem 328, as cited in de Wolf, §5.3), but it already shows that a uniformly random residue modulo n is a unit with inverse-logarithmic probability, as needed in the classical post-processing of Shor's algorithm. The file also records φ(n ^ 2) = n * φ(n).

Main results #

References #

theorem Nat.prod_le_card_add_one_mul_prod_sub_one (s : Finset ℕ) (hs : ∀ p ∈ s, 2 ≤ p) :
∏ p ∈ s, p ≤ (s.card + 1) * ∏ p ∈ s, (p - 1)

If every element of s is at least 2, then ∏ p ∈ s, p ≤ (#s + 1) * ∏ p ∈ s, (p - 1): the i-th smallest element is at least i + 1, so ∏ p ∈ s, (1 - 1/p) ≥ ∏ i < #s, (1 - 1/(i+2)) = 1 / (#s + 1).

An elementary lower bound for Euler's totient function: n ≤ φ n * (ω n + 1), where ω n = #n.primeFactors; equivalently φ n / n ≥ 1 / (ω n + 1).

A number has at most log₂ n distinct prime factors.

theorem Nat.le_totient_mul_log_add_one (n : ℕ) :
n ≤ n.totient * (log 2 n + 1)

n ≤ φ n * (log₂ n + 1), i.e. φ n / n ≥ 1 / (log₂ n + 1) for n ≠ 0.

theorem Nat.totient_sq (n : ℕ) :
(n ^ 2).totient = n * n.totient

The totient of a square: φ (n ^ 2) = n * φ n.