Evaluation of $ \sum_{k=0}^n \cos k\theta $
Use: $$ \sin \frac{\theta}{2} \cdot \cos(k \theta) = \underbrace{\frac{1}{2} \sin\left( \left(k+\frac{1}{2}\right)\theta\right)}_{f_{k+1}} - \underbrace{\frac{1}{2} \sin\left( \left(k-\frac{1}{2}\right)\theta\right)}_{f_{k}} $$ Thus $$ \begin{eqnarray} \sin \frac{\theta}{2} \cdot \sum_{k=1}^n \cos(k \theta) &=& \sum_{k=1}^n \left(f_{k+1} - f_k\right) = f_{n+1}-f_1 \\ &=& \frac{1}{2} \underbrace{\sin\left(\left(n+\frac{1}{2}\right)\theta\right)}_{\sin(\alpha+\beta)}-\frac{1}{2} \underbrace{\sin \frac{\theta}{2}}_{\sin(\alpha-\beta)} = \cos(\alpha) \sin(\beta) \\ &=& \cos\left(\frac{n+1}{2}\theta\right) \sin\left(\frac{n}{2} \theta\right) \end{eqnarray} $$ where $\alpha = \frac{n+1}{2} \theta$ and $\beta = \frac{n}{2} \theta$.
Note that $\cos(n\theta) = \Re({e^{in\theta}})$. Thus, our sum can be thought of as $\Re(\sum_{n = 0}^{N}{e^{in\theta}})$. Now, $$\sum_{n = 0}^N{e^{in\theta}} = \frac{e^{i(N+1)\theta}-1}{e^{i\theta} - 1}.$$ Now $$\frac{e^{i(N+1)\theta}-1}{e^{i\theta} - 1} = \frac{e^{i(N+1)\theta/2}}{e^{i\theta/2}}\frac{e^{i(N+1)\theta/2} - e^{-i(N+1)\theta/2}}{e^{i\theta/2} - e^{-i\theta/2}}.$$ Take the real part of the right hand side of the equality and simplify and you will get the result you want. The tricky part is knowing to break up $\frac{e^{i(N+1)\theta}-1}{e^{i\theta} - 1}$ as we did in the above equation. Let me know if you get stuck or don't understand.