Skip to content

Commit 88d529b

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

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)