# Why is this a representation of the Legendre symbol?

Reading through the paper "On Modular forms of Half-integer Weight" by Goro Shimura, he uses at one point the property that $$p^{-1/2}\sum_{n=1}^p \exp\Big(\frac{2\pi i n^2 a}{p}\Big) = \Bigg(\frac{a}{p}\Bigg) = \begin{cases}1 & \exists y \mid a = y^2 \pmod p\\ -1 &\not\exists y \mid a = y^2 \pmod p\end{cases}$$ where the left-hand side is the Legendre symbol (and assuming that $\gcd(a,p) = 1$)

Edit: This isn't exactly correct; there is a factor of $i$ that arises if $p \equiv 3 \pmod 4$. However, other than that, this is correct

My question is: Why on earth is this true? It seems that one can compute for small values of $p$ by hand that this is the case, but it hasn't been illuminating to do so.

It certainly isn't crazy that the expression on the right-hand side would depend on whether or not $a$ is a square mod $p$; for example, if it is, then the expression reduces to the equality $$p^{-1/2}\sum_{n=1}^p \exp\Big(\frac{2\pi i n^2}{p}\Big) = \Bigg(\frac{1}{p}\Bigg) = 1$$ but I don't see how to prove this in general.

• You can make a search regarding Gauss and Jacobi sums, or look at Apostol's text or the classical text by Ireland and Rosen. – Pedro Tamaroff Mar 3 '15 at 10:22