TITLE: A curious Gauss-Sum type identity
QUESTION [9 upvotes]: Let $q=e^{2\pi i/m}$, $a\in\mathbb{R}$ and $1\leq j\leq m-1$.  I would like to prove that:
$$(a-1)\sum_{n=0}^{m-1} q^n\frac{\prod_{k=0}^{j-2} (q^{n+k+1}-a)}{\prod_{k=0}^{j} (aq^{n+k}-1)}=0.$$
For $j=1$ I can prove it by induction: the left-hand side of the expression factors as $$\frac{\prod_{1<d|m}\Phi_d}{aq^m-1}$$ where $\Phi_d$ is the $d$th cyclotomic polynomial and the product runs over all divisors of $m$ (besides $1$).  For larger values of $j$ I cannot guess a formula.  For small values of $m$ I have checked that it is true.
I can also verify this identity for several values of $a$, such as $0,1$ and $\infty$.  The $(a-1)$ in the numerator is necessary as without it there is a pole at $a=1$.
Is this a known identity?  Can anyone point me towards a proof of the general case?

REPLY [5 votes]: Perhaps, this can be simplified; but here is some (more or less general) computation. One can easily see how far it can be generalized.
Every term of the sum reads
$$
  q^n\frac{\prod_{k=0}^{j-2}(q^{n+k+1}-a)}{\prod_{k=0}^j(aq^{n+k}-1)}
  =q^n\frac{(-1)^{j+1}\prod_{k=1}^{j-1}(a-q^{n+k})}
    {q^{n(j+1)}q^{j(j+1)/2}\prod_{k=0}^j(a-q^{-n-k})}
  =Cq^{-nj}\frac{\prod_{k=1}^{j-1}(a-q^{n+k})\prod_{k=1}^{m-j-1}(a-q^{-n+k})}
    {\prod_{k=0}^{m-1}(a-q^{-n-k})}\\
  =\frac{C}{(a^m-1)}\cdot
    t_n^j\prod_{k=1}^{j-1}(a-t_n^{-1}q^k)\prod_{k=1}^{m-j-1}(a-t_nq^k)
$$
here $C=(-1)^{j+1}q^{-j(j+1)/2}$ is a constant and $t_n=q^{-n}$. Thus we need to show that the sum of the values of Laurent polynomial 
$$
  P(t)=t^j\prod_{k=1}^{j-1}(a-t^{-1}q^k)\prod_{k=1}^{m-j-1}(a-tq^k)
$$
at all $m$th degree roots of unity vanishes. In fact, expanding the brackets, we see that $P$ is a usual polynomial, and all its monomials have degrees from $1$ to $m-1$; Thus the claim follows from $\sum_{n=0}^{m-1}q^{nk}=0$ for all $k=1,2,\dots,m-1$.
REMARK. Since the numerator is a polynomial in $a$, the identity also holds for all complex $a$, and even the poles at the roots of unity cancel.