Formula for the sum of the value of a rational function over roots of unity Let $n,k$ be integers, and let $U$ be the set of all $n$-ths roots of unity (so there are exactly $n$ elements in $U$). Let $U'=U \setminus \lbrace 1 \rbrace$. Are there simple formulas (in terms of $n$ and $k$) for the sums
$$
S_k=\sum_{\varepsilon \in U'} \frac{\varepsilon^k}{\varepsilon-1}, \
T_k=\sum_{\varepsilon \in U'} \frac{\varepsilon^k}{(\varepsilon-1)^2}
$$
 A: Note that the sums $S_k$ and $T_k$ obviously only depend on $k$ modulo
$n$. So for simplicity we may assume wlog that $1\leq k\leq n$. 
If $\varepsilon$ is any complex number, we have the algebraic identity
$$
\bigg(\sum_{j=0}^{n-2} (j+1-n)\varepsilon^j\bigg)
(\varepsilon-1)-n=n-\bigg(\sum_{j=0}^{n-1} \varepsilon^j\bigg) \tag{1}
$$
If, in addition, $\varepsilon\in U'$ then we deduce
$$
\frac{1}{\varepsilon-1}=\frac{1}{n} \sum_{j=0}^{n-2} (j+1-n)\varepsilon^j
$$
and hence
$$
S_k=\frac{1}{n}
\sum_{j=0}^{n-2} (j+1-n)\sum_{\varepsilon\in U'}\varepsilon^{j+k}
$$
and the sum $\sum_{\varepsilon\in U'}\varepsilon^{j+k}$ is $-1$, except when $j+k$ is divisible by
$n$, i.e. when $j=n-k$. So
$$
\begin{eqnarray}
nS_k &=& (n-1)(1-k)+\sum_{j\neq n-k}^{} (n-(j+1)) \\
&=& (n-1)(1-k)-(k-1)+\sum_{j=0}^{n-2} (n-(j+1)) \\
&=& n(1-k)+\sum_{j=0}^{n-2} (n-(j+1)) \\
&=& n(1-k)+\sum_{j'=0}^{n-1} j’ \\
&=& n(1-k)+n\frac{n-1}{2}=\frac{n(n+1-2k)}{2}.
\end{eqnarray}
$$
and hence $S_k=\frac{n+1-2k}{2}$. Similarly, if $\varepsilon$ is any complex number, we have the algebraic identity
$$
\bigg(\sum_{j=0}^{n-2} (j+1)(n-(j+1))\varepsilon^j\bigg)
(\varepsilon-1)^2-2n=\bigg(\sum_{j=0}^{n-1} \varepsilon^j\bigg)\big(
(n-1)\varepsilon-(n+1) 
\big)
$$
If, in addition, $\varepsilon\in U'$ then we deduce
$$
\frac{1}{(\varepsilon-1)^2}=\frac{1}{2n} \sum_{j=0}^{n-2} (j+1)(n-(j+1))\varepsilon^j
$$
and hence
$$
T_k=\frac{1}{2n}
\sum_{j=0}^{n-2} (j+1)(n-(j+1))\sum_{\varepsilon\in U'}\varepsilon^{j+k}
$$
and the sum $\sum_{\varepsilon\in U'}\varepsilon^{j+k}$ is $-1$, except when $j+k$ is divisible by $n$, i.e. when $j=n-k$. So
$$
\begin{eqnarray}
(2n)T_k &=& (n-k+1)(k-1)(n-1)+\sum_{j\neq n-k}^{} (j+1)(n-(j+1))(-1) \\
&=& (n-k+1)(k-1)(n-1)+(n-k+1)(k-1) -\sum_{j=0}^{n-2} (j+1)(n-(j+1)) \\
&=& (n-k+1)(k-1)n -\sum_{j=0}^{n-2} (j+1)(n-(j+1)) \\
&=& (n-k+1)(k-1)n -\frac{n^3-n}{6} 
\end{eqnarray}
$$
So we finally have
$$
T_k=\frac{6(n-k+1)(k-1)-(n^2-1)}{12}
$$
