1 Chapter 8: Congruences Practice HW p. 62 # 1, 2, 3, 5, 6, Additional Web Exercises In this section, we look at the fundamental concept of modular arithmetic, which is used in a variety of applications in number theory. Modular Arithmetic Definition: Given two integers a, b and a positive integer m , we say that a is congruent to b modulo m, written a b (mod m) if m | (a b) . The number m is called the modulus of the congruence. Example 1: Explain why 23 3 (mod 5), 48 12 (mod 6) but 20 3 (mod 4) . Solution: 23 3 (mod 5) and 48 12 (mod 6) since 5 | (23 3) or 5 | 20 and 6 | (48 12) or 6 | 36 . However, 20 3 (mod 4) since 4 | (20 3) or 4 | 17 . █ Theorem: a b (mod m) if and only if a b km for some integer k Proof: █ 2 Fact: Computationally, b (mod m) gives the integer remainder of b m . We say that a b (mod m) if a and b produce the same integer remainder upon division by m. For example, 23 8 (mod 5) since both 23 and 8 produce are remainder of 3 when divided by 5, that is 23 (mod 5) 3 and 8 (mod 5) 3 . We can write 23 8 3 (mod 5) . Note: When performing modular arithmetic computationally, the remainder r should never be negative (this fact comes from the division algorithm that when computing b qm r for b m that 0 r m ). Hence, when finding the remainder for b (mod m) , look for the nearest integer that m divides that is less than b. Example 2: Compare computing 23 (mod 9) with 23 (mod 9) . Solution: █ 3 Doing Modular Arithmetic For Larger Numbers With A Calculator To do modular arithmetic with a calculator, we use the fact from the division algorithm that b qm r , and solve for the remainder to obtain r b qm . We put this result in division tableau format as follows: m q b qm b qm r Take Floor of Quotient (largest integer less than calculator value of b m ). (1) Remainder Example 3: Compute 1024 (mod 37) Solution: █ 4 Example 4: Compute 500234 (mod 10301) 500234 48.6 . The largest integer less than 48.6 10301 is 48. Hence, we assign q = floor(48.6) = 48. If we let b= 500234 and m = 10301 in (2), then 48 10301 500234 . Solution: Using a calculator, we obtain 494448 5786 The remainder of the division is r = 5786. Hence, 500234 (mod 10301) 5786 . █ Example 5: Compute 3071 (mod 107) 3071 28.7 . The largest integer less than 107 28.7 is 29 . Hence, we assign q = floor(-28.7) = -29. If we let b= -3071 and m = 107 in (2), then Solution: Using a calculator, we obtain 29 3071 107 3103 32 Thus, 3071 (mod 107) 32 Maple Commands for Doing Modular Arithmetic Compute 1024 (mod 37) > 1024 mod 37; Compute 500234 (mod 10301) > 500234 mod 10301; Compute 3071 (mod 107) > -3071 mod 107; █ 5 Generalization of Modular Arithmetic Fact: The common remainder of two numbers have when they are divided can be used to define a congruence class. The remainder r will be the smallest positive integer in the congruence class. Suppose r is the remainder of x divided by m, that is x r (mod m). Theorem 1 says that then x r km , where k is an integer. Example 6: Find all elements of the congruence class x 4 (mod 7) . Solution: █ Example 7 Find congruence class 2 modulo 7. Solution: █ Note: For x b (mod 7) , the set of distinct congruence classes are 0 , 1 , 2 , 3 , 4 , 5 , and 6 . This partitions the integers Z into disjoint subsets. 6 Fact: Given x b (mod m) , Z can be partitioned into distinct congruence classes of the form _____ 0, 1, 2, 3, m 1 Facts about Congruences 1. If a b (mod m) , then a t b t (mod m ) and at bt (mod m) for any integer t. Proof: █ 7 2. If a1 b1 (mod m) and a2 b2 (mod m) , then a1 a2 b1 b2 (mod m) , a1 a2 b1 b2 (mod m) and a1a2 b1b2 (mod m) . Proof: █ Note: Computationally, in mod m arithmetic, we have [a1 a2 ak ](mod m) [a1 (mod m) a2 (mod m) a k (mod m)] (mod m) [a1 a2 ak ](mod m) [a1 (mod m) a2 (mod m)ak (mod m)] (mod m) For example, we can by simplify 50 mod 3 as Now, consider the problem of solving ax c, a 0 8 Solving Equations Involving Congruences We want to consider the problem of solving the linear congruence equation ax c (mod m) for x. For example, consider the problem of solving the linear congruence 4 x 2(mod 10) Note that we can see that x 3 is a solution since x 3 4(3) 12 mod 10 2 Also, it can be seen that x 13 is a solution since x 13 4(13) 52 mod 10 2 However, x 3 and x 13 are in the same congruence class modulo 10, since both 3 mod 10 3 and 13 mod 10 3 . We want solution representations that are not in the same congruence class. These solutions are called incongruent solutions. Fact: One way to find all of the incongruent solutions when solving a congruence for x in mod m arithmetic, set x 0, 1, 2, 3, , m 1 and find the values of x that satisfies the congruence. This is known as the method of brute force for finding the incongruent solutions. Example 8: Find the incongruent solutions to 4 x 2(mod 10) . Solution: █ 9 However, the brute force method becomes less practical for finding incongruent solutions to congruences with larger moduli, like for example, solving the congruence 1000 x 2000 (mod 1076) The next theorem deals with this issue. Theorem: Linear Congruence Theorem. Let a, c, and m be integers where m 1 and let g gcd( a, m). For ax c (mod m) * i.) ii.) If g | c , then * has no solutions. If g | c , then * has exactly g incongruent solutions. To find these g incongruent solutions , we first using the Euclidean Algorithm remainder solution process to find a solution ( x , y ) to the equation ax my g gcd( a, m) Then a complete set of incongruent solutions is given by c x m x k (mod m), g g k 0, 1, 2, , g 1 Proof: To prove part i, suppose there is a solution to ax c (mod m) when g | c . Since ax c (mod m) , then by the definition of congruence m | ( ax c ) , or ax c tm or ax tm c Since g gcd( a, m) , g | a and g | m . Hence g | ( ax tm) , which implies g | c . This is a contradiction. Thus, when, g | c , * has no solutions. To prove part ii, assume g | c . Since g gcd( a, m) , there exist integers x and y to the equation ax my g c We multiply both sides of this equation by the integer (recall g | c ) to get g cx cy a m c g g Continued on Next Page 10 Hence, cx cy a c m g g cx cx which says m | a c or by definition of congruence a c (mod m) . Hence g g cx is a solution to *. To find the other g 1 incongruent solutions, suppose x is x0 g another solution to *. Then ax ax0 c (mod m) or ax ax0 (mod m) . Then m | (ax ax0 ) or ax ax0 tm a ( x x0 ) tm t is an integer Since g gcd( a, m) , g | a and g | m and hence are integers. We divide both sides of the previous relationship by g. a ( x x0 ) m t . g g m a ( x x0 ) m a m a or | | ( x x0 ) . We claim gcd( , ) 1 , for if not, there exists g g g g g g a m m a a common divisor d 1 where d | and d | . Thus ud and vd for integers g g g g u and v. Solving for m and a, we get m u (dg ) and a v (dg ) . Hence, dg | m and dg | a , which contradicts that gcd( a, m) g ( dg g ). Hence, Now, since m a m a m | ( x x0 ) and gcd( , ) 1 , this implies that | ( x x0 ) . g g g g g Hence, we have 11 x x0 k m g or m k )(mod m) g cx m x ( k )(mod m) g g x ( x0 Now, that taking k 0, 1, 2, , g 1 produces g incongruent solutions. Note, if k g , a previous value would be repeated, since if k g i for any 0 i g 1 would give x( cx m cx m cx m cx m ( g i ))(mod m) ( m i )(mod m) ( 0 i ) mod m ( i )(mod m) g g g g g g g g Since 0 i g 1 , this value will have been repeated. This completes the proof. █ 12 Example 9: Use the Linear Congruence Theorem to find all of the incongruent solutions to 12 x 6 (mod 18) Solution: █ 13 Example 10: Use the Linear Congruence Theorem to find all of the incongruent solutions to 76 x 50 (mod 176) Solution: █ 14 Example 11: Use the Linear Congruence Theorem to find all of the incongruent solutions to 1000 x 2000 (mod 1076) Solution: █ 15 Corollary to the Linear Congruence Theorem: The congruence ax 1 (mod m) has a solution for x (note that x a 1 is the multiplicative inverse of a modulo m if gcd( a, m ) 1 ). The solution is unique for 1 x m . Proof: █ Solving Congruences of Higher Degree Solving congruences of higher degrees are generally more difficult than linear congruences. If the modulus m is small enough, the brute force method will suffice. 16 Example 12: Find the incongruent solutions for x 2 x 0 (mod 6) Solution: █ 17 Example 13: Find the incongruent solutions for x 2 3 (mod 8) Solution: █ However, the brute force method becomes more inefficient the larger the modulus. In our examples, we saw that x 2 x 0 (mod 6) has 4 solutions and that x 2 3 (mod 8) has none. Is there any way we can predict the number of incongruent solutions beforehand? The next theorem partially answers this question. 18 Theorem: Polynomial Roots Mod p Theorem. Let p be a prime and let f ( x ) a0 x d a1 x d 1 a0 be a polynomial of degree d 1 with integer coefficients and with p | a0 . Then the congruence f ( x ) 0 (mod p ) has at most d incongruent solutions. Proof: Suppose there at least one polynomial where p does not divide the leading coefficient that has more distinct incongruent solutions then its degree. Let d be a polynomial of least degree for these polynomials given by f ( x ) a0 x d a1 x d 1 a0 Suppose r1 , r2 , rd , rd 1 be these incongruent solutions. For each incongruent solution rk of r1 , r2 , rd , rd 1 , we know that f (rk ) 0 (mod p) Since r1 is a zero, by the factor theorem for polynomials, f ( x) ( x r1 ) g( x) where g ( x ) is of degree d 1 , that is, g ( x ) has the form g ( x ) a0 x d 1 b1 x d 2 bd 1 For the other incongruent solutions rk r1 of f ( x ) , we have f (rk ) (rk r1 ) g (rk ) 0 (mod p) Since rk r1 (mod p ) , it follows from the prime divisibility property that g ( rk ) 0 (mod p) . Hence, r2 , r3 , rd , rd 1 are incongruent solutions to g ( x ) , which says that g ( x ) has d incongruent solutions, which is a contradiction that f ( x ) is the polynomial of least degree that has more incongruent solutions than its degree. Thus, the result holds. █ 19 Example 14: Find the incongruent solutions for x 2 9 (mod 61) Solution: █