Theorem: Real.hasSum_log_sub_log_of_abs_lt_1
File: Mathlib/Analysis/SpecialFunctions/Log/Deriv.lean

tactic: set term := fun n : ℕ => -1 * ((-x) ^ (n + 1) / ((n : ℝ) + 1)) + x ^ (n + 1) / (n + 1)
state_before: x : ℝ
h : abs x < 1
⊢ HasSum (fun k => 2 * (1 / (2 * ↑k + 1)) * x ^ (2 * k + 1)) (log (1 + x) - log (1 - x))

tactic: rw [← h_term_eq_goal, (mul_right_injective₀ (two_ne_zero' ℕ)).hasSum_iff]
state_before: x : ℝ
h : abs x < 1
term : ℕ → ℝ := fun n => -1 * ((-x) ^ (n + 1) / (↑n + 1)) + x ^ (n + 1) / (↑n + 1)
h_term_eq_goal : term ∘ (fun x x_1 => x * x_1) 2 = fun k => 2 * (1 / (2 * ↑k + 1)) * x ^ (2 * k + 1)
⊢ HasSum (fun k => 2 * (1 / (2 * ↑k + 1)) * x ^ (2 * k + 1)) (log (1 + x) - log (1 - x))

tactic: ext n
state_before: x : ℝ
h : abs x < 1
term : ℕ → ℝ := fun n => -1 * ((-x) ^ (n + 1) / (↑n + 1)) + x ^ (n + 1) / (↑n + 1)
⊢ term ∘ (fun x x_1 => x * x_1) 2 = fun k => 2 * (1 / (2 * ↑k + 1)) * x ^ (2 * k + 1)

tactic: rw [Odd.neg_pow (⟨n, rfl⟩ : Odd (2 * n + 1)) x]
state_before: case h
x : ℝ
h : abs x < 1
term : ℕ → ℝ := fun n => -1 * ((-x) ^ (n + 1) / (↑n + 1)) + x ^ (n + 1) / (↑n + 1)
n : ℕ
⊢ -1 * ((-x) ^ (2 * n + 1) / (↑(2 * n) + 1)) + x ^ (2 * n + 1) / (↑(2 * n) + 1) =
    2 * (1 / (2 * ↑n + 1)) * x ^ (2 * n + 1)

tactic: push_cast
state_before: case h
x : ℝ
h : abs x < 1
term : ℕ → ℝ := fun n => -1 * ((-x) ^ (n + 1) / (↑n + 1)) + x ^ (n + 1) / (↑n + 1)
n : ℕ
⊢ -1 * (-x ^ (2 * n + 1) / (↑(2 * n) + 1)) + x ^ (2 * n + 1) / (↑(2 * n) + 1) = 2 * (1 / (2 * ↑n + 1)) * x ^ (2 * n + 1)

tactic: ring_nf
state_before: case h
x : ℝ
h : abs x < 1
term : ℕ → ℝ := fun n => -1 * ((-x) ^ (n + 1) / (↑n + 1)) + x ^ (n + 1) / (↑n + 1)
n : ℕ
⊢ -1 * (-x ^ (2 * n + 1) / (2 * ↑n + 1)) + x ^ (2 * n + 1) / (2 * ↑n + 1) = 2 * (1 / (2 * ↑n + 1)) * x ^ (2 * n + 1)

tactic: have h₁ := (hasSum_pow_div_log_of_abs_lt_1 (Eq.trans_lt (abs_neg x) h)).mul_left (-1)
state_before: x : ℝ
h : abs x < 1
term : ℕ → ℝ := fun n => -1 * ((-x) ^ (n + 1) / (↑n + 1)) + x ^ (n + 1) / (↑n + 1)
h_term_eq_goal : term ∘ (fun x x_1 => x * x_1) 2 = fun k => 2 * (1 / (2 * ↑k + 1)) * x ^ (2 * k + 1)
⊢ HasSum term (log (1 + x) - log (1 - x))

tactic: convert h₁.add (hasSum_pow_div_log_of_abs_lt_1 h) using 1
state_before: x : ℝ
h : abs x < 1
term : ℕ → ℝ := fun n => -1 * ((-x) ^ (n + 1) / (↑n + 1)) + x ^ (n + 1) / (↑n + 1)
h_term_eq_goal : term ∘ (fun x x_1 => x * x_1) 2 = fun k => 2 * (1 / (2 * ↑k + 1)) * x ^ (2 * k + 1)
h₁ : HasSum (fun i => -1 * ((-x) ^ (i + 1) / (↑i + 1))) (-1 * -log (1 - -x))
⊢ HasSum term (log (1 + x) - log (1 - x))

tactic: ring_nf
state_before: case h.e'_6
x : ℝ
h : abs x < 1
term : ℕ → ℝ := fun n => -1 * ((-x) ^ (n + 1) / (↑n + 1)) + x ^ (n + 1) / (↑n + 1)
h_term_eq_goal : term ∘ (fun x x_1 => x * x_1) 2 = fun k => 2 * (1 / (2 * ↑k + 1)) * x ^ (2 * k + 1)
h₁ : HasSum (fun i => -1 * ((-x) ^ (i + 1) / (↑i + 1))) (-1 * -log (1 - -x))
⊢ log (1 + x) - log (1 - x) = -1 * -log (1 - -x) + -log (1 - x)

tactic: intro m hm
state_before: x : ℝ
h : abs x < 1
term : ℕ → ℝ := fun n => -1 * ((-x) ^ (n + 1) / (↑n + 1)) + x ^ (n + 1) / (↑n + 1)
h_term_eq_goal : term ∘ (fun x x_1 => x * x_1) 2 = fun k => 2 * (1 / (2 * ↑k + 1)) * x ^ (2 * k + 1)
⊢ ∀ (x : ℕ), ¬x ∈ Set.range ((fun x x_1 => x * x_1) 2) → term x = 0

tactic: rw [range_two_mul, Set.mem_setOf_eq, ← Nat.even_add_one] at hm
state_before: x : ℝ
h : abs x < 1
term : ℕ → ℝ := fun n => -1 * ((-x) ^ (n + 1) / (↑n + 1)) + x ^ (n + 1) / (↑n + 1)
h_term_eq_goal : term ∘ (fun x x_1 => x * x_1) 2 = fun k => 2 * (1 / (2 * ↑k + 1)) * x ^ (2 * k + 1)
m : ℕ
hm : ¬m ∈ Set.range ((fun x x_1 => x * x_1) 2)
⊢ term m = 0

tactic: dsimp
state_before: x : ℝ
h : abs x < 1
term : ℕ → ℝ := fun n => -1 * ((-x) ^ (n + 1) / (↑n + 1)) + x ^ (n + 1) / (↑n + 1)
h_term_eq_goal : term ∘ (fun x x_1 => x * x_1) 2 = fun k => 2 * (1 / (2 * ↑k + 1)) * x ^ (2 * k + 1)
m : ℕ
hm : Even (m + 1)
⊢ term m = 0

tactic: rw [Even.neg_pow hm, neg_one_mul, neg_add_self]
state_before: x : ℝ
h : abs x < 1
term : ℕ → ℝ := fun n => -1 * ((-x) ^ (n + 1) / (↑n + 1)) + x ^ (n + 1) / (↑n + 1)
h_term_eq_goal : term ∘ (fun x x_1 => x * x_1) 2 = fun k => 2 * (1 / (2 * ↑k + 1)) * x ^ (2 * k + 1)
m : ℕ
hm : Even (m + 1)
⊢ -1 * ((-x) ^ (m + 1) / (↑m + 1)) + x ^ (m + 1) / (↑m + 1) = 0