Proving $\sum\limits_{k=0}^{n}\cos(kx)=\frac{1}{2}+\frac{\sin(\frac{2n+1}{2}x)}{2\sin(x/2)}$

$$\sum_{0\le r\le n}e^{ikx}=\frac{e^{i(n+1)x}-1}{e^{ix}-1}$$

$$=\frac{e^{\frac{i(n+1)x}2}}{e^{\frac{ix}2}}\frac{\left(e^{\frac{i(n+1)x}2}-e^{-\frac{i(n+1)x}2}\right)}{\left( e^{\frac{ix}2}-e^{-\frac{ix}2}\right)}$$

$$=e^{\frac{inx}2}\frac{2i\sin\frac{(n+1)x}2}{2i\sin{\frac{x}2}}$$ as $e^{iy}-e^{-iy}=2i\sin y,$

$$=(\cos\frac{nx}2+i\sin\frac{nx}2)\frac{\sin\frac{(n+1)x}2}{\sin{\frac{x}2}}$$ using Euler's identity.

Its real part is $$\cos\frac{nx}2 \frac{\sin\frac{(n+1)x}2}{\sin{\frac{x}2}}=\frac{2\cos\frac{nx}2\sin\frac{(n+1)x}2}{2\sin{\frac{x}2}}=\frac{\sin\frac{(2n+1)x}2+\sin{\frac{x}2}}{2\sin{\frac{x}2}}$$ using $2\sin A\cos B=\sin(A+B)+\sin(A-B)$


Just multiply both sides by $2\sin(x/2)$ and use Briggs' formula: $$ 2 \sin(x/2)\cos(kx) = \sin((k+1/2)x)-\sin((k-1/2)x)$$ to get a telescoping sum.


Here is the simplest way I've found. \begin{align} 1+2\sum_{k=1}^ncos(\theta) & = \sum_{k=-n}^n e^{ik\theta} \\ & = \frac{e^{i(n+1/2)\theta}-e^{-i(n-1/2)\theta}}{e^{i\theta /2}-e^{-i\theta / 2}} \\ & =\frac{\sin(n+1/2)\theta}{\sin(\theta/2)} \\ \end{align} which can easily be rearranged to get the desired identity. See https://en.wikipedia.org/wiki/List_of_trigonometric_identities#Lagrange's_trigonometric_identities