-- Mathlib/Analysis/SpecialFunctions/Complex/LogBounds.lean
/-- The difference of `log (1+z)` and its `(n+1)`st Taylor polynomial can be bounded in
terms of `‖z‖`. -/
lemma norm_log_sub_logTaylor_le (n : ℕ) {z : ℂ} (hz : ‖z‖ < 1) :
    ‖log (1 + z) - logTaylor (n + 1) z‖ ≤ ‖z‖ ^ (n + 1) * (1 - ‖z‖)⁻¹ / (n + 1)

Proof state:
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
hderiv : ∀ t ∈ Set.Icc 0 1, HasDerivAt f (f' (0 + ↑t * z)) (0 + ↑t * z)
⊢ ContinuousOn (fun t => f' (0 + ↑t * z)) (Set.Icc 0 1)

Tactic:
simp only [zero_add, zero_le_one, not_true_eq_false]

Result:
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
hderiv : ∀ t ∈ Set.Icc 0 1, HasDerivAt f (f' (0 + ↑t * z)) (0 + ↑t * z)
⊢ ContinuousOn (fun t => f' (↑t * z)) (Set.Icc 0 1)

Proof state:
case h.e'_2
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
hderiv : ∀ t ∈ Set.Icc 0 1, HasDerivAt f (f' (0 + ↑t * z)) (0 + ↑t * z)
hcont : ContinuousOn (fun t => f' (0 + ↑t * z)) (Set.Icc 0 1)
⊢ f z = f (0 + z) - f 0

Tactic:
simp only [f, zero_add, add_zero, log_one, logTaylor_at_zero, sub_self, sub_zero]

Result:
no goals

Proof state:
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
hderiv : ∀ t ∈ Set.Icc 0 1, HasDerivAt f (f' (0 + ↑t * z)) (0 + ↑t * z)
hcont : ContinuousOn (fun t => f' (0 + ↑t * z)) (Set.Icc 0 1)
⊢ f z = z * ∫ (t : ℝ) in 0 ..1, (-(↑t * z)) ^ n * (1 + ↑t * z)⁻¹

Tactic:
convert (integral_unitInterval_deriv_eq_sub hcont hderiv).symm using 1

Result:
case h.e'_2
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
hderiv : ∀ t ∈ Set.Icc 0 1, HasDerivAt f (f' (0 + ↑t * z)) (0 + ↑t * z)
hcont : ContinuousOn (fun t => f' (0 + ↑t * z)) (Set.Icc 0 1)
⊢ f z = f (0 + z) - f 0

case h.e'_3
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
hderiv : ∀ t ∈ Set.Icc 0 1, HasDerivAt f (f' (0 + ↑t * z)) (0 + ↑t * z)
hcont : ContinuousOn (fun t => f' (0 + ↑t * z)) (Set.Icc 0 1)
⊢ z * ∫ (t : ℝ) in 0 ..1, (-(↑t * z)) ^ n * (1 + ↑t * z)⁻¹ = z • ∫ (t : ℝ) in 0 ..1, f' (0 + t • z)

Proof state:
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
t : ℝ
ht : t ∈ Set.Icc 0 1
⊢ HasDerivAt f (f' (0 + ↑t * z)) (0 + ↑t * z)

Tactic:
rw [zero_add]

Result:
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
t : ℝ
ht : t ∈ Set.Icc 0 1
⊢ HasDerivAt f (f' (↑t * z)) (↑t * z)

Proof state:
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
t : ℝ
ht : t ∈ Set.Icc 0 1
⊢ HasDerivAt f (f' (↑t * z)) (↑t * z)

Tactic:
exact hasDerivAt_log_sub_logTaylor n <|
  StarConvex.add_smul_mem starConvex_one_slitPlane (mem_slitPlane_of_norm_lt_one hz) ht.1 ht.2

Result:
no goals

Proof state:
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
hderiv : ∀ t ∈ Set.Icc 0 1, HasDerivAt f (f' (0 + ↑t * z)) (0 + ↑t * z)
hcont : ContinuousOn (fun t => f' (0 + ↑t * z)) (Set.Icc 0 1)
H : log (1 + z) - logTaylor (n + 1) z = z * ∫ (t : ℝ) in 0 ..1, (-(↑t * z)) ^ n * (1 + ↑t * z)⁻¹
⊢ (1 - ‖z‖)⁻¹ * ((1 ^ (n + 1) - 0 ^ (n + 1)) / (↑n + 1)) = (1 - ‖z‖)⁻¹ / (↑n + 1)

Tactic:
field_simp

Result:
no goals

Proof state:
n : ℕ
z : ℂ
hz : ‖z‖ < 1
⊢ ‖log (1 + z) - logTaylor (n + 1) z‖ ≤ ‖z‖ ^ (n + 1) * (1 - ‖z‖)⁻¹ / (↑n + 1)

Tactic:
have help : IntervalIntegrable (fun t : ℝ ↦ t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1 :=
  IntervalIntegrable.mul_const (Continuous.intervalIntegrable (by fun_prop) 0 1) (1 - ‖z‖)⁻¹

Result:
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
⊢ ‖log (1 + z) - logTaylor (n + 1) z‖ ≤ ‖z‖ ^ (n + 1) * (1 - ‖z‖)⁻¹ / (↑n + 1)

Proof state:
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
hderiv : ∀ t ∈ Set.Icc 0 1, HasDerivAt f (f' (0 + ↑t * z)) (0 + ↑t * z)
⊢ Continuous fun t => (-(↑t * z)) ^ n

Tactic:
fun_prop

Result:
no goals

Proof state:
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
hderiv : ∀ t ∈ Set.Icc 0 1, HasDerivAt f (f' (0 + ↑t * z)) (0 + ↑t * z)
hcont : ContinuousOn (fun t => f' (0 + ↑t * z)) (Set.Icc 0 1)
H : log (1 + z) - logTaylor (n + 1) z = z * ∫ (t : ℝ) in 0 ..1, (-(↑t * z)) ^ n * (1 + ↑t * z)⁻¹
t : ℝ
ht : t ∈ Set.uIcc 0 1
⊢ ‖↑t ^ n * (1 + ↑t * z)⁻¹‖ = t ^ n * ‖(1 + ↑t * z)⁻¹‖

Tactic:
rw [Set.uIcc_of_le zero_le_one, Set.mem_Icc] at ht

Result:
n : ℕ
z : ℂ
hz : ‖z‖ < 1
help : IntervalIntegrable (fun t => t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1
f : ℂ → ℂ := fun z => log (1 + z) - logTaylor (n + 1) z
f' : ℂ → ℂ := fun z => (-z) ^ n * (1 + z)⁻¹
hderiv : ∀ t ∈ Set.Icc 0 1, HasDerivAt f (f' (0 + ↑t * z)) (0 + ↑t * z)
hcont : ContinuousOn (fun t => f' (0 + ↑t * z)) (Set.Icc 0 1)
H : log (1 + z) - logTaylor (n + 1) z = z * ∫ (t : ℝ) in 0 ..1, (-(↑t * z)) ^ n * (1 + ↑t * z)⁻¹
t : ℝ
ht : 0 ≤ t ∧ t ≤ 1
⊢ ‖↑t ^ n * (1 + ↑t * z)⁻¹‖ = t ^ n * ‖(1 + ↑t * z)⁻¹‖