TITLE: Finding a closed form expression for $\sum_{i=1}^{n-1}\csc{\frac{i\pi}{n}}$
QUESTION [5 upvotes]: Consider
$\displaystyle{S =
\sum_{k = 1}^{n - 1}\csc\left(k\,{\pi \over n}\right) =
\frac{1}{\sin\left(\pi/n\right)} +
\frac{1}{\sin\left(2\pi/n\right)} +
\frac{1}{\sin\left(3\pi/n\right)} + \cdots +
\frac{1}{\sin\left(\left[n - 1\right]\pi/n\right)}}$
How can we find a general formula for $S$ using trigonometry identities or complex numbers ?.

REPLY [5 votes]: Let we assume for first that $n$ is an odd number, $n=2N+1$. In such a case the given sum is
$$ \sum_{k=1}^{2N}\frac{1}{\sin\left(\frac{\pi k}{2N+1}\right)} = 2\sum_{k=1}^{N}\frac{1}{\sin\left(\frac{\pi k}{2N+1}\right)}=\frac{4N+2}{\pi}H_N+2\sum_{k=1}^{N}\left[\frac{1}{\sin\left(\frac{\pi k}{2N+1}\right)}-\frac{1}{\frac{\pi k}{2N+1}}\right] $$
and $\frac{1}{\sin(x)}-\frac{1}{x}$ is an integrable function on the interval $\left(0,\frac{\pi}{2}\right)$, whose integral equals $\log\frac{4}{\pi}$.$^{(*)}$
By Riemann sums is follows that:
$$ \sum_{k=1}^{2N}\frac{1}{\sin\left(\frac{\pi k}{2N+1}\right)} = \frac{4N}{\pi}\left[H_N+\log\frac{4}{\pi}\right]+O(\log N).$$
In the general case we get that the given sum behaves like $Cn\log n$.

$^{(*)}$ Since $\text{Res}\left(\frac{1}{\sin x},x=k\pi\right)=(-1)^k$, by Herglotz' trick we have
$$\frac{1}{\sin x}-\frac{1}{x}=\sum_{k\geq 1}\left(\frac{1}{x-k\pi}+\frac{1}{x+k\pi}\right)(-1)^k $$
and by termwise integration
$$ \int_{0}^{\pi/2}\left(\frac{1}{\sin x}-\frac{1}{x}\right)\,dx = \sum_{k\geq 1}(-1)^k \log\left(1-\frac{1}{4k^2}\right) $$
so $I=\log\frac{4}{\pi}$ by simplifying the partial sums of the last series and recalling Wallis product.