Theorem: Real.tendsto_sum_pi_div_four
File: Mathlib/Data/Real/Pi/Leibniz.lean

tactic: rw [tendsto_iff_norm_tendsto_zero, ← tendsto_zero_iff_norm_tendsto_zero]
state_before: ⊢ Tendsto (fun k => ∑ i in Finset.range k, (-1) ^ i / (2 * ↑i + 1)) atTop (𝓝 (π / 4))

tactic: let u := fun k : ℕ => (k : NNReal) ^ (-1 / (2 * (k : ℝ) + 1))
state_before: ⊢ Tendsto (fun e => ∑ i in Finset.range e, (-1) ^ i / (2 * ↑i + 1) - π / 4) atTop (𝓝 0)

tactic: refine' squeeze_zero_norm _ H
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
⊢ Tendsto (fun e => ∑ i in Finset.range e, (-1) ^ i / (2 * ↑i + 1) - π / 4) atTop (𝓝 0)

tactic: intro k
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
⊢ ∀ (n : ℕ), ‖∑ i in Finset.range n, (-1) ^ i / (2 * ↑i + 1) - π / 4‖ ≤ 1 - ↑(u n) + ↑(u n ^ (2 * ↑n + 1))

tactic: let U := u k
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
⊢ ‖∑ i in Finset.range k, (-1) ^ i / (2 * ↑i + 1) - π / 4‖ ≤ 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))

tactic: let b (i : ℕ) x := (-(1 : ℝ)) ^ i * x ^ (2 * i + 1) / (2 * i + 1)
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
⊢ ‖∑ i in Finset.range k, (-1) ^ i / (2 * ↑i + 1) - π / 4‖ ≤ 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))

tactic: let f x := arctan x - ∑ i in Finset.range k, b i x
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
⊢ ‖∑ i in Finset.range k, (-1) ^ i / (2 * ↑i + 1) - π / 4‖ ≤ 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))

tactic: suffices f_bound : |f 1 - f 0| ≤ (1 : ℝ) - U + U ^ (2 * (k : ℝ) + 1)
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
⊢ ‖∑ i in Finset.range k, (-1) ^ i / (2 * ↑i + 1) - π / 4‖ ≤ 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))

tactic: have hU2 := NNReal.coe_nonneg U
state_before: case f_bound
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
⊢ abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))

tactic: let f' := fun x : ℝ => (-x ^ 2) ^ k / (1 + x ^ 2)
state_before: case f_bound
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
⊢ abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))

tactic: have hderiv1 : ∀ x ∈ Icc (U : ℝ) 1, HasDerivWithinAt f (f' x) (Icc (U : ℝ) 1) x := fun x _ =>
  (has_deriv_at_f x).hasDerivWithinAt
state_before: case f_bound
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
⊢ abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))

tactic: have hderiv2 : ∀ x ∈ Icc 0 (U : ℝ), HasDerivWithinAt f (f' x) (Icc 0 (U : ℝ)) x := fun x _ =>
  (has_deriv_at_f x).hasDerivWithinAt
state_before: case f_bound
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
⊢ abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))

tactic: have f'_bound : ∀ x ∈ Icc (-1 : ℝ) 1, |f' x| ≤ |x| ^ (2 * k) := by
  intro x _
  rw [abs_div, IsAbsoluteValue.abv_pow abs (-x ^ 2) k, abs_neg, IsAbsoluteValue.abv_pow abs x 2,
    ← pow_mul]
  refine' div_le_of_nonneg_of_le_mul (abs_nonneg _) (pow_nonneg (abs_nonneg _) _) _
  refine' le_mul_of_one_le_right (pow_nonneg (abs_nonneg _) _) _
  rw_mod_cast [abs_of_nonneg (add_nonneg zero_le_one (sq_nonneg x) : (0 : ℝ) ≤ _)]
  exact (le_add_of_nonneg_right (sq_nonneg x) : (1 : ℝ) ≤ _)
state_before: case f_bound
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
⊢ abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))

tactic: have hbound1 : ∀ x ∈ Ico (U : ℝ) 1, |f' x| ≤ 1 := by
  rintro x ⟨hx_left, hx_right⟩
  have hincr := pow_le_pow_of_le_left (le_trans hU2 hx_left) (le_of_lt hx_right) (2 * k)
  rw [one_pow (2 * k), ← abs_of_nonneg (le_trans hU2 hx_left)] at hincr
  rw [← abs_of_nonneg (le_trans hU2 hx_left)] at hx_right
  linarith [f'_bound x (mem_Icc.mpr (abs_le.mp (le_of_lt hx_right)))]
state_before: case f_bound
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
⊢ abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))

tactic: have hbound2 : ∀ x ∈ Ico 0 (U : ℝ), |f' x| ≤ U ^ (2 * k) := by
  rintro x ⟨hx_left, hx_right⟩
  have hincr := pow_le_pow_of_le_left hx_left (le_of_lt hx_right) (2 * k)
  rw [← abs_of_nonneg hx_left] at hincr hx_right
  rw [← abs_of_nonneg hU2] at hU1 hx_right
  exact (f'_bound x (mem_Icc.mpr (abs_le.mp (le_trans (le_of_lt hx_right) hU1)))).trans hincr
state_before: case f_bound
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
⊢ abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))

tactic: have mvt1 := norm_image_sub_le_of_norm_deriv_le_segment' hderiv1 hbound1 _ (right_mem_Icc.mpr hU1)
state_before: case f_bound
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
hbound2 : ∀ (x : ℝ), x ∈ Ico 0 ↑U → abs (f' x) ≤ ↑(U ^ (2 * k))
⊢ abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))

tactic: have mvt2 := norm_image_sub_le_of_norm_deriv_le_segment' hderiv2 hbound2 _ (right_mem_Icc.mpr hU2)
state_before: case f_bound
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
hbound2 : ∀ (x : ℝ), x ∈ Ico 0 ↑U → abs (f' x) ≤ ↑(U ^ (2 * k))
mvt1 : ‖f 1 - f ↑U‖ ≤ 1 * (1 - ↑U)
⊢ abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))

tactic: calc
  |f 1 - f 0| = |f 1 - f U + (f U - f 0)| := by simp
  _ ≤ 1 * (1 - U) + U ^ (2 * k) * (U - 0) :=
    (le_trans (abs_add (f 1 - f U) (f U - f 0)) (add_le_add mvt1 mvt2))
  _ = 1 - U + (U : ℝ) ^ (2 * k) * U := by simp
  _ = 1 - u k + u k ^ (2 * (k : ℝ) + 1) := by rw [← pow_succ' (U : ℝ) (2 * k)]; norm_cast
state_before: case f_bound
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
hbound2 : ∀ (x : ℝ), x ∈ Ico 0 ↑U → abs (f' x) ≤ ↑(U ^ (2 * k))
mvt1 : ‖f 1 - f ↑U‖ ≤ 1 * (1 - ↑U)
mvt2 : ‖f ↑U - f 0‖ ≤ ↑(U ^ (2 * k)) * (↑U - 0)
⊢ abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))

tactic: convert (((tendsto_rpow_div_mul_add (-1) 2 1 two_ne_zero.symm).neg.const_add 1).add
    tendsto_inv_atTop_zero).comp tendsto_nat_cast_atTop_atTop using 1
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
⊢ Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)

tactic: ext k
state_before: case h.e'_3
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
⊢ (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) = (fun x => 1 + -x ^ (-1 / (2 * x + 1)) + x⁻¹) ∘ Nat.cast

tactic: simp only [NNReal.coe_nat_cast, Function.comp_apply, NNReal.coe_rpow]
state_before: case h.e'_3.h
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
k : ℕ
⊢ 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1)) = ((fun x => 1 + -x ^ (-1 / (2 * x + 1)) + x⁻¹) ∘ Nat.cast) k

tactic: rw [← rpow_mul (Nat.cast_nonneg k) (-1 / (2 * (k : ℝ) + 1)) (2 * (k : ℝ) + 1),
  @div_mul_cancel _ _ (2 * (k : ℝ) + 1) _
    (by norm_cast; simp only [Nat.succ_ne_zero, not_false_iff]),
  rpow_neg_one k, sub_eq_add_neg]
state_before: case h.e'_3.h
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
k : ℕ
⊢ 1 - ↑k ^ (-1 / (2 * ↑k + 1)) + (↑k ^ (-1 / (2 * ↑k + 1))) ^ (2 * ↑k + 1) = 1 + -↑k ^ (-1 / (2 * ↑k + 1)) + (↑k)⁻¹

tactic: norm_cast
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
k : ℕ
⊢ 2 * ↑k + 1 ≠ 0

tactic: simp only [Nat.succ_ne_zero, not_false_iff]
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
k : ℕ
⊢ ¬2 * k + 1 = 0

tactic: simp only [add_zero, add_right_neg]
state_before: case h.e'_5
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
⊢ 𝓝 0 = 𝓝 (1 + -1 + 0)

tactic: rw [← norm_neg]
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
f_bound : abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))
⊢ ‖∑ i in Finset.range k, (-1) ^ i / (2 * ↑i + 1) - π / 4‖ ≤ 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))

tactic: convert f_bound using 1
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
f_bound : abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))
⊢ ‖-(∑ i in Finset.range k, (-1) ^ i / (2 * ↑i + 1) - π / 4)‖ ≤ 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))

tactic: simp
state_before: case h.e'_3
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
f_bound : abs (f 1 - f 0) ≤ 1 - ↑U + ↑(U ^ (2 * ↑k + 1))
⊢ ‖-(∑ i in Finset.range k, (-1) ^ i / (2 * ↑i + 1) - π / 4)‖ = abs (f 1 - f 0)

tactic: by_cases hk : k = 0
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
⊢ ↑U ≤ 1

tactic: simp [hk]
state_before: case pos
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hk : k = 0
⊢ ↑U ≤ 1

tactic: exact rpow_le_one_of_one_le_of_nonpos
  (by norm_cast; exact Nat.succ_le_iff.mpr (Nat.pos_of_ne_zero hk)) (le_of_lt
    (@div_neg_of_neg_of_pos _ _ (-(1 : ℝ)) (2 * k + 1) (neg_neg_iff_pos.mpr zero_lt_one)
      (by norm_cast; exact Nat.succ_pos')))
state_before: case neg
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hk : ¬k = 0
⊢ ↑U ≤ 1

tactic: norm_cast
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hk : ¬k = 0
⊢ 1 ≤ ↑↑k

tactic: exact Nat.succ_le_iff.mpr (Nat.pos_of_ne_zero hk)
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hk : ¬k = 0
⊢ 1 ≤ k

tactic: norm_cast
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hk : ¬k = 0
⊢ 0 < 2 * ↑k + 1

tactic: exact Nat.succ_pos'
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hk : ¬k = 0
⊢ 0 < 2 * k + 1

tactic: intro x
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
⊢ ∀ (x : ℝ), HasDerivAt f (f' x) x

tactic: convert (hasDerivAt_arctan x).sub (HasDerivAt.sum has_deriv_at_b) using 1
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
has_deriv_at_b : ∀ (i : ℕ), i ∈ Finset.range k → HasDerivAt (b i) ((-x ^ 2) ^ i) x
⊢ HasDerivAt f (f' x) x

tactic: have g_sum :=
  @geom_sum_eq _ _ (-x ^ 2) ((neg_nonpos.mpr (sq_nonneg x)).trans_lt zero_lt_one).ne k
state_before: case h.e'_7
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
has_deriv_at_b : ∀ (i : ℕ), i ∈ Finset.range k → HasDerivAt (b i) ((-x ^ 2) ^ i) x
⊢ f' x = ↑1 / (↑1 + x ^ 2) - ∑ i in Finset.range k, (-x ^ 2) ^ i

tactic: simp only at g_sum ⊢
state_before: case h.e'_7
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
has_deriv_at_b : ∀ (i : ℕ), i ∈ Finset.range k → HasDerivAt (b i) ((-x ^ 2) ^ i) x
g_sum : ∑ i in Finset.range k, (-x ^ 2) ^ i = ((-x ^ 2) ^ k - 1) / (-x ^ 2 - 1)
⊢ f' x = ↑1 / (↑1 + x ^ 2) - ∑ i in Finset.range k, (-x ^ 2) ^ i

tactic: rw [g_sum, ← neg_add' (x ^ 2) 1, add_comm (x ^ 2) 1, sub_eq_add_neg, neg_div', neg_div_neg_eq]
state_before: case h.e'_7
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
has_deriv_at_b : ∀ (i : ℕ), i ∈ Finset.range k → HasDerivAt (b i) ((-x ^ 2) ^ i) x
g_sum : ∑ i in Finset.range k, (-x ^ 2) ^ i = ((-x ^ 2) ^ k - 1) / (-x ^ 2 - 1)
⊢ (-x ^ 2) ^ k / (↑1 + x ^ 2) = ↑1 / (↑1 + x ^ 2) - ∑ i in Finset.range k, (-x ^ 2) ^ i

tactic: ring
state_before: case h.e'_7
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
has_deriv_at_b : ∀ (i : ℕ), i ∈ Finset.range k → HasDerivAt (b i) ((-x ^ 2) ^ i) x
g_sum : ∑ i in Finset.range k, (-x ^ 2) ^ i = ((-x ^ 2) ^ k - 1) / (-x ^ 2 - 1)
⊢ (-x ^ 2) ^ k / (↑1 + x ^ 2) = ↑1 / (↑1 + x ^ 2) + ((-x ^ 2) ^ k - 1) / (1 + x ^ 2)

tactic: intro i _
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
⊢ ∀ (i : ℕ), i ∈ Finset.range k → HasDerivAt (b i) ((-x ^ 2) ^ i) x

tactic: convert HasDerivAt.const_mul ((-1 : ℝ) ^ i / (2 * i + 1))
    (HasDerivAt.pow (2 * i + 1) (hasDerivAt_id x)) using 1
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
i : ℕ
a✝ : i ∈ Finset.range k
⊢ HasDerivAt (b i) ((-x ^ 2) ^ i) x

tactic: ext y
state_before: case h.e'_6
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
i : ℕ
a✝ : i ∈ Finset.range k
⊢ b i = fun y => (-1) ^ i / (2 * ↑i + 1) * id y ^ (2 * i + 1)

tactic: simp only [id.def]
state_before: case h.e'_6.h
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
i : ℕ
a✝ : i ∈ Finset.range k
y : ℝ
⊢ b i y = (-1) ^ i / (2 * ↑i + 1) * id y ^ (2 * i + 1)

tactic: ring
state_before: case h.e'_6.h
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
i : ℕ
a✝ : i ∈ Finset.range k
y : ℝ
⊢ (-1) ^ i * y ^ (2 * i + 1) / (2 * ↑i + 1) = (-1) ^ i / (2 * ↑i + 1) * y ^ (2 * i + 1)

tactic: simp
state_before: case h.e'_7
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
i : ℕ
a✝ : i ∈ Finset.range k
⊢ (-x ^ 2) ^ i = (-1) ^ i / (2 * ↑i + 1) * (↑(2 * i + 1) * id x ^ (2 * i + 1 - 1) * 1)

tactic: rw [← mul_assoc, @div_mul_cancel _ _ (2 * (i : ℝ) + 1) _ (by norm_cast; linarith),
  pow_mul x 2 i, ← mul_pow (-1 : ℝ) (x ^ 2) i]
state_before: case h.e'_7
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
i : ℕ
a✝ : i ∈ Finset.range k
⊢ (-x ^ 2) ^ i = (-1) ^ i / (2 * ↑i + 1) * ((2 * ↑i + 1) * x ^ (2 * i))

tactic: ring_nf
state_before: case h.e'_7
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
i : ℕ
a✝ : i ∈ Finset.range k
⊢ (-x ^ 2) ^ i = (-1 * x ^ 2) ^ i

tactic: norm_cast
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
i : ℕ
a✝ : i ∈ Finset.range k
⊢ 2 * ↑i + 1 ≠ 0

tactic: linarith
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
x : ℝ
i : ℕ
a✝ : i ∈ Finset.range k
⊢ ¬2 * i + 1 = 0

tactic: intro x _
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
⊢ ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)

tactic: rw [abs_div, IsAbsoluteValue.abv_pow abs (-x ^ 2) k, abs_neg, IsAbsoluteValue.abv_pow abs x 2,
  ← pow_mul]
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
x : ℝ
a✝ : x ∈ Icc (-1) 1
⊢ abs (f' x) ≤ abs x ^ (2 * k)

tactic: refine' div_le_of_nonneg_of_le_mul (abs_nonneg _) (pow_nonneg (abs_nonneg _) _) _
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
x : ℝ
a✝ : x ∈ Icc (-1) 1
⊢ abs x ^ (2 * k) / abs (↑1 + x ^ 2) ≤ abs x ^ (2 * k)

tactic: refine' le_mul_of_one_le_right (pow_nonneg (abs_nonneg _) _) _
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
x : ℝ
a✝ : x ∈ Icc (-1) 1
⊢ abs x ^ (2 * k) ≤ abs x ^ (2 * k) * abs (↑1 + x ^ 2)

tactic: rw_mod_cast [abs_of_nonneg (add_nonneg zero_le_one (sq_nonneg x) : (0 : ℝ) ≤ _)]
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
x : ℝ
a✝ : x ∈ Icc (-1) 1
⊢ 1 ≤ abs (↑1 + x ^ 2)

tactic: exact (le_add_of_nonneg_right (sq_nonneg x) : (1 : ℝ) ≤ _)
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
x : ℝ
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * k + 1))) atTop (𝓝 0)
hU1 : U ≤ 1
hU2 : 0 ≤ U
a✝ : x ∈ Icc (↑(Int.negSucc 0)) 1
⊢ 1 ≤ 1 + x ^ 2

tactic: rintro x ⟨hx_left, hx_right⟩
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
⊢ ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1

tactic: have hincr := pow_le_pow_of_le_left (le_trans hU2 hx_left) (le_of_lt hx_right) (2 * k)
state_before: case intro
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
x : ℝ
hx_left : ↑U ≤ x
hx_right : x < 1
⊢ abs (f' x) ≤ 1

tactic: rw [one_pow (2 * k), ← abs_of_nonneg (le_trans hU2 hx_left)] at hincr
state_before: case intro
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
x : ℝ
hx_left : ↑U ≤ x
hx_right : x < 1
hincr : x ^ (2 * k) ≤ 1 ^ (2 * k)
⊢ abs (f' x) ≤ 1

tactic: rw [← abs_of_nonneg (le_trans hU2 hx_left)] at hx_right
state_before: case intro
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
x : ℝ
hx_left : ↑U ≤ x
hx_right : x < 1
hincr : abs x ^ (2 * k) ≤ 1
⊢ abs (f' x) ≤ 1

tactic: linarith [f'_bound x (mem_Icc.mpr (abs_le.mp (le_of_lt hx_right)))]
state_before: case intro
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
x : ℝ
hx_left : ↑U ≤ x
hx_right : abs x < 1
hincr : abs x ^ (2 * k) ≤ 1
⊢ abs (f' x) ≤ 1

tactic: rintro x ⟨hx_left, hx_right⟩
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
⊢ ∀ (x : ℝ), x ∈ Ico 0 ↑U → abs (f' x) ≤ ↑(U ^ (2 * k))

tactic: have hincr := pow_le_pow_of_le_left hx_left (le_of_lt hx_right) (2 * k)
state_before: case intro
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
x : ℝ
hx_left : 0 ≤ x
hx_right : x < ↑U
⊢ abs (f' x) ≤ ↑(U ^ (2 * k))

tactic: rw [← abs_of_nonneg hx_left] at hincr hx_right
state_before: case intro
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
x : ℝ
hx_left : 0 ≤ x
hx_right : x < ↑U
hincr : x ^ (2 * k) ≤ ↑U ^ (2 * k)
⊢ abs (f' x) ≤ ↑(U ^ (2 * k))

tactic: rw [← abs_of_nonneg hU2] at hU1 hx_right
state_before: case intro
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
x : ℝ
hx_left : 0 ≤ x
hx_right : abs x < ↑U
hincr : abs x ^ (2 * k) ≤ ↑U ^ (2 * k)
⊢ abs (f' x) ≤ ↑(U ^ (2 * k))

tactic: exact (f'_bound x (mem_Icc.mpr (abs_le.mp (le_trans (le_of_lt hx_right) hU1)))).trans hincr
state_before: case intro
u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : abs ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
x : ℝ
hx_left : 0 ≤ x
hx_right : abs x < abs ↑U
hincr : abs x ^ (2 * k) ≤ ↑U ^ (2 * k)
⊢ abs (f' x) ≤ ↑(U ^ (2 * k))

tactic: simp
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
hbound2 : ∀ (x : ℝ), x ∈ Ico 0 ↑U → abs (f' x) ≤ ↑(U ^ (2 * k))
mvt1 : ‖f 1 - f ↑U‖ ≤ 1 * (1 - ↑U)
mvt2 : ‖f ↑U - f 0‖ ≤ ↑(U ^ (2 * k)) * (↑U - 0)
⊢ abs (f 1 - f 0) = abs (f 1 - f ↑U + (f ↑U - f 0))

tactic: simp
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
hbound2 : ∀ (x : ℝ), x ∈ Ico 0 ↑U → abs (f' x) ≤ ↑(U ^ (2 * k))
mvt1 : ‖f 1 - f ↑U‖ ≤ 1 * (1 - ↑U)
mvt2 : ‖f ↑U - f 0‖ ≤ ↑(U ^ (2 * k)) * (↑U - 0)
⊢ 1 * (1 - ↑U) + ↑(U ^ (2 * k)) * (↑U - 0) = 1 - ↑U + ↑U ^ (2 * k) * ↑U

tactic: rw [← pow_succ' (U : ℝ) (2 * k)]
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
hbound2 : ∀ (x : ℝ), x ∈ Ico 0 ↑U → abs (f' x) ≤ ↑(U ^ (2 * k))
mvt1 : ‖f 1 - f ↑U‖ ≤ 1 * (1 - ↑U)
mvt2 : ‖f ↑U - f 0‖ ≤ ↑(U ^ (2 * k)) * (↑U - 0)
⊢ 1 - ↑U + ↑U ^ (2 * k) * ↑U = 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))

tactic: norm_cast
state_before: u : ℕ → NNReal := fun k => ↑k ^ (-1 / (2 * ↑k + 1))
H : Tendsto (fun k => 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))) atTop (𝓝 0)
k : ℕ
U : NNReal := u k
b : ℕ → ℝ → ℝ := fun i x => (-1) ^ i * x ^ (2 * i + 1) / (2 * ↑i + 1)
f : ℝ → ℝ := fun x => arctan x - ∑ i in Finset.range k, b i x
hU1 : ↑U ≤ 1
hU2 : 0 ≤ ↑U
f' : ℝ → ℝ := fun x => (-x ^ 2) ^ k / (↑1 + x ^ 2)
has_deriv_at_f : ∀ (x : ℝ), HasDerivAt f (f' x) x
hderiv1 : ∀ (x : ℝ), x ∈ Icc (↑U) 1 → HasDerivWithinAt f (f' x) (Icc (↑U) 1) x
hderiv2 : ∀ (x : ℝ), x ∈ Icc 0 ↑U → HasDerivWithinAt f (f' x) (Icc 0 ↑U) x
f'_bound : ∀ (x : ℝ), x ∈ Icc (-1) 1 → abs (f' x) ≤ abs x ^ (2 * k)
hbound1 : ∀ (x : ℝ), x ∈ Ico (↑U) 1 → abs (f' x) ≤ 1
hbound2 : ∀ (x : ℝ), x ∈ Ico 0 ↑U → abs (f' x) ≤ ↑(U ^ (2 * k))
mvt1 : ‖f 1 - f ↑U‖ ≤ 1 * (1 - ↑U)
mvt2 : ‖f ↑U - f 0‖ ≤ ↑(U ^ (2 * k)) * (↑U - 0)
⊢ 1 - ↑U + ↑U ^ (2 * k + 1) = 1 - ↑(u k) + ↑(u k ^ (2 * ↑k + 1))