How to prove Lagrange trigonometric identity [duplicate]
$2\sin\frac{\theta}{2}\cos r\theta=\sin\frac{(2r+1)\theta}{2} - \sin\frac{(2r-1)\theta}{2}$
Putting r=1,2,....,n,
$2\sin\frac{\theta}{2}\cos \theta=\sin\frac{3\theta}{2} - \sin\frac{\theta}{2}$
$2\sin\frac{\theta}{2}\cos 2\theta=\sin\frac{5\theta}{2} - \sin\frac{3\theta}{2}$
...
$2\sin\frac{\theta}{2}\cos n\theta=\sin\frac{(2n+1)\theta}{2} - \sin\frac{(2n-1)\theta}{2}$
Adding we get,
$\sum_{1≤r≤n}2\sin\frac{\theta}{2}\cos r\theta=\sin\frac{(2n+1)\theta}{2} - \sin\frac{\theta}{2}$
Divide both sides by $2\sin\frac{\theta}{2}$, we shall get,
$\sum_{1≤r≤n}\cos r\theta=\frac{\sin\frac{(2n+1)\theta}{2}}{2\sin\frac{\theta}{2}} - \frac{1}{2}$ (Assuming $\sin\frac{\theta}{2}≠0$ or $\theta≠2s\pi$ where s is any integer.)
Or, $1+\sum_{1≤r≤n}\cos r\theta=\frac{\sin\frac{(2n+1)\theta}{2}}{2\sin\frac{\theta}{2}} + \frac{1}{2}$ (adding 1 to both sides )
Just observe that for $\sum_{r}\cos(A+2rB)$ where A,B are constants and r is an integer, we need to multiply with $2\sin B$ as
$2\cos(A+2rB)\sin B=sin(A+(2r+1)B) - sin(A+(2r-1)B)$
Putting different ranges of values of r & adding them, we shall get their sums in the compact form.
In the current problem, $A=0, 2B=\theta, 1≤r≤n$
Also as, $2\sin B\sin(A+2rB) = cos(A+(2r-1)B) - cos(A+(2r+1)B)$
This can be used for $\sum_{r}\sin(A+2rB)$.
Also using DonAntonio's approach, we know $$\sin x=\frac{e^{ix}-e^{-ix}}{2i} \implies e^{ix}-e^{-ix}=2i\sin x$$
So, $$\begin{align} \frac{e^{(n+1)i\theta}-1}{e^{i\theta}-1} &=\frac{e^{(n+1)i\theta/2}\left(e^{(n+1)i\theta/2}-e^{-(n+1)i\theta/2}\right)}{e^{i\theta/2}\left(e^{i\theta/2}-e^{-i\theta/2}\right)} \\[0.5em] &=e^{ni\theta/2}\frac{2i\sin\frac{(n+1)\theta}{2}}{2i\sin\frac{\theta}{2}} \\[0.5em] &=\frac{\sin\frac{(n+1)\theta}{2}}{\sin\frac{\theta}{2}}\left(\cos\frac{n\theta}{2}+i\sin\frac{n\theta}{2}\right)\end{align}$$
Its real part is $$\begin{align} \frac{\sin\frac{(n+1)\theta}{2}}{\sin\frac{\theta}{2}}\cos\frac{n\theta}{2} &=\frac{2\sin\frac{(n+1)\theta}{2}\cos\frac{n\theta}{2}}{2\sin\frac{\theta}{2}} \\ &=\frac{\sin\frac{(2n+1)\theta}{2}+\sin\frac{\theta}{2}}{2\sin\frac{\theta}{2}}\\ &=\frac{\sin\frac{(2n+1)\theta}{2}}{2\sin\frac{\theta}{2}}+\frac{1}{2} \end{align}$$
$$1+e^{i\theta}+e^{2i\theta}+...+e^{ni\theta}=\frac{e^{(n+1)i\theta}-1}{e^{i\theta}-1}$$
Now separate real and imaginary parts:
$$1+\cos\theta+...+\cos n\theta=\operatorname {Re}\left(\frac{\cos(n+1)\theta-1+i\sin(n+1)\theta}{\cos\theta -1+i\sin \theta}\right)=$$ $$=\frac{cos[(n+1)\theta](\cos \theta-1)+\sin\theta\sin[(n+1)\theta]}{(\cos\theta-1)^2+\sin^2\theta}$$ and finally use a little trigonometry. :)
Added: Following A.D.'s comment, let us check what happens with the above in case $\,\theta=2k\pi\,\,,\,k\in\Bbb Z\,$. In this case, we get: $$\sin\left(\frac{2n+1}{2}2k\pi\right)=0\,,\,\sin\frac{2k\pi}{2}=0\Longrightarrow$$ $$\,LHS=1+\cos 2k\pi+...+ 2kn\pi=1+...+1=n+1$$ $$RHS=\frac{1}{2}+\lim_{\theta\to 2k\pi}\frac{\sin\frac{2n+1}{2}\theta}{2\sin\frac{\theta}{2}}\stackrel{L'H}=\frac{1}{2}+\lim_{\theta\to 2k\pi}\frac{\frac{2n+1}{2}\cos\frac{2n+1}{2}\theta}{\cos\frac{\theta}{2}}=\frac{1}{2}+n+\frac{1}{2}=n+1$$
Note that both denominator and numerator above have the same parity no matter what $\,k\,$ is , and because of this the limit is $\,1\,$ in any case.
Here's a variation of @lab's variation of @DonAntonio's solution:
$$\begin{align} \frac{e^{(n+1)i\theta}-1}{e^{i\theta-1}-1} &= \frac{e^{(n+1)i\theta}-1}{e^{i\theta/2} \left(e^{i\theta/2}-e^{-i\theta/2}\right)} \\ &= \frac{e^{(n+1/2)i\theta}-e^{-i\theta/2}}{2i\sin\frac{\theta}{2}} \\ &= \frac{\mathrm{cis}\frac{(2n+1)i\theta}{2}-\mathrm{cis}\frac{-\theta}{2}}{2i\sin\frac{\theta}{2}} \\ &= \frac{-i\;\left(\mathrm{cis}\frac{(2n+1)i\theta}{2}-\mathrm{cis}\frac{-\theta}{2}\right)}{2\sin\frac{\theta}{2}} \\ \end{align} $$ where, of course, "$\mathrm{cis}\,x := \cos x + i \sin x$". The real part is then $$\begin{align} \frac{1}{2\sin\frac{\theta}{2}}\left(-i^2\sin\frac{(2n+1)\theta}{2}+i^2\sin\frac{-\theta}{2}\right) &= \frac{1}{2\sin\frac{\theta}{2}}\left(\sin\frac{(2n+1)\theta}{2}+\sin\frac{\theta}{2}\right) \\ &= \frac{1}{2}\left(\frac{\sin\frac{(2n+1)\theta}{2}}{\sin\frac{\theta}{2}}+1\right) \end{align}$$
In this variation, we avoid appealing to the lesser-known sine-times-cosine prosthaphaeresis identity (although that identity is helpful to know!).