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.

-
Can't you rewrite this in the form: $$\sum_{n=0}^k e^{-\frac{2\pi i}{4k+8} (n+1)^2}$$ with the term $e^{\pi i/(2k+4)}$ removed from the right side? – Thomas Andrews May 23 '11 at 19:43
@Thomas Andrews: I guess I could, which would make it look at bit neater. – fuglede May 23 '11 at 19:48
On a similar note, letting $r = k + 2$ simplifies the expression a bit as well. – fuglede May 23 '11 at 19:54
Yes, you can substitute $m=n+1$ too, and rewrite this formula as: $$\sum_{m=1}^{r-1} e^{-\pi i \frac{m^2}{2r}} = \sqrt{r}\frac{1-i}{2} - \frac{e^{-\pi i r}+1}2$$ – Thomas Andrews May 23 '11 at 19:59
@Thomas Andrews: Right. Small comment though; the phase $-\pi i r$ should be $-\pi i r/2$. – fuglede May 23 '11 at 20:03

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.

-
FWIW: The general Gauss sum $G(a,b) = \displaystyle\sum_{x \in \mathbb{Z}/b\mathbb{Z}} e(ax^2/b)$ has the value $$G(a,b) = \left\{ \begin{array}{ll} \varepsilon_b \left( \frac{a}{b} \right) \sqrt{b} & b \equiv 1\pmod{2} \\ 0 & b \equiv 2\pmod{4} \\ (1+i)\varepsilon_a^{-1} \left( \frac{b}{a} \right) \sqrt{b} & b \equiv 0\pmod{4}, \quad \text{ and }\quad a \equiv 1\pmod{2} \end{array}\right.$$ where $\left( \frac{\cdot}{b} \right)$ is the Jacobi symbol and $\varepsilon_b = \left\{ \begin{array}{cc} 1 & b \equiv 1\pmod{4}\\ i & b \equiv 3\pmod{4} \end{array} \right..$ – JavaMan May 24 '11 at 2:15
The terms arising for $n > r - 1$ are not quite the same as those for $n \leq r - 1$, when $r$ is odd (but for $r$ even, this technique definitely works). I'm sure, this is the way to go, and I have reduced the problem to proving that $$\sum_{n=1}^{r-1} e^{\tfrac{\pi i}{2r}n^2} (1- e^{\pi i r/2}e^{\pi i n}) = 0$$ for all $r$. – fuglede May 24 '11 at 17:12
Great, as noted in my edited post, this seems to work. Thanks. – fuglede May 24 '11 at 17:24