When is 2 a quadratic residue mod p I'm trying to prove that 2 is a QR when $p = \pm \ 1 \text{ mod } 8.$ I know how to prove via a "factorial" proof, butI'm given the hint to use the fact that if $ \zeta $ is a primitive 8-root of unity, then $(\zeta + \bar{\zeta})^2 = 2$, and would like to solve the exercise using the hint. This is where I got so far: $$ \text{ I can use the fact that } 2 \text{ is a quadratic residue if and only if } 2^{\frac{p-1}{2}}=1 \text{ mod p}$$
$$ 2^{\frac{p-1}{2}} = (\zeta + \bar{\zeta})^{p-1} = \sum_{k = 0} ^{p-1} {p-1 \choose k} \bar\zeta^k \zeta^{p-1-k} = \sum_{k = 0} ^{p-1} {p-1 \choose k}\zeta^{p-1+6k}$$ Now I guess I should use the fact that $ \zeta^4 = -1$, and thus the symmetry of the sum cancels many factors, but I'm stuck at this point, and even computing the sum for small p didn't help much. Can someone help me out? Thanks!
 A: Since $\zeta^p + \bar{\zeta}^p \equiv (\zeta + \bar{\zeta})^{p} \equiv (\zeta + \bar{\zeta})\left(\frac{2}{p}\right) \pmod{p}$, you can do casework on if $p \equiv \pm 1 \pmod{8}$ or $p \equiv \pm 3 \pmod{8}$ and the fact that $\zeta^4 \equiv -1 \pmod{p}$.
A: Another method is based on this answer. It considers $\sqrt2$ times an eighth root of unity.
When $p$ is prime and $k\not\in\{0,p\}$, $\binom{p}{k}\equiv0\pmod{p}$. Thus, the Binomial Theorem says that
$$\newcommand{\Re}{\operatorname{Re}}
(1+i)^p\equiv1+i^p\pmod{p}\tag1
$$
We also have that
$$
\begin{align}
(1+i)^p
&=\left(\sqrt2\,e^{\frac{\pi i}4}\right)^p\\
&=2^{\frac{p-1}2}\sqrt2\,e^{\frac{\pi i}4p}\tag2
\end{align}
$$
Comparing $(1)$ and $(2)$, we get that
$$
2^{\frac{p-1}2}\Re\left(\sqrt2\,e^{\frac{\pi i}4p}\right)\equiv1\pmod{p}\tag3
$$
Then, we only need note that $\Re\left(\sqrt2\,e^{\frac{\pi i}4p}\right)=1$ when $p\equiv\pm1\pmod8$ and that $\Re\left(\sqrt2\,e^{\frac{\pi i}4p}\right)=-1$ when $p\equiv\pm3\pmod8$.
A: Here's another proof that also uses the fact that $(\zeta+\overline{\zeta})^2=2$.
From the equation $2=(\zeta+\overline{\zeta})^2=(\zeta+\zeta^{-1})^2$, we see that $\Bbb Q(\zeta)$ contains $\Bbb Q(\sqrt{2})$.
It is well-known that the map $(\Bbb Z/8\Bbb Z)^\times \to \mathrm{Gal}(\Bbb Q(\zeta)/\Bbb Q)$ which sends $\overline{a}$ to the unique automorphism $\varphi_a$ that satisfies $\varphi_a(\zeta)=\zeta^a$ is an isomorphism of groups.
Now using that $(\zeta+\zeta^{-1})^2=2$ one sees that under the isomorphism above the subgroup $\mathrm{Gal}(\Bbb Q(\zeta)/\Bbb Q(\sqrt{2})) \subset \mathrm{Gal}(\Bbb Q(\zeta)/\Bbb Q)$ corresponds to the subgroup $\{\overline{\pm 1\}}\subset (\Bbb Z/8\Bbb Z)^\times$.
Now every odd prime $p$ is unramified in $\Bbb Q(\zeta)$, so we have a Frobenius element $\left(\frac{\Bbb Q(\zeta)/\Bbb Q}{p}\right)$ in the Galois group which is just given by $\varphi_p:\zeta \mapsto \zeta^p$. We have that this restricts to a Frobenius element in the Galois group $\mathrm{Gal}(\Bbb Q(\sqrt{2})/\Bbb Q)$ (directly by definition of Frobenius element) $\left(\frac{\Bbb Q(\zeta)/\Bbb Q}{p} \right)|_{\Bbb Q(\sqrt{2})}=\left(\frac{\Bbb Q(\sqrt{2})/\Bbb Q}{p} \right)$.
Now $p$ splits in $\Bbb Q(\sqrt{2})$ iff $\left(\frac{\Bbb Q(\sqrt{2})/\Bbb Q}{p} \right)=\mathrm{id}$. This can be seen easily by the definition of Frobenius element: take $\mathfrak{P}$ above $p$ in $\Bbb Z[\sqrt{2}]$, then the residue field extension $\Bbb Z[\sqrt{2}]/\mathfrak{P}$ over $\Bbb Z/(p)$ has degree $1$ iff $p$ splits.
$p$ splitting in $\Bbb Z[\sqrt{2}]$ is equivalent to the splitting of the polynomial $x^2-2$ mod $p$ which splits iff $2$ is a quadratic residue mod $p$.
In summary, we get that $2$ is a quadratic residue mod $p$ iff $p$ splits in $\Bbb Q(\sqrt{2})$ iff the Frobenius element $\left(\frac{\Bbb Q(\sqrt{2})/\Bbb Q}{p} \right)$ is the identity.
But we have seen that the Frobenius element $\left(\frac{\Bbb Q(\sqrt{2})/\Bbb Q}{p} \right)$ is just the restriction of $\varphi_p$ to $\Bbb Q(\sqrt{2})$. This restriction is the identity iff $\varphi_p \in \mathrm{Gal}(\Bbb Q(\zeta)/\Bbb Q(\sqrt{2}))$. But using the isomorphism $\mathrm{Gal}(\Bbb Q(\zeta)/ \Bbb Q) \cong (\Bbb Z/8\Bbb Z)^\times$, $\varphi_p$ is sent to $\overline{p}$ and $\mathrm{Gal}(\Bbb Q(\zeta)/\Bbb Q(\sqrt{2}))$ is sent to $\{\overline{\pm 1}\}$. Thus $\varphi_p |_{\Bbb Q(\sqrt{2})}=\mathrm{id} \Leftrightarrow p \equiv \pm 1 \pmod{8}$. This finishes the proof.
To summarize the whole argument, we have
$2$ is a quadratic residue mod $p$ $\Leftrightarrow$ $p$ splits in $\Bbb Q(\sqrt{2})$ $\Leftrightarrow$ $\mathrm{id}=\left(\frac{\Bbb Q(\sqrt{2})/\Bbb Q}{p}\right) = \left(\frac{\Bbb Q(\zeta)/\Bbb Q}{p}\right)|_{\Bbb Q(\sqrt{2})}=(\varphi_p)|_{\Bbb Q(\sqrt{2})}$ $\Leftrightarrow$ $\varphi_p \in \mathrm{Gal}(\Bbb Q(\zeta)/\Bbb Q(\sqrt{2}))$ $\Leftrightarrow$ $p \equiv \pm 1 \pmod{8}$
This argument is more advanced because it uses Galois theory and basic algebraic number theory, but it feels more conceptual as it avoids explicit calculations. Given the tags "Galois theory" and "algebraic number theory", it seems appropriate.
