Computing Legendre symbols by quadratic reciprocity Created 2026-10-14 Updated 2026-10-31
The practical reward of quadratic reciprocity is a smaller modulus: swap a pair of distinct odd primes, record the required sign, then reduce the numerator by modular arithmetic. Use multiplicativity of the Legendre symbol and the second supplementary law for quadratic reciprocity to handle a factor of two. For example,
Here are both modulo , so the first swap changes sign; gives ; the swap involving five has no sign change. An independent square check is . The method determines existence of a square root without itself finding that root.
A composite numerator is allowed in a Legendre symbol; a composite denominator instead calls for a Jacobi symbol. Its Jacobi reciprocity law supports repeated swaps and remainder reductions, in the spirit of the Euclidean algorithm.[ref]
A final Jacobi symbol of one is not a square-existence certificate for a composite number modulus. For example,
yet is impossible: reducing it modulo three would require a square congruent to two, and squares modulo three are only zero or one. The product has hidden two local failures. By contrast, for a prime denominator, a Legendre symbol of one does certify a quadratic residue.
The Hasse-Minkowski theorem says that a nondegenerate quadratic form over a number field has a nonzero isotropic vector over that field if and only if it has one over every completion. In particular, over one tests and every . For the present integral form, a rational isotropic vector can be multiplied by a common denominator to give an integer one. This is the Hasse-Minkowski principle.
Write , and . All three primes are odd and exceed three: or would make composite. The second supplementary law for quadratic reciprocity gives
Necessity at . Scale any nonzero vector over so that its coordinates lie in and at least one is a unit. Reduction of its equation modulo gives , since twelve is invertible modulo . If the Legendre symbol is , this forces . The original equation then forces , because its other two terms are divisible by . This contradicts the normalization. Thus
Sufficiency at the coefficient primes. Suppose . A nonzero solution modulo is . Its -derivative is nonzero modulo , so fixing the other two coordinates and applying the Hensel lemma lifts it to .
Since , the same Legendre symbol criterion gives . Modulo , the equation reduces to , and the vector is a simple zero in the coordinate. It lifts to . Modulo , the coefficients of and are respectively and , so is a zero with nonzero -derivative. It lifts to .
The remaining odd primes. If is odd and divides none of , the reduced ternary quadratic form is nondegenerate. An elementary finite-field argument finds a zero with : if its coefficients are , the sets
both have elements, so intersect. The resulting vector has nonzero -derivative , and the Hensel lemma lifts it. This isotropy of nondegenerate ternary quadratic forms over finite fields verifies every remaining odd completion without an extra congruence condition.
The dyadic and real places. Setting reduces the dyadic problem to
The right side is a 2-adic unit congruent to modulo eight. The unit square classes of the p-adic integers computed above show that it is a square in . This also explains the printed hint: its integer can be taken as . Over , the positive and negative coefficients make the form indefinite; for instance gives a nonzero zero.
All completions now have a nonzero isotropic vector. The Hasse-Minkowski theorem, followed by clearing denominators, proves
For an odd prime , the Legendre symbol is
Euler criterion states that
The Gauss lemma says that, for , if of the least positive residues of
lie in , then
To prove it, replace every residue above by its negative. The resulting absolute residues are distinct up to sign and therefore form a permutation of
Multiplying the congruences gives
Cancel the nonzero factorial and apply Euler's criterion.
For , the residues are . The number above is
whose parity gives the second supplementary law for quadratic reciprocity
Consequently, for odd primes,
The congruence is also soluble for .
Because and commute, the matrix binomial theorem gives
For prime , every intermediate coefficient is divisible by , proving the prime-power binomial congruence for a matrix
For
one has and . If , then
so . If , then and
so .
By Euler criterion, . In either case the preceding congruence gives . Since has the same parity as for , this is the second supplementary law for quadratic reciprocity
Gauss's lemma states that, for , if of the least positive residues of exceed , then .
For , the residues are simply , with no reduction needed. Write . A term exceeds exactly when , so
If is congruent to modulo eight, the parity of this count is respectively even, odd, odd, even. Gauss's lemma therefore gives
This proves the second supplementary law for quadratic reciprocity, rather than merely applying it.
For distinct odd primes , quadratic reciprocity states
Here the Legendre symbol records whether a nonzero congruence class is a quadratic residue. The first supplementary law for quadratic reciprocity and second supplementary law for quadratic reciprocity give
Thus minus one is a square exactly when , and two is a square exactly when or .
To test the specified congruence class, factor . Since , multiplicativity of the Legendre symbol and quadratic reciprocity yield
There is no sign change on swapping and because . Finally , so multiplicativity of the Legendre symbol gives , since . Therefore
For an odd prime , Euler's criterion states
For , the Legendre symbol is for a quadratic residue and for a quadratic nonresidue; if , both sides are zero.
The product is a single power because the arithmetic progression of exponents has sum :
Since , the second supplementary law for quadratic reciprocity gives . Hence Euler's criterion gives . Reduce the exponent using and :
The least nonnegative remainder is therefore .
Quadratic reciprocity Created 2026-09-24 Updated 2026-10-13
Quadratic reciprocity compares two questions: is the prime number a quadratic residue modulo , and is a quadratic residue modulo ? Let be distinct odd primes. In terms of the Legendre symbol,
The two Legendre symbols have opposite signs exactly when both primes are modulo ; otherwise they are equal. Their values are nonzero because the primes are distinct. Equal signs can mean two quadratic residues or two quadratic nonresidues: reciprocity compares the answers rather than declaring either answer positive.[ref]
For a direct computation, the nonzero quadratic residues modulo are respectively , , and . Squaring just suffices because and have the same square modulo an odd prime .
The pair has a sign flip, whereas has two negative signs. These small quadratic residue tables make the distinction tangible.
Figure 1.
Small prime square-residue tables distinguish opposite and equal Legendre symbol signs
. Each row uses half the nonzero inputs; the missing entries are unnecessary. The comparisons and are exact finite examples of quadratic reciprocity, not evidence by themselves for every prime pair. Details.
The first supplementary law for quadratic reciprocity handles numerator , and the second supplementary law for quadratic reciprocity handles numerator :
For an odd prime , is a quadratic residue exactly when , while is a quadratic residue exactly when . The remaining odd congruence classes modulo , namely , make a quadratic nonresidue. These laws fill the cases excluded from swapping distinct odd primes.[ref]
For , the first order bound already gives . The second supplementary law for quadratic reciprocity says that two is then a quadratic residue modulo . Euler's criterion gives , so its multiplicative order divides . Thus , further reducing the candidate factors. At , meets this bound. The restriction matters: has factor five, which is not one modulo eight.