Understanding a step in applying deMoivre's Theorem to $\sum_{k=0}^n \cos(k\theta)$ 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!
 A: At (1), both the numerator and denominator have been multiplied by $-e^{\frac{-i\theta}{2}}$. Going to step (2), in the denominator,
$$\begin{align}e^{\frac{i\theta}{2}}-e^{-\frac{i\theta}{2}} =&\cos{\frac{\theta}{2}}+i \sin{\frac{\theta}{2}}-\cos{\frac{\theta}{2}}+i\sin{\frac{\theta}{2}} \\
=& 2i\sin{\frac{\theta}{2}},
\end{align}$$
so, the "$2i$" has been moved to the numerator. The numerator at the step after (2) is
$$\begin{align}&\mathrm{Re}\Big(\frac{1}{2i}\Big(e^{(n+\frac{1}{2})i\theta}-e^{-\frac{i\theta}{2}}\Big)\Big) \\
 = &\mathrm{Re}\Big(\frac{1}{2i}\Big(\cos\Big(\Big(n+\tfrac{1}{2}\Big)\theta\Big)+i\sin\Big(\Big(n+\tfrac{1}{2}\Big)\theta\Big)-\cos\Big(-\frac{\theta}{2}\Big)-i\sin\Big(-\frac{\theta}{2}\Big)\Big)\Big) \\
 = &\mathrm{Re}\Big(\frac{1}{2i}\cos\Big(\Big(n+\tfrac{1}{2}\Big)\theta\Big)+\frac{1}{2}\sin\Big(\Big(n+\tfrac{1}{2}\Big)\theta\Big)-\frac{1}{2i}\cos\Big(-\frac{\theta}{2}\Big)-\frac{1}{2}\sin\Big(-\frac{\theta}{2}\Big)\Big)\Big) \\
 = &\frac{1}{2}\Big(\sin\Big(\Big(n+\tfrac{1}{2}\Big)\theta\Big)+\sin\Big(\frac{\theta}{2}\Big)\Big). \\
\end{align}$$
If we set $\alpha\equiv(n+1/2)\theta$ and $\beta\equiv\theta/2$, the trig identity
$$\sin\alpha + \sin\beta = 2\sin\Big(\frac{\alpha+\beta}{2}\Big)\cos\Big(\frac{\alpha-\beta}{2}\Big)$$
shows the last expression is equal to
$$\sin(\tfrac{1}{2}(n+1)\theta)\cos(\tfrac{1}{2}n\theta),$$
which is the last step.
