Theorem of the convergence of the series of fourier! During the demonstration of the theorem of the convergence of the series of fourier, my teacher wrote :$$  \frac{1}{2}+ \sum_{k=1}^{n} \cos(ky)=\frac{\sin((n+\frac{1}{2})y)}{2\sin(\frac{y}{2})} $$
he doesn't explain how to get this for the lack of time, I'm curious so I tried alone, without success.
How I can get this equality?

Multiply both sides by $2\sin(\dfrac{y}{2})$ and remark that
$2\sin(\dfrac{y}{2})\cos(ky) = \sin(\dfrac{2k+1}{2}y) - \sin(\dfrac{2k-1}{2}y)$
