1 / 59

L14: Inverses and GCDs

Learn about calculating inverses, GCDs, and their properties. Understand Euclid’s Division Theorem and the GCD Algorithm. Explore multiplicative inverses and efficient computation methods.

leric
Download Presentation

L14: Inverses and GCDs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. L14: Inverses and GCDs • Objective: • When does have an inverse? • How to compute the inverse? • Need: Greatest common dividers (GCDs) • Results will be used in L15. • Reading • Textbook, pp. 105-120

  2. Inverses and GCDs • Greatest Common Divisors (GCDs) • Definitions • Euclid’s Division Theorem • The GCD Algorithm • Multiplicative Inverses • Definition and Properties • Link to GCD • The extended GCD algorithm. • Computing inverses

  3. Divisors of an Integer

  4. Page 4 Prime Numbers

  5. Common Divisors

  6. Relatively Prime • How to calculate gcd(m, n)? • Need Euclid’s division theorem

  7. Inverses and GCDs • Greatest Common Divisors (GCDs) • Definitions • Euclid’s Division Theorem • The GCD Algorithm • Multiplicative Inverses • Definition and Properties • Link to GCD • The extended GCD algorithm. • Computing inverses

  8. Euclid’s Division Theorem

  9. Euclid’s Division Theorem

  10. Choose the smallest such m Equation (*) not true for m and any q, r Equation (*) true for m’ <m and some q, r • Need to prove: For any m ≥0 , Exist q & r , s. t . m = qn + r ( 0 ≤ r < n) * Proof by contradiction * Assume exists m ≥ 0 , s . t . m = qn + r( * ) Not true for any q , r ( 0 ≤ r < n ) * Two cases: m < n , m ≥ n

  11. * If m < n , m = 0 · n + m ( 0 ≤ m <n ) ( q = 0 , r = m ) Satisfies m = qn + r ( 0 ≤ r < n ) Contradicts the choice of m ! * If m ≥ n , • Let m’ = m – n , m’ ≥ 0 • m’ < m There must exist q’ , r’ s. t. m’ = q’ n + r’ ( 0 ≤ r’ < n ) => m – n = q’n + r’ => m = ( 1 + q’ ) n + r’ Contradicts the choice of m ! Proof completed

  12. Page 13 Proof by Smallest Counter Example

  13. Proof of Theorem 2.12 2nd Step * Need to prove: m = qn + r ( 0≤r <n ) ( * ) m = q’n + r’ ( 0 ≤r’<n) ( ** ) => q = q’ , r = r’ ∣r’ – r ∣< n * Subtract ( * ) and ( ** ) 0 = ( q – q’ ) n + r – r’ => ∣q’ – q∣ n < n ☆ => ∣q’ - q∣ = 0 => ( q – q’ ) n = r’ – r => q’ = q => ∣q – q’ ∣n = ∣r’ – r ∣ => r’ = r Proved

  14. Inverses and GCDs • Greatest Common Divisors (GCDs) • Definitions • Euclid’s Division Theorem • The GCD Algorithm • Multiplicative Inverses • Definition and Properties • Link to GCD • The extended GCD algorithm. • Computing inverses .

  15. A Lemma • This lemma gives us a way to calculate GCDs. • Example • 10 = 4 * 2 + 2 • gcd(10, 4) = 2 = gcd(4, 2)

  16. Proof * Case 1: r = 0 => k = jq , j ︱k Always have j︱j , gcd ( j , k ) ≤ j => gcd( j , k ) = j j︱j , j︱0 , gcd ( j , 0 ) ≤ j => gcd ( j , 0 ) = j => gcd ( j , k ) = gcd ( j , r )

  17. * Case 2 : r > 0 Will show : d︱j , d︱k <=> d︱j , d︱r (*) => gcd ( j , k ) = gcd ( r , j ) “=>” : d | j , d | k Proof of (*) => k = i1 d , j = i2 d => r = k -j q = i1 d - i2 d q = ( i1 – i2q ) d => d | r => d︱j , d︱r . proved “<=” : Similar Lemma proved

  18. Euclid’s GCD algorithm • The 2nd argument is nonnegative • Decreases in each recursive call • Becomes 0 in a finite number of steps

  19. Euclid’s GCD algorithm

  20. Euclid’s GCD algorithm

  21. Inverses and GCDs • Greatest Common Divisors (GCDs) • Definitions • Euclid’s Division Theorem • The GCD Algorithm • Multiplicative Inverses • Definition and Properties • Link to GCD • The extended GCD algorithm. • Computing inverses

  22. Multiplicative Inverse mod n

  23. Determine Inverses from Multiplication Table • Which nonzero elements of have multiplicative inverses?

  24. Determine Inverses from Multiplication Table • Which nonzero elements of have multiplicative inverses?

  25. Determine Inverses from Multiplication Table • It seems determining inverses is simple • Just scan multiplication tables • But do you see a problem with this method? • Yes, too complex… • For e-commerce, we need to determine inverse of integers of more 200 or 300 digits… • Computationally . • Next: • Show a way to prove inverse does not exist. • Develop efficient way to calculate inverses if they exist.

  26. First, uniqueness Proof * Let b and c be two inverses of a . Zn b = b ·n 1 = b ·n (a ·nc) = (b ·na ) ·nc = 1·nc = c. So, the inverse is unique.

  27. Multiplicative Inverse mod n

  28. Proving Inverse does not Exist * Lemma 2 . 5 a has inverse => a ·n x = b in zn has unique solution for ANY b • Gives us a way to prove that inverse does not exist

  29. Proving Inverse does not Exist

  30. Proving Inverse does not Exist Page 32 3has inverse inz6? * 3 ·6 x = 2 ( * ) => 3x : multiple of 3 => 3x mod 6 : multiple of 3 => Can never be 2 => ( * ) has no solution => 3 has no inverse in Z6 • Will the proof go through with 3 ·6 x = 4?

  31. Proving Inverse does not Exist * 6has no inverse inz9? 6 ·9 x = 2 ( * * ) => 6x : multiple of 3 => 6x mod 9 : multiple of 3 => ( ** ) has no solution => 6 has no inverse in Z9

  32. Inverses and GCDs • Greatest Common Divisors (GCDs) • Definitions • Euclid’s Division Theorem • The GCD Algorithm • Multiplicative Inverses • Definition and Properties • Link to GCD • The extended GCD algorithm. • Computing inverses

  33. Link to GCD • Objective: • Show the following two important results

  34. Lemma 2. 8 : a ·nx = 1 has solution in zn Modular Equations and Normal Equations <=> a x + n y = 1 for some integers x & y Proof : “=>” : Exist b ∈ zn , a ·n b = 1 => a b mod n = 1 => a b = q n + 1 => a b + n ( - q ) = 1 => a x + n y = 1 : x = b ,y = -q

  35. Lemma 2 . 8 : a ·nx = 1 has soln in zn <=> a x + n y = 1 for some integers x & y . Proof : “<=” : Exist x & y , a x + n y = 1 => a x = ( - y ) n + 1 => a x mod n = 1 => ( a ( x mod n ) ) mod n = 1 Let b = x mod n => a b mod n = 1 => a ·n b = 1 , b ∈ zn Proved

  36. Inverse and Normal Equations

  37. Exist x & y , a x + n y = 1 => a x = ( - y )n + 1 => a x mod n = 1 => ( a ( x mod n )) mod n = 1 => a b mod n = 1 => a ·n b = 1 , b ∈ zn Let b = x mod n Clue on Finding Inverse • Second part of the proof of Lemma 2.8: • Does this give us a way to find the inverse of a? • Yes, b = x mod n

  38. Clue on Finding Inverse • So, given a and n, if we can find x and y, such that a x + ny =1 (*) Then, we find inverse of a, i.e., x mod n • Given a and n, how do we find x and y, to satisfy (*)? • Link to GCD

  39. Link to GCD Proof : Supposek|a , k|n , k > 0 => a = sk, n = qk, form some s, q 1 = ax + ny = skx + qky = (sx + qy)k ★ => k|1 => k = 1 => gcd ( a , n ) = 1 Proved .

  40. Link to GCD/Summary

  41. Inverses and GCDs • Greatest Common Divisors (GCDs) • Definitions • Euclid’s Division Theorem • The GCD Algorithm • Multiplicative Inverses • Definition and Properties • Link to GCD • The extended GCD algorithm. • Computing inverses

  42. Page 43 Extended GCD Algo ﹡ Input : a , n > 0 , integers ﹡ Output : - gcd (a , n) - x , y s . t . ax + ny = gcd ( a , n ) • gcd(a, n)=1 • a have inverse in Zn, it is x mod n • gcd(a, n) \= 1 • a does not have inverse in Zn.

  43. Page 44 The GCD algorithm Revisited • Computes GCD, but nothing else

  44. The Extended GCD Algorithm/Base Case • Base case: k=jq gcd(k, j) = j j * 1 + k * 0 = gcd(k, j),x=1, y=0 How to calculate: gcd, x, y?

  45. Need to find x , y s.t. j x + k y = gcd ( k , j ) (*) The Extended GCD Algorithm/Induction • Induction: k \= jq k = jq + r ① Recursive call GCD( j, r ) Returns gcd ( j , r ) x’ , y’ : rx’ + jy’ = gcd ( j , r )② Know : gcd ( k , j ) = gcd ( j , r )

  46. Need to find x . y s. t. jx + ky = gcd ( j, r )* So, Equation (* ) is satisfied we set x = y’ – qx’ , y = x’ k = jq + r ① x’ , y’ : r x’ + j y’ = gcd ( j , r ) ② ① => r = k - jq ③ ③ + ② => (k – jq )x’ + jy’ = gcd ( j , r ) => j ( y’ – qx’ ) + kx’ = gcd ( j , r ) = gcd ( k, j ) Remember: Swap x & y, subtract qx’ from x

  47. The Extended GCD Algorithm

  48. Page 49 The Extended GCD Algorithm/Example

  49. Without remembering: Easy Manual Way to Find x and y

More Related