Show that $\left(\frac{2}{p}\right) = \large(-1)^{\frac{p^2-1}{8}\large}$

I'm working on the following problem that is using the Legendre Symbol:

Show that $$\left(\frac{2}{p}\right) = \large(-1)^{\frac{p^2-1}{8}\large}$$

So I know that $\left(\frac{2}{p}\right) = \left\{ \begin{array}{ll} 1 &\text{if }\>\>p\equiv\pm1\>\text{ mod }8\\ -1 &\text{if }\>\>p\equiv\pm3\>\text{ mod }8 \end{array} \right.$

But I'm not sure how to use this for the proof (assuming it's relevant).

Whether it's $1$ or $-1$ will depend on if the exponent is even or odd.

I'm not sure how to tie that all together. Any pointers?

• For most primes, $p^2$ can't be even… ;o) – Bernard Oct 6 '16 at 23:31
• @Bernard "most" made me chuckle – ÍgjøgnumMeg Oct 6 '16 at 23:33
• Ah, right... a bit of an oversight on my part haha – kojak Oct 6 '16 at 23:36

Just calculate the values of $\dfrac{p^2-1}8$ in both cases:
• if $p=8k\pm 1$, $\dfrac{p^2-1}8=\dfrac{64k^2\pm16k}8=2k(4k\pm1)$ is even,
• if $p=8k\pm 3$, $\dfrac{p^2-1}8=\dfrac{64k^2\pm48k+8}8=2k(4k\pm3)+1$ is odd.
The complicated exponent $$\frac{p^2 -1}{8}$$ is just a somewhat confusing way to express what you say you know about the quadratic character of $2$. You can prove that by checking the four possible cases for $p \pmod 8$.
This is just like using the exponent $n-1$ in the expression $(-1)^{n-1}$ as a way to distinguish between even and odd $n$ - that is, $n \pmod 2$. If you wanted to cover the two odd cases modulo $4$ you could use the exponent $(n-1)/2$.