|
| 1 | +/- |
| 2 | +Copyright (c) 2023 Eric Wieser. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Eric Wieser |
| 5 | +-/ |
| 6 | +import analysis.special_functions.exponential |
| 7 | +/-! |
| 8 | +# Trigonometric functions as sums of infinite series |
| 9 | +
|
| 10 | +In this file we express trigonometric functions in terms of their series expansion. |
| 11 | +
|
| 12 | +## Main results |
| 13 | +
|
| 14 | +* `complex.has_sum_cos`, `complex.tsum_cos`: `complex.cos` as the sum of an infinite series. |
| 15 | +* `real.has_sum_cos`, `real.tsum_cos`: `real.cos` as the sum of an infinite series. |
| 16 | +* `complex.has_sum_sin`, `complex.tsum_sin`: `complex.sin` as the sum of an infinite series. |
| 17 | +* `real.has_sum_sin`, `real.tsum_sin`: `real.sin` as the sum of an infinite series. |
| 18 | +-/ |
| 19 | + |
| 20 | +open_locale nat |
| 21 | + |
| 22 | +/-! ### `cos` and `sin` for `ℝ` and `ℂ` -/ |
| 23 | + |
| 24 | +section sin_cos |
| 25 | + |
| 26 | +lemma complex.has_sum_cos' (z : ℂ) : |
| 27 | + has_sum (λ n : ℕ, (z * complex.I) ^ (2 * n) / ↑(2 * n)!) (complex.cos z) := |
| 28 | +begin |
| 29 | + rw [complex.cos, complex.exp_eq_exp_ℂ], |
| 30 | + have := ((exp_series_div_has_sum_exp ℂ (z * complex.I)).add |
| 31 | + (exp_series_div_has_sum_exp ℂ (-z * complex.I))).div_const 2, |
| 32 | + replace := ((nat.div_mod_equiv 2)).symm.has_sum_iff.mpr this, |
| 33 | + dsimp [function.comp] at this, |
| 34 | + simp_rw [←mul_comm 2 _] at this, |
| 35 | + refine this.prod_fiberwise (λ k, _), |
| 36 | + dsimp only, |
| 37 | + convert has_sum_fintype (_ : fin 2 → ℂ) using 1, |
| 38 | + rw fin.sum_univ_two, |
| 39 | + simp_rw [fin.coe_zero, fin.coe_one, add_zero, pow_succ', pow_mul, |
| 40 | + mul_pow, neg_sq, ←two_mul, neg_mul, mul_neg, neg_div, add_right_neg, zero_div, add_zero, |
| 41 | + mul_div_cancel_left _ (two_ne_zero : (2 : ℂ) ≠ 0)], |
| 42 | +end |
| 43 | + |
| 44 | +lemma complex.has_sum_sin' (z : ℂ) : |
| 45 | + has_sum (λ n : ℕ, (z * complex.I) ^ (2 * n + 1) / ↑(2 * n + 1)! / complex.I) (complex.sin z) := |
| 46 | +begin |
| 47 | + rw [complex.sin, complex.exp_eq_exp_ℂ], |
| 48 | + have := (((exp_series_div_has_sum_exp ℂ (-z * complex.I)).sub |
| 49 | + (exp_series_div_has_sum_exp ℂ (z * complex.I))).mul_right complex.I).div_const 2, |
| 50 | + replace := ((nat.div_mod_equiv 2)).symm.has_sum_iff.mpr this, |
| 51 | + dsimp [function.comp] at this, |
| 52 | + simp_rw [←mul_comm 2 _] at this, |
| 53 | + refine this.prod_fiberwise (λ k, _), |
| 54 | + dsimp only, |
| 55 | + convert has_sum_fintype (_ : fin 2 → ℂ) using 1, |
| 56 | + rw fin.sum_univ_two, |
| 57 | + simp_rw [fin.coe_zero, fin.coe_one, add_zero, pow_succ', pow_mul, |
| 58 | + mul_pow, neg_sq, sub_self, zero_mul, zero_div, zero_add, |
| 59 | + neg_mul, mul_neg, neg_div, ← neg_add', ←two_mul, neg_mul, neg_div, mul_assoc, |
| 60 | + mul_div_cancel_left _ (two_ne_zero : (2 : ℂ) ≠ 0), complex.div_I], |
| 61 | +end |
| 62 | + |
| 63 | +/-- The power series expansion of `complex.cos`. -/ |
| 64 | +lemma complex.has_sum_cos (z : ℂ) : |
| 65 | + has_sum (λ n : ℕ, ((-1) ^ n) * z ^ (2 * n) / ↑(2 * n)!) (complex.cos z) := |
| 66 | +begin |
| 67 | + convert complex.has_sum_cos' z using 1, |
| 68 | + simp_rw [mul_pow, pow_mul, complex.I_sq, mul_comm] |
| 69 | +end |
| 70 | + |
| 71 | +/-- The power series expansion of `complex.sin`. -/ |
| 72 | +lemma complex.has_sum_sin (z : ℂ) : |
| 73 | + has_sum (λ n : ℕ, ((-1) ^ n) * z ^ (2 * n + 1) / ↑(2 * n + 1)!) (complex.sin z) := |
| 74 | +begin |
| 75 | + convert complex.has_sum_sin' z using 1, |
| 76 | + simp_rw [mul_pow, pow_succ', pow_mul, complex.I_sq, ←mul_assoc, |
| 77 | + mul_div_assoc, div_right_comm, div_self complex.I_ne_zero, mul_comm _ ((-1 : ℂ)^_), mul_one_div, |
| 78 | + mul_div_assoc, mul_assoc] |
| 79 | +end |
| 80 | + |
| 81 | +lemma complex.cos_eq_tsum' (z : ℂ) : |
| 82 | + complex.cos z = ∑' n : ℕ, (z * complex.I) ^ (2 * n) / ↑(2 * n)! := |
| 83 | +(complex.has_sum_cos' z).tsum_eq.symm |
| 84 | + |
| 85 | +lemma complex.sin_eq_tsum' (z : ℂ) : |
| 86 | + complex.sin z = ∑' n : ℕ, (z * complex.I) ^ (2 * n + 1) / ↑(2 * n + 1)! / complex.I := |
| 87 | +(complex.has_sum_sin' z).tsum_eq.symm |
| 88 | + |
| 89 | +lemma complex.cos_eq_tsum (z : ℂ) : |
| 90 | + complex.cos z = ∑' n : ℕ, ((-1) ^ n) * z ^ (2 * n) / ↑(2 * n)! := |
| 91 | +(complex.has_sum_cos z).tsum_eq.symm |
| 92 | + |
| 93 | +lemma complex.sin_eq_tsum (z : ℂ) : |
| 94 | + complex.sin z = ∑' n : ℕ, ((-1) ^ n) * z ^ (2 * n + 1) / ↑(2 * n + 1)! := |
| 95 | +(complex.has_sum_sin z).tsum_eq.symm |
| 96 | + |
| 97 | +/-- The power series expansion of `real.cos`. -/ |
| 98 | +lemma real.has_sum_cos (r : ℝ) : |
| 99 | + has_sum (λ n : ℕ, ((-1) ^ n) * r ^ (2 * n) / ↑(2 * n)!) (real.cos r) := |
| 100 | +by exact_mod_cast complex.has_sum_cos r |
| 101 | + |
| 102 | +/-- The power series expansion of `real.sin`. -/ |
| 103 | +lemma real.has_sum_sin (r : ℝ) : |
| 104 | + has_sum (λ n : ℕ, ((-1) ^ n) * r ^ (2 * n + 1) / ↑(2 * n + 1)!) (real.sin r) := |
| 105 | +by exact_mod_cast complex.has_sum_sin r |
| 106 | + |
| 107 | +lemma real.cos_eq_tsum (r : ℝ) : |
| 108 | + real.cos r = ∑' n : ℕ, ((-1) ^ n) * r ^ (2 * n) / ↑(2 * n)! := |
| 109 | +(real.has_sum_cos r).tsum_eq.symm |
| 110 | + |
| 111 | +lemma real.sin_eq_tsum (r : ℝ) : |
| 112 | + real.sin r = ∑' n : ℕ, ((-1) ^ n) * r ^ (2 * n + 1) / ↑(2 * n + 1)! := |
| 113 | +(real.has_sum_sin r).tsum_eq.symm |
| 114 | + |
| 115 | +end sin_cos |
0 commit comments