Lagrange's Trigonometric Identity Lagrange's Trig identity is
$$
1+\cos\theta+\cos 2\theta +\cdots + \cos n \theta=\frac{1}{2}+\frac{\sin\frac{(2n+1)\theta}{2}}{2\sin \frac{\theta}{2}},\quad (0<\theta <2\pi).
$$
How can we prove this identity using series method and complex variables?  I tried to use 
$$
\sum_{n=0}^\infty z^n=\frac{1}{1-z}\quad |z|<1
$$
and writing left hand side as
$$
\sum_{n=0}^\infty (\cos \theta)^n=\frac{1}{2}+\frac{\sin\frac{(2n+1)\theta}{2}}{2\sin \frac{\theta}{2}}.
$$
Re-arranging this I get
$$
\sum_{n=0}^\infty (\cos \theta)^n-\frac{1}{2}=\frac{1}{2}+
\sum_{n=1}^\infty (\cos \theta)^n=\frac{\sin\frac{(2n+1)\theta}{2}}{2\sin \frac{\theta}{2}}.
$$
Now if I deal with the right hand side 
$$
2\sin \frac{\theta}{2}=2\Im (e^{i\theta/2} ),\quad \sin\frac{(2n+1)\theta}{2}=\Im \big(e^{i(2n+1)\theta/2}\big).
$$
This is where I am stuck now. Thank you for reading
 A: $$
\begin{align}
\sum_{k=0}^n\cos(k\theta)
&=\frac12\sum_{k=0}^n\left(\color{#C00000}{e^{ik\theta}}+\color{#C000C0}{e^{-ik\theta}}\right)\tag{1}\\
&=\frac12\left(\color{#C00000}{\frac{e^{i(n+1)\theta}-1}{e^{i\theta}-1}}+\color{#C000C0}{\frac{e^{-i(n+1)\theta}-1}{e^{-i\theta}-1}}\right)\tag{2}\\
&=\frac12\left(\frac{\color{#00A000}{e^{i(n+1/2)\theta}-e^{-i\theta/2}}}{e^{i\theta/2}-e^{-i\theta/2}}
+\frac{\color{#0000FF}{e^{i\theta/2}-e^{-i(n+1/2)\theta}}}{e^{i\theta/2}-e^{-i\theta/2}}\right)\tag{3}\\
&=\frac12\left(\frac{\color{#00A000}{e^{i(n+1/2)\theta}}\color{#0000FF}{-e^{-i(n+1/2)\theta}}}{e^{i\theta/2}-e^{-i\theta/2}}
+\frac{\color{#0000FF}{e^{i\theta/2}}\color{#00A000}{-e^{-i\theta/2}}}{e^{i\theta/2}-e^{-i\theta/2}}\right)\tag{4}\\
&=\frac12\left(\frac{\sin((2n+1)\theta/2)}{\sin(\theta/2)}+1\right)\tag{5}
\end{align}
$$
Explanation:
$(1)$: rewrite cosine: $\cos(x)=\dfrac{e^{ix}+e^{-ix}}{2}$
$(2)$: sum of geometric series: $\sum\limits_{k=0}^nr^k=\dfrac{r^{n+1}-1}{r-1}$
$(3)$: multiply the left fraction by $\dfrac{e^{-i\theta/2}}{e^{-i\theta/2}}$ and the right fraction by $\dfrac{-e^{i\theta/2}}{-e^{i\theta/2}}$
$(4)$: shuffle terms $\vphantom{\dfrac{e^{-i\theta/2}}{e^{-i\theta/2}}}$
$(5)$: rewrite sine: $\sin(x)=\dfrac{e^{ix}-e^{-ix}}{2i}$
A: Hint
$$\sum_{k=0}^n\cos(k\theta)=\Re\left(\sum_{k=0}^n e^{ik\theta}\right)=\Re\left(\frac{1-e^{i(n+1)\theta}}{1-e^{i\theta}}\right)$$
Can you take it from here?
Edit Now we have
$$\frac{1-e^{i(n+1)\theta}}{1-e^{i\theta}}=\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}}=e^{in\theta/2}\frac{\sin((n+1)\theta/2)}{\sin(\theta/2)}$$
so the real part is
$$\cos(n\theta/2)\frac{\sin((n+1)\theta/2)}{\sin(\theta/2)}$$
Finally use the relation (with $p=n\theta/2$ and $q=(n+1)\theta/2$)
$$\cos p\sin q=\frac12(\sin(q+p)+\sin(q-p))$$
to get the desired result.
A: Here's a proof that doesn't involve complex numbers. Multiply the LHS through by $2\sin\!\frac12\!\theta$. Notice that each term of the form $2\cos{k\theta}\sin\!\frac12\!\theta\;(k=0,...,n)$ can be expressed as $\sin{(k+\frac12)}\theta-\sin{(k-\frac12)}\theta$, by a standard trig identity. In this form, the series telescopes, with the first term of each difference cancelling the second (subtracted) term of the next one, leaving just $\sin{\frac12\!\theta}$ at the beginning and $\sin{(n+\frac12)\theta}$ at the end. Now divide by the original multiplier $2\sin\!\frac12\!\theta$, and you are home.
If you want to convert this simple proof to one that involves complex numbers, just express each sine and cosine in complex-exponential form. (It isn't quite as neat to write down as the trigonometric version, however.)
A: If $S = 1+z+z^2+\cdots+z^n$, then $$S-zS=(1+z+z^2+\cdots+z^n)-(z+z^2+z^3+\cdots+z^{n+1})=1-z^{n+1}.$$
Therefore, $S=\frac{1-z^{n+1}}{1-z}$, with $z \not=1$. Equating both expressions of $S$, we have $$1+z+z^2+\cdots+z^n=\frac{1-z^{n+1}}{1-z}$$
Substitute $z=e^{i\theta}$, with $0 < \theta < 2\pi$, into the expression, and we get $$1+e^{i\theta}+e^{2i\theta}+\cdots+e^{ni\theta}=\frac{1-e^{(n+1)i\theta}}{1-e^{i\theta}}$$
The real component of the left side is $1+\cos\theta+\cos 2\theta + \cdots + \cos n\theta$. For the right side, the real component is (skipping a few steps on this one, but it is) $$\frac{1}{2}+\frac{\sin \frac{(2n+1)\theta}{2}}{2 \sin \frac{\theta}{2}}$$
If we equate the real components from both sides, we get $$1+\cos\theta+\cos 2\theta + \cdots + \cos n\theta=\frac{1}{2}+\frac{\sin \frac{(2n+1)\theta}{2}}{2 \sin \frac{\theta}{2}}$$
