Show $1+\cosθ+\cos(2θ)+\cdots+\cos(nθ)=\frac{1}{2}+\frac{\sin[(n+1/2)θ]}{2\sin(θ/2)}$ Show 
$$1+\cosθ+\cos(2θ)+\cdots+\cos(nθ)=\frac12+\frac{\sin\left(\left(n+\frac12\right)θ\right)}{2\sin\left(\frac\theta2\right)}$$
I want to use De Moivre's formula and $$1+z+z^2+\cdots+z^n=\frac{z^{n+1}-1}{z-1}.$$  I set $z=x+yi$, but couldn't get it.

Consider the series $S_{n} = \sum_{k=0}^{n} e^{ik\theta}$.
From the GP relations, you get 
\begin{eqnarray}
S_{n}&=&\frac{1-e^{(n+1)i\theta}}{1-e^{i\theta}}=\frac{(1-e^{(n+1)i\theta})(1-e^{-i\theta})}{2-2\cos\theta}\\
\therefore Re(S_{n})&=&\frac{1-\cos(n+1)\theta-\cos n\theta+\cos\theta}{2-2\cos\theta}
\end{eqnarray}
Simplify. The form you give above could be obtained by trigonometric manipulation
