The starting point is the following practical formula:
$
(\cos x + i \sin x)^n = \cos(nx) + i \sin(nx)
$
It is a direct consequence of Euler's identity $e^{ix} = \cos(0) + i \sin(0)$: you obtain De Moivre's formula if you apply Euler's identity to either side of the equation:
$
(e^{ix})^n = e^{inx}
$
Dividing by $\sin^n x$, we also have
$
\frac{\cos(nx)}{\sin^n x} + i \frac{\sin(nx)}{\sin^n x} = \left(\frac{\cos x + i \sin x}{\sin x}\right)^n = (\cot x + i)^n
$
We can rewrite the last expression using the binomial theorem:
$
= \left[\binom{n}{0} \cot^n x - \binom{n}{2} \cot^{n-2} x + \binom{n}{4} \cot^{n-4} x - \ldots\right] + i \left[\binom{n}{1} \cot^{n-1} x - \binom{n}{3} \cot^{n-3} x + \binom{n}{5} \cot^{n-5} x - \ldots\right]
$
Case 1: $n = 2m + 1$ (odd)
Comparing the imaginary parts of the above expression, we find
$
\sin(nx) \sin^n x = \binom{n}{1} \cot^{n-1} x - \binom{n}{3} \cot^{n-3} x + \binom{n}{5} \cot^{n-5} x - \ldots \pm \binom{n}{n} \cot^0 x = \binom{n}{1} \cot^{2m} x - \binom{n}{3} \cot^{2m-2} x + \binom{n}{5} \cot^{2m-4} x - \ldots \pm \binom{n}{2m+1} \cot^0 x
$
$
= \binom{n}{1} (\cot^2 x)^m - \binom{n}{3} (\cot^2 x)^{m-1} + \binom{n}{5} (\cot^2 x)^{m-2} - \ldots \pm \binom{n}{2m+1} \cdot 1
$
$
= P(\cot^2 x)
$
where $\(P(x_i) = \sum_{k=0}^{m} a_k x_i^k\) with \(a_k = \binom{n}{2m+1-2k}$
$\(P(x_i)$ is a polynomial of order $m$ and by the fundamental theorem of algebra has $m$ zeros $x_{i_1}$, $\ldots$, $x_{i_m}$. As we've established that $(P(\cot^2 x)$ = $\frac{\sin(nx)}{\sin^n x}$ it is easy to see that with $(x_k = \frac{k \pi}{n}$ the polynomial becomes zero for the $m$ distinct arguments $(x_i^k = \cot^2(x_k)$
$
P\left(\cot^2 x_k\right) = P\left(\cot^2 \left(\frac{k \pi}{n}\right)\right) = -\frac{\sin(k \pi)}{\sin^n\left(\frac{k \pi}{n}\right)} = 0
$
With this knowledge, we can rewrite the polynomial $P(x_i)$ as:
$
P(x_i) = a_m(x_i - x_{i_1})(x_i - x_{i_2}) \ldots (x_i - x_{i_m}) = a_m x_i^m - a_m (x_{i_1} + x_{i_2} + \ldots + x_{i_m}) x_i^{m-1} + \ldots
$
Comparing this with the previous expression, we can infer that
$
x_{i_1} + x_{i_2} + \ldots + x_{i_m} = \frac{a_{m-1}}{a_m} = \frac{\binom{n}{3}}{\binom{n}{1}} = \frac{n!}{(n-3)!3!} \cdot \frac{n!}{(n-1)!1!} = \frac{(n-1)(n-2)}{6} = \frac{2m(2m-1)}{6} = \frac{2m(2m-1)}{6} = \frac{2m^2 - m}{3}
$
Next, we'll use the identity
$
\cot^2 x = \frac{\cos^2 x}{\sin^2 x} = \frac{1 - \sin^2 x}{\sin^2 x} = \frac{1}{\sin^2 x} - 1
$
So,
$
\cot^2 x_1 + \cot^2 x_2 + \ldots + \cot^2 x_m = \left(\frac{1}{\sin^2 x_1} - 1\right) + \left(\frac{1}{\sin^2 x_2} - 1\right) + \ldots + \left(\frac{1}{\sin^2 x_m} - 1\right) = \frac{2m^2 - m}{3}
$
or equivalently
$
\frac{1}{\sin^2 x_1} + \frac{1}{\sin^2 x_2} + \ldots + \frac{1}{\sin^2 x_m} = \frac{2m^2 + 2m}{3}
$
As a consequence of $\frac{1}{\sin x}$'s symmetries, the sum of the $k = m + 1$, $2m$ terms has the same value as the sum of the $k = 1$, $\ldots$, $m$ terms.
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/XN8Pn.jpg)
We've established that
$
\frac{1}{\sin^2 x_1} + \ldots + \frac{1}{\sin^2 x_{2m}} = \frac{1}{\sin^2 \left(\frac{\pi n}{n}\right)} + \ldots + \frac{1}{\sin^2 \left(\frac{\pi (n - 1)}{n}\right)} = \sum_{k=1}^{n-1} \frac{1}{\sin^2 \left(\frac{\pi k}{n}\right)} = \frac{2(2m^2 + 2m)}{3} = \frac{(2m + 1)(2m + 1) - 1}{3} = \frac{n^2 - 1}{3}.
$
This completes the proof for the case of odd values of $n$
\begin{equation*}
\text{Case 2: } n = 2m (even)
\end{equation*}
Comparing the imaginary parts of (3) and (4), we now find
\begin{align*}
\sin(nx) \sin^n x \cot x &= \binom{n}{1} \cot^{2m} x - \binom{n}{3} \cot^{2m-2} x + \binom{n}{5} \cot^{2m-4} x - \ldots \pm \binom{n}{2m-1} \cot^2 x \\
&= \binom{n}{1} \cot^{2m} x - \binom{n}{3} \cot^{2m-2} x + \binom{n}{5} \cot^{2m-4} x - \ldots \pm \binom{n}{2m-1} \cot^2 x \\
&= \binom{n}{1} (cot^2 x)^m - \binom{n}{3} (cot^2 x)^{m-1} + \binom{n}{5} (cot^2 x)^{m-2} - \ldots \pm \binom{n}{2m-1} \cot^2 x
\end{align*}
\begin{equation}
= P(cot^2 x), \text{ where } P(\overline{xi}) = \sum_{k=1}^{m} a_k \overline{xi}^k \text{ with } a_k = \binom{n}{2m+1-2k}.
\end{equation}
That means, compared to the odd case, we just brought in one extra factor $\cot x$ (which won't be zero for any $x = x_i$ we are interested in) to make all powers of $\cot x$ on the right even powers of $\cot x$. From this point onwards, the proof proceeds in a perfectly analogous way to the odd-$n$-case.