Prove $\sum_{k=1}^{n-1} k \cos\frac{3 \pi k}{n} \sin\frac{\pi k}{n}=\frac n4\csc\frac{2\pi}n$ I would like to evaluate the sum
$$\sum_{k=1}^{n-1} k \cos\frac{3 \pi k}{n} \sin\frac{\pi k}{n}
$$
which is said to reduce to the simple close-form $\frac n4\csc\frac{2\pi}n$. I have verified it numerically for a large number of $n$’s. However, I have struggled to prove it by using familiar trigonometric identities. The index term $k$ in front of the sequence is problematic. I am not sure how to get around it. Appreciate any hint or proof.
 A: Noting that
$$
\begin{aligned}
\sum_{k=1}^{n-1} k \sin (k \theta) &=-\sum_{k=1}^{n-1} \frac{d}{d \theta}(\cos (k \theta))=-\frac{d}{d \theta}\left(\sum_{k=1}^{n-1} \cos k \theta\right)
\end{aligned}
$$
Using the identity
$$\sum_{k=1}^{n-1} \cos k \theta= 
\frac{1}{2}\left[-\cos (n \theta)+\cot \left(\frac{\theta}{2}\right) \sin (n \theta)-1\right]$$
Hence $$\sum_{k=1}^{n-1} k \sin (k \theta)= \frac{1}{2}\left[-n \sin (n \theta)-n \cot \left(\frac{\theta}{2}\right) \cos (n\theta)+\frac{1}{2} \csc ^{2}\left(\frac{\theta}{2}\right) \sin (n \theta)\right] \cdots(*) $$
Converting the product to sum yields
$$ \begin{aligned}\sum_{k=1}^{n-1} k \cos\frac{3 \pi k}{n} \sin\frac{\pi k}{n} &= \frac 1 2\sum_{k=1}^{n-1} k \left[\sin \left (\frac {4\pi k}{n}\right) -\sin \left (\frac {2\pi k}{n}\right)\right]\end{aligned}$$
Putting $\theta=\frac{4 \pi}{n}$ and $\frac{2 \pi}{n}$ in the identity (*), simplifies the  sum as
$$\begin{aligned}\sum_{k=1}^{n-1} k \cos\frac{3 \pi k}{n} \sin\frac{\pi k}{n}=
&=\frac{n}{4}\left[\cot \left(\frac{\pi}{n}\right)-\cot \left(\frac{2 \pi}{n}\right)\right]=\frac{n}{4} \csc \left(\frac{2 \pi}{n}\right)
\end{aligned} $$
A: To get rid of the $k$, I use the following identity:
$$\sum_{k=1}^{n-1}  kz^k=z\frac{d}{dz}\sum_{k=0}^{n-1}z^k=z\frac{d}{dz}\frac{1-z^n}{1-z}=\frac{(n-1)z^{n+1}-nz^n+z}{(1-z)^2}$$
Thus using $z=e^{\frac {4i\pi}n}$,
$$\begin{split}
\sum_{k=1}^{n-1} k \cos\frac{3 \pi k}{n} \sin\frac{\pi k}{n} &= \frac 1 2\sum_{k=1}^{n-1} k \left(\sin \left (\frac {4\pi k}{n}\right) -\sin \left (\frac {2\pi k}{n}\right)\right)\\
&= \frac 1 2 \Im \left [ \sum_{k=1}^{n-1} k e^{\frac {4i\pi k}{n}} -\sum_{k=1}^{n-1} k e^{\frac {2i\pi k}{n}}\right]\\
&= \frac 1 2 \Im\left[ \frac{(n-1)e^{\frac {4i\pi}{n}}-n+e^{\frac {4i\pi}{n}}}{(1-e^{\frac {4i\pi}{n}})^2} - \frac{(n-1)e^{\frac {2i\pi}{n}}-n+e^{\frac {2i\pi}{n}}}{(1-e^{\frac {2i\pi}{n}})^2}\right]\\
&= \frac 1 2 \Im\left[ \frac{(n-1)e^{\frac {4i\pi}{n}}-n+e^{\frac {4i\pi}{n}}}{(1-e^{\frac {4i\pi}{n}})^2} - \frac{(n-1)e^{\frac {2i\pi}{n}}-n+e^{\frac {2i\pi}{n}}}{(1-e^{\frac {4i\pi}{n}})^2}(1+e^{\frac {2i\pi}{n}})^2\right]\\
&= \frac 1 2 \Im\left[ \frac{ne^{\frac {2i\pi}{n}}(1-e^{\frac {4i\pi}{n}})}{(1-e^{\frac {4i\pi}{n}})^2} \right]\\
&= \frac 1 2 \Im\left[ \frac{ne^{\frac {2i\pi}{n}}}{(1-e^{\frac {4i\pi}{n}})} \right]\\
&= \frac n 2 \Im\left[ \frac{1}{-2i\sin\left(\frac {4\pi}{n}\right)} \right]\\
&= \frac n 4 \csc \left(\frac {4i\pi}{n}\right)
\end{split}$$
