Identity regarding roots of unity Let $\zeta$ be a primitive $n$-th root of unity and $m \in \{0,1,\dots,n-1\}$. I am interested in finding the value of the following expression:
$$\sum_{k=1}^{n-1}\frac{\zeta^{mk}}{1-\zeta^k}.$$
This has come up in a context where it should be a rational number (in fact it seems like it will be of the form $\frac{r}{2}$ where $r \in \mathbb Z$). For example for $m=0$ I can get the values $\frac{n-1}{2}$ by letting $f(x) = \frac{x^n-1}{x-1}$ and noticing that the desired sum equals $\frac{f'(1)}{f(1)}$. However I am not able to find such a "trick" when $m$ is nonzero.
 A: An idea is to use a Bezout identity with the polynomials $1-x$ and $1+X+\cdots+X^{n-1}$ to express $1/(1-\zeta^k)$ as a polynomial of $\zeta^k$.
$$n-(1+X+\cdots+X^{n-1}) = \sum_{k=1}^{n-1} (1-X^k) = (1-X)\sum_{k=1}^{n-1}\Big(\sum_{\ell=0}^{k-1}X^\ell\Big)$$
$$n-(1+X+\cdots+X^{n-1}) = (1-X)\sum_{\ell=0}^{n-2}(n-1-\ell)X^\ell.$$
Applying the equality to $\zeta^k$ for $1 \le k \le n$ yields
$$n = (1-\zeta^k)\sum_{\ell=0}^{n-2}(n-1-\ell)\zeta^{k\ell}.$$
Hence
$$\sum_{k=1}^{n-1} \frac{\zeta^{km}}{1-\zeta^k} = \frac{1}{n}\sum_{k=1}^{n-1}\zeta^{km}\sum_{\ell=0}^{n-2}(n-1-\ell)\zeta^{k\ell}.$$
$$\sum_{k=1}^{n-1} \frac{\zeta^{km}}{1-\zeta^k} = \frac{1}{n}\sum_{\ell=0}^{n-2}(n-1-\ell)\sum_{k=1}^{n-1}\zeta^{k(m+\ell)}.$$
But $$\sum_{k=1}^{n-1}\zeta^{k(m+\ell)} = \sum_{k=0}^{n-1}\zeta^{k(m+\ell)} - 1 = n 1_{[n \textrm{ divides } m+\ell]} - 1.$$
The only term for which $n$ divides $m+\ell$ is given by $\ell = n-m$. Hence
$$\sum_{k=1}^{n-1} \frac{\zeta^{km}}{1-\zeta^k} = \frac{1}{n} \Big((m-1)n - \sum_{\ell=0}^{n-2}(n-1-\ell)\Big).$$
$$\sum_{k=1}^{n-1} \frac{\zeta^{km}}{1-\zeta^k} = \frac{1}{n} \Big((m-1)n - \frac{n(n-1)}{2}\Big) = (m-1) - \frac{n-1}{2}.$$
A: Note that with $\zeta$ being primitive the powers $\zeta^k$ with  $0\le
k\le n-1$ just permute the powers of $\zeta = \exp(2\pi i/n)$ so we  may
take that as our root. Next introduce
$$f(z) = \frac{z^m}{1-z} \frac{n/z}{z^n-1}.$$
We have for $1\le k\le n-1$
$$\mathrm{Res}(f(z); z = \zeta^k)
= \frac{\zeta^{km}}{1-\zeta^k}.$$
Residues sum to zero and with $m\lt n$ the residue at infinity is
zero. Hence the desired sum must be minus the residue at $z=1.$ We
write (the minus from the residue cancels the minus from the $1/(1-z)$
term):
$$- \mathrm{Res}(f(z); z=1) =
\mathrm{Res}\left(\frac{z^m}{z-1}
\frac{n/z}{(z-1)(1+z+z^2+\cdots+z^{n-1})}; z=1\right)
\\ = \left. \left( \frac{nz^{m-1}}{1+z+z^2+\cdots+z^{n-1}}
\right)' \right|_{z=1}
\\ = \left. \left( \frac{n(m-1)z^{m-2}}{1+z+z^2+\cdots+z^{n-1}}
- \frac{nz^{m-1} (1+2z+3z^2+\cdots+(n-1)z^{n-2})}
{(1+z+z^2+\cdots+z^{n-1})^2}
\right)\right|_{z=1}
\\ = \frac{n(m-1)}{n} - \frac{n \frac{1}{2} (n-1) n}{n^2}
\\ = m-1 - \frac{1}{2} (n-1).$$
