A quadratic reciprocity formula

Inspired by a problem of calculating explicitly the invariants by Reshetikhin and Turaev for certain 3-manifolds, I have come across the following problem involving Gauss sums:

I would like to prove that $$\sum_{n=0}^k e^{-\tfrac{2\pi i}{4k+8}(n^2+2n)} = e^{\pi i/(2k+4)}\left(\sqrt{\tfrac{k}{2}+1}e^{-\pi i/4} - \frac{-e^{-\pi ik/2}+1}{2} \right).$$

Edits: By a number of simplifications (see the comments below), this becomes $$\sum_{n=1}^{r-1} e^{\tfrac{\pi i}{2r}n^2} = \sqrt{r}\frac{1+i}{2} - \frac{e^{\pi i r/2} + 1}{2}.$$

This on the other hand is equivalent to $$\sum_{n=1}^{r-1} e^{\tfrac{\pi i}{2r}n^2} = \sum_{n=1}^{r-1} e^{\tfrac{\pi i}{2r}(n+r)^2}$$ for all $r$, and this can be checked by noting that the two sums contain the same terms.

The rest of this question is left over from my original wording: When $k$ (or $r$) is even, this formula holds by the following quadratic reciprocity theorem (and a couple of tricks):

Let $a,b,c$ be integers, $a \not= 0$, $c \not= 0$, and assume that $ac+b$ is even. Then

$$\sum_{n=0}^{\lvert c \rvert -1} e^{\pi i(an^2+bn)/c} = \lvert c/a \rvert^{1/2} e^{\pi i (\lvert ac \rvert-b^2)/(4ac)} \sum_{n=0}^{\lvert a\rvert-1} e^{-\pi i (c n^2+b n)/a}.$$

However, when my $k$ is odd, this can not be applied directly. Any suggestions are welcome.


Solution 1:

Serge Lang, Algebraic Number Theory, page 85, defines $$G(a,b)=\sum_{x{\rm\ mod\ }b}e^{2\pi iax^2/b}$$ for $a$, $b$ non-zero integers, $b\gt0$, $\gcd(a,b)=1$, and states on page 87 $$\eqalign{G(1,b)&=(1+i)\sqrt b{\rm\ if\ }b\equiv0\pmod4,\cr &=\sqrt b{\rm\ if\ }b\equiv1\pmod4,\cr &=0{\rm\ if\ }b\equiv2\pmod4,\cr &=i\sqrt b{\rm\ if\ }b\equiv3\pmod4.\cr}$$

I realize that's not exactly the sum you have, but the terms for $n\gt r-1$ just duplicate those for $n\le r-1$, so you should be able to get what you want out of these formulas.