Solution (source code)

= Solution

Use the imaginary part of the finite complex sum:
$$
\sum_{n=0}^N\binom Nn\sin(n\theta+\phi)
=\operatorname{Im}\left[e^{i\phi}\sum_{n=0}^N\binom Nn e^{in\theta}\right]
=\operatorname{Im}\left[e^{i\phi}(1+e^{i\theta})^N\right].
$$
The identity $1+e^{i\theta}=2e^{i\theta/2}\cos(\theta/2)$ then gives
$$
\boxed{\sum_{n=0}^N\binom Nn\sin(n\theta+\phi)
=2^N\cos^N(\theta/2)\sin(N\theta/2+\phi).}
$$
Here $N$ is a nonnegative integer. Keeping the signed cosine raised to the integer power makes the result valid even when $\cos(\theta/2)<0$; inserting an absolute value would lose the sign for odd $N$.