<s>[INST] Using that $1 + z + z^{2} + ... + z^{n} = \frac{1-z^{n+1}}{1-z}$ and taking the real parts, prove that: $$ 1 + \cos \theta + \cos2\theta + ... + \cos n\theta = \frac12+\frac{\sin[(n + \frac{1}{2})\theta]}{2\sin(\frac{\theta}{2})} $$
for $0 < \theta < 2\pi$.
Alright. What I have done is this, using the De Moivre's Formula:
$$ 1 + \cos \theta + \cos2\theta + ... + \cos n\theta = \operatorname{Re}(1 + (\cos\theta + i\sin\theta) + (\cos2\theta + i\sin2\theta) + ... + (\cos n\theta + i \sin n \theta))$$
That is equivalent to
$$ \operatorname{Re}(1 + e^{i\theta} + e^{2i\theta} + ... e^{ni\theta}) = \operatorname{Re} \biggl(\frac{1 - e^{(n+1)i\theta}}{1 - e^{i\theta}}\biggr)$$
I've reached to this point, but now I don't know what to do. Any hint or idea?
 [/INST] $$ 1 + \cos \theta + \cos2\theta + ... + \cos n\theta = \frac{\sin[(n + \frac{1}{2})\theta]}{2\sin(\frac{\theta}{2})} $$
Using De moivre's theorem you arrived that
$$ \operatorname{Re}(1 + e^{i\theta} + e^{2i\theta} + ... e^{ni\theta}) = \operatorname{Re} \biggl(\frac{1 - e^{(n+1)i\theta}}{1 - e^{i\theta}}\biggr)$$
Now will reverse-engineer the process back to trigonomety using
$$e^{ix} = \cos(x)+i\sin(x)$$
$$\operatorname{Re} \biggl( \frac{ 1 -( \cos{(n+1)\theta}+i\sin{(n+1)\theta} )}{ 1 - ( \cos{\theta}+i\sin{\theta} ) }\biggr)$$
$$\frac{ 1 - \cos{(n+1)\theta}-i\sin{(n+1)\theta}}{ 1 - \cos{\theta}- i\sin{\theta} }$$
We would now multiply the numerator and the denominator by the conjugate of the denominator $1 - \cos{\theta} + i\sin{\theta}$
$$\frac{ 1 - \cos{(n+1)\theta}-i\sin{(n+1)\theta} }{ 1 - \cos{\theta}- i\sin{\theta} }\cdot\frac{1 - \cos{\theta} + i\sin{\theta}}{1 - \cos{\theta} + i\sin{\theta}}$$
$$\frac{ (1 - \cos{(n+1)\theta}-i\sin{(n+1)\theta})\cdot(1 - \cos{\theta} + i\sin{\theta} )}{ (1 - \cos{\theta}- i\sin{\theta})\cdot(1 - \cos{\theta} + i\sin{\theta}) }$$
$$\frac{ (1 - \cos{(n+1)\theta}-i\sin{(n+1)\theta})\cdot(1 - \cos{\theta} + i\sin{\theta} )}{ (1 - \cos{\theta} )^2 - (i\sin{\theta})^2 }$$
Now since the denominator is off imaginary number, it's easy to equate $\mathbb{R}$
$$\frac{ (1 - \cos{(n+1)\theta}-i\sin{(n+1)\theta})\cdot(1 - \cos{\theta} + i\sin{\theta} )}{ (1 - \cos{\theta} )^2 + (\sin{\theta})^2 }$$
$$\frac{ (\sin{\theta}*\sin{(n+1)\theta}+\cos{\theta}*\cos{(n+1)\theta}-\cos{(n+1)\theta}-\cos{\theta}+1) + i\cdot(\cos{\theta}*\sin{(n+1)\theta}-\sin{(n+1)\theta}-\sin{\theta}*\cos{(n+1)\theta}+\sin{\theta}) }{ (1 - \cos{\theta} )^2 + (\sin{\theta})^2 }$$
so when we take away imaginary the expression becomes
$$\frac{ (\sin{\theta}*\sin{(n+1)\theta}+\cos{\theta}*\cos{(n+1)\theta}-\cos{(n+1)\theta}-\cos{\theta}+1) }{ (1 - \cos{\theta} )^2 + (\sin{\theta})^2 }$$
let's simplify further
$$\frac{-1\cos{(n+1)\theta}+\cos{n\theta}-\cos{\theta}+1 }{ 1-2\cos{\theta}+(\cos{\theta} )^2 + (\sin{\theta})^2 }$$
$$\frac{ -1\cos{(n+1)\theta}+\cos{n\theta}-\cos{\theta}+1 }{ 2 -2\cos{\theta} }$$
We still simplify further to reduce this
it turns out that $- H  = \frac{1}{2} + \frac{\sin{(n+\frac{1}{2})\theta} }{2\sin{\frac{\theta}{2}}}$, and there was no mistake in my calculations
$$H = \frac{ -1\cos{(n+1)\theta}+\cos{n\theta}-\cos{\theta}+1 }{ 2 -2\cos{\theta} }$$

Proof of error, remember $$ 1 + \cos \theta + \cos2\theta + ... + \cos n\theta = \frac{\sin[(n + \frac{1}{2})\theta]}{2\sin(\frac{\theta}{2})} $$, say $n=1$
But $$ 1+\cos{\theta} ≠ \frac{\sin[(n + \frac{1}{2})\theta]}{2\sin(\frac{\theta}{2})}$$, for every $\theta$ it doesn't turn out to be equal because it is with a displacement of $\frac{1}{2}$
So that $$ 1 + \cos \theta + \cos2\theta + ... + \cos n\theta = \frac{1}{2} + \frac{\sin[(n + \frac{1}{2})\theta]}{2\sin(\frac{\theta}{2})} $$
Check $\theta$ and $n$ therein

</s>