Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP 170 L2 Page 1 L05: Inverses and GCDs l Objective: n When does have an inverse? n How to compute the inverse? n Need: Greatest common dividers (GCDs)

Similar presentations


Presentation on theme: "COMP 170 L2 Page 1 L05: Inverses and GCDs l Objective: n When does have an inverse? n How to compute the inverse? n Need: Greatest common dividers (GCDs)"— Presentation transcript:

1 COMP 170 L2 Page 1 L05: Inverses and GCDs l Objective: n When does have an inverse? n How to compute the inverse? n Need: Greatest common dividers (GCDs) n Results will be used in L06.

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

3 COMP 170 L2 Page 3 Divisors of an Integer

4 COMP 170 L2 Page 4 Prime Numbers

5 COMP 170 L2 Page 5 Common Divisors

6 COMP 170 L2 Page 6 Relatively Prime

7 COMP 170 L2 Page 7 How to Find GCD? l How to calculate gcd(m, n)? n Need Euclid’s division theorem

8 COMP 170 L2 Page 8 Inverses and GCDs l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD n The extended GCD algorithm. n Computing inverses

9 COMP 170 L2 Page 9 Euclid’s Division Theorem

10 COMP 170 L2 Page 10 Euclid’s Division Theorem

11 COMP 170 L2 Page 11

12 COMP 170 L2 Page 12

13 COMP 170 L2 Page 13

14 COMP 170 L2 Page 14 Proof by Smallest Counter Example

15 COMP 170 L2 Page 15

16 COMP 170 L2 Page 16 Inverses and GCDs l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD n The extended GCD algorithm. n Computing inverses.

17 COMP 170 L2 Page 17 A Lemma l This lemma gives us a way to calculate GCDs. l Example n 10 = 4 * 2 + 2 n gcd(10, 4) = 2 = gcd(4, 2)

18 COMP 170 L2 Page 18

19 COMP 170 L2 Page 19

20 COMP 170 L2 Page 20 Euclid’s GCD algorithm l The 2 nd argument is nonnegative l Decreases in each recursive call l Becomes 0 in a finite number of steps

21 COMP 170 L2 Page 21 Euclid’s GCD algorithm

22 COMP 170 L2 Page 22 Euclid’s GCD algorithm

23 COMP 170 L2 Page 23 Inverses and GCDs l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD n The extended GCD algorithm. n Computing inverses

24 COMP 170 L2 Page 24 Multiplicative Inverse mod n

25 COMP 170 L2 Page 25 Determine Inverses from Multiplication Table l Which nonzero elements of have multiplicative inverses?

26 COMP 170 L2 Page 26 Determine Inverses from Multiplication Table l Which nonzero elements of have multiplicative inverses?

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

28 COMP 170 L2 Page 28 Multiplicative Inverse mod n

29 COMP 170 L2 Page 29 Multiplicative Inverse mod n

30 COMP 170 L2 Page 30 Proving Inverse does not Exist l Gives us a way to prove that inverse does not exist

31 COMP 170 L2 Page 31 Proving Inverse does not Exist

32 COMP 170 L2 Page 32 Proving Inverse does not Exist

33 COMP 170 L2 Page 33 Proving Inverse does not Exist

34 COMP 170 L2 Page 34 Inverses and GCDs l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD n The extended GCD algorithm. n Computing inverses

35 COMP 170 L2 Page 35 Link to GCD l Objective: n Show the following two important results

36 COMP 170 L2 Page 36 Modular Equations and Normal Equations

37 COMP 170 L2 Page 37

38 COMP 170 L2 Page 38 Inverse and Normal Equations

39 COMP 170 L2 Page 39 Clue on Finding Inverse l Second part of the proof of Lemma 2.8: l Does this give us a way to find the inverse of a? n Yes,

40 COMP 170 L2 Page 40 Clue on Finding Inverse l 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 l Given a and n, how do we find x and y, to satisfy (*)? n Link to GCD

41 COMP 170 L2 Page 41 Link to GCD

42 COMP 170 L2 Page 42 Link to GCD/Summary

43 COMP 170 L2 Page 43 Inverses and GCDs l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD n The extended GCD algorithm. n Computing inverses

44 COMP 170 L2 Page 44 The GCD algorithm Revisited l Computes GCD, but does not give x and y such that a x + ny =1

45 COMP 170 L2 Page 45

46 COMP 170 L2 Page 46 The Extended GCD Algorithm/Base Case l Base case: k=jq gcd(k, j) = j j * 1 + k * 0 = gcd(k, j), x=1, y=0

47 COMP 170 L2 Page 47 The Extended GCD Algorithm/Induction l Induction: k \= jq

48 COMP 170 L2 Page 48

49 COMP 170 L2 Page 49 The Extended GCD Algorithm

50 COMP 170 L2 Page 50 The Extended GCD Algorithm/Example

51 COMP 170 L2 Easy Manual Way to Find x and y l Without remembering: Page 51

52 COMP 170 L2 The Extended GCD Algorithm Page 52 l Proved by induction already.

53 COMP 170 L2 Related Results l Together, those two imply: Page 53

54 COMP 170 L2 Related Results Page 54 l Together, those two imply:

55 COMP 170 L2

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

57 COMP 170 L2 Extend GCD Algo and Inverses Page 57 l Together, those two imply:

58 COMP 170 L2 Finding Inverse/Example l Find the Page 58

59 COMP 170 L2 Manual Way to Find Inverse Page 59

60 COMP 170 L2

61 02-03-2010: Recap l Proved: Page 61 l Proof technique l Proof by contradiction l Proof by smallest counter example

62 COMP 170 L2 02-03-2010: Recap Page 62

63 COMP 170 L2 02-03-2010: Today l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD (only results, proofs later) n The extended GCD algorithm. n Computing inverses Page 63

64 COMP 170 L2 04-03-2010: Recap Page 64 l a has multiplicative inverse in Zn iff gcd(a, n) =1 l In that case, inverse of a = x mod n. l Today : prove correctness

65 COMP 170 L2 A Note on an Old Exam Question Page 65 l Question: Should I first try to run extended GCD or try to show equation with no solution? How to figure “3” in second case?

66 COMP 170 L2 A Note on an Old Exam Question l Answer: Factorize the numbers into product of primes Page 66 l 53 cannot be divided by 2, 3, 5, 7, 11, 13, 17, 23, 29 l So, it is a prime number. l Inverse exist. Run extended GCD.

67 COMP 170 L2 A Note on an Old Exam Question Page 67 l Answer: Factorize the numbers into product of primes l 12 = 3 * 4 l 147 = 3 * 49 l = 3 * 7 * 7 l 12 and 147 have common divisor 3 l Left divisible by 3, but not right. l Write proof


Download ppt "COMP 170 L2 Page 1 L05: Inverses and GCDs l Objective: n When does have an inverse? n How to compute the inverse? n Need: Greatest common dividers (GCDs)"

Similar presentations


Ads by Google