On the “funny” identity $\tfrac{1}{\sin(2\pi/7)} + \tfrac{1}{\sin(3\pi/7)} = \tfrac{1}{\sin(\pi/7)}$

This equality in the title is one answer in the MSE post Funny Identities. At first, I thought it had to do with $7$ being a Mersenne prime, but a little experimentation with Mathematica‘s integer relations found,

$$\frac{1}{\sin(2\pi/15)} + \frac{1}{\sin(4\pi/15)} + \frac{1}{\sin(7\pi/15)} = \frac{1}{\sin(\pi/15)}$$

$$\frac{1}{\sin(2\pi/31)} + \frac{1}{\sin(4\pi/31)} + \frac{1}{\sin(8\pi/31)} + \frac{1}{\sin(15\pi/31)} = \frac{1}{\sin(\pi/31)}$$

so the Mersenne number need not be prime. Let $M_n = 2^n-1$. How do we prove that,

$$\frac{1}{\sin(M_{n-1}\pi/M_n)}+\sum_{k=1}^{n-2} \frac{1}{\sin(2^k\pi/M_n)} = \frac{1}{\sin(\pi/M_n)}$$

indeed holds true for all integer $n>2$?

Edit (an hour later):

I just realized that since, for example, $\sin(3\pi/7)=\sin(4\pi/7)$, then the question can be much simplified as,

$$\sum_{k=1}^{n-1} \frac{1}{\sin(2^k\pi/M_n)} \overset{?}{=} \frac{1}{\sin(\pi/M_n)}$$

Solutions Collecting From Web of "On the “funny” identity $\tfrac{1}{\sin(2\pi/7)} + \tfrac{1}{\sin(3\pi/7)} = \tfrac{1}{\sin(\pi/7)}$"

Let $$\displaystyle S=\sum_{k=1}^{n-1}\csc \left(\frac{2^k \pi}{2^n-1} \right)$$
Using Euler’s Formula, we can express this sum in terms of complex numbers.
$$S=\sum_{k=1}^{n-1} \frac{2i}{e^{i 2^k \pi/(2^n-1)}-e^{-i2^k\pi /(2^n-1)}}=2i \sum_{k=1}^{n-1}\frac{e^{i 2^k \pi/(2^n-1)}}{e^{i 2^{k+1}\pi/(2^n-1)}-1}$$
For simplicity, let us assume $x=e^{i\pi/(2^n-1)}$. Then
$$\begin{align*}
S &= 2i\sum_{k=1}^{n-1}\frac{x^{2^k}}{x^{2^{k+1}}-1} \\
&= 2i \sum_{k=1}^{n-1}\frac{(x^{2^k}+1)-1}{(x^{2^k}+1)(x^{2^k}-1)} \\
&= 2i \sum_{k=1}^{n-1}\left( \frac{1}{x^{2^k}-1}-\frac{1}{x^{2^{k+1}}-1}\right)
\end{align*}$$
This is a telescoping sum and it’s value is
$$\begin{align*}
S &= 2i \left( \frac{1}{x^2-1}-\frac{1}{x^{2^n}-1}\right)
\end{align*}$$
Back substituting, gives
$$\begin{align*}
S &= 2i \left( \frac{1}{e^{2i\pi/(2^n-1)}-1}-\frac{1}{e^{i 2^n \pi/(2^n-1)}-1}\right) \\
&= 2i \left( \frac{1}{e^{2i\pi/(2^n-1)}-1}+\frac{1}{e^{i\pi/(2^n-1)}+1}\right)\\
&= 2i \frac{e^{i\pi/(2^n-1)}}{e^{2i\pi/(2^n-1)}-1} \\
&= \csc \left( \frac{\pi}{2^n-1}\right)
\end{align*}$$
as desired.

I would suggest a further simplification of your problem, namely that $ \frac{1}{ \sin (\pi/ M_n) } = – \frac{1}{ \sin ( 2^n \pi / M_n)} $. The identity then becomes

$$ \sum_{i=1}^n \frac{1}{\sin (2^n \pi / M_n )} = 0. $$

We now use

$$ \frac{1}{\sin \theta} = \cot \frac{\theta}{2} – \cot \theta,$$

which you can verify for yourself, to conclude that the result follows from telescoping, since $ \cot \frac{ \pi}{2^n – 1} = \cot \frac{ 2^n \pi } { 2^n – 1}$.

Note: I got the trig identity from Wikipedia trig identity, knowing that I wanted $\csc \theta$ and something that could telescope.