I'm studying de Moivre's theorem's application on the summation of trigonometric series. Here's what I have so far:
\begin{align*} \sum_{k=0}^n \cos(k\theta)&= \text{Re}\sum_{k=0}^n e^{ki\theta} \\[4pt] &=\text{Re}\left(\frac{1-e^{(n+1)i\theta}}{1-e^{i\theta}}\right) \\[4pt] & = \text{Re} \left(\frac{e^{(n+\frac12)i\theta} - e^{\frac{-i\theta}2}}{e^{\frac{i\theta}2}- e^{\frac{-i\theta}2}}\right) \qquad \text{this is where I'm stuck} \tag{1} \\[4pt] & = \frac{\text{Re}\dfrac1{2i}\left(e^{(n+\frac12)}- e^{\frac{-i\theta}2} \right)}{\sin\frac\theta2} \tag{2} \\[4pt] & = \frac{\frac12(\sin(n+\frac12)\theta + \sin\frac\theta2)}{\sin\frac\theta2} \\[9pt] & = \frac{\cos\frac{n\theta}2\sin\frac{(n+1)\theta}2}{\sin\frac\theta2} \end{align*}
At (1), I do not understand where the new expression came from, and starting (2), I need help understanding the numerators. I have looked around a lot on the internet for this and I can't seem to find something helpful. Thanks in advance!