Theorem: Complex.hasSum_cos'
File: Mathlib/Analysis/SpecialFunctions/Trigonometric/Series.lean

tactic: rw [Complex.cos, Complex.exp_eq_exp_ℂ]
state_before: z : ℂ
⊢ HasSum (fun n => (z * I) ^ (2 * n) / ↑(2 * n)!) (cos z)
state_after: z : ℂ
⊢ HasSum (fun n => (z * I) ^ (2 * n) / ↑(2 * n)!) ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)

tactic: have := ((expSeries_div_hasSum_exp ℂ (z * Complex.I)).add
  (expSeries_div_hasSum_exp ℂ (-z * Complex.I))).div_const 2
state_before: z : ℂ
⊢ HasSum (fun n => (z * I) ^ (2 * n) / ↑(2 * n)!) ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
state_after: z : ℂ
this :
  HasSum (fun i => ((z * I) ^ i / ↑i ! + (-z * I) ^ i / ↑i !) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
⊢ HasSum (fun n => (z * I) ^ (2 * n) / ↑(2 * n)!) ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)

tactic: replace := (Nat.divModEquiv 2).symm.hasSum_iff.mpr this
state_before: z : ℂ
this :
  HasSum (fun i => ((z * I) ^ i / ↑i ! + (-z * I) ^ i / ↑i !) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
⊢ HasSum (fun n => (z * I) ^ (2 * n) / ↑(2 * n)!) ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
state_after: z : ℂ
this :
  HasSum ((fun i => ((z * I) ^ i / ↑i ! + (-z * I) ^ i / ↑i !) / 2) ∘ ⇑(Nat.divModEquiv 2).symm)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
⊢ HasSum (fun n => (z * I) ^ (2 * n) / ↑(2 * n)!) ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)

tactic: dsimp [Function.comp_def] at this
state_before: z : ℂ
this :
  HasSum ((fun i => ((z * I) ^ i / ↑i ! + (-z * I) ^ i / ↑i !) / 2) ∘ ⇑(Nat.divModEquiv 2).symm)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
⊢ HasSum (fun n => (z * I) ^ (2 * n) / ↑(2 * n)!) ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
state_after: z : ℂ
this :
  HasSum
    (fun x => ((z * I) ^ (x.1 * 2 + ↑x.2) / ↑(x.1 * 2 + ↑x.2)! + (-z * I) ^ (x.1 * 2 + ↑x.2) / ↑(x.1 * 2 + ↑x.2)!) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
⊢ HasSum (fun n => (z * I) ^ (2 * n) / ↑(2 * n)!) ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)

tactic: simp_rw [← mul_comm 2 _] at this
state_before: z : ℂ
this :
  HasSum
    (fun x => ((z * I) ^ (x.1 * 2 + ↑x.2) / ↑(x.1 * 2 + ↑x.2)! + (-z * I) ^ (x.1 * 2 + ↑x.2) / ↑(x.1 * 2 + ↑x.2)!) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
⊢ HasSum (fun n => (z * I) ^ (2 * n) / ↑(2 * n)!) ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
state_after: z : ℂ
this :
  HasSum
    (fun x => ((z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)! + (-z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)!) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
⊢ HasSum (fun n => (z * I) ^ (2 * n) / ↑(2 * n)!) ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)

tactic: refine this.prod_fiberwise fun k => ?_
state_before: z : ℂ
this :
  HasSum
    (fun x => ((z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)! + (-z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)!) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
⊢ HasSum (fun n => (z * I) ^ (2 * n) / ↑(2 * n)!) ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
state_after: z : ℂ
this :
  HasSum
    (fun x => ((z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)! + (-z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)!) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
k : ℕ
⊢ HasSum
    (fun c =>
      ((z * I) ^ (2 * (k, c).1 + ↑(k, c).2) / ↑(2 * (k, c).1 + ↑(k, c).2)! +
          (-z * I) ^ (2 * (k, c).1 + ↑(k, c).2) / ↑(2 * (k, c).1 + ↑(k, c).2)!) /
        2)
    ((z * I) ^ (2 * k) / ↑(2 * k)!)

tactic: dsimp only
state_before: z : ℂ
this :
  HasSum
    (fun x => ((z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)! + (-z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)!) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
k : ℕ
⊢ HasSum
    (fun c =>
      ((z * I) ^ (2 * (k, c).1 + ↑(k, c).2) / ↑(2 * (k, c).1 + ↑(k, c).2)! +
          (-z * I) ^ (2 * (k, c).1 + ↑(k, c).2) / ↑(2 * (k, c).1 + ↑(k, c).2)!) /
        2)
    ((z * I) ^ (2 * k) / ↑(2 * k)!)
state_after: z : ℂ
this :
  HasSum
    (fun x => ((z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)! + (-z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)!) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
k : ℕ
⊢ HasSum (fun c => ((z * I) ^ (2 * k + ↑c) / ↑(2 * k + ↑c)! + (-z * I) ^ (2 * k + ↑c) / ↑(2 * k + ↑c)!) / 2)
    ((z * I) ^ (2 * k) / ↑(2 * k)!)

tactic: convert hasSum_fintype (_ : Fin 2 → ℂ) using 1
state_before: z : ℂ
this :
  HasSum
    (fun x => ((z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)! + (-z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)!) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
k : ℕ
⊢ HasSum (fun c => ((z * I) ^ (2 * k + ↑c) / ↑(2 * k + ↑c)! + (-z * I) ^ (2 * k + ↑c) / ↑(2 * k + ↑c)!) / 2)
    ((z * I) ^ (2 * k) / ↑(2 * k)!)
state_after: case h.e'_6
z : ℂ
this :
  HasSum
    (fun x => ((z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)! + (-z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)!) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
k : ℕ
⊢ (z * I) ^ (2 * k) / ↑(2 * k)! =
    ∑ b : Fin 2, ((z * I) ^ (2 * k + ↑b) / ↑(2 * k + ↑b)! + (-z * I) ^ (2 * k + ↑b) / ↑(2 * k + ↑b)!) / 2

tactic: rw [Fin.sum_univ_two]
state_before: case h.e'_6
z : ℂ
this :
  HasSum
    (fun x => ((z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)! + (-z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)!) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
k : ℕ
⊢ (z * I) ^ (2 * k) / ↑(2 * k)! =
    ∑ b : Fin 2, ((z * I) ^ (2 * k + ↑b) / ↑(2 * k + ↑b)! + (-z * I) ^ (2 * k + ↑b) / ↑(2 * k + ↑b)!) / 2
state_after: case h.e'_6
z : ℂ
this :
  HasSum
    (fun x => ((z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)! + (-z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)!) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
k : ℕ
⊢ (z * I) ^ (2 * k) / ↑(2 * k)! =
    ((z * I) ^ (2 * k + ↑0) / ↑(2 * k + ↑0)! + (-z * I) ^ (2 * k + ↑0) / ↑(2 * k + ↑0)!) / 2 +
      ((z * I) ^ (2 * k + ↑1) / ↑(2 * k + ↑1)! + (-z * I) ^ (2 * k + ↑1) / ↑(2 * k + ↑1)!) / 2

tactic: simp_rw [Fin.val_zero, Fin.val_one, add_zero, pow_succ, pow_mul, mul_pow, neg_sq, ← two_mul,
  neg_mul, mul_neg, neg_div, add_right_neg, zero_div, add_zero,
  mul_div_cancel_left₀ _ (two_ne_zero : (2 : ℂ) ≠ 0)]
state_before: case h.e'_6
z : ℂ
this :
  HasSum
    (fun x => ((z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)! + (-z * I) ^ (2 * x.1 + ↑x.2) / ↑(2 * x.1 + ↑x.2)!) / 2)
    ((NormedSpace.exp ℂ (z * I) + NormedSpace.exp ℂ (-z * I)) / 2)
k : ℕ
⊢ (z * I) ^ (2 * k) / ↑(2 * k)! =
    ((z * I) ^ (2 * k + ↑0) / ↑(2 * k + ↑0)! + (-z * I) ^ (2 * k + ↑0) / ↑(2 * k + ↑0)!) / 2 +
      ((z * I) ^ (2 * k + ↑1) / ↑(2 * k + ↑1)! + (-z * I) ^ (2 * k + ↑1) / ↑(2 * k + ↑1)!) / 2
state_after: no goals