<s>[INST] 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
 [/INST] 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}}$$
</s>