Skip to content

Commit 2151840

Browse files
committed
feat(Analysis): Sum of sines and cosines
1 parent f6d7788 commit 2151840

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

  • Mathlib/Analysis/SpecialFunctions/Trigonometric
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/-
2+
Copyright (c) 2026 Weiyi Wang. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Weiyi Wang
5+
-/
6+
module
7+
8+
public import Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex
9+
10+
/-!
11+
# Sum of sines and cosines
12+
13+
This file collects theorems about `∑ i ∈ Finset.range n, sin (a * i + b)` and
14+
`∑ i ∈ Finset.range n, cos (a * i + b)`.
15+
-/
16+
17+
public section
18+
19+
open scoped Real
20+
21+
namespace Complex
22+
23+
theorem sin_mul_sum_sin (n : ℕ) (a b : ℂ) :
24+
sin (a / 2) * ∑ i ∈ Finset.range n, sin (a * i + b) =
25+
sin (n * a / 2) * sin ((n - 1) * a / 2 + b) := by
26+
apply mul_left_cancel₀ (show (-2 : ℂ) ≠ 0 by simp)
27+
simp_rw [← mul_assoc, Finset.mul_sum]
28+
convert_to ∑ i ∈ Finset.range n,
29+
-2 * sin (((a * ((i + 1 : ℕ) - 1 / 2) + b) + -(a * (i - 1 / 2) + b)) / 2) *
30+
sin (((a * ((i + 1 : ℕ) - 1 / 2) + b) - -(a * (i - 1 / 2) + b)) / 2) =
31+
-2 * sin (n * a / 2) * sin ((n - 1) * a / 2 + b)
32+
· push_cast
33+
ring_nf
34+
simp_rw [← cos_sub_cos, cos_neg]
35+
rw [Finset.sum_range_sub (fun i ↦ cos (a * (i - 1 / 2) + b)) n, cos_sub_cos]
36+
ring_nf
37+
38+
theorem sum_sin (n : ℕ) {a : ℂ} (h : ∀ k : ℤ, a ≠ k * (2 * π)) (b : ℂ) :
39+
∑ i ∈ Finset.range n, sin (a * i + b) =
40+
sin (n * a / 2) * sin ((n - 1) * a / 2 + b) / sin (a / 2) := by
41+
rw [← sin_mul_sum_sin, mul_div_cancel_left₀]
42+
rw [sin_ne_zero_iff]
43+
grind
44+
45+
theorem sin_mul_sum_cos (n : ℕ) (a b : ℂ) :
46+
sin (a / 2) * ∑ i ∈ Finset.range n, cos (a * i + b) =
47+
sin (n * a / 2) * cos ((n - 1) * a / 2 + b) := by
48+
apply mul_left_cancel₀ (show (2 : ℂ) ≠ 0 by simp)
49+
simp_rw [← mul_assoc, Finset.mul_sum]
50+
convert_to ∑ i ∈ Finset.range n,
51+
2 * sin (((a * ((i + 1 : ℕ) - 1 / 2) + b) - (a * (i - 1 / 2) + b)) / 2) *
52+
cos (((a * ((i + 1 : ℕ) - 1 / 2) + b) + (a * (i - 1 / 2) + b)) / 2) =
53+
2 * sin (n * a / 2) * cos ((n - 1) * a / 2 + b)
54+
· push_cast
55+
ring_nf
56+
simp_rw [← sin_sub_sin]
57+
rw [Finset.sum_range_sub (fun i ↦ sin (a * (i - 1 / 2) + b)) n, sin_sub_sin]
58+
ring_nf
59+
60+
theorem sum_cos (n : ℕ) {a : ℂ} (h : ∀ k : ℤ, a ≠ k * (2 * π)) (b : ℂ) :
61+
∑ i ∈ Finset.range n, cos (a * i + b) =
62+
sin (n * a / 2) * cos ((n - 1) * a / 2 + b) / sin (a / 2) := by
63+
rw [← sin_mul_sum_cos, mul_div_cancel_left₀]
64+
rw [sin_ne_zero_iff]
65+
grind
66+
67+
end Complex
68+
69+
namespace Real
70+
71+
theorem sin_mul_sum_sin (n : ℕ) (a b : ℝ) :
72+
sin (a / 2) * ∑ i ∈ Finset.range n, sin (a * i + b) =
73+
sin (n * a / 2) * sin ((n - 1) * a / 2 + b) := by
74+
exact_mod_cast congr($(Complex.sin_mul_sum_sin n a b).re)
75+
76+
theorem sum_sin (n : ℕ) {a : ℝ} (h : ∀ k : ℤ, a ≠ k * (2 * π)) (b : ℝ) :
77+
∑ i ∈ Finset.range n, sin (a * i + b) =
78+
sin (n * a / 2) * sin ((n - 1) * a / 2 + b) / sin (a / 2) := by
79+
have h := Complex.sum_sin n (a := a) (by exact_mod_cast h) b
80+
exact_mod_cast congr($(h).re)
81+
82+
theorem sin_mul_sum_cos (n : ℕ) (a b : ℝ) :
83+
sin (a / 2) * ∑ i ∈ Finset.range n, cos (a * i + b) =
84+
sin (n * a / 2) * cos ((n - 1) * a / 2 + b) := by
85+
exact_mod_cast congr($(Complex.sin_mul_sum_cos n a b).re)
86+
87+
theorem sum_cos (n : ℕ) {a : ℝ} (h : ∀ k : ℤ, a ≠ k * (2 * π)) (b : ℝ) :
88+
∑ i ∈ Finset.range n, cos (a * i + b) =
89+
sin (n * a / 2) * cos ((n - 1) * a / 2 + b) / sin (a / 2) := by
90+
have h := Complex.sum_cos n (a := a) (by exact_mod_cast h) b
91+
exact_mod_cast congr($(h).re)
92+
93+
end Real

0 commit comments

Comments
 (0)