Sum of harmonics of the sine/cosine function $ F(x) = \sum_{n=1}^N \sin(nx)$. I am interested to know if the following sum has a closed form expression:

$$ F(x) = \sum_{n=1}^N \sin(nx) .$$

By 'closed form expression', I mean an expression which may be used to evaluate the function using a number of operations that is independent of $N$. Any of the usual well known functions may be used in the closed form expression.
What if we replace the $\sin()$ by $\cos()$?
 A: Hint:
One simple way is obtaining
$$-2\sin x~F(x) = \sum_{n=1}^N -2\sin x\sin nx$$
then simplify it with telescopic property!
A: Since $\sin(x) = \text{Im}(e^{ix})$ we have:
$$f(x) = \sum_{n=1}^N \text{Im}(e^{inx}) = \text{Im}\left(\sum_{n=1}^N e^{inx} \right) = \text{Im}\left(\frac{e^{ix}(e^{Nix} - 1)}{e^{ix} - 1}\right)$$
Now we can simplify this fraction:
$$\frac{e^{ix}(e^{Nix} - 1)}{e^{ix} - 1} = \frac{e^{ix}(e^{Nix} - 1)\cdot (e^{-ix} - 1)}{(e^{ix} - 1)\cdot(e^{-ix} - 1)} = -\frac{(e^{Nix} - 1)(e^{ix} - 1)}{(e^{ix} - 1)(e^{-ix} - 1)}$$
This may not look simpler, but because the denominator is something multiplied by it's conjugate we find that it's real, in fact $2 - 2\cos(x)$, giving:
$$f(x) = -\frac{\text{Im}((e^{Nix} - 1)(e^{ix} - 1))}{(e^{ix} - 1)(e^{-ix} - 1)} = -\frac{\text{Im}((e^{Nix} - 1)(e^{ix} - 1))}{2 - 2\cos(x)}$$
We expand the numerator and find the imaginary part of each separately:
$$\text{Im}((e^{Nix} - 1)(e^{ix} - 1)) =  \text{Im}(e^{Nix + ix} - e^{Nix} - e^{ix} + 1)$$
$$\sin((N+1)x) - \sin(Nx) - \sin(x)$$
Giving final answer:
$$f(x) = \frac{\sin((N+1)x) - \sin(Nx) - \sin(x)}{2\cos(x) - 2}$$
If we replaced $\sin$ by $\cos$ all that would change is replacing $\text{Im}$ with $\text{Re}$, meaning that we can simply replace $\sin$ with $\cos$ in our final answer.
