Sum of Trigonometric Functions Orthogonal to Each Other
Formula
Define $C_{n}$ and $S_{n}$ as follows.
$$ \begin{align*} C_{n}: &= 1+\cos x + \cos 2x + \cdots +\cos nx \\ S_{n}: &= \sin x +\sin 2x + \cdots + \sin nx \end{align*} $$
Then, the following equation holds.
$$ \begin{align*} C_{n} &= \dfrac{\sin \dfrac{n+1}{2}x}{\sin \dfrac{1}{2}x} \cos \dfrac{n}{2}x \\ S_{n} &= \dfrac{\sin \dfrac{n+1}{2}x}{\sin \dfrac{1}{2}x}\sin \dfrac{n}{2}x \end{align*} $$
Proof
Use the Euler’s formula.
$$ \begin{align*} & C_{n}+ i S_{n} \\ =&\ (1+\cos x + \cos 2x + \cdots + \cos nx) + i(\sin x + \sin 2x + \cdots + \sin nx) \\ =&\ 1+(\cos x + i\sin x) + (\cos 2x + i \sin 2x) + \cdots + (\cos nx + i\sin nx) \\ =&\ e^{i0x}+e^{i1x}+e^{i2x}+\cdots +e^{inx} \\ =&\ \sum \limits_{k=0}^{n} \left( e^{ix} \right)^k \\ =&\ \dfrac{e^{i(n+1)x}-1}{e^{ix}-1} \\ =&\ \dfrac{ e^{i(n+1)x/2} } {e^{ix/2} }\dfrac{ e^{i(n+1)x/2- e^{-i(n+1)x/2} } }{e^{ix/2}-e^{-ix/2}} \\ =&\ e^{inx/2}\dfrac{ \sin \dfrac{n+1}{2}x }{\sin \dfrac{1}{2}x} \\ =&\ \dfrac{ \sin \dfrac{n+1}{2}x }{\sin \dfrac{1}{2}x}(\cos \dfrac{n}{2}x+i\sin\dfrac{n}{2}x) \\ =&\ \dfrac{ \sin \dfrac{n+1}{2}x }{\sin \dfrac{1}{2}x}\cos \dfrac{n}{2}x+i \dfrac{ \sin \dfrac{n+1}{2}x }{\sin \dfrac{1}{2}x}\sin\dfrac{n}{2}x \end{align*} $$
The fifth equality uses the formula for the sum of a geometric series.
■