For an odd prime , a nonzero congruence class is a quadratic residue when for some integer . Here "quadratic residue" excludes zero: zero is a square of a number, but is neither a quadratic residue nor a quadratic nonresidue under this convention. Some treatments include zero among quadratic residues; the distinction matters when counting them or discussing their subgroup.[ref]
Quadratic Residue Patterns Modulo a Prime by Keith Conrad. Keith Conrad, Quadratic Residue Patterns Modulo a Prime, §1, p. 1: nonzero convention and equal counts
Modulo seven, squaring the six nonzero congruence classes givesThus the set of quadratic residues is , and the quadratic nonresidues are . In particular, has exactly the two solutions : and . Modulo eleven the quadratic residues are instead . Two is therefore a quadratic residue modulo seven and a quadratic nonresidue modulo eleven: being a quadratic residue depends on the modulus.
Why do the square roots come in pairs? If , the prime number divides , so it divides one factor: or . For nonzero these are distinct, because is an odd prime. Every nonempty nonzero fiber of a function of therefore contains exactly two inputs. Pairing the nonzero congruence classes gives exactly quadratic residues and quadratic nonresidues. Including zero gives different squares, with one rather than two square roots for zero.
The quadratic residues form a subgroup of the multiplicative group of a finite field , with index of a subgroup two. Indeed, one is a square, , and ; the inverses exist because the inputs are nonzero in the prime field. Equivalently, the squaring group homomorphism has kernel of a group homomorphism and image of a function . The apparent loss of a sign in squaring becomes a precise division of the nonzero arithmetic into two equal parts.
This structure turns a search for square roots into a yes-or-no test: Euler's criterion detects quadratic residues through modular exponentiation, and the Legendre symbol records the result as a sign. For a general integer modulus, the modular congruence still makes sense, but the two-root count and the prime field argument need not survive. For example, has four solutions ; the Chinese remainder theorem separates the sign choices modulo three and five.
The congruence is soluble exactly for or . For odd , Fermat's little theorem applied to a prospective root forces even. Conversely, when , pair opposite factors in and use the Wilson theorem to obtain .
A nonzero congruence class modulo an odd prime is a quadratic nonresidue when it is not a square. In the convention of quadratic residue, zero belongs to neither class. Thus are the quadratic nonresidues modulo seven, while are the quadratic nonresidues modulo eleven. No integer satisfies , as the complete square map under quadratic residue shows.
A quadratic nonresidue is not an arithmetic dead end: multiplying by any fixed quadratic nonresidue exchanges the quadratic residues and the quadratic nonresidues. If were a square for a square , division by would make a square. Hence consists entirely of quadratic nonresidues; it has elements, because multiplication by nonzero is a bijection. It therefore equals the entire other coset of the quadratic residue subgroup. Modulo seven, .
The product of two quadratic nonresidues is consequently a quadratic residue: write them as in that same coset, and their product is , a square. For example, , whereas remains a quadratic nonresidue. The multiplicativity of the Legendre symbol packages these rules as ordinary sign multiplication.
For an odd prime , the least quadratic nonresidue is the smallest positive integer whose nonzero residue class is a quadratic nonresidue modulo .
On a dyadic interval , every such exceptional prime makes all -smooth integers quadratic residues. By positive density of power-smooth integers, there are of these integers up to . Apply the variance form of the large sieve or its forbidden-residue consequence with interval length and prime cutoff . Each exceptional prime excludes residue classes and contributes at least a fixed positive amount to the sieve denominator. Hence each dyadic interval contains exceptional primes. Summing the intervals gives the logarithmic bound.
// Target: analytic-number-theory.bigb
If, for every , the smooth numbers up to with all prime factors at most have density at least , then for fixed there are only primes with . Apply the variance form of the large sieve to the indicator function of the -smooth numbers up to . For every exceptional prime, all these numbers are nonzero quadratic residues, so half its nonzero residue classes are empty. Their variance contribution is at least one third of the square of the total count. The large sieve bounds the sum of contributions by a constant times times that count. The density assumption with finishes the argument.
For and the Legendre symbol , the quadratic Gauss sum isIt equals for and for with the standard choice of square root.
If and are the nonzero square and nonsquare classes modulo eleven and , thenTheir sum is , and their difference is the Quadratic Gauss sum .
Its value depends only on the congruence class of modulo ; the displayed notation is a symbol, not division. The value zero handles separately from quadratic residues and quadratic nonresidues.[ref]
Quadratic Residues by Ben Lynn. Ben Lynn, Quadratic Residues, The Legendre Symbol: three values and dependence on an odd prime
For example, , , , and . The equality illustrates that choosing a different integer representative does not change the answer. An arbitrary odd composite denominator uses the Jacobi symbol, not the Legendre symbol. For instance,but two is not a square modulo fifteen: any such square root would also give a square root modulo three, where the only nonzero square is one. A Jacobi symbol of one therefore cannot replace the Legendre symbol's square test.
The Legendre symbol also counts square roots compactly. For every congruence class in the prime field ,The three cases give two, one and zero solutions for a quadratic residue, zero and a quadratic nonresidue, respectively. This is useful when counting solutions of modular congruences involving polynomials: a solvability question becomes a sum of Legendre symbols, as in the complete Legendre-symbol sum and quadratic Legendre-symbol correlation.
For an odd prime and any integers , the Legendre symbol obeysIn particular, if , then , where is a modular multiplicative inverse. Multiplication by a nonzero square also leaves the Legendre symbol unchanged: for .[ref]
Quadratic Residues by Ben Lynn. Ben Lynn, Quadratic Residues, The Legendre Symbol: multiplicativity and invariance under a nonzero square factor
The subgroup and coset arguments under quadratic residue and quadratic nonresidue prove the sign rule without computing a large power: square times square is square, square times nonsquare is nonsquare, and nonsquare times nonsquare is square. If either factor is zero modulo , both sides of the identity vanish. On , the Legendre symbol is thus a group homomorphism to whose kernel of a group homomorphism is the quadratic residue subgroup. Viewed on all integers, it is a completely multiplicative function and a Dirichlet character modulo .
For an original calculation, factor the numerator . Modulo seven, , agreeing with . Modulo eleven, the signs are instead , giving , agreeing with . The same factorization can therefore certify different square behavior at different prime numbers.
Alternatively, Euler's criterion gives modulo . For nonzero factors both sides correspond to signs in . Since is odd, these signs are distinct modulo , so the modular congruence proves the asserted equality of integers, not merely an equality of representatives.
Thus a quadratic residue gives one and a quadratic nonresidue gives minus one, represented by if a nonnegative remainder is used. The formula also holds when , because and both sides are zero modulo .[ref]
Quadratic Residues by Ben Lynn. Ben Lynn, Quadratic Residues, Euler's Criterion and The Legendre Symbol: exponent test and the zero value
For example, modulo seven the exponent is three: confirms that two is a quadratic residue, while confirms that three is a quadratic nonresidue. Modulo eleven the exponent is five, and confirms that two is a quadratic nonresidue. The test answers whether a square root exists; it does not itself return the roots of .
A short proof needs only Fermat's little theorem and the root bound for a polynomial. Put . If in the prime field, then . There are already such quadratic residues. The nonzero polynomial has polynomial degree , so it has no other polynomial roots. Finally, for every nonzero , Fermat's little theorem gives . Factoring in the field shows ; every quadratic nonresidue must take the remaining value . This proves the criterion without first finding a primitive root.
For a larger original example, decide whether seven is a quadratic residue modulo the prime number . Exponentiation by squaring computes the required power without listing fifty squares:Therefore and has no solution. Each intermediate product is reduced modulo , as in modular exponentiation. The advantage is that exponentiation by squaring uses a number of multiplications proportional to the binary digit length of the exponent rather than testing every potential square root.
The odd prime hypothesis is essential. For the composite modulus nine, , which is neither one nor minus one. Although four is a nonzero square modulo nine, , so even the square-to-one implication fails. The Jacobi symbol and Euler pseudoprime discuss different questions for odd composite moduli; they do not make this a universal square test.
Every odd prime factor of an odd square plus four is one modulo four. The integer is five modulo eight, so at least one prime factor is five modulo eight. Choosing the odd square divisible by any proposed finite list excludes the list and proves infinitude.
For an odd prime ,For , write using a primitive root ; then the left side is , which is one exactly when is even and is a square.
If listed all primes congruent to seven modulo eight, then for the odd number is seven modulo eight. Every prime factor is one or seven modulo eight, at least one is seven, and none is among the , a contradiction.
Let count primes at most congruent to modulo eight. Bounding the prime-power divisibility ofabove and its size below gives, for all sufficiently large ,
For an integer matrix and prime , the commuting-matrix binomial theorem and divisibility of for give
For , one has when , and for every .
If , the sum of the least positive quadratic residues below isThe proof uses to compare the sum of all residues with its image under doubling.
For , the congruence has a solution exactly when its discriminant is zero or a quadratic residue modulo .
Articles by others on the same topic
A quadratic residue is a concept from number theory, particularly in the study of modular arithmetic.

