Prove $\sum_{k=1}^{\lfloor n/2\rfloor} (n+1-2k)\sin\frac{(2k-1)\pi}n= \frac n2\csc\frac\pi n $ Encountered the series summation below
$$\sum_{k=1}^{\lfloor n/2\rfloor} (n+1-2k)\sin\frac{(2k-1)\pi}n
$$
which is supposed to reduce to the close-form expression $\frac n2\csc\frac\pi n$. I have struggled though to see it quickly with familiar  algebraic manipulations. The proportional term $2k$ in the sequence is a bit annoying.
 A: I won't provide a complete answer since I think you're more than capable of working out the details, but the first thing to consider is writing $$\sin \frac{(2k-1)\pi}{n} = \sin \left( \frac{(2k-1-n)\pi}{n} + \pi \right) = -\sin \frac{(2k-1-n)\pi}{n}.$$
Next, consider the function $$f(z) = \sum_{k=1}^{\lfloor n/2 \rfloor} \cos (2k-1-n)z.$$  Then look at the derivative of this function with respect to $z$, evaluated at $z = \pi/n$.
A: We assume $n>1$. Let the sum be $S_n$; observe that $\sum_{k=1}^{\lfloor n/2\rfloor}=\frac12\sum_{k=1}^n$ because 1) the term is invariant under $k\mapsto n+1-k$ and 2) if $n$ is odd, the term at $k=(n+1)/2\color{gray}{[=n+1-k]}$ is zero. Hence,
\begin{align*}
4S_n\sin\frac{\pi}{n}&=\sum_{k=1}^n(n+1-2k)\left(\cos\frac{2(k-1)\pi}{n}-\cos\frac{2k\pi}{n}\right)
\\&=\sum_{k=0}^{n-1}(n-1-2k)\cos\frac{2k\pi}{n}-\sum_{k=1}^n(n+1-2k)\cos\frac{2k\pi}{n}
\\&=\underbrace{(n-1)}_{k=0}-\underbrace{(1-n)}_{k=n}-2\underbrace{\sum_{k=1}^{n-1}\cos\frac{2k\pi}{n}}_{=-1}=2n.
\end{align*}
