THE JACOBI SYMBOL For any odd prime number p and any integer

THE JACOBI SYMBOL
For anyodd
prime number p and any integer a not divisible by p, we have defined the Legendre
a
symbol p to be 1 if a is a quadratic residue modulo p, and −1 otherwise. In practice, the value
of a Legendre symbol can be efficiently computed by using Euler’s Criterion.
Theorem (Euler’s Criterion). Let p be an odd prime number, and a an integer not divisible by p.
Then
a
≡ a(p−1)/2 (mod p).
p
15
Example. To determine the value of
, we can compute 1518 (mod 37) by using successive
37
squaring.
152 ≡ 3
4
Thus
1518
≡ 12 · 3 ≡ −1 (mod 37), so
(mod 37)
15 ≡ 9
(mod 37)
158 ≡ 7
(mod 37)
16
15
≡ 12
15
37
(mod 37)
= −1.
We’ve seen that the Legendre symbol has the following properties:
• If a ≡ b (mod p), then ap = pb .
b
= ap
• ab
p
p
• −1
= (−1)(p−1)/2
p
2
• p2 = (−1)(p −1)/8
Furthermore, we will work through Eisenstein’s proof of the following reciprocity law.
Theorem (Quadratic Reciprocity). Let p and q be distinct odd primes. Then
p−1 q−1
p
q
=
(−1) 2 · 2 .
q
p
This reciprocity theorem, together with the properties of the Legendre symbol listed above, provides
a second way of determining the value of a Legendre symbol: given a, we can factor
a = (−1)ε · 2e · pe11 · · · perr ,
where
ε = 1 or 2 and p1 , . . . , pr are distinct odd primes (and different from p). Then the symbol
a
p can be computed by using the multiplicativity of the Legendre symbol and the various rules
stated above.
1
15
by using the above method.
37
15
3
5
37
37
1
2
=
=
=
= −1.
37
37
37
3
5
3
5
Example. We recompute the value of
From a computational standpoint, this method for computing the Legendre symbol (a/p) is very
fast once the factorization of a is known, but would be prohibitively slow if a is a large integer
whose factorization is not known.
The Jacobi symbol is a generalization of the Legendre symbol that is of great theoretical importance.
In addition, it proves to be a very useful computational tool, as it allows us to sidestep the issue of
factorization in computing a Legendre symbol.
Definition. Let n be an odd positive integer, and let n = p1 · · · pr be its factorization
into (not
necessarily distinct) primes. If a is any integer coprime to n, the Jacobi symbol na is defined by
the formula
r a Y
a
=
.
n
pi
i=1
5
5
Example. 111
= 53 37
= 32 52 = (−1)(−1) = 1.
We will see that the Jacobi symbol inherits many – but not all – of the properties of the Legendre
symbol.
Theorem (Properties of the Jacobi symbol). Let n be an odd positive integer, and let a and b be
integers coprime to n. Then the following hold.
• If a ≡ b (mod n), then na = nb .
b
a
• ab
n = n
n
a
a
a
• mn = m n if m is odd and positive.
Proof. Easy from the definitions and the corresponding properties of the Legendre symbol.
Caution: While it is true that if a is a square modulo n then na = 1, the converse does not hold
in general. You will be asked to provide an example of this in your homework.
Theorem. Let n be an odd positive integer. Then
(a) −1
= (−1)(n−1)/2
n
2
(b) n2 = (−1)(n −1)/8
Proof. We will prove part (a), and part (b) will be left as an exercise. Before doing the general
case, consider first the case when n = pe is a prime power. Then
e
−1
−1
−1
=
=
= (−1)e(p−1)/2 .
e
n
p
p
Thus, we need to show that (n − 1)/2 is congruent to e(p − 1)/2 modulo 2, or equivalently, that
n − 1 ≡ e(p − 1) (mod 4). We are therefore required to show that
(1)
pe − 1 ≡ e(p − 1)
2
(mod 4).
If p ≡ 1 (mod 4), this is obvious since both sides of the congruence are 0. If p ≡ 3 (mod 4), then
(1) becomes
pe − 1 ≡ 2e (mod 4).
At this point we need to consider two cases. If e is even, say e = 2k, then
pe = (p2 )k ≡ 1k ≡ 1
(mod 4),
and so the congruence holds because both sides are 0. If e is odd, say e = 2k + 1, then
pe = p(p2 )k ≡ p · 1k ≡ p ≡ 3
(mod 4),
pe
so
− 1 ≡ 2 (mod 4). Hence, the congruence holds because both sides are 2 modulo 4. This
proves the result when n is a prime power.
For the general case, factor n = pe11 · · · perr . Then, by definition,
Y
r r
P
−1 ei Y
−1
=
=
(−1)ei (pi −1)/2 = (−1) i ei (pi −1)/2 .
n
pi
i=1
i=1
P
We therefore have to show that (n − 1)/2 ≡ ri=1 ei (pi − 1)/2 (mod 2), or equivalently, that
n−1≡
(2)
r
X
ei (pi − 1)
(mod 4).
i=1
Using (1) we have
n=
r
Y
pei i
≡
i=1
r
Y
(1 + ei (pi − 1))
(mod 4).
i=1
Expanding this product and noting that (pi − 1)(pj − 1) ≡ 0 (mod 4) for all i, j, we obtain
n≡1+
r
X
ei (pi − 1)
(mod 4),
i=1
and (2) follows immediately.
Theorem (Quadratic Reciprocity for the Jacobi symbol). Let a and b be positive odd integers with
gcd(a, b) = 1. Then
a b a−1 b−1
=
(−1) 2 · 2 .
b
a
Proof. We will need the following preliminary result.
Lemma. If r1 , . . . , rm are odd integers, then
m
X
ri − 1
r1 r2 · · · rm − 1
≡
2
2
(mod 2).
i=1
Proof. This is a simple induction on m. Consider first the base case m = 2. Then we have to show
that
r1 − 1 r2 − 1
r1 r2 − 1
+
≡
(mod 2),
2
2
2
or equivalently, that r1 + r2 − 2 ≡ r1 r2 − 1 (mod 4). This follows immediately from the observation
that (r1 − 1)(r2 − 1) ≡ 0 (mod 4) since both r1 and r2 are odd.
3
To prove the theorem, factor a = p1 · · · pr and b = q1 · · · qs . Then
a b Y Y p q P
j
i
=
= (−1) i,j
b
a
qj
pi
i
pi −1 qj −1
· 2
2
.
j
By the lemma, we have
X X pi − 1 qj − 1 X pi − 1 X qj − 1 X pi − 1 b − 1
·
=
·
≡
·
2
2
2
2
2
2
i
j
i
j
i
b − 1 X pi − 1
b−1 a−1
≡
·
≡
·
2
2
2
2
(mod 2).
i
Therefore,
a b b
a
= (−1)
b−1 a−1
· 2
2
,
and the result follows.
The Jacobi symbol is a convenient aid for computing Legendre symbols without factoring.
Example.
173
43
65
22
2
11
11
65
=
=
=
=
=
·
=−
173
65
65
43
43
43
43
43
43
10
2
5
5
11
1
=
=
=
=−
=−
=−
= −1.
11
11
11
11
11
5
5
Note that we are in the end computing a Legendre symbol, but we had to use a few Jacobi symbols
to obtain the result. The key point of this example is that we did not need to factor 65.
Remark. For applications to cryptography and primality testing it’s very important to be able
to quickly compute Legendre symbols. The method which uses Euler’s Criterion together with
successive squaring to compute a(p−1)/2 (mod p) is fast, running in time O(log3 p). However, the
method using the Jacobi symbol as above is even faster, running in time O(log2 p).
4