Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Mathematics Section 3.7 Applications of Number Theory 大葉大學 資訊工程系 黃鈴玲.

Similar presentations


Presentation on theme: "Discrete Mathematics Section 3.7 Applications of Number Theory 大葉大學 資訊工程系 黃鈴玲."— Presentation transcript:

1 Discrete Mathematics Section 3.7 Applications of Number Theory 大葉大學 資訊工程系 黃鈴玲

2 Ch3-2 3.6 Integers and Algorithms ※ The Euclidean Algorithm ( 輾轉相除法求 gcd ) Example : Find gcd(91,287) Sol: 287 = 91  3 + 14 91 = 14  6 + 7 14 = 7  2 ∴ gcd(91,287) = 7 Lemma 1 Let a = bq + r, where a, b, q, and r  Z. Then gcd(a, b) = gcd (b, r). if x |91 & x |287  x |14 ∴ gcd (91,287) = gcd(91,14) gcd (91,14) = gcd (14,7) gcd (14,7) = 7

3 Ch3-3 3.7 Applications of Number Theory Theorem 1. If a and b are positive integers, then there exist integers s and t such that gcd(a,b) = sa+tb. gcd(a,b) can be expressed as a linear combination with integer coefficients of a and b. ※將 gcd(a,b) 寫成 a 跟 b 的線性組合: The extended Euclidean Algorithm

4 Ch3-4 Example 1 Express gcd(252, 198) =18 as a linear combination of 252 and 198. Sol: 252 = 1  198 + 54 198 = 3  54 + 36 54 = 1  36 + 18 36 = 2  18 ∴ gcd(252, 198) = 18 18 = 54 – 1  36 36 =198 – 3  54 54 =252 – 1  198 18 = 54 – 1  36  = 54 – 1  (198 – 3  54 ) = 4  54 – 1  198= 4  (252 – 1  198) – 1  198 = 4  252 – 5  198 Exercise : 1(g)

5 Ch3-5 Lemma 1. If a, b and c are positive integers such that gcd(a,b) = 1 and a | bc, then a | c. Lemma 2. If p is a prime and p | a 1 a 2 …a n, where each a i is an integer, then p | a i for some i. Example 2 14  8 (mod 6), 但  的左右兩邊同除以 2 後不成立 because 14/2=7, 8/2=4, but 7  4(mod 6). Q: 何時可以讓  的左右同除以一數後還成立呢? 另, 14  8 (mod 3), 同除以 2 後, 7  4 (mod 3) 成立

6 Ch3-6 Theorem 2. Let m be a positive integer and let a, b, and c be integers. If ac  bc (mod m) and gcd(c, m) = 1, then a  b (mod m). ※ Linear Congruences A congruence ( 同餘式 ) of the form ax  b (mod m), where m is a positive integer, a and b are integers, and x is a variable, is called a linear congruence. How can we solve the linear congruence ax  b (mod m) ? Def: If ax  1 (mod m), and let a be an answer of x, a is called an inverse ( 反元素 ) of a modulo m

7 Ch3-7 Theorem 3. If a and m are relatively prime integers and m>1, then an inverse of a modulo m exists. Furthermore, this inverse is unique modulo m. Proof. (existence) (unique 的部分是 exercise) By Thm 1, because gcd(a, m) = 1, there exist integers s and t such that sa + tm =1.  sa + tm  1 (mod m). Because tm  0 (mod m), sa  1 (mod m),  s is an inverse of a modulo m.

8 Ch3-8 Example 3 Find an inverse of 3 modulo 7. Sol. Because gcd(3, 7) = 1, find s, t such that 3s + 7t =1.   2 is an inverse of 3 modulo 7.  7 = 2  3 + 1  1 =  2  3 + 1  7 (Note that every integer congruent to  2 modulo 7 is also an inverse of 3, such as 5,  9, 12, and so on. ) Exercise : 5

9 Ch3-9 Example 4 What are the solutions of the linear congruence 3x  4 (mod 7) ? Sol. By Example 3   2 is an inverse of 3 modulo 7  If x is a solution, then x   8  6 (mod 7).   2  3x   2  4 (mod 7) Because  6  1 (mod 7), and  8  6 (mod 7), We need to determine whether every x with x  6 (mod 7) is a solution. Assume x  6 (mod 7), then 3x   6 = 18  4 (mod 7). Therefore every such x is a solution: x = 6, 13, 20, …, and  1,  8,  15, …. Exercise : 11 將 3x  4 (mod 7) 左右同乘  2   6x   (mod 7)  3  (  2)  1 (mod 7)

10 Ch3-10 Example 5. 孫子算經 : 「某物不知其數,三三數之餘二,五五數之 餘三,七七數之餘二,問物幾何 ? 」 ( 又稱為「韓信點兵」問題 ) i.e. x ≡ 2 (mod 3) x ≡ 3 (mod 5) x = ? x ≡ 2 (mod 7) Theorem 4. (The Chinese Remainder Theorem) Let m 1,m 2,…,m n be pairwise relatively prime positive integers and a 1, a 2, …, a n arbitrary integers. Then the system x ≡ a 1 (mod m 1 ) x ≡ a 2 (mod m 2 ) : x ≡ a n (mod m n ) has a unique solution modulo m = m 1 m 2 …m n. ( 即有一解 x, where 0  x < m, 且所有其他解 mod m 都等於 x ) The Chinese Remainder Theorem ( 中國餘數定理 )

11 Ch3-11 Proof of Thm 4: Let M k = m / m k  1  k  n ∵ m 1, m 2,…, m n are pairwise relatively prime ∴ gcd ( M k, m k ) = 1  integer y k s.t. M k y k ≡ 1 (mod m k ) ( by Thm. 3)  a k M k y k ≡ a k (mod m k ),  1  k  n Let x = a 1 M 1 y 1 +a 2 M 2 y 2 +…+a n M n y n ∵ m i | M j,  i ≠ j ∴ x ≡ a k M k y k ≡ a k (mod m k )  1  k  n x is a solution. All other solution y satisfies y ≡ x (mod m k ). x ≡ a 1 (mod m 1 ) x ≡ a 2 (mod m 2 ) : x ≡ a n (mod m n ) m = m 1 m 2 …m n

12 Ch3-12 Example 6. (Solve the system in Example 5) Let m = m 1 m 2 m 3 = 3  5  7 = 105 M 1 = m / m 1 = 105 / 3 = 35 ( 也就是 m 2 m 3 ) M 2 = m / m 2 = 105 / 5 = 21 M 3 = m / m 3 = 105 / 7 = 15 35 ≡ 2 (mod 3)  35  2 ≡ 2  2 ≡ 1 (mod 3) 21 ≡ 1 (mod 5)  21  1 ≡ 1 (mod 5) 15 ≡ 1 (mod 7)  15  1 ≡ 1 (mod 7) ∴ x = a 1 M 1 y 1 + a 2 M 2 y 2 + a 3 M 3 y 3 = 2  35  2 + 3  21  1 + 2  15  1 = 233 ≡ 23 (mod 105) ∴ 最小的解為 23 ,其餘解都等於 23+105t for some t  Z + M1M1 y1y1 M2M2 y2y2 M3M3 y3y3 x ≡ 2 (mod 3) x ≡ 3 (mod 5) x = ? x ≡ 2 (mod 7) 找 y 1 使得 M 1 y 1 = 1 (mod 3)

13 Ch3-13 Exercise 18. Find all solutions to the system of congruences x ≡ 2 (mod 3) x ≡ 1 (mod 4) x ≡ 3 (mod 5) Sol : a 1 =2, a 2 =1, a 3 =3, m 1 =3, m 2 =4, m 3 =5 m=3  4  5=60 M 1 =20, M 2 =15, M 3 =12 20≡2 (mod 3)  20  2≡1 (mod 3) 15≡3 (mod 4)  15  3≡1 (mod 4) 12≡2 (mod 5)  12  3≡1 (mod 5) ∴ x = 2  20  2+1  15  3+3  12  3 = 80+45+108=233≡53 (mod 60)

14 Ch3-14 ※ 補充: (when m i is not prime) Ex 20. Find all solutions, if any, to the system of congruences. x≡5 (mod 6) x≡3 (mod 10) x≡8 (mod 15) Sol. Rewrite the system as the following: x ≡ 1 (mod 2)x≡2 (mod 3) i.e., x≡1 (mod 2) x≡2 (mod 3) … x≡3 (mod 5) Exercise : 做完此題 x ≡ 1 (mod 2) x ≡ 2 (mod 3) x≡3 (mod 5)

15 Ch3-15 ※ 補充: (when m i is a prime power) Ex 21. Find all solutions, if any, to the system of congruences. x≡7 (mod 9) x≡4 (mod 12) x≡16 (mod 21) Sol. Rewrite the system as the following: x≡7 (mod 9) ( 不能拆! ) x≡0 (mod 4) i.e., x≡7 (mod 9) ( 此式取代 x≡1 (mod 3) 式子 ) x≡0 (mod 4) … x≡2 (mod 7) x≡1 (mod 3) x≡2 (mod 7)

16 Ch3-16 Computer Arithmetic with Large Integers Suppose that m 1,m 2,…,m n be pairwise relatively prime integers greater than or equal to 2 and let m = m 1 m 2 … m n. By the Chinese Remainder Theorem, we can show that an integer a with 0  a < m can be uniquely represented by the n -tuple ( a mod m 1, a mod m 2, …, a mod m n ). Example 7 What are the pairs used to represent the nonnegative integers x<12 when they are represented by the order pair ( x mod 3, x mod 4 )? Sol 0=(0, 0), 1=(1, 1), 2=(2, 2), 3=(0, 3), 4=(1, 0), 5=(2, 1), 6=(0, 2), 7=(1, 3), 8=(2, 0), 9=(0, 1), 10=(1, 2), 11=(2, 3). Exercise : 37

17 Ch3-17 To perform arithmetic with larger integers, we select moduli (modulus 的複數 ) m 1,m 2,…,m n, where each m i is an integer greater than 2, gcd(m i, m j )=1 whenever i  j, and m=m 1 m 2 …m n is greater than the result of the arithmetic operations we want to carry out.

18 Ch3-18 Example 8 Suppose that performing arithmetic with integers less than 100 on a certain processor is much quicker than doing arithmetic with larger integers. We can restrict almost all our computations to integers less than 100 if we represent integers using their remainders modulo pairwise relatively prime integers less than 100. For example, 99, 98, 97, and 95 are pairwise relatively prime. every nonnegative integer less than 99  98  97  95 = 89403930 can be represented uniquely by its remainders when divided by these four moduli. E.g., 123684 = (33, 8, 9, 89), and 413456 = (32, 92, 42, 16) 123684 + 413456 = (33, 8, 9, 89) + (32, 92, 42, 16) = (65 mod 99, 100 mod 98, 51 mod 97, 105 mod 95) = (65, 2, 51, 10) Use Chinese Remainder Thm to find this sum  537140.

19 Ch3-19 Theorem 5 (Fermat’s Little Theorem) If p is prime and a is an integer not divisible by p, then a p  1  1 (mod p) Furthermore, for every integer a we have a p  a (mod p) Exercise 27(a) Show that 2 340  1 (mod 11) by Fermat’s Little Theorem and noting that 2 340 = (2 10 ) 34. Proof 11 is prime and 2 is an integer not divisible by 11.  2 10  1 (mod 11)  2 340  1 (mod 11) by Thm 5 of Sec. 3.4 (a  b (mod m) and c  d (mod m)  ac  bd (mod m) ) Exercise : Compute 5 2003 (mod 7)


Download ppt "Discrete Mathematics Section 3.7 Applications of Number Theory 大葉大學 資訊工程系 黃鈴玲."

Similar presentations


Ads by Google