-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: explicit logarithmic bounds on the harmonic numbers (#9984)
Prove $\log(n+1) \le H_n \le 1 + \log(n)$ for all natural numbers $n$. There is an existing proof that $H_n$ is not an integer which uses p-adics. Since the new result uses some heavy machinery that is disjoint from the existing proof, the file is split into three parts to keep the dependencies lighter. See [zulip](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/basic.20log.20bounds.20on.20harmonic.20sums) Co-authored-by: Arend Mellendijk <FLDutchmann@users.noreply.github.com>
- Loading branch information
1 parent
0bc6ec2
commit 13f623e
Showing
5 changed files
with
162 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/- | ||
Copyright (c) 2024 Arend Mellendijk. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Arend Mellendijk | ||
-/ | ||
|
||
import Mathlib.Analysis.SpecialFunctions.Integrals | ||
import Mathlib.Analysis.SumIntegralComparisons | ||
import Mathlib.NumberTheory.Harmonic.Defs | ||
|
||
/-! | ||
This file proves $\log(n+1) \le H_n \le 1 + \log(n)$ for all natural numbers $n$. | ||
-/ | ||
|
||
open BigOperators | ||
|
||
theorem log_add_one_le_harmonic (n : ℕ) : | ||
Real.log ↑(n+1) ≤ harmonic n := by | ||
calc _ = ∫ x in (1:ℕ)..↑(n+1), x⁻¹ := ?_ | ||
_ ≤ ∑ d in Finset.Icc 1 n, (d:ℝ)⁻¹ := ?_ | ||
_ = harmonic n := ?_ | ||
· rw [Nat.cast_one, integral_inv (by simp [(show ¬ (1 : ℝ) ≤ 0 by norm_num)]), div_one] | ||
· exact (inv_antitoneOn_Icc_right <| by norm_num).integral_le_sum_Ico (Nat.le_add_left 1 n) | ||
· simp only [harmonic_eq_sum_Icc, Rat.cast_sum, Rat.cast_inv, Rat.cast_coe_nat] | ||
|
||
theorem harmonic_le_one_add_log (n : ℕ) : | ||
harmonic n ≤ 1 + Real.log n := by | ||
by_cases hn0 : n = 0 | ||
· simp [hn0] | ||
have hn : 1 ≤ n := Nat.one_le_iff_ne_zero.mpr hn0 | ||
simp_rw [harmonic_eq_sum_Icc, Rat.cast_sum, Rat.cast_inv, Rat.cast_coe_nat] | ||
rw [← Finset.sum_erase_add (Finset.Icc 1 n) _ (Finset.left_mem_Icc.mpr hn), add_comm, | ||
Nat.cast_one, inv_one] | ||
refine add_le_add_left ?_ 1 | ||
simp only [Nat.lt_one_iff, Finset.mem_Icc, Finset.Icc_erase_left] | ||
calc ∑ d : ℕ in .Ico 2 (n + 1), (d : ℝ)⁻¹ | ||
_ = ∑ d in .Ico 2 (n + 1), (↑(d + 1) - 1)⁻¹ := ?_ | ||
_ ≤ ∫ x in (2).. ↑(n + 1), (x - 1)⁻¹ := ?_ | ||
_ = ∫ x in (1)..n, x⁻¹ := ?_ | ||
_ = Real.log ↑n := ?_ | ||
· simp_rw [Nat.cast_add, Nat.cast_one, add_sub_cancel] | ||
· exact @AntitoneOn.sum_le_integral_Ico 2 (n + 1) (fun x : ℝ ↦ (x - 1)⁻¹) (by linarith [hn]) <| | ||
sub_inv_antitoneOn_Icc_right (by norm_num) | ||
· convert intervalIntegral.integral_comp_sub_right _ 1 | ||
· norm_num | ||
· simp only [Nat.cast_add, Nat.cast_one, add_sub_cancel] | ||
· convert integral_inv _ | ||
· rw [div_one] | ||
· simp only [Nat.one_le_cast, hn, Set.uIcc_of_le, Set.mem_Icc, Nat.cast_nonneg, | ||
and_true, not_le, zero_lt_one] | ||
|
||
theorem log_le_harmonic_floor (y : ℝ) (hy : 0 ≤ y) : | ||
Real.log y ≤ harmonic ⌊y⌋₊ := by | ||
by_cases h0 : y = 0 | ||
· simp [h0] | ||
· calc | ||
_ ≤ Real.log ↑(Nat.floor y + 1) := ?_ | ||
_ ≤ _ := log_add_one_le_harmonic _ | ||
gcongr | ||
apply (Nat.le_ceil y).trans | ||
norm_cast | ||
exact Nat.ceil_le_floor_add_one y | ||
|
||
theorem harmonic_floor_le_one_add_log (y : ℝ) (hy : 1 ≤ y) : | ||
harmonic ⌊y⌋₊ ≤ 1 + Real.log y := by | ||
refine (harmonic_le_one_add_log _).trans ?_ | ||
gcongr | ||
· exact_mod_cast Nat.floor_pos.mpr hy | ||
· exact Nat.floor_le <| zero_le_one.trans hy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/- | ||
Copyright (c) 2023 Koundinya Vajjha. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Koundinya Vajjha, Thomas Browning | ||
-/ | ||
|
||
import Mathlib.Algebra.BigOperators.Order | ||
import Mathlib.Algebra.BigOperators.Intervals | ||
import Mathlib.Tactic.Linarith | ||
import Mathlib.Data.Nat.Interval | ||
|
||
/-! | ||
This file defines the harmonic numbers. | ||
* `Mathilb/NumberTheory/Harmonic/Int.lean` proves that the `n`th harmonic number is not an integer. | ||
* `Mathlib/NumberTheory/Harmonic/Bounds.lean` provides basic log bounds. | ||
-/ | ||
|
||
open BigOperators | ||
|
||
/-- The nth-harmonic number defined as a finset sum of consecutive reciprocals. -/ | ||
def harmonic : ℕ → ℚ := fun n => ∑ i in Finset.range n, (↑(i + 1))⁻¹ | ||
|
||
@[simp] | ||
lemma harmonic_zero : harmonic 0 = 0 := | ||
rfl | ||
|
||
@[simp] | ||
lemma harmonic_succ (n : ℕ) : harmonic (n + 1) = harmonic n + (↑(n + 1))⁻¹ := | ||
Finset.sum_range_succ .. | ||
|
||
lemma harmonic_pos {n : ℕ} (Hn : n ≠ 0) : 0 < harmonic n := | ||
Finset.sum_pos (fun _ _ => inv_pos.mpr (by norm_cast; linarith)) <| | ||
Finset.nonempty_range_iff.mpr Hn | ||
|
||
lemma harmonic_eq_sum_Icc {n : ℕ} : harmonic n = ∑ i in Finset.Icc 1 n, (↑i)⁻¹ := by | ||
rw [harmonic, Finset.range_eq_Ico, Finset.sum_Ico_add' (fun (i : ℕ) ↦ (i : ℚ)⁻¹) 0 n (c := 1), | ||
Nat.Ico_succ_right] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters