I just wanted to evaluate
$ \sum_{k=0}^n \cos k\theta $
and I know that it should give
$ \cos\left(\frac{n\theta}{2}\right)\frac{\sin\left(\frac{(n+1)\theta}{2}\right)}{\sin(\theta / 2)} $
I tried to start by writing the sum as
$ 1 + \cos\theta + \cos 2\theta + \cdots + \cos n\theta $
and expand each cosine by its series representation. But this soon looked not very helpful so I need some clue about how this partial sum is calculated more efficiently ...