The Law of Heng Li

History of the Law of Quadratic Reciprocity

The law of quadratic reciprocity is a theorem that provides conditions for the solvability of quadratic equations modulo prime numbers. Theorem states that

For any distinct odd prime p, q. Then     p q p−1 · q−1 = (−1) 2 2 q p Also

 1, p ≡ ±1 (mod 8) −1 p−1 2  = (−1) 2 and = p p −1, p ≡ ±3 (mod 8)

Fermat, Euler, Lagrange, and Legendre, all have considered this theorem in their own way, and they have provided a lot of helpful mathematical works on the quadratic reciprocity for later scholars.

Pierre de Fermat was a French amateur mathematician, throughout his life he has worked in many different areas of mathematics. He’s well known by his ”Fermat’s last theorem”, a theorem that took more than 300 hundred years for the mathematical community to proof. He’s also known as the founder of the . Fermat is the first one who discovered the concept of . He stated the conjecture, For a p:

P = x2 + y2 if and only if p = 2 or p ≡ 1 (mod 4)

After this conjecture, he also stated another similar theorems, For primes of the form,

x2 + ny2 for n = ±2, ±3, −5

Fermat never stated the law of quadratic reciprocity, it was these theorem and conjecture that Fermat have stated. Which Euler continued to studied on then led to the discovery of quadratic reciprocity.

Leonhard Paul Euler was a Swiss mathematician, he was one of the most famous mathematicians of the 18th century. He is the first person to state the law of quadratic reciprocity. Euler had a great interest in number theory and worked on many of Fermat’s conjectures and theorems. The first proof that relates to quadratic reciprocity that Euler has provided is Euler’s Criterion for Quadratic Residue.

In the year 1744, Euler first stated a theorem that was equivalent to the law of quadratic reciprocity without proofs. Euler finally stated the law of quadratic reciprocity in the year 1783. However, the theorem was not published after his death. From 1744 to 1783 about forty years, Euler, one of the greatest mathematicians was not able to provide a proof for the quadratic .

Another mathematician that has made a major contribution to the law of quadratic reciprocity is Adrien- Marie Legendre. Legendre was a French mathematician, just like Fermat, he also worked in many fields of mathematics, but most of his works were about number theory. Legendre did a lot of work on quadratic reciprocity. Throughout Legendre’s life he provided two proofs for the law of quadratic reciprocity, however, both of these proofs were later found invalid. Even though, his proofs were incomplete and invalid, but he has provided many insightful ideas for later scholars, and today mathematicians are still using many of his notations and statement. For example, his Legendre symbol. He introduced his Legendre symbol in his second major publications ”Essai sur la Theorie des Nombres” Today, the Legendre symbol is widely used regarding the law of quadratic reciprocity, and today the law of quadratic reciprocity is expressed in the Legendre symbol. Another interesting fact about Legendre is that he is actually the first one who started to use the word ”Reciprocity” in a mathematical way, in another word somewhat Legendre named the law of quadratic reciprocity.

Johann was a German mathematician who has made significant contributions to many areas of mathematics including number theory. Gauss was also known as the Prince of Mathematics. He was very well known by the story of how he quickly find the sum from 1 to 100. Gauss provided the first proof of quadratic reciprocity on April 8, 1796 when he was only 19. Then later the proof was published in his work ”Disquisitiones Arithmeticae”(Latin: Investigations in Arithmetic.) Gauss was so into the theorem that he called the law of quadratic reciprocity, ”Theorema Aureum” (the golden theorem), and throughout his lifetime he provided a total number of eight proofs for the law of quadratic reciprocity.

The law of quadratic reciprocity have gathered the attentions of some of the most famous and greatest math- ematicians. Until today, there is a total of 233 proofs of the law of quadratic reciprocity have been published. The law of the quadratic reciprocity provides a fast algorithm to compute Legendre symbols, and extremely useful for the problem p = x2 + ny2. Besides the importance in the number theory, the law of quadratic reciprocity is also very important to mathematical cryptography, especially in probabilistic encryptions. For example the Goldwasser-Micali public key cryptosystem is largely based on the law of quadratic reciprocity. The following is some intuition of the idea of Goldwasser-Micali cryptosystem,

Let p, q be secret primes and let N = pq. For a given integer a, determine whether a is a square mod N.

In this particularly situation, L gendre symbols, quadratic residues, and the law of quadratic reciprocity are very useful and crucial to the cryptosystem.

Quadratic Residue

To prove the law of quadratic reciprocity, we need to define and prove many other thing first. Quadratic Residue is one of them.

Defination of quadratic residue:

Let a, m be some integers with gcd(a, m) = 1 If there exists an integer x such that x2 ≡ a (mod m). Then a is called a quadratic residue (mod m)

If there’s no such x exist then a is called a quadratic non-residue (mod m).

i.e x2 ≡ Q (mod p) Here we know that Q is a quadratic residue, because there exist an x, such that x2 (mod p) is congruent to Q (mod p).

Let’s say p = 7 , Q = 4. So x2 ≡ 4 (mod 7)

2 We can see that there is an integer x , such that x2 = 4.

22 ≡ 4 (mod 7)

Fermat’s Little Theorem

Fermat’s little Theorem states that, Let p be a prime number, for any integer a. The number ap − a is an integer multiple of p. In the notation of ,

ap ≡ a (mod p)

p−1 If p - a, then a − 1 is an integer multiple of p, or:

ap−1 ≡ 1 (mod p)

Euler’s Criterion for Quadratic Residue

It would be easier for us to proof the law of quadratic reciprocity if we know the Euler’s criterion for quadratic residue

Theorem: p−1 p−1 If p is an odd prime with p - a, and a is a quadratic residue (mod p) then a 2 ≡ 1 (mod p). a 2 ≡ −1 (mod p) if a is a quadratic non-residue.

In Legendre symbol(which we will define later):

a = 1 p if an only if: (p−1) a 2 ≡ 1 (mod p)

P roof :

Note for any a with p - a

p−1 2 p−1 (a 2 ) ≡ a ≡ 1 (mod p)

So, (p−1) a a 2 ≡ p 

Legendre Symbol

In order to prove the law of quadratic reciprocity, we must first define the Legendre Symbol.

Let p be an odd prime and a be an element of integer with p does not divide a.

3 a Then Legendre symobol is defind as 1 if a is a quadratic residue (mod p), −1 if a is a non-quadratic q residue (mod p).

a i.e for 7 does not divide a q

12 ≡ 1 (mod p) 22 ≡ 4 (mod 7) 32 ≡ 2 (mod 7) 42 ≡ 2 (mod 7) 52 ≡ 4 (mod 7) 62 ≡ 1 (mod 7)

Here we can see that 1, 2, 4 are quadratic residue (mod 7)

Therefore in Legendre symbol: 1 2 3 4 5 = 1 = 1 = −1 = 1 = −1 7 7 7 7 7 6 = −1 7 Elementary Properties of Legendre Symbol

Let p be an odd prime and a, bZ with p - a, b Then

i/ ab a  b  = p p p

ii/ a  b  if a ≡ b (mod p) then = p p

iii/ a2  = 1 p

The second and third properties are very simple and straight forward. But we still need to proof that the first property is true. In this proof we will be using Euler’s criterion for quadratic residue that we have talked about earlier.

T heorem : Let p be an odd prime and a, bZ with p - a, b. Then, ab a  b  i/ = p p p P roof : ab p−1 ≡ (ab) 2 (mod p) p This also congruent to, p−1 p−1 a 2 ∗ a 2 (mod p)

4 p−1 a We know that in Euler’s criterion that a 2 ≡ (mod p) p Such that, ab a  b  ≡ p p p 

Gauss’s Lemma

We are using Gauss’s Lemma to proof the law of quadratic reciprocity, so we need to proof Gauss’s Lemma first.

Gauss’s Lemma:

Let p be an odd prime and a is an integer with p - a. Consider the following set of Values

p − 1 {a, 2a, 3a, ...... , a (mod p)} 2 −p p reduced each of them to a value between − 2 and 2 .

Let v be the number of negative value in the resulting set. Then a = (−1)v p a Thus the value of the Legendre Symbol depends only on the pravity of v. In here we do not need to p know the specific value of v. All we have to know is the v’s value of (mod 2).

P roof:

Let’s say l1a, ....., lva are congruent to the negative values and {−l(v+1)a, ...., −l p−1 } are all congruent to ( 2 a) positive values.

We claim that as subset of Zp p − 1 {−l1a, ....., −lva, l(v+1)a, ...., l( p−1 a)} = {1, 2, ....., } 2 2

p−1 p−1 Note: There are 2 values have listed, they are all elements of { 1, 2, ....., 2 } We must show that they are distinct. {−l1a, ....., −lva} are distinct from each other and {l(v+1)a, ...., l p−1 } ( 2 a) are distinct from each other. The only thing we have to worry about is wether there an element exist in negative values is same as one of the element in the positive values.

Suppose that there’s is such element exist, so,

−lia ≡ lja (mod p)

5 Then this implies that (lj + li)a ≡ 0 (mod p) Which Means that, p|(lj + li)

Since p - a and p − 1 0 < l ≤ j 2 and p − 1 0 < l ≤ i 2

So this implies that, p − 1 p − 1 0 < (l + l ) ≤ + i j 2 2 And we can rewrite as this, 0 < (li + lj) ≤ p − 1

Right now, it’s saying that p is a divisor of (lj + li), and (lj + li) is between 0 and p − 1. This is impossible. Therefore this is a contradiction. So the elements have to be distinct from one another.

We have already shown that p − 1 {−l1a, ....., −lva, l(v+1)a, ...., l( p−1 a)} = {1, 2, ....., } 2 2 are distinct from one another. Such that, p − 1 {(−l1a) · (−l2a) · ...... (−lva) · (l(v+1)a) · ...... (l( p−1 )a)} ≡ {1 · 2 · 3 · ...... · } (mod p) 2 2

We see that, p − 1 p − 1 {1 · 2 · 3 · ...... · } = ! 2 2 We can also see that,

v p−1 {(−l1a) · (−l2a) · ...... (−lva) · (l(v+1)a) · ...... (l p−1 a)} = {(−1) · a 2 · l1 · l2 · ...... · l p−1 } ( 2 ) 2

· v p−1 p − 1 ··{(−1) · a 2 · l1 · l2 · ...... · l p−1 } ≡ ! (mod p) 2 2 From the above we can see that, p − 1 {l1 · l2 · ...... · l p−1 } = ! 2 2 p−1 So we can cancel the term 2 ! on both side. Then we got,

v p−1 (−1) · a 2 ≡ 1 (mod p)

6 p−1 a According to Euler criterion of quadratic residue that a 2 is actually the same as the Legendre symbol . p So we can rewrite the equation as, a (−1)v · ≡ 1 (mod p) p a Since is either 1 or −1, So we can rewrite the equation again as, p a ≡ (−1)v (mod p) Q.E.D p

Properties of Greatest Integer Function

For xR, [x] denotes the greatest integer less than or equal to x. i/: For any integer n and real number x,[x + n] = [x] + n. ii/: For any real number x,

 [−x], x  Z [−x] =  −[x] − 1, xR iii/: if (α, β) is an interval of real and non-integer end points, then the numbers of integer in (α, β) is [β] − [α].

Formula for v in Gauss’s Lemma a We have already proven the Gauss’s Lemma, and shown that = (−1)v. Now, we need a formula to find p such v.

Let a be a positive integer and p be an odd prime with p - a. Our task is to determine the value of v in Gauss’s p−1 Lemma. First we must count the numbers of values a, 2a, 3a, ....., 2 a (These numbers are positive integers). When you reduce them (mod p) and they will belong to one of the following intervals. p 3 5 1 ( , p), ( p, 2p), ( , 3p), ...... , ((b − ), bp) 2 2 2 2

p−1 1 p+1 a where b satisfies the following two conditions, 2 a < (b + 2 )p and ( 2 a < bp), and b = [ 2 ] will satisfies both of the conditions.

By choosing b as the above, v is just the number of multiples of a in one of the interval that was listed above. The interval above are of the form 1 ((j − )p, jp) 2 where j runs from 1 to b.

Our task now, is to count the number of values of k such that, 1 ka ∈ ((j − )p, jp) 2

7 for j is running from 1 to b. This equation is also equivalent to, 1 p p k∈((j − ) , j ) 2 a a

Let a be a positive integer, and p be an odd prime with p - a. The value of v that occurs in the Gauss’s Lemma is given by, b X p 1 p v = [j ] − [(j − ) ] a 2 a j=1 a where b is [ 2 ]

The Key Lemma for Quadratic Reciprocity

Before our final proof of the law of quadratic reciprocity, we need to proof the following lemma first.

Lemma: a a Let a be a positive integer, and p, q be odd prime, and with p a, q a. If p ≡ ±q (mod 4a), then = . - - p q

a P roof: Let’s Recall = (−1)v in the Gauss’s Lemma, where p

b X p 1 p v = [j ] − [(j − ) ] a 2 a j=1

a and = (−1)v, where q b X q 1 q v0 = [j ] − [(j − ) ] a 2 a j=1

0 We must show that v ≡ v (mod 2). Let’s say that p = ±q + 4at, t∈Z

b X p 1 p v = [j ] − [(j − ) ] (mod 2) a 2 a j=1

Now, we substitue ±q + 4at for p. So we got,

b X ±q + 4at 1 ±q + 4at v = [j · ] − [(j − ) · ] (mod 2) a 2 a j=1

b 1 1 X ±jq 4jat ±(j − )q (j − )4at v = [ + ] − [ 2 + 2 ] (mod 2) a a a a j=1

1 4jat (j− 2 )4at We can cancel the a in a and a . So we now have,

b 1 X ±jp ±(j − )q 1 v = [ + 4jt] − [ 2 + (j − )4t] (mod 2) a a 2 j=1

8 1 Because of we only care about their value of (mod 2), and we can see that 4jt and (j − 2 )4t are even integers. So we can pull them out of the bracket and take the (mod 2) value of them. Now, we left with,

b X ±jq 1 q v = [ ] − [±(j − ) ] (mod 2) a 2 2 j=1 We can clearly see that, if we substitute +q + 4at, we will get,

b X jq 1 q v = [ ] − [(j − ) ] a 2 a j=1

Which is same as v0. Such that we have verified that v = v0 (mod 2) in the case of q + 4at. If we write our equation in − case, then we will have,

b X −jq 1 q v = [ ] − [−(j − ) ] a 2 a j=1 let’s recall the properties of greatest integer function, that  [−x], x∈  Z [−x] =  −[x] − 1, x∈R So We apply this to the equation, then we can rewrite it as,

b X jq 1 q v = ([ ] − 1) − ([(j − ) ] − 1) a 2 a j=1 We see that -1 is in both of the terms, so they cancel each other, then we left with,

b X jq 1 q v = [ ] − [(j − ) ] a 2 a j=1

Now we have proved that in both cases we will get v = v0. Which means that if p ≡ ±q (mod 4a), then a a = . p q 

Proof of the Law of Quadratic Reciprocity

T heorem : For any distinct odd prime p, q. Then     p q p−1 · q−1 = (−1) 2 2 q p Also

 1, p ≡ ±1 (mod 8) −1 p−1 2  = (−1) 2 and = p p −1, p ≡ ±3 (mod 8)

9 P roof :

First, suppose p ≡ q (mod 4), let’s say that p = q + 4t, for t∈Z. So, p q + 4t = q q

For Legendre symbol, we only need the value of the top mod the bottom. So,

p q + 4t 4t 4  t  = = = q q q q q

4 is a perfect square for q so, p  t  = q q

Same for q, q  p − 4t −4t −1  t  = = = p p p p p Since p ≡ q (mod 4t), because p = q + 4t. So, by our key lemma,

q  −1  t  −1  t  = = p p p p q

p q  −1 Now, we have that and differ by . Thus, q p p             p q −1 p q −1 p−1 p−1 · q−1 = = = = (−1) 2 = (−1) 2 2 q p p q p p

Next, suppose that p 6≡ q (mod 4). So p ≡ −q (mod 4), and p = −q + 4t, t∈Z. In this case, we have, p −q + 4t 4t  t  = = = q q q q

q  −p + 4t 4t  t  = = = p q p p

    t t p−1 · q−1 Since p ≡ −q (mod 4t). The key lemma implies that = . Also, since (−1) 2 2 = 1. This proof q p is complete. Q.E.D.

10 References

1. https://crypto.stanford.edu/pbc/notes/numbertheory/quadrecip.html

2. http://math.uga.edu/~pete/4400qrlaw.pdf 3. http://www.barzilai.org/math_sym.htm

4. http://wstein.org/edu/2007/spring/ent/ent-html/node48.html

5. https://www.youtube.com/watch?v=ZZHkTIW-25o&index=1&list=PLPRfta3h6E3E0xt4eE8hnXlIuMkau34ZA

6. https://www.youtube.com/watch?v=LKeWqxfU8PI

7. http://seanelvidge.com/wp-content/uploads/2011/04/HistoryQR.pdf

8. https://en.wikipedia.org/wiki/Quadratic_reciprocity

9. http://math.stackexchange.com/questions/10233/uses-of-quadratic-reciprocity-theorem

11