1 Chapter 11: Euler’s Phi Function Practice HW p. 80 # 1, 2a, 3, 5 (Additional Web Exercises) In this chapter, we want to look at how to compute efficiently the number (m) , which (m) , is the number of integers between 1 and m that are relatively prime to m. That is, (m) # {a : 1 a m 1 and gcd( a, m) 1} We would like to have a method of computing (m) when m is larger. The next theorems describe some efficient ways of doing this. Theorem 1: If p is a prime number, then ( p ) p 1 . Proof: █ Example 1: Compute (11) and (97) . Solution: █ 2 Theorem 2: If p is a prime number, then ( p k ) p k p k 1 . Proof: The only divisors of p k are 1 and the powers of p less than k, that is p i | p k for 1 i k . Let a be an integer where 1 a p k . If gcd( a, p k ) 1 , then a must have a factor of p , that is p | a . Thus, a number a is not relatively prime ( gcd( a, p k ) 1) when p | a . Thus ( p k ) p k #{a : 1 a p k and p | a} If p | a , then a kp for some integer k. The multiples of p between 1 and p k are (1) p, 2 p, 3 p, , ( p k 1 1) p, p k 1 p p k , which is p k 1 multiples of p. Hence, #{a : 1 a p k and p | a} p k 1 and thus ( p k ) p k p k 1 . █ Example 2: Compute (64) . Solution: █ We next state and prove a lemma that will be useful in a later result. 3 Lemma: For integers a, m, and n, gcd( a, mn) 1 if and only if gcd( a, m ) 1 and gcd( a, n ) 1 . Proof: Assume gcd( a, mn) 1 and suppose gcd( a, m ) d 1 . Then d | a and d | m . Hence d | mn . This contradicts the fact that gcd( a, mn) 1 . A similar argument can be made if we assume gcd( a, n ) d 1 . Thus gcd( a, m ) 1 and gcd( a, n ) 1 Now assume gcd( a, m ) 1 and gcd( a, n ) 1 and suppose gcd( a, mn) d 1 . Then d | a and d | mn . By the Fundamental Theorem of Arithmetic, d must have a prime divisor p where p | d . Thus, p | a and p | mn . By the prime divisibility property, that says that p | m or p | n . If p | m , since p | a this contradicts the fact that gcd( a, m ) 1 . Similarly, if p | n , since p | a this contradicts the fact that gcd( a, n ) 1 . In either case, we have a contradiction and hence gcd( a, mn) 1 . █ For example, if a = 5, m = 6, and c = 7, the lemma implies gcd( 5,6) 1, gcd( 5,7) 1 gcd( 5,6 7) gcd( 5,42) 1 We next use the previous lemma to prove a fundamental result. Theorem 3: For two positive integers m and n, if the gcd( m, n) 1 , then (mn) (m) (n) . Proof: We rearrange the integers between 1 and mn into an n n array with n rows and m columns. 1 2 r m 1 m2 mr 2m 2m 1 2m 2 2m r 3m m ( n 1)m 1 ( n 1)m 2 ( n 1)m r nm By Lemma 5, (mn) # {a : gcd( a, mn) 1} # {a : gcd( a, m) 1 and gcd( a, n) 1} Consider the r th column of the array. Each entry in the r th column when paired with m, has the same greatest common divisor. Continued on Next Page 4 That is, if 0 i, j n 1 , gcd( im r, m) gcd( jm r, m) 1 (This can be seen by calculating both using the first step of the Euclidean Algorithm). Since all elements in each column have the same greatest common divisor, (m) of the columns will have the elements in the array that are relatively prime to m. Now, consider the (m) columns. We must now show that each of these columns has (n ) elements relatively prime to n, thus giving a total of (m) (n ) total elements relatively prime to both m and n and hence m n by the previous lemma. Consider the r th column 2m r n total entries ( n 1)m r r mr Claim: In modulo n arithmetic, all entries in this column are just a rearrangement of 1, 2, 3,, n 1, that is, each entry in the column is in a the same distinct congruence class as one of the integers 1, 2, 3,, n 1 . For if not, there would exist integers 0 i, j n 1 such that jm r im r (mod n) This implies that n | ( j i )m Since by the Theorem assumption, gcd( m, n) 1 , this implies that n | ( j i ) which is impossible since | j i | n . Hence, since the r th column elements r, m r, 2m r,, (n 1)m r and 1, 2, 3,, n 1 are the same elements with respect to congruence in modulo n arithmetic and there are (n ) elements relatively prime to n in list 1, 2, 3,, n 1, there are (n ) elements in the r th column r, m r, 2m r,, (n 1)m r relatively prime to n. Thus there are (m) columns in the array containing the elements relatively prime to n, and in each of these (m) columns (n ) entries relatively prime to n. This gives a total of ( m) ( n ) total elements that are relatively prime to both m and n. Since, by the previous lemma, these are the same elements relatively prime to m n , we have the result ( mn) ( m) ( n ) █ 5 Example 3: Compute (24) . Solution: █ Theorem 4: If m has the prime factorization m p1k1 p 2k2 prkr , then (m) ( p1k1 p2k2 prkr ) ( p1k1 ) ( p2k2 ) ( prkr ) ( p k1 p1k1 1 )( p k2 p2k2 1 ) ( p kr prkr 1 ) . Proof: We can prove this result using mathematical induction. For the trivial case, that is, if r 1 , then using Theorem 13.6 we have (m) ( p1k1 ) ( p1k1 p1k11 ) . Now, assume the result is true if m is a product of r primes. We want to show the result is true if m is a product of r + 1 primes. Suppose m p1k1 p2k2 prkr prkr 11 . Noting that gcd( p1k1 p2k2 prkr , prkr 11 ) 1, we have ( m) (( p1k1 p2k 2 prk r ) prkr 11 ) ( p1k1 p2k 2 prk r ) ( prkr 11 ) (Use previous Theorem 3) ( p k1 p1k1 1 )( p k 2 p2k 2 1 ) ( p k r prk r 1 ) ( prkr 11 ) (By the induction hypothesis ) ( p k1 p1k1 1 )( p k 2 p2k 2 1 ) ( p k r prk r 1 )( prkr 11 prkr 11 1 ) (Use previous Theorem 2) Hence, by the principle of mathematical induction, the result holds. █ Corollary 1: If p and q are primes where p q , then ( pq) ( p) (q) ( p 1)( q 1) . Proof: █ 6 Example 4: Compute (35) . Solution: █ Example 5: Compute (360) . Solution: █ Example 6: Compute (1575) . Solution: █ 7 Euler Phi Function with Maple Note that the numtheory package must be loaded to the home directory using the with statement before the phi command can be used. > with(numtheory): Compute (35) . > phi(35); Compute (360) . > phi(360); Compute (1575) . > phi(1575); 8 Chinese Remainder Theorem Theorem 5: Chinese Remainder Theorem. The system of linear congruences x a1 (mod m1 ) x a2 (mod m2 ) * x ak (mod mk ) where gcd( mi , m j ) 1 (Moduli are pairwise relatively prime) can be solved for an integer x modulus M m1 m2 mk . Moreover, if y is another solution to these congruences, then y x (mod M ) . Proof: Let M i M for 1, 2, 3,, k . mi Then gcd( M i , mi ) 1 (Proof Exercise). By the Linear Congruence Theorem, there exists an integer y i where M i yi 1 (mod mi ) (Note y i is the multiplicative inverse of M i mod mi Also, M i 0 (mod m j ) whenever i j . (Proof Exercise) k Let x ai M i yi (mod M ) (a1M 1 y1 a2 M 2 y2 ak M k yk ) (mod M ) i 1 Claim that x satisfies every linear congruence. To show, that the jth arbitrary congruence with modulus m j . Then x ( a1M 1 y1 a2 M 2 y 2 a j M j y j ak M k y k (mod m j ) a j M j y j (mod m j ) aj Continued on Next Page 9 To show there are no other incongruent solutions, suppose y is another solution to *. Then for all 1 j k , y a j (mod m j ) . Since x a j (mod m j ) , it follows that x y (mod m j ) Thus, m j | ( x y ) . Since gcd( mi , m j ) 1 when i j , then it follows that M m1 m2 mk | ( x y ) Hence, M | ( x y ) and x y (mod M ) . This completes the proof. █ Chinese Remainder Theorem Summary To solve the system of linear congruences x a1 (mod m1 ) x a2 (mod m2 ) gcd( mi , m j ) 1 x ak (mod mk ) We compute k x ai M i yi (mod M ) (a1M 1 y1 a2 M 2 y2 ak M k yk ) (mod M ) i 1 where each ai comes from the right had side of the given congruences M m1 m2 mk , M Mi for 1, 2, 3,, k , mi yi is the multiplicative inverse of M i mod mi , that is, yi solves the congruence M i yi 1 (mod mi ) for 1, 2, 3,, k . 10 Example 7: Use the Chinese Remainder Theorem to solve the system of congruences x 2(mod 3) , x 4(mod 5) , x 6(mod 19) Solution: 11 █ 12 13 Using the Chinese Remainder Theorem in Maple To solve x 2(mod 3) , x 4(mod 5) , x 6(mod 19) > chrem( [2, 4, 6], [3, 5, 19] );