# Finite sum involving root of unity

I have the following sum:

$$\sum_{\sigma=1,\text{odd}}^{\frac{p}{2}-2}\frac{\sin \frac{r \sigma \pi}{p}}{\sin \frac{q \sigma \pi}{p}}$$

where $$p\equiv2\pmod4$$, $$p$$ and $$q$$ are coprime numbers such that $$p-q\ge1$$, and $$r\in \{1,\dots,p-1\}$$ is odd. I know the result is of the form $$\pm \frac{\frac{p}{2}\pm 1}{2},$$ but the signs depend on the relation of $$r, p, q$$, and it is not easy to guess.

Is there some formula for this type of sums?

I tried to reduce it using exponentials as the following:

$$\sum_{\sigma=1,odd}^{\frac{p}{2}-2}e^{i\pi\frac{(q-r)\sigma}{p}}\frac{e^{2i\pi\frac{r\sigma}{p}}-1}{e^{2i\pi\frac{q\sigma}{p}}-1}$$

and define $$\omega=e^{2 i\pi\frac{q}{p}}$$ which is a primitive root of unity but I don't know how this can help.

• @alpoge, it should be taking $r \equiv a q \pmod{2p}$, not just $r \equiv a q \pmod p$, right? Otherwise it seems there is a sign issue. – LSpice May 17 '19 at 17:22