The Jacobi Symbol
Suppose you want to know whether has a solution. However, is composite. You have no quick way to factor it. The Legendre Symbol only makes sense for a prime modulus. So it cannot be applied directly to . Yet the formula that computes Legendre symbols via The Law of Quadratic Reciprocity looks purely combinatorial. It flips numerator and denominator with a sign correction. This almost begs to be extended past primality. The Jacobi symbol is exactly this extension. It is a multiplicative bookkeeping device defined for any odd positive denominator. It is built by multiplying Legendre symbols over the prime factorization. The payoff is enormous. Reciprocity for the Jacobi symbol lets us compute for huge and odd . We use an algorithm that looks exactly like the Euclidean algorithm. It is a sequence of reductions and flips. This runs in time polynomial in , without ever factoring . This is remarkable for one key reason. The Legendre symbol's own defining property (quadratic residue or not) genuinely depends on primality. Yet the Jacobi symbol strips this dependency away from the computation. It does this while sacrificing part of its meaning. A Jacobi symbol of no longer certifies that is a square mod . The big picture is this. The Jacobi symbol is a completely multiplicative function on the group of integers coprime to . It agrees with the Legendre symbol prime by prime. It also satisfies its own reciprocity law. This law mirrors quadratic reciprocity almost verbatim. This makes it the natural setting for fast primality tests (Solovay–Strassen). It also suits the definition of pseudosquares in cryptography. And it enables a cleaner theoretical treatment of quadratic forms over composite moduli. This article gives the precise definition and proves complete multiplicativity. It proves the three supplementary laws and the reciprocity law in full. It works two nontrivial numerical examples. It shows exactly where the Jacobi symbol fails to detect quadratic residues. This is the price paid for its computational freedom. It closes by pointing toward the algorithmic and cryptographic uses. These uses make this symbol indispensable in practice.
- The Jacobi symbol extends the Legendre symbol to any odd by multiplying over 's prime factors.
- It is completely multiplicative in both the top and bottom arguments (for odd, coprime, positive denominators).
- It satisfies its own reciprocity law: for odd coprime , .
- Supplementary laws for and hold in exactly the same form as for the Legendre symbol.
- Crucially, does not imply is a quadratic residue mod when is composite.
- Key idea: factoring out primality lets reciprocity become a fast recursive algorithm, at the cost of losing the residue-detection meaning.
Let be a positive odd integer with prime factorization
(where the are distinct primes, possibly giving ), and let be any integer. The Jacobi symbol is defined by
where each factor is the ordinary Legendre Symbol. By convention for every (the empty product). Thus the Jacobi symbol takes values in : it is if and only if , and otherwise it is .
Intuition
The definition is deliberately naive: to evaluate , factor and multiply Legendre symbols. This immediately shows the symbol is whenever is an actual quadratic residue mod (with ), because each prime-power Legendre-symbol factor is forced to be when is a square mod each . But the converse fails: the symbol can be by an even number of factors canceling, without being a square mod any of the individual primes dividing . This is the central subtlety of the whole theory, and it is why the Jacobi symbol is a computational tool rather than a residue-detector once is composite. The deeper reason the symbol is useful despite this is that its multiplicativity and reciprocity properties hold unconditionally, regardless of what is happening internally with residues. The proof of Jacobi reciprocity reduces cleanly to the prime case via a careful additivity argument on the exponents and that appear in the Legendre supplementary laws — the whole engineering effort of this article is checking that these exponents behave well modulo 2 under multiplication of odd numbers, so that products of prime factorizations reciprocate coherently.
Let be positive odd integers and integers.
(1) Multiplicativity in the top: .
(2) Multiplicativity in the bottom: .
(3) Supplementary law for : if is not required here since itself determines this;
(4) Supplementary law for :
(5) Reciprocity: if in addition , then
Define and for odd positive . Then for odd positive :
Equivalently, and .
Technique: direct algebraic identity via writing , . Write and with integers (since are odd). Then
so
This proves the first identity, since reducing an exponent of modulo 2 does not change the value . For the second identity, we use the standard fact that for any odd integer , (proof: , so , and is even, so is divisible by ; in fact one checks directly and the sharper mod-16 fact is not needed — we redo this cleanly below). Actually we only need , i.e. . Let . Then . Since is always even (product of consecutive integers), write ; then , so , which is the -th triangular number . We must show . Compute directly:
Divide by 8:
Since are odd, and (as shown: is an integer), so is divisible by , hence is divisible by , in particular even. Therefore modulo 2,
as required.
∎Proof of the Theorem. Technique: reduction to the Legendre symbol case via prime factorization, using multiplicativity of both the symbol and the reciprocity exponent (previous lemma). Write and, when needed, , with odd primes.
(1) Multiplicativity in the top. By definition,
For each prime , the Legendre symbol is completely multiplicative: . This is a standard property of the Legendre symbol, provable via Euler's criterion , since . Substituting,
(2) Multiplicativity in the bottom. The prime factorization of is the "concatenation" of the factorizations of and (multiply exponents of shared primes if ; if the prime sets are disjoint, but the argument works regardless since the Jacobi symbol definition is literally a product over the multiset of prime-power factors). Precisely, if (merging exponents where primes coincide), then by definition
directly from the definition applied separately to and to , since the definition of only depends on the multiset of prime-power factors of and multiplies Legendre-symbol contributions independently for each. No property of the Legendre symbol beyond its own definition is needed here; this is purely a statement about how the defining product behaves under merging factorizations.
(3) Supplementary law for . By definition and the known Legendre-symbol supplementary law (a standard consequence of Euler's criterion, part of The Law of Quadratic Reciprocity package),
We must show . This follows by repeated application of the additivity lemma: writing as a product of copies of each (i.e. , a product of odd primes with repetition), the lemma gives
by induction on the number of factors (base case one factor is trivial; inductive step is exactly the additivity identity of the Lemma applied to "current partial product" times "next prime factor"). Hence .
(4) Supplementary law for . Identical argument using the Legendre supplementary law and the second part of the additivity Lemma, by the same induction on the factorization of into (not necessarily distinct) odd primes:
(5) Reciprocity. Let and with , so no equals any . By definition and multiplicativity already established (parts 1–2 applied repeatedly, or directly from the definition):
Expand (Legendre symbol multiplicativity in the top, as in part 1 but now with the Legendre symbol directly) and similarly . Substituting,
Since are distinct odd primes, The Law of Quadratic Reciprocity gives
Substituting and combining exponents,
By the computation in part (3) above, and . Since we only care about the exponent modulo 2 (as it exponentiates ), we conclude
This completes the proof of all five parts.
∎Worked examples
Example 1: Evaluate where is prime, without directly testing quadratic residuosity. First check is odd (it is) and that : factor , and none of divides (since is prime and larger than each), so the gcd is and the symbol is . We use the Jacobi-symbol algorithm — reciprocity plus reduction mod the current denominator — even though happens to be prime, illustrating that the method doesn't care about primality of either argument. Step 1: . Both and are odd and positive, and coprime, so reciprocity applies. We have (since ) — actually let's directly track the sign via the formula . Compute (even) and (odd). The product is even (since is even), so the reciprocity sign is . Hence
Step 2: Reduce . Compute (check: , ). So
Step 3: Factor out powers of : , and is odd. So
Step 4: Evaluate . Since (as ), we have hence certainly is even (the standard supplementary rule states when ). So . Step 5: Now handle , both odd, coprime (since is prime and does not divide ). Reciprocity sign: (even), so the sign is automatically regardless of 's residue mod 4. So
Step 6: Reduce : (check: , ). So
Step 7: Reciprocity again: (odd), (even); product is even, sign :
Step 8: Reduce : (check: , ). So
Step 9: Reciprocity: (even), sign :
Step 10: Reduce : . So
Step 11: Reciprocity: (even), sign :
Step 12: Reduce :
(since and cubing a value in preserves it). Step 13: . Since , the standard rule gives (rule: when ). Let's double check via the formula: , , which is odd, so . Confirmed. Tracing back: every reciprocity sign used above was , and the only sign contribution is this final . So
This tells us is a quadratic non-residue mod the prime — and since is prime, this conclusion is fully justified (unlike in composite-modulus cases).
Example 2: Evaluate where is composite, and compare direct factorization with the reciprocity algorithm. Check validity: is odd. : , and share no common factor with , so gcd is . Method A: direct factorization. . (since ). Squares mod are ; is not among them, so . . We need . Use reciprocity (both primes, , so sign automatically regardless): . Reduce . So . Reciprocity: so sign : . Reduce : (any nonzero square is , since squaring gives ). So , hence . Therefore . Method B: Jacobi reciprocity directly on without factoring. : first pull out the factor of : , so
. Since (as ), the rule gives . Now : reciprocity sign ; both and are odd so the product is odd, sign is . So
Reduce : , so . Factor : . : reciprocity sign , odd times odd is odd, sign : . Reduce : . Since , rule gives . So . : reciprocity sign , odd, sign : . Reduce . . Since , rule gives . So , hence . So , thus , thus . Finally . Both methods agree: . Since the symbol is , we can immediately conclude is not a square mod (a value always correctly certifies non-residuosity — this direction never fails, as we prove below). The subtlety only arises when the symbol equals .
The reciprocity theorem requires ; dropping this makes the formula meaningless (the symbol may be and the exponent identity has no residue-theoretic content). But the more instructive failure, central to why the Jacobi symbol is not simply "a bigger Legendre symbol," is this: the implication " and is a square mod " is false for composite . Take and . Compute
Squares mod are (nonzero residues ; ), so is a non-residue mod : . Squares mod are ; is not among them, so . Hence
Yet is a quadratic non-residue mod both and mod individually, and by the Chinese Remainder Theorem, has a solution if and only if has a solution mod and mod simultaneously — which it does not, since it fails mod already. So is not a square mod , despite . This shows precisely what breaks: the Legendre symbol's residue-detection meaning relies on being a field, where the squares form an index- subgroup of and Euler's criterion converts symbol value into an exact residue test. For composite , splits (by CRT) into a product of the prime-power unit groups, and "being a square in the product" requires being a square in every factor — a much stronger condition than the product of signs being . The Jacobi symbol only ever sees the product of signs, so it cannot distinguish "even number of non-residue factors" from "residue in every factor." Note carefully what does not break: if , then some prime factor of must contribute to the product, and in particular for that prime (with odd), so is a non-residue mod , hence cannot be a square mod (again by CRT, since it already fails at one prime power). So the one-directional implication " is a non-residue mod " remains true; only the converse direction (from ) fails.
Scope, edge cases & common traps
| Situation | What holds | What can fail |
|---|---|---|
| prime | Jacobi symbol = Legendre symbol exactly | nothing — full residue-detection meaning holds |
| composite, symbol | is provably a non-residue mod | none; this direction is always valid |
| composite, symbol | multiplicativity/reciprocity still hold | does not imply is a residue mod |
| symbol is | reciprocity formula is vacuous/inapplicable | |
| even or negative | undefined in this article's convention | some texts extend to negative or even with extra care; formulas must be re-derived |
The most common mistake is treating for composite as proof that is solvable. It is only a necessary condition, never sufficient, once has more than one distinct prime factor (or a repeated prime factor with an odd total multiplicity contribution can also mask things). Always remember: the Jacobi symbol answers a question about a signed product, not a genuine existential quantifier over solutions, unless the denominator is prime.
The mathematician behind it
Jacobi was one of the most prolific mathematicians of the 19th century, renowned for foundational work on elliptic functions, the theory of determinants (the Jacobian), and dynamics (Hamilton–Jacobi theory). His introduction of the generalized symbol bearing his name, in an 1837 paper extending Gauss and Legendre's work on quadratic residues, was a small but structurally important piece of his broader program of turning number-theoretic identities into computational and algebraic machinery, a hallmark of his mathematical style across many fields.
Where this lives today
The Jacobi symbol's chief modern role is computational: because it can be evaluated in bit operations via a Euclidean-style recursive algorithm (exactly mirroring the worked examples above), it gives a fast way to compute Legendre symbols for large primes without needing to run Euler's criterion (which would require modular exponentiation, itself efficient but structurally different) — the two methods cross-check each other in implementations. This same fast evaluation underlies the Solovay–Strassen primality test, a foundational randomized algorithm in Cryptography and complexity theory: for a candidate prime , one checks whether for random , exploiting the counterexample phenomenon above (composite will often fail this check because the Jacobi symbol's verdict does not match true residue behavior). In cryptography, the gap this article highlights — that does not imply is a square mod — is not a bug but a feature exploited constructively: it defines the notion of a pseudosquare, an integer with Jacobi symbol that is nevertheless not a quadratic residue. The hardness of distinguishing true squares from pseudosquares modulo an RSA-like composite (the quadratic residuosity problem) underlies the semantic security of the Goldwasser–Micali public-key cryptosystem, one of the first schemes proven secure under a precise cryptographic hardness assumption. Beyond cryptography, the Jacobi symbol appears throughout analytic and algebraic number theory: in the theory of binary Quadratic Forms and their composition, in class field theory as a prototype for more general power-residue symbols (cubic and higher-order reciprocity), and in the study of character sums, where is used as a real Dirichlet character modulo when is not a perfect square, feeding into -functions and the analytic study of quadratic fields.
Ask the tutor: How does the Solovay–Strassen test use Euler's criterion together with fast Jacobi symbol computation to detect compositeness efficiently?
Is the Jacobi symbol defined when is even or negative?
The classical definition given here requires to be a positive odd integer, matching the article's convention. Many textbooks extend the definition to negative odd using conventions tied to the sign of , and some extend to or specific even cases with care, but these extensions require re-deriving multiplicativity and reciprocity from scratch since the proofs above rely essentially on unique factorization into odd primes and on the additivity lemma for and , both of which assume odd and positive. Within this article's scope, always assume and odd; consult specialized references before using extended conventions elsewhere.
Why does the Jacobi symbol equal the Legendre symbol when is prime?
When is an odd prime, the factorization in the definition collapses to the single term , so the defining product has exactly one factor: . So the Jacobi symbol reduces to exactly the Legendre symbol in this case, with no discrepancy — this is why all the supplementary laws and reciprocity look identical in form to their Legendre-symbol counterparts, since they must specialize correctly when happens to be prime.
Can the Jacobi symbol ever be used to prove is composite?
Yes, and this is precisely the mechanism behind the Solovay–Strassen primality test. If is an odd prime, then Euler's criterion guarantees for every coprime to . If one computes both sides for a random and finds they disagree, then cannot be prime (the criterion, applicable to Legendre symbols of primes, must have failed, so is composite), giving a probabilistic compositeness witness without needing to factor .
Does ever have any residue-related meaning for composite ?
It has a precise but weaker meaning: it says the number of prime-power factors of for which is a non-residue mod , counted with the parity of , is even. By the Chinese Remainder Theorem this is strictly weaker than " is a residue mod every prime power factor of ," which is the actual condition for to be a square mod (when ). The gap between these two conditions is exactly what defines a pseudosquare, discussed in the cryptography applications above.
How is the Jacobi symbol actually computed efficiently in practice?
The algorithm mirrors the worked examples: repeatedly extract factors of 2 from the numerator using the supplementary law for 2, then apply reciprocity to swap numerator and denominator (tracking the sign via , which only needs ), then reduce the new numerator modulo the new denominator, and repeat. This is essentially the binary/Euclidean GCD algorithm with sign bookkeeping, running in bit operations (or faster with binary-GCD-style optimizations), entirely avoiding factorization of either argument.
Is the Jacobi symbol a group homomorphism?
Yes, in the following precise sense: for fixed odd , the map restricted to (integers coprime to ) is a group homomorphism into , by the multiplicativity property proved above. This makes it a real-valued Dirichlet character modulo (when is not a perfect square, it is a nontrivial character), which is the perspective used in analytic number theory when studying -functions attached to quadratic fields.
What role does the additivity lemma for and play, conceptually?
It is the technical hinge that lets the entire theorem reduce to the prime case. Because Jacobi symbol identities are defined via products over prime factorizations, and because the Legendre-symbol supplementary laws and reciprocity law involve exponents and , one needs these exponents to combine additively (mod 2) when primes are multiplied together into a composite . Without this lemma, there would be no way to lift the prime-based reciprocity law to a genuine composite-denominator statement; with it, the lift is mechanical.