A sum of sines

In this post I want to prove a lemma which gives a closed-form expression for the summation $\sum_{n=1}^m\sin(nx)$. The method of proof has come up before; it uses basic algebra, the complex exponential expression for sine, and the summation of a geometric series formula.

\begin{align*}
\sum_{n=1}^m\sin(nx) &= \sum_{n=1}^m \frac{e^{inx}-e^{-inx}}{2i} \\
&= \frac{1}{2i}\Bigl(e^{ix}\frac{e^{imx}-1}{e^{ix}-1}-e^{-ix}\frac{e^{-imx}-1}{e^{-ix}-1}\Bigr) \\
&= \frac{e^{ix}(e^{-ix}-1)(e^{imx}-1)-e^{-ix}(e^{ix}-1)(e^{-mx}-1)}{2i(e^{ix}-1)(e^{-ix}-1)} \\
&= \frac{(1-e^{ix})(e^{imx}-1)-(1-e^{-ix})(e^{-mx}-1)}{2i(e^{ix/2}-e^{-ix/2})(e^{-ix/2}-e^{ix/2})} \\
&= \frac{e^{imx}-e^{-imx}-(e^{i(m+1)x}-e^{-i(m+1)x})+e^{ix}-e^{-ix}}{-2i(e^{ix/2}-e^{-ix/2})^2} \\
&= \frac{\sin(mx)-\sin((m+1)x)+\sin x}{4((e^{ix/2}-e^{-ix/2})/2i)^2} \\
&= \frac{\sin(mx)-\sin((m+1)x)+\sin x}{4\sin(x/2)^2}
\end{align*}

Most of this is just grunt-work algebra, although in the fourth lineĀ a factor of $e^{ix/2}$ was creatively moved from one factor in the denominator to the other. This allows us to write the denominator in terms of sine; the denominator would end up being $2-2\cos x$ if this step was skipped.