Modular Arithmetic II
Total Page:16
File Type:pdf, Size:1020Kb
Modular arithmetic II We now look at modular arithmetic again, to prove some results that we skipped over the first time. 1 Chinese remainder theorem We first prove what is commonly known as the \Chinese remainder theorem". As an application, this will let us quickly calculate φ(m) in terms of the prime factorization of m. Let's go ahead and state the result about φ(m), so that we are not burying the lede. a1 ar Theorem 1. Suppose m = p1 ··· pr is the prime factorization of m, so that aj ≥ 1 for j = Qr aj −1 1; 2; : : : ; r. Then φ(m) = j=1 (pj − 1)pj . Example 2. Here are two special cases of the theorem: 1. Suppose m = p1p2. Then φ(m) = (p1 − 1)(p2 − 1). So, for example, φ(15) = 2 · 4 = 8, as we computed before. 2. Suppose m = pj is a power of p. Then φ(m) = (p − 1)pj−1. So, for example, φ(9) = 2 · 3 = 6 and φ(27) = 2 · 9 = 18. Example 3. This is a non-example. Is there an integer x that is • ≡ 3 (mod 10) • ≡ 2 (mod 15)? The answer is \no", because such an x must on the one hand be 3 modulo 5 and on the other hand be 2 modulo 5. So, the problem, so to speak, is that 5j10 and 5j15, so there is a possibility for an obvious incompatibility between the two congruences. This leads us to Theorem 4 (Chinese Remainder Theorem). Suppose (m1; m2) = 1, and a1; a2 are two integers. Then there is an x with • x ≡ a1 (mod m1) • x ≡ a2 (mod m2). Moreover, such an x is unique modulo m = m1m2. Proof. Let's do uniqueness first. If x; x0 are two solutions to the above two congruence, then x − x0 0 0 is ≡ 0 modulo m1 and modulo m2. Thus m1j(x − x ) and m2j(x − x ). Because (m1; m2) = 1, 0 0 m = m1m2 divides x − x . Thus x ≡ x (mod m). For the existence, one proceeds as follows. As we have shown before, (m1; m2) = 1 implies that there exists integers y1; y2 with m1y1 + m2y2 = 1. From this equation, we obtain • m1y1 ≡ 0 (mod m1) and ≡ 1 (mod m2), while 1 • m2y2 ≡ 1 (mod m1) and ≡ 0 (mod m2). Set x = a2(m1y1) + a1(m2y2). Multiplying the above congruences by a2 and a1, respectively, and adding, one gets the desired result for x. Example 5. Note that 4 · 7 − 3 · 9 = 1. Find an integer x so that • x ≡ 4 (mod 7) • x ≡ 3 (mod 9). Answer: • 4 · 7 is ≡ 0 (mod 7) and 1 (mod 9) while • (−3) · 9 is ≡ 1 (mod 7) and ≡ 0 (mod 9). Thus 3 · 7 · 4 + 4 · 9 · (−3) = 12 · (7 − 9) = −24 is equivalent to 4 (mod 7) and ≡ 3 (mod 9). We could also take x = −24 + 63 = 39 for x. We stated a simple version of the CRT. Here is the more general version: Theorem 6. Suppose m1; m2; : : : ; mr are pairwise relatively prime, so that (mi; mj) = 1 if i 6= j. Let a1; : : : ; aj be integers. Then there is an integer x with x ≡ aj (mod mj) for j = 1; 2; : : : ; r. Moreover, x is unique modulo m = m1 ··· mr. Proof. Set m0 = m . Because m , m0 are relatively prime, there exists an integer b with m0 b ≡ 1 j mj j j j j j (mod mj). Set r X 0 x = mjbjaj: j=1 th th Then all but the j term in the sum is 0 modulo mj, while the j -term is equivalent to aj modulo mj. Thus x ≡ aj (mod mj) for each j. The uniqueness of x modulo m follows just as the m = m1m2 case of the CRT proved above. 2 Euler's φ function The function φ(m) is called Euler's φ function, or his \totient" function (not that you need to know that.) Recall Definition 7. For a positive integer m, φ(m) is the number of integers a with 1 ≤ a ≤ m and (a; m) = 1. In order to prove Theorem 1, we require the following lemma. Lemma 8. Suppose m = m1m2 with (m1; m2) = 1. Then φ(m) = φ(m1)φ(m2). Proof. We want to count the integers x with • 1 ≤ x ≤ m1m2 2 • (x; m1) = 1 • (x; m2) = 1. Equivalently, we want to count the x modulo m with (x; m1) = 1 and (x; m2) = 1. Suppose • a1; : : : ; aφ(m1) are the classes modulo m1 prime to m1 and • b1; : : : ; bφ(m2) are the classes modulo m2 prime to m2. Then (x; m1) = 1 and (x; m2) = 1 if and only if there is some j; k with • x ≡ aj (mod m1) and • x ≡ bk (mod m2). By the CRT, there exists a unique x modulo m for each pair (aj; bk). Thus, the total number of x with 1 ≤ x ≤ m1m2 and (x; m1) = 1, (x; m2) = 1 is φ(m1)φ(m2). Let's do an example: Take m = 15 = 3 · 5. ∗ 0 1 2 3 4 0 0 6 12 3 9 : 1 10 1 7 13 4 2 5 11 2 8 14 The table shows the 15 residue classes modulo 15. Which row a number sits in say what this number is modulo 3, and which column a number sits in says what this number is modulo 5. The way to make such a table is to start with the 0 in the upper left corner, and move \southeast", writing in 0; 1; 2; :::. And then, when one reaches the bottom one \wraps around" to the top, and when one reaches the right edge, one \wraps around" to the left. Note that all the numbers that are outside the 0th row and column are the residue classes that are relatively prime to 15. So, the picture shows that φ(15) = φ(3)φ(5) = 2 · 4. From Lemma 8, we can now prove Theorem 1: Proof of Theorem 1. We have φ(p) = p − 1 if p is a prime. More generally, consider powers of primes. If 1 ≤ x ≤ pj, then x is prime to pj if and only if x is prime to p. So φ(pj) = pj − pj−1 because • pj is the number of x with 1 ≤ x ≤ pj • pj−1 is the number of multiples of p between 1 and pj. j j−1 Thus φ(p ) = (p − 1)p . Theorem 1 thus follows from φ(m1m2) = φ(m1)φ(m2) when m1; m2 are relatively prime. We are getting closer to proving Theorem 9. If p is a prime, then there exists g with ordp(g) = p − 1. Our proof uses the following proposition about the Euler φ-function. 3 Proposition 10. One has X φ(d) = m: djm For example • m = p, then φ(1) + φ(p) = 1 + (p − 1) = p • m = p1p2, then φ(1) + φ(p1) + φ(p2) + φ(p1p2) = 1 + (p1 − 1) + (p2 − 2) + (p1 − 1)(p2 − 1) = p1p2: Proof of Proposition 10. If m is prime, we are done by the above example. Otherwise, m = m1m2 for some integers m1; m2 with 1 < mj < m and (m1; m2) = 1. Now, note that an integer djm if and only if d = d1d2 for integers d1; d2 where d1jm1 and d2jm2. Thus X X φ(d) = φ(d1d2) djm d1jm1;d2jm2 X = φ(d1)φ(d2) d1jm1;d2jm2 0 1 0 1 X X = @ φ(d1)A @ φ(d2)A d1jm1 d2jm2 = m1m2: The last equality follows by induction. 3 Generators modulo p We are almost ready to prove Theorem 9. For p a prime, and h an integer, denote by Np(h) the number of nonzero residue classes r modulo p with ordp(r) = h. Lemma 11. With notation as above, Np(h) ≤ φ(h). In fact, Np(h) = 0 or Np(h) = φ(h). Proof. If there are no elements r with ordp(r) = h, then Np(h) = 0 and we are done. Thus, suppose h ordp(r) = h. Then, r is a solution to x − 1 ≡ 0 (mod p). We have already proved that degree h equations have at most h roots modulo p, so Np(h) ≤ h. Why ≤ φ(h)? 2 h−1 • ordp(r) = h ) 1; r; r ; : : : ; r are distinct modulo p • these powers of r are solutions to xh − 1 ≡ 0 (mod p) • Thus, these powers of r are the only solutions to xh − 1 ≡ 0 (mod p). d h • However, we have already proved ordp(r ) = gcd(h;d) . 4 d • Thus, ordp(r ) = h if and only if (d; h) = 1. Therefore, the classes modulo p with order h are exactly the rd with (d; h) = 1. Consequently, if Np(h) ≥ 1 then Np(h) = φ(h). This proves the lemma. Let's show how the proof of Theorem 9 works in an example, so you get the idea: Example 12. Suppose p = 23. Then φ(p) = 22 = 2·11. Therefore, the possible orders for elements modulo p are the divisors of p − 1 = 22, so 1; 2; 11; 22. h 1 2 11 22 : N(h) ≤ φ(1) = 1 ≤ φ(2) = 1 ≤ φ(11) = 10 ≤ φ(22) = 10 On the one hand, the lemma puts an upper bound on the number Np(h) for each possible h. But P on the other hand, because every element modulo p has some order, hjp−1 Np(h) = p − 1. Since 1 + 1 + 10 + 10 = 22 = p − 1, all the ≤ must be equalities. In particular, φ(22) = 10 ≥ 1, proving that there is a g with ord23(g) = 22.