= Finite trigonometric sum
Taking the real and imaginary parts of the <finite geometric series> $\sum_{m=1}^N e^{im\theta}$ yields
$$
\sum_{m=1}^N\cos(m\theta)=\frac{\sin(N\theta/2)\cos((N+1)\theta/2)}{\sin(\theta/2)},\qquad\sum_{m=1}^N\sin(m\theta)=\frac{\sin(N\theta/2)\sin((N+1)\theta/2)}{\sin(\theta/2)}.
$$
These formulas apply when $\theta\notin2\pi\mathbb Z$. At multiples of $2\pi$, the sums are directly $N$ and $0$. Complex exponentials turn two real trigonometric summations into one <finite geometric series>.
Back to article page