= Solution
For $\theta\notin2\pi\mathbb Z$, use the <finite geometric series> with ratio $e^{i\theta}$:
$$
\sum_{n=0}^{N-1}e^{in\theta}=\frac{1-e^{iN\theta}}{1-e^{i\theta}}=e^{i(N-1)\theta/2}\frac{\sin(N\theta/2)}{\sin(\theta/2)}.
$$
The second equality follows by factoring $1-e^{it}=-2ie^{it/2}\sin(t/2)$ in numerator and denominator. Taking <real parts> proves the <finite trigonometric sum> identity
$$
\boxed{\sum_{n=0}^{N-1}\cos(n\theta)=\frac{\cos((N-1)\theta/2)\sin(N\theta/2)}{\sin(\theta/2)}.}
$$
When $\theta=2p\pi$, every <cosine> is $1$, so the <sum> is $\boxed{N}$. This also gives the continuous limiting value at the excluded arguments.
Back to article page