Theorem: Stirling.log_stirlingSeq_diff_le_geo_sum
File: Mathlib/Analysis/SpecialFunctions/Stirling.lean

tactic: have h_nonneg : ↑0 ≤ ((1:ℝ) / (2 * n.succ + 1)) ^ 2 := sq_nonneg _
state_before: n : ℕ
⊢ Real.log (stirlingSeq (succ n)) - Real.log (stirlingSeq (succ (succ n))) ≤
    (1 / (2 * ↑(succ n) + 1)) ^ 2 / (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2)

tactic: have hab : ∀ k : ℕ, (1:ℝ) / (↑2 * k.succ + ↑1) * (((1:ℝ) / (2 * n.succ + 1)) ^ 2) ^ k.succ ≤
    (((1:ℝ) / (2 * n.succ + 1)) ^ 2) ^ k.succ := by
  refine' fun k => mul_le_of_le_one_left (pow_nonneg h_nonneg k.succ) _
  rw [one_div]
  exact inv_le_one (le_add_of_nonneg_left <| by positivity)
state_before: n : ℕ
h_nonneg : 0 ≤ (1 / (2 * ↑(succ n) + 1)) ^ 2
g :
  HasSum (fun k => ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k)
    ((1 / (2 * ↑(succ n) + 1)) ^ 2 / (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2))
⊢ Real.log (stirlingSeq (succ n)) - Real.log (stirlingSeq (succ (succ n))) ≤
    (1 / (2 * ↑(succ n) + 1)) ^ 2 / (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2)

tactic: exact hasSum_le hab (log_stirlingSeq_diff_hasSum n) g
state_before: n : ℕ
h_nonneg : 0 ≤ (1 / (2 * ↑(succ n) + 1)) ^ 2
g :
  HasSum (fun k => ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k)
    ((1 / (2 * ↑(succ n) + 1)) ^ 2 / (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2))
hab :
  ∀ (k : ℕ),
    1 / (2 * ↑(succ k) + 1) * ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k ≤ ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k
⊢ Real.log (stirlingSeq (succ n)) - Real.log (stirlingSeq (succ (succ n))) ≤
    (1 / (2 * ↑(succ n) + 1)) ^ 2 / (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2)

tactic: have := (hasSum_geometric_of_lt_1 h_nonneg ?_).mul_left (((1:ℝ) / (2 * n.succ + 1)) ^ 2)
state_before: n : ℕ
h_nonneg : 0 ≤ (1 / (2 * ↑(succ n) + 1)) ^ 2
⊢ HasSum (fun k => ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k)
    ((1 / (2 * ↑(succ n) + 1)) ^ 2 / (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2))

tactic: rw [one_div, inv_pow]
state_before: case refine_1
n : ℕ
h_nonneg : 0 ≤ (1 / (2 * ↑(succ n) + 1)) ^ 2
⊢ (1 / (2 * ↑(succ n) + 1)) ^ 2 < 1

tactic: exact inv_lt_one (one_lt_pow ((lt_add_iff_pos_left 1).mpr <| by positivity) two_ne_zero)
state_before: case refine_1
n : ℕ
h_nonneg : 0 ≤ (1 / (2 * ↑(succ n) + 1)) ^ 2
⊢ ((2 * ↑(succ n) + 1) ^ 2)⁻¹ < 1

tactic: simp_rw [← _root_.pow_succ] at this
state_before: case refine_2
n : ℕ
h_nonneg : 0 ≤ (1 / (2 * ↑(succ n) + 1)) ^ 2
this :
  HasSum (fun i => (1 / (2 * ↑(succ n) + 1)) ^ 2 * ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ i)
    ((1 / (2 * ↑(succ n) + 1)) ^ 2 * (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2)⁻¹)
⊢ HasSum (fun k => ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k)
    ((1 / (2 * ↑(succ n) + 1)) ^ 2 / (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2))

tactic: exact this
state_before: case refine_2
n : ℕ
h_nonneg : 0 ≤ (1 / (2 * ↑(succ n) + 1)) ^ 2
this :
  HasSum (fun i => ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ (i + 1))
    ((1 / (2 * ↑(succ n) + 1)) ^ 2 * (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2)⁻¹)
⊢ HasSum (fun k => ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k)
    ((1 / (2 * ↑(succ n) + 1)) ^ 2 / (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2))

tactic: positivity
state_before: n : ℕ
h_nonneg : 0 ≤ (1 / (2 * ↑(succ n) + 1)) ^ 2
⊢ 0 < 2 * ↑(succ n)

tactic: refine' fun k => mul_le_of_le_one_left (pow_nonneg h_nonneg k.succ) _
state_before: n : ℕ
h_nonneg : 0 ≤ (1 / (2 * ↑(succ n) + 1)) ^ 2
g :
  HasSum (fun k => ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k)
    ((1 / (2 * ↑(succ n) + 1)) ^ 2 / (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2))
⊢ ∀ (k : ℕ),
    1 / (2 * ↑(succ k) + 1) * ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k ≤ ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k

tactic: rw [one_div]
state_before: n : ℕ
h_nonneg : 0 ≤ (1 / (2 * ↑(succ n) + 1)) ^ 2
g :
  HasSum (fun k => ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k)
    ((1 / (2 * ↑(succ n) + 1)) ^ 2 / (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2))
k : ℕ
⊢ 1 / (2 * ↑(succ k) + 1) ≤ 1

tactic: exact inv_le_one (le_add_of_nonneg_left <| by positivity)
state_before: n : ℕ
h_nonneg : 0 ≤ (1 / (2 * ↑(succ n) + 1)) ^ 2
g :
  HasSum (fun k => ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k)
    ((1 / (2 * ↑(succ n) + 1)) ^ 2 / (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2))
k : ℕ
⊢ (2 * ↑(succ k) + 1)⁻¹ ≤ 1

tactic: positivity
state_before: n : ℕ
h_nonneg : 0 ≤ (1 / (2 * ↑(succ n) + 1)) ^ 2
g :
  HasSum (fun k => ((1 / (2 * ↑(succ n) + 1)) ^ 2) ^ succ k)
    ((1 / (2 * ↑(succ n) + 1)) ^ 2 / (1 - (1 / (2 * ↑(succ n) + 1)) ^ 2))
k : ℕ
⊢ 0 ≤ 2 * ↑(succ k)