Here are two questions that seem unrelated: is $13$ a square mod $47$? Is $47$ a square mod $13$? Gauss proved, as a teenager, that the answers are linked by a simple sign rule. He called it the golden theorem and gave several different proofs of it. With it and the supplementary laws, any Legendre symbol shrinks quickly, much like the Euclidean algorithm.
The law of quadratic reciprocity. For distinct odd primes $p$ and $q$, $$\left(\frac{p}{q}\right)\left(\frac{q}{p}\right) = (-1)^{\frac{p-1}{2} \cdot \frac{q-1}{2}}.$$ In words: $\left(\frac{p}{q}\right) = \left(\frac{q}{p}\right)$, unless $p \equiv q \equiv 3 \pmod{4}$, in which case $\left(\frac{p}{q}\right) = -\left(\frac{q}{p}\right)$.
Why it works
- Reduce the top mod the bottom.
- Factor the top. Drop squared factors; handle $-1$ and $2$ with the supplementary laws.
- For each odd prime on top, flip with reciprocity (minus sign if both are $3 \bmod 4$), and repeat.
Worked example: One flip
- $13 \equiv 1 \pmod{4}$, so no sign: $\left(\frac{13}{47}\right) = \left(\frac{47}{13}\right)$.
- $47 \equiv 8 \pmod{13}$: $\left(\frac{8}{13}\right) = \left(\frac{2}{13}\right)^{3} = \left(\frac{2}{13}\right)$.
- $13 \equiv 5 \pmod{8}$, so $\left(\frac{2}{13}\right) = -1$.
Answer: $\left(\frac{13}{47}\right) = -1$: 13 is not a square mod 47.
Worked example: Watch the sign
- $19 \equiv 43 \equiv 3 \pmod{4}$, so $\left(\frac{19}{43}\right) = -\left(\frac{43}{19}\right) = -\left(\frac{5}{19}\right)$.
- $5 \equiv 1 \pmod{4}$: $\left(\frac{5}{19}\right) = \left(\frac{19}{5}\right) = \left(\frac{4}{5}\right) = 1$, since 4 is a square.
- So $\left(\frac{19}{43}\right) = -1$.
Answer: $-1$.
Worked example: A composite top
- Factor first: $\left(\frac{12}{31}\right) = \left(\frac{2}{31}\right)^{2}\left(\frac{3}{31}\right) = \left(\frac{3}{31}\right)$.
- $3 \equiv 31 \equiv 3 \pmod{4}$: $\left(\frac{3}{31}\right) = -\left(\frac{31}{3}\right) = -\left(\frac{1}{3}\right) = -1$.
Answer: $-1$.
Common mistake
Key idea