Proving $\sum\limits_{k=0}^{n}\cos(kx)=\frac{1}{2}+\frac{\sin(\frac{2n+1}{2}x)}{2\sin(x/2)}$ I am being asked to prove that $$\sum\limits_{k=0}^{n}\cos(kx)=\frac{1}{2}+\frac{\sin(\frac{2n+1}{2}x)}{2\sin(x/2)}$$
I have some progress made, but I am stuck and could use some help.
What I did:
It holds that
$$\sum\limits_{k=0}^{n}\cos(kx)=\sum\limits_{k=0}^{n}Re(\cos(kx))=\sum\limits_{k=0}^{n}Re(\cos(x)^{k})=Re(\sum\limits_{k=0}^{n}\cos(x)^{k})=Re\left(\cos(0)\cdot\frac{\cos(x)^{n}-1}{\cos(x)-1}\right)=Re\left(\frac{\cos(x)^{n}-1}{\cos(x)-1}\right)
$$
For any $z_{1},z_{2}\in\mathbb{C}$ we have it that if $z_{1}=a+bi,z_{2}=c+di$
then $$\frac{z_{1}}{z_{2}}=\frac{z_{1}\overline{z2}}{|z_{2}|^{2}}=\frac{(a+bi)(c-di)}{|z_{2}|^{2}}=\frac{ac-bd+i(bc-ad)}{|z_{2}|^{2}}$$
hence $$Re\left(\frac{z_{1}}{z_{2}}\right)=\frac{Re(z_{1})Re(z_{2})-Im(z_{1})Im(z_{2})}{|z_{2}|^{2}}$$
Thus, $$Re\left(\frac{\cos(x)^{n}-1}{\cos(x)-1}\right)=\frac{(\cos(nx)-1)(\cos(x)-1)-\sin(nx)\sin(x)}{(\cos(x)-1)^{2}+\sin^{2}(x)}=\frac{\cos(nx)\cos(x)-\cos(nx)-\cos(x)+1-\sin(nx)\sin(x)}{\cos^{2}(x)-2\cos(x)+1+\sin^{2}(x)}=\frac{\cos(nx)\cos(x)-\cos(nx)-\cos(x)+1-\sin(nx)\sin(x)}{-2\cos(x)+2}=\frac{\cos(nx)\cos(x)-\cos(nx)-\cos(x)+1-\sin(nx)\sin(x)}{-2(\cos(x)-1)}=
\frac{=\cos(nx)\cos(x)-\cos(nx)-\cos(x)+1-\sin(nx)\sin(x)}{-2(-2\cdot\sin^{2}(x/2))}=\frac{\cos(nx)\cos(x)-\cos(nx)-\cos(x)+1-\sin(nx)\sin(x)}{4\sin^{2}(x/2)}=\frac{\cos(nx)\cos(x)-\cos(nx)-\cos(x)+1-\sin(nx)\sin(x)}{4\sin^{2}(x/2)}=\frac{\cos(x(n+1))-\cos(nx)-\cos(x)+1}{4\sin^{2}(x/2)}
$$
This is the part where I am stuck, I would appriciate any help or hint on how to continue.
Edit: Given the corrections by André I get:
$$(\cos(nx+x)-1)(\cos(x)-1)+\sin(nx+x)\sin(x)=\cos(nx+x)\cos(x)-\cos(nx)-\cos(x)+1+\sin(nx+x)\sin(x)$$
so $$\cos(nx+x)\cos(x)+\sin(nx+x)\sin(x)=\cos(xn+x-x)-\cos(nx)=0$$
Edit 2: I found anoter mistake in the above, I will try to correct
Edit 3: When multiplying correctly the above it works out :-)

$\require{cancel}$
Start by being inspired by the product-to-sum identity:
$$
2 \cos a \sin b = \sin(a+b) - \sin(a-b) ,
$$
then naturally let $a = kx$, next, in order for the right-hand side terms to be eliminated when multiple equalities are superimposedly added, which eventually making the remaining terms as few as possible, the value of $((a+b)-(a-b))$ should be the smallest integer multiple of $x$, hence let $b=\dfrac{x}{2} ,$ so the equality changes as
$$
2 \cos kx \sin\dfrac{x}{2}
=
\sin\left(k+\dfrac{1}{2}\right)x - \sin\left(k-\dfrac{1}{2}\right)x .
$$
And then, use a table to visualize the cumulative destructive process of the right-hand side terms:
$$\begin{array}{c|cc}
{\small(+)~}\ k+\dfrac{1}{2} & \cancel{\dfrac{3}{2}} & \cancel{\dfrac{5}{2}} & \cancel{\dfrac{7}{2}} & \cdots & \cancel{n-\dfrac{1}{2}} & n+\dfrac{1}{2}\\
\hline
{\small(-)~}\ k-\dfrac{1}{2} & \dfrac{1}{2} & \cancel{\dfrac{3}{2}} & \cancel{\dfrac{5}{2}} & \cdots & \cancel{n-\dfrac{3}{2}} & \cancel{n-\dfrac{1}{2}}
\end{array}
\\
⇓
\\
\sum_{k=1}^n \left[\sin\left(k+\dfrac{1}{2}\right)x - \sin\left(k-\dfrac{1}{2}\right)x\right]
 = \sin\left(n+\dfrac{1}{2}\right)x - \sin\dfrac{x}{2} .
$$
Thus
$$
\sum_{k=1}^n \cos kx
 = \left.\left[\sin\left(n+\dfrac{1}{2}\right)x - \sin\dfrac{x}{2}\right] \middle/
   \left(2 \sin\dfrac{x}{2}\right)\right. .
$$

P.S. Similarly,
$$\sum_{k=1}^n \sin kx
 = \left.\left[\cos\dfrac{x}{2} - \cos\left(n+\dfrac{1}{2}\right)x\right] \middle/
   \left(2 \sin\dfrac{x}{2}\right)\right.$$
can be derived from $2 \sin a \sin b = \cos(a-b) - \cos(a+b)$ through the same steps.
