Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit ccf84e0

Browse files
eric-wiesersgouezel
andcommitted
feat(analysis/special_functions/trigonometric/series): express cos/sin as infinite sums (#18352)
I wasn't able to find a nice way to prove this with `has_sum.even_add_odd`, so instead I transported across `nat.div_mod_equiv` such that I could split even and odd terms. If nothing else, this provides a nice example of how to use similar equivs to split by remainders upon division by values other than 2. [Zulip](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/real.2Ecos.20and.20real.2Esin.20as.20infinite.20series/near/325193524) Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
1 parent 916aaa1 commit ccf84e0

4 files changed

Lines changed: 123 additions & 17 deletions

File tree

docs/undergrad.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ Single Variable Complex Analysis:
370370
antiderivative: ''
371371
complex exponential: 'complex.exp'
372372
extension of trigonometric functions to the complex plane: 'complex.sin'
373-
power series expansion of elementary functions: ''
373+
power series expansion of elementary functions: 'complex.has_sum_cos'
374374
Functions on one complex variable:
375375
holomorphic functions: 'differentiable_on'
376376
Cauchy-Riemann conditions: ''

src/analysis/normed_space/exponential.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,4 +623,10 @@ end
623623
lemma exp_ℝ_ℂ_eq_exp_ℂ_ℂ : (exp ℝ : ℂ → ℂ) = exp ℂ :=
624624
exp_eq_exp ℝ ℂ ℂ
625625

626+
/-- A version of `complex.of_real_exp` for `exp` instead of `complex.exp` -/
627+
@[simp, norm_cast]
628+
lemma of_real_exp_ℝ_ℝ (r : ℝ) : ↑(exp ℝ r) = exp ℂ (r : ℂ) :=
629+
(map_exp ℝ (algebra_map ℝ ℂ) (continuous_algebra_map _ _) r).trans
630+
(congr_fun exp_ℝ_ℂ_eq_exp_ℂ_ℂ _)
631+
626632
end scalar_tower

src/analysis/special_functions/exponential.lean

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ has_strict_deriv_at_exp_zero.has_deriv_at
202202

203203
end deriv_R_or_C
204204

205-
section complex
206-
207205
lemma complex.exp_eq_exp_ℂ : complex.exp = exp ℂ :=
208206
begin
209207
refine funext (λ x, _),
@@ -212,18 +210,5 @@ begin
212210
(exp_series_div_summable ℝ x).has_sum.tendsto_sum_nat
213211
end
214212

215-
end complex
216-
217-
section real
218-
219213
lemma real.exp_eq_exp_ℝ : real.exp = exp ℝ :=
220-
begin
221-
refine funext (λ x, _),
222-
rw [real.exp, complex.exp_eq_exp_ℂ, ← exp_ℝ_ℂ_eq_exp_ℂ_ℂ, exp_eq_tsum, exp_eq_tsum_div,
223-
← re_to_complex, ← re_clm_apply, re_clm.map_tsum (exp_series_summable' (x : ℂ))],
224-
refine tsum_congr (λ n, _),
225-
rw [re_clm.map_smul, ← complex.of_real_pow, re_clm_apply, re_to_complex, complex.of_real_re,
226-
smul_eq_mul, div_eq_inv_mul]
227-
end
228-
229-
end real
214+
by { ext x, exact_mod_cast congr_fun complex.exp_eq_exp_ℂ x }
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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

Comments
 (0)