![Page 1: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/1.jpg)
Inverses
Today: finding inverses quickly.
Euclid’s Algorithm.Runtime.
Euclid’s Extended Algorithm.
![Page 2: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/2.jpg)
Inverses
Today: finding inverses quickly.
Euclid’s Algorithm.
Runtime.Euclid’s Extended Algorithm.
![Page 3: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/3.jpg)
Inverses
Today: finding inverses quickly.
Euclid’s Algorithm.Runtime.
Euclid’s Extended Algorithm.
![Page 4: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/4.jpg)
Inverses
Today: finding inverses quickly.
Euclid’s Algorithm.Runtime.
Euclid’s Extended Algorithm.
![Page 5: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/5.jpg)
Refresh
Does 2 have an inverse mod 8?
No.
Does 2 have an inverse mod 9? Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 6: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/6.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 7: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/7.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9?
Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 8: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/8.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes.
52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 9: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/9.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 5
2(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 10: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/10.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 5
2(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 11: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/11.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 12: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/12.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9?
No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 13: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/13.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 14: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/14.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only if
gcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 15: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/15.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1?
No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 16: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/16.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1?
Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 17: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/17.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 18: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/18.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!
Compute Inverse modulo m.
![Page 19: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/19.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 20: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/20.jpg)
Refresh
Does 2 have an inverse mod 8? No.
Does 2 have an inverse mod 9? Yes. 52(5) = 10 = 1 mod 9.
Does 6 have an inverse mod 9? No.
x has an inverse modulo m if and only ifgcd(x ,m)> 1? No.gcd(x ,m) = 1? Yes.
Today:Compute gcd!Compute Inverse modulo m.
![Page 21: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/21.jpg)
Divisibility...
Notation: d |x means “d divides x” or
x = kd for some integer k .
Fact: If d |x and d |y then d |(x +y) and d |(x−y).Proof: d |x and d |y or
x = `d and y = kd
=⇒ x−y = kd − `d = (k − `)d =⇒ d |(x−y)
![Page 22: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/22.jpg)
Divisibility...
Notation: d |x means “d divides x” orx = kd for some integer k .
Fact: If d |x and d |y then d |(x +y) and d |(x−y).Proof: d |x and d |y or
x = `d and y = kd
=⇒ x−y = kd − `d = (k − `)d =⇒ d |(x−y)
![Page 23: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/23.jpg)
Divisibility...
Notation: d |x means “d divides x” orx = kd for some integer k .
Fact: If d |x and d |y then d |(x +y) and d |(x−y).
Proof: d |x and d |y orx = `d and y = kd
=⇒ x−y = kd − `d = (k − `)d =⇒ d |(x−y)
![Page 24: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/24.jpg)
Divisibility...
Notation: d |x means “d divides x” orx = kd for some integer k .
Fact: If d |x and d |y then d |(x +y) and d |(x−y).Proof: d |x and d |y or
x = `d and y = kd
=⇒ x−y = kd − `d = (k − `)d =⇒ d |(x−y)
![Page 25: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/25.jpg)
Divisibility...
Notation: d |x means “d divides x” orx = kd for some integer k .
Fact: If d |x and d |y then d |(x +y) and d |(x−y).Proof: d |x and d |y or
x = `d and y = kd
=⇒ x−y = kd − `d = (k − `)d =⇒ d |(x−y)
![Page 26: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/26.jpg)
Divisibility...
Notation: d |x means “d divides x” orx = kd for some integer k .
Fact: If d |x and d |y then d |(x +y) and d |(x−y).Proof: d |x and d |y or
x = `d and y = kd
=⇒ x−y = kd − `d
= (k − `)d =⇒ d |(x−y)
![Page 27: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/27.jpg)
Divisibility...
Notation: d |x means “d divides x” orx = kd for some integer k .
Fact: If d |x and d |y then d |(x +y) and d |(x−y).Proof: d |x and d |y or
x = `d and y = kd
=⇒ x−y = kd − `d = (k − `)d
=⇒ d |(x−y)
![Page 28: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/28.jpg)
Divisibility...
Notation: d |x means “d divides x” orx = kd for some integer k .
Fact: If d |x and d |y then d |(x +y) and d |(x−y).Proof: d |x and d |y or
x = `d and y = kd
=⇒ x−y = kd − `d = (k − `)d =⇒ d |(x−y)
![Page 29: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/29.jpg)
Divisibility...
Notation: d |x means “d divides x” orx = kd for some integer k .
Fact: If d |x and d |y then d |(x +y) and d |(x−y).Proof: d |x and d |y or
x = `d and y = kd
=⇒ x−y = kd − `d = (k − `)d =⇒ d |(x−y)
![Page 30: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/30.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 31: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/31.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).
Proof: mod (x ,y) = x−bx/yc ·y= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 32: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/32.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 33: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/33.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s
= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 34: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/34.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `
= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 35: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/35.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 36: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/36.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y).
And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 37: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/37.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 38: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/38.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 39: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/39.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar.
Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 40: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/40.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home.
.
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 41: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/41.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 42: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/42.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).
Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 43: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/43.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.
Same common divisors =⇒ largest is the same.
![Page 44: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/44.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 45: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/45.jpg)
More divisibility
Notation: d |x means “d divides x” orx = kd for some integer k .
Lemma 1: If d |x and d |y then d |y and d | mod (x ,y).Proof: mod (x ,y) = x−bx/yc ·y
= x−s ·y for integer s= kd −s`d for integers k , `= (k −s`)d
Therefore d | mod (x ,y). And d |y since it is in condition.
Lemma 2: If d |y and d | mod (x ,y) then d |y and d |x .Proof...: Similar. Try this at home. .
GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).Proof: x and y have same set of common divisors as x andmod (x ,y) by Lemma.Same common divisors =⇒ largest is the same.
![Page 46: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/46.jpg)
Euclid’s algorithm.GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y)) ***
Theorem: Euclid’s algorithm computes the greatest common divisorof x and y if x ≥ y .
Proof: Use Strong Induction.Base Case: y = 0, “x divides y and x”
=⇒ “x is common divisor and clearly largest.”Induction Step: mod (x ,y)< y ≤ x when x ≥ y
call in line (***) meets conditions plus arguments “smaller”and by strong induction hypothesiscomputes gcd(y , mod (x ,y))
which is gcd(x ,y) by GCD Mod Corollary.
![Page 47: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/47.jpg)
Euclid’s algorithm.GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y)) ***
Theorem: Euclid’s algorithm computes the greatest common divisorof x and y if x ≥ y .
Proof: Use Strong Induction.Base Case: y = 0, “x divides y and x”
=⇒ “x is common divisor and clearly largest.”Induction Step: mod (x ,y)< y ≤ x when x ≥ y
call in line (***) meets conditions plus arguments “smaller”and by strong induction hypothesiscomputes gcd(y , mod (x ,y))
which is gcd(x ,y) by GCD Mod Corollary.
![Page 48: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/48.jpg)
Euclid’s algorithm.GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y)) ***
Theorem: Euclid’s algorithm computes the greatest common divisorof x and y if x ≥ y .
Proof: Use Strong Induction.
Base Case: y = 0, “x divides y and x”=⇒ “x is common divisor and clearly largest.”
Induction Step: mod (x ,y)< y ≤ x when x ≥ y
call in line (***) meets conditions plus arguments “smaller”and by strong induction hypothesiscomputes gcd(y , mod (x ,y))
which is gcd(x ,y) by GCD Mod Corollary.
![Page 49: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/49.jpg)
Euclid’s algorithm.GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y)) ***
Theorem: Euclid’s algorithm computes the greatest common divisorof x and y if x ≥ y .
Proof: Use Strong Induction.Base Case: y = 0, “x divides y and x”
=⇒ “x is common divisor and clearly largest.”Induction Step: mod (x ,y)< y ≤ x when x ≥ y
call in line (***) meets conditions plus arguments “smaller”and by strong induction hypothesiscomputes gcd(y , mod (x ,y))
which is gcd(x ,y) by GCD Mod Corollary.
![Page 50: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/50.jpg)
Euclid’s algorithm.GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y)) ***
Theorem: Euclid’s algorithm computes the greatest common divisorof x and y if x ≥ y .
Proof: Use Strong Induction.Base Case: y = 0, “x divides y and x”
=⇒ “x is common divisor and clearly largest.”
Induction Step: mod (x ,y)< y ≤ x when x ≥ y
call in line (***) meets conditions plus arguments “smaller”and by strong induction hypothesiscomputes gcd(y , mod (x ,y))
which is gcd(x ,y) by GCD Mod Corollary.
![Page 51: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/51.jpg)
Euclid’s algorithm.GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y)) ***
Theorem: Euclid’s algorithm computes the greatest common divisorof x and y if x ≥ y .
Proof: Use Strong Induction.Base Case: y = 0, “x divides y and x”
=⇒ “x is common divisor and clearly largest.”Induction Step: mod (x ,y)< y ≤ x when x ≥ y
call in line (***) meets conditions plus arguments “smaller”and by strong induction hypothesiscomputes gcd(y , mod (x ,y))
which is gcd(x ,y) by GCD Mod Corollary.
![Page 52: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/52.jpg)
Euclid’s algorithm.GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y)) ***
Theorem: Euclid’s algorithm computes the greatest common divisorof x and y if x ≥ y .
Proof: Use Strong Induction.Base Case: y = 0, “x divides y and x”
=⇒ “x is common divisor and clearly largest.”Induction Step: mod (x ,y)< y ≤ x when x ≥ y
call in line (***) meets conditions plus arguments “smaller”
and by strong induction hypothesiscomputes gcd(y , mod (x ,y))
which is gcd(x ,y) by GCD Mod Corollary.
![Page 53: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/53.jpg)
Euclid’s algorithm.GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y)) ***
Theorem: Euclid’s algorithm computes the greatest common divisorof x and y if x ≥ y .
Proof: Use Strong Induction.Base Case: y = 0, “x divides y and x”
=⇒ “x is common divisor and clearly largest.”Induction Step: mod (x ,y)< y ≤ x when x ≥ y
call in line (***) meets conditions plus arguments “smaller”and by strong induction hypothesis
computes gcd(y , mod (x ,y))which is gcd(x ,y) by GCD Mod Corollary.
![Page 54: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/54.jpg)
Euclid’s algorithm.GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y)) ***
Theorem: Euclid’s algorithm computes the greatest common divisorof x and y if x ≥ y .
Proof: Use Strong Induction.Base Case: y = 0, “x divides y and x”
=⇒ “x is common divisor and clearly largest.”Induction Step: mod (x ,y)< y ≤ x when x ≥ y
call in line (***) meets conditions plus arguments “smaller”and by strong induction hypothesiscomputes gcd(y , mod (x ,y))
which is gcd(x ,y) by GCD Mod Corollary.
![Page 55: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/55.jpg)
Euclid’s algorithm.GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y)) ***
Theorem: Euclid’s algorithm computes the greatest common divisorof x and y if x ≥ y .
Proof: Use Strong Induction.Base Case: y = 0, “x divides y and x”
=⇒ “x is common divisor and clearly largest.”Induction Step: mod (x ,y)< y ≤ x when x ≥ y
call in line (***) meets conditions plus arguments “smaller”and by strong induction hypothesiscomputes gcd(y , mod (x ,y))
which is gcd(x ,y) by GCD Mod Corollary.
![Page 56: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/56.jpg)
Euclid’s algorithm.GCD Mod Corollary: gcd(x ,y) = gcd(y , mod (x ,y)).
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y)) ***
Theorem: Euclid’s algorithm computes the greatest common divisorof x and y if x ≥ y .
Proof: Use Strong Induction.Base Case: y = 0, “x divides y and x”
=⇒ “x is common divisor and clearly largest.”Induction Step: mod (x ,y)< y ≤ x when x ≥ y
call in line (***) meets conditions plus arguments “smaller”and by strong induction hypothesiscomputes gcd(y , mod (x ,y))
which is gcd(x ,y) by GCD Mod Corollary.
![Page 57: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/57.jpg)
Excursion: Value and Size.
Before discussing running time of gcd procedure...
What is the value of 1,000,000?
one million or 1,000,000!
What is the “size” of 1,000,000?
Number of digits: 7.
Number of bits: 21.
For a number x , what is its size in bits?
n = b(x)≈ log2 x
![Page 58: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/58.jpg)
Excursion: Value and Size.
Before discussing running time of gcd procedure...
What is the value of 1,000,000?
one million or 1,000,000!
What is the “size” of 1,000,000?
Number of digits: 7.
Number of bits: 21.
For a number x , what is its size in bits?
n = b(x)≈ log2 x
![Page 59: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/59.jpg)
Excursion: Value and Size.
Before discussing running time of gcd procedure...
What is the value of 1,000,000?
one million or 1,000,000!
What is the “size” of 1,000,000?
Number of digits: 7.
Number of bits: 21.
For a number x , what is its size in bits?
n = b(x)≈ log2 x
![Page 60: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/60.jpg)
Excursion: Value and Size.
Before discussing running time of gcd procedure...
What is the value of 1,000,000?
one million or 1,000,000!
What is the “size” of 1,000,000?
Number of digits: 7.
Number of bits: 21.
For a number x , what is its size in bits?
n = b(x)≈ log2 x
![Page 61: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/61.jpg)
Excursion: Value and Size.
Before discussing running time of gcd procedure...
What is the value of 1,000,000?
one million or 1,000,000!
What is the “size” of 1,000,000?
Number of digits: 7.
Number of bits: 21.
For a number x , what is its size in bits?
n = b(x)≈ log2 x
![Page 62: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/62.jpg)
Excursion: Value and Size.
Before discussing running time of gcd procedure...
What is the value of 1,000,000?
one million or 1,000,000!
What is the “size” of 1,000,000?
Number of digits: 7.
Number of bits: 21.
For a number x , what is its size in bits?
n = b(x)≈ log2 x
![Page 63: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/63.jpg)
Excursion: Value and Size.
Before discussing running time of gcd procedure...
What is the value of 1,000,000?
one million or 1,000,000!
What is the “size” of 1,000,000?
Number of digits: 7.
Number of bits: 21.
For a number x , what is its size in bits?
n = b(x)≈ log2 x
![Page 64: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/64.jpg)
Excursion: Value and Size.
Before discussing running time of gcd procedure...
What is the value of 1,000,000?
one million or 1,000,000!
What is the “size” of 1,000,000?
Number of digits: 7.
Number of bits: 21.
For a number x , what is its size in bits?
n = b(x)≈ log2 x
![Page 65: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/65.jpg)
Excursion: Value and Size.
Before discussing running time of gcd procedure...
What is the value of 1,000,000?
one million or 1,000,000!
What is the “size” of 1,000,000?
Number of digits: 7.
Number of bits: 21.
For a number x , what is its size in bits?
n = b(x)≈ log2 x
![Page 66: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/66.jpg)
GCD procedure is fast.
Theorem: GCD uses 2n “divisions” where n is the number of bits.
Is this good? Better than trying all numbers in {2, . . .y/2}?Check 2, check 3, check 4, check 5 . . . , check y/2.
2n−1 divisions! Exponential dependence on size!
101 bit number. 2100 ≈ 1030 = “million, trillion, trillion” divisions!
2n is much faster! .. roughly 200 divisions.
![Page 67: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/67.jpg)
GCD procedure is fast.
Theorem: GCD uses 2n “divisions” where n is the number of bits.
Is this good?
Better than trying all numbers in {2, . . .y/2}?Check 2, check 3, check 4, check 5 . . . , check y/2.
2n−1 divisions! Exponential dependence on size!
101 bit number. 2100 ≈ 1030 = “million, trillion, trillion” divisions!
2n is much faster! .. roughly 200 divisions.
![Page 68: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/68.jpg)
GCD procedure is fast.
Theorem: GCD uses 2n “divisions” where n is the number of bits.
Is this good? Better than trying all numbers in {2, . . .y/2}?
Check 2, check 3, check 4, check 5 . . . , check y/2.
2n−1 divisions! Exponential dependence on size!
101 bit number. 2100 ≈ 1030 = “million, trillion, trillion” divisions!
2n is much faster! .. roughly 200 divisions.
![Page 69: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/69.jpg)
GCD procedure is fast.
Theorem: GCD uses 2n “divisions” where n is the number of bits.
Is this good? Better than trying all numbers in {2, . . .y/2}?Check 2,
check 3, check 4, check 5 . . . , check y/2.
2n−1 divisions! Exponential dependence on size!
101 bit number. 2100 ≈ 1030 = “million, trillion, trillion” divisions!
2n is much faster! .. roughly 200 divisions.
![Page 70: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/70.jpg)
GCD procedure is fast.
Theorem: GCD uses 2n “divisions” where n is the number of bits.
Is this good? Better than trying all numbers in {2, . . .y/2}?Check 2, check 3,
check 4, check 5 . . . , check y/2.
2n−1 divisions! Exponential dependence on size!
101 bit number. 2100 ≈ 1030 = “million, trillion, trillion” divisions!
2n is much faster! .. roughly 200 divisions.
![Page 71: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/71.jpg)
GCD procedure is fast.
Theorem: GCD uses 2n “divisions” where n is the number of bits.
Is this good? Better than trying all numbers in {2, . . .y/2}?Check 2, check 3, check 4,
check 5 . . . , check y/2.
2n−1 divisions! Exponential dependence on size!
101 bit number. 2100 ≈ 1030 = “million, trillion, trillion” divisions!
2n is much faster! .. roughly 200 divisions.
![Page 72: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/72.jpg)
GCD procedure is fast.
Theorem: GCD uses 2n “divisions” where n is the number of bits.
Is this good? Better than trying all numbers in {2, . . .y/2}?Check 2, check 3, check 4, check 5 . . . , check y/2.
2n−1 divisions! Exponential dependence on size!
101 bit number. 2100 ≈ 1030 = “million, trillion, trillion” divisions!
2n is much faster! .. roughly 200 divisions.
![Page 73: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/73.jpg)
GCD procedure is fast.
Theorem: GCD uses 2n “divisions” where n is the number of bits.
Is this good? Better than trying all numbers in {2, . . .y/2}?Check 2, check 3, check 4, check 5 . . . , check y/2.
2n−1 divisions! Exponential dependence on size!
101 bit number. 2100 ≈ 1030 = “million, trillion, trillion” divisions!
2n is much faster! .. roughly 200 divisions.
![Page 74: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/74.jpg)
GCD procedure is fast.
Theorem: GCD uses 2n “divisions” where n is the number of bits.
Is this good? Better than trying all numbers in {2, . . .y/2}?Check 2, check 3, check 4, check 5 . . . , check y/2.
2n−1 divisions! Exponential dependence on size!
101 bit number.
2100 ≈ 1030 = “million, trillion, trillion” divisions!
2n is much faster! .. roughly 200 divisions.
![Page 75: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/75.jpg)
GCD procedure is fast.
Theorem: GCD uses 2n “divisions” where n is the number of bits.
Is this good? Better than trying all numbers in {2, . . .y/2}?Check 2, check 3, check 4, check 5 . . . , check y/2.
2n−1 divisions! Exponential dependence on size!
101 bit number. 2100 ≈ 1030 = “million, trillion, trillion” divisions!
2n is much faster! .. roughly 200 divisions.
![Page 76: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/76.jpg)
GCD procedure is fast.
Theorem: GCD uses 2n “divisions” where n is the number of bits.
Is this good? Better than trying all numbers in {2, . . .y/2}?Check 2, check 3, check 4, check 5 . . . , check y/2.
2n−1 divisions! Exponential dependence on size!
101 bit number. 2100 ≈ 1030 = “million, trillion, trillion” divisions!
2n is much faster!
.. roughly 200 divisions.
![Page 77: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/77.jpg)
GCD procedure is fast.
Theorem: GCD uses 2n “divisions” where n is the number of bits.
Is this good? Better than trying all numbers in {2, . . .y/2}?Check 2, check 3, check 4, check 5 . . . , check y/2.
2n−1 divisions! Exponential dependence on size!
101 bit number. 2100 ≈ 1030 = “million, trillion, trillion” divisions!
2n is much faster! .. roughly 200 divisions.
![Page 78: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/78.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)gcd(568, 132)
gcd(132, 40)gcd(40, 12)gcd(12, 4)
gcd(4, 0)4
Notice: The first argument decreases rapidly.At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 79: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/79.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)gcd(568, 132)
gcd(132, 40)gcd(40, 12)gcd(12, 4)
gcd(4, 0)4
Notice: The first argument decreases rapidly.At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 80: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/80.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)gcd(568, 132)
gcd(132, 40)gcd(40, 12)gcd(12, 4)
gcd(4, 0)4
Notice: The first argument decreases rapidly.At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 81: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/81.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)
gcd(568, 132)gcd(132, 40)
gcd(40, 12)gcd(12, 4)
gcd(4, 0)4
Notice: The first argument decreases rapidly.At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 82: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/82.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)gcd(568, 132)
gcd(132, 40)gcd(40, 12)gcd(12, 4)
gcd(4, 0)4
Notice: The first argument decreases rapidly.At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 83: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/83.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)gcd(568, 132)
gcd(132, 40)
gcd(40, 12)gcd(12, 4)
gcd(4, 0)4
Notice: The first argument decreases rapidly.At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 84: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/84.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)gcd(568, 132)
gcd(132, 40)gcd(40, 12)
gcd(12, 4)gcd(4, 0)
4
Notice: The first argument decreases rapidly.At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 85: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/85.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)gcd(568, 132)
gcd(132, 40)gcd(40, 12)
gcd(12, 4)
gcd(4, 0)4
Notice: The first argument decreases rapidly.At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 86: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/86.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)gcd(568, 132)
gcd(132, 40)gcd(40, 12)
gcd(12, 4)gcd(4, 0)
4
Notice: The first argument decreases rapidly.At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 87: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/87.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)gcd(568, 132)
gcd(132, 40)gcd(40, 12)
gcd(12, 4)gcd(4, 0)
4
Notice: The first argument decreases rapidly.At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 88: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/88.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)gcd(568, 132)
gcd(132, 40)gcd(40, 12)
gcd(12, 4)gcd(4, 0)
4
Notice: The first argument decreases rapidly.
At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 89: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/89.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)gcd(568, 132)
gcd(132, 40)gcd(40, 12)
gcd(12, 4)gcd(4, 0)
4
Notice: The first argument decreases rapidly.At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 90: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/90.jpg)
Algorithms at work.
Trying everything
Check 2, check 3, check 4, check 5 . . . , check y/2.
“gcd(x, y)” at work.
gcd(700,568)gcd(568, 132)
gcd(132, 40)gcd(40, 12)
gcd(12, 4)gcd(4, 0)
4
Notice: The first argument decreases rapidly.At least a factor of 2 in two recursive calls.
(The second is less than the first.)
![Page 91: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/91.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 92: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/92.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 93: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/93.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.
One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 94: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/94.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.
1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 95: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/95.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.
O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 96: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/96.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 97: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/97.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 98: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/98.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 99: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/99.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 100: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/100.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,
and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 101: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/101.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 102: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/102.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 103: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/103.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc=
x−y ≤x−x/2 = x/2
![Page 104: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/104.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2
= x/2
![Page 105: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/105.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 106: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/106.jpg)
Proof.gcd (x, y)
if (y = 0) thenreturn x
elsereturn gcd(y, mod(x, y))
Theorem: GCD uses O(n) ”divisions” where n is the number of bits.
Proof:
Fact:First arg decreases by at least factor of two in two recursive calls.
After 2 log2 x = O(n) recursive calls, argument x is 1 bit number.One more recursive call to finish.1 division per recursive call.O(n) divisions.
Proof of Fact: Recall that first argument decreases every call.
Case 1: y ≤ x/2, first argument is y=⇒ true in one recursive call;
Case 2: Will show “y > x/2” =⇒ “mod(x ,y)≤ x/2.”
mod (x ,y) is second argument in next recursive call,and becomes the first argument in the next one.
When y > x/2, then
bxyc= 1,
mod (x ,y) = x−ybxyc= x−y ≤x−x/2 = x/2
![Page 107: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/107.jpg)
Finding an inverse?
We showed how to efficiently tell if there is an inverse.
Extend Euclid’s algo to find inverse.
![Page 108: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/108.jpg)
Finding an inverse?
We showed how to efficiently tell if there is an inverse.
Extend Euclid’s algo to find inverse.
![Page 109: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/109.jpg)
Euclid’s GCD algorithm.
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y))
Computes the gcd(x ,y) in O(n) divisions.
For x and m, if gcd(x ,m) = 1 then x has an inverse modulo m.
![Page 110: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/110.jpg)
Euclid’s GCD algorithm.
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y))
Computes the gcd(x ,y) in O(n) divisions.
For x and m, if gcd(x ,m) = 1 then x has an inverse modulo m.
![Page 111: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/111.jpg)
Euclid’s GCD algorithm.
gcd (x, y)if (y = 0) then
return xelse
return gcd(y, mod(x, y))
Computes the gcd(x ,y) in O(n) divisions.
For x and m, if gcd(x ,m) = 1 then x has an inverse modulo m.
![Page 112: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/112.jpg)
Multiplicative Inverse.
GCD algorithm used to tell if there is a multiplicative inverse.
How do we find a multiplicative inverse?
![Page 113: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/113.jpg)
Multiplicative Inverse.
GCD algorithm used to tell if there is a multiplicative inverse.
How do we find a multiplicative inverse?
![Page 114: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/114.jpg)
Extended GCD
Euclid’s Extended GCD Theorem: For any x ,y there are integersa,b such that
ax +by = gcd(x ,y)
= d where d = gcd(x ,y).
“Make d out of sum of multiples of x and y .”
What is multiplicative inverse of x modulo m?
By extended GCD theorem, when gcd(x ,m) = 1.
ax +bm = 1ax ≡ 1−bm ≡ 1 (mod m).
So a multiplicative inverse of x if gcd(a,x) = 1!!Example: For x = 12 and y = 35 , gcd(12,35) = 1.
(3)12+(−1)35 = 1.
a = 3 and b =−1.The multiplicative inverse of 12 (mod 35) is 3.
![Page 115: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/115.jpg)
Extended GCD
Euclid’s Extended GCD Theorem: For any x ,y there are integersa,b such that
ax +by = gcd(x ,y) = d where d = gcd(x ,y).
“Make d out of sum of multiples of x and y .”
What is multiplicative inverse of x modulo m?
By extended GCD theorem, when gcd(x ,m) = 1.
ax +bm = 1ax ≡ 1−bm ≡ 1 (mod m).
So a multiplicative inverse of x if gcd(a,x) = 1!!Example: For x = 12 and y = 35 , gcd(12,35) = 1.
(3)12+(−1)35 = 1.
a = 3 and b =−1.The multiplicative inverse of 12 (mod 35) is 3.
![Page 116: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/116.jpg)
Extended GCD
Euclid’s Extended GCD Theorem: For any x ,y there are integersa,b such that
ax +by = gcd(x ,y) = d where d = gcd(x ,y).
“Make d out of sum of multiples of x and y .”
What is multiplicative inverse of x modulo m?
By extended GCD theorem, when gcd(x ,m) = 1.
ax +bm = 1ax ≡ 1−bm ≡ 1 (mod m).
So a multiplicative inverse of x if gcd(a,x) = 1!!Example: For x = 12 and y = 35 , gcd(12,35) = 1.
(3)12+(−1)35 = 1.
a = 3 and b =−1.The multiplicative inverse of 12 (mod 35) is 3.
![Page 117: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/117.jpg)
Extended GCD
Euclid’s Extended GCD Theorem: For any x ,y there are integersa,b such that
ax +by = gcd(x ,y) = d where d = gcd(x ,y).
“Make d out of sum of multiples of x and y .”
What is multiplicative inverse of x modulo m?
By extended GCD theorem, when gcd(x ,m) = 1.
ax +bm = 1ax ≡ 1−bm ≡ 1 (mod m).
So a multiplicative inverse of x if gcd(a,x) = 1!!Example: For x = 12 and y = 35 , gcd(12,35) = 1.
(3)12+(−1)35 = 1.
a = 3 and b =−1.The multiplicative inverse of 12 (mod 35) is 3.
![Page 118: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/118.jpg)
Extended GCD
Euclid’s Extended GCD Theorem: For any x ,y there are integersa,b such that
ax +by = gcd(x ,y) = d where d = gcd(x ,y).
“Make d out of sum of multiples of x and y .”
What is multiplicative inverse of x modulo m?
By extended GCD theorem, when gcd(x ,m) = 1.
ax +bm = 1ax ≡ 1−bm ≡ 1 (mod m).
So a multiplicative inverse of x if gcd(a,x) = 1!!Example: For x = 12 and y = 35 , gcd(12,35) = 1.
(3)12+(−1)35 = 1.
a = 3 and b =−1.The multiplicative inverse of 12 (mod 35) is 3.
![Page 119: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/119.jpg)
Extended GCD
Euclid’s Extended GCD Theorem: For any x ,y there are integersa,b such that
ax +by = gcd(x ,y) = d where d = gcd(x ,y).
“Make d out of sum of multiples of x and y .”
What is multiplicative inverse of x modulo m?
By extended GCD theorem, when gcd(x ,m) = 1.
ax +bm = 1
ax ≡ 1−bm ≡ 1 (mod m).
So a multiplicative inverse of x if gcd(a,x) = 1!!Example: For x = 12 and y = 35 , gcd(12,35) = 1.
(3)12+(−1)35 = 1.
a = 3 and b =−1.The multiplicative inverse of 12 (mod 35) is 3.
![Page 120: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/120.jpg)
Extended GCD
Euclid’s Extended GCD Theorem: For any x ,y there are integersa,b such that
ax +by = gcd(x ,y) = d where d = gcd(x ,y).
“Make d out of sum of multiples of x and y .”
What is multiplicative inverse of x modulo m?
By extended GCD theorem, when gcd(x ,m) = 1.
ax +bm = 1ax ≡ 1−bm ≡ 1 (mod m).
So a multiplicative inverse of x if gcd(a,x) = 1!!Example: For x = 12 and y = 35 , gcd(12,35) = 1.
(3)12+(−1)35 = 1.
a = 3 and b =−1.The multiplicative inverse of 12 (mod 35) is 3.
![Page 121: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/121.jpg)
Extended GCD
Euclid’s Extended GCD Theorem: For any x ,y there are integersa,b such that
ax +by = gcd(x ,y) = d where d = gcd(x ,y).
“Make d out of sum of multiples of x and y .”
What is multiplicative inverse of x modulo m?
By extended GCD theorem, when gcd(x ,m) = 1.
ax +bm = 1ax ≡ 1−bm ≡ 1 (mod m).
So a multiplicative inverse of x if gcd(a,x) = 1!!
Example: For x = 12 and y = 35 , gcd(12,35) = 1.
(3)12+(−1)35 = 1.
a = 3 and b =−1.The multiplicative inverse of 12 (mod 35) is 3.
![Page 122: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/122.jpg)
Extended GCD
Euclid’s Extended GCD Theorem: For any x ,y there are integersa,b such that
ax +by = gcd(x ,y) = d where d = gcd(x ,y).
“Make d out of sum of multiples of x and y .”
What is multiplicative inverse of x modulo m?
By extended GCD theorem, when gcd(x ,m) = 1.
ax +bm = 1ax ≡ 1−bm ≡ 1 (mod m).
So a multiplicative inverse of x if gcd(a,x) = 1!!Example: For x = 12 and y = 35 , gcd(12,35) = 1.
(3)12+(−1)35 = 1.
a = 3 and b =−1.The multiplicative inverse of 12 (mod 35) is 3.
![Page 123: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/123.jpg)
Extended GCD
Euclid’s Extended GCD Theorem: For any x ,y there are integersa,b such that
ax +by = gcd(x ,y) = d where d = gcd(x ,y).
“Make d out of sum of multiples of x and y .”
What is multiplicative inverse of x modulo m?
By extended GCD theorem, when gcd(x ,m) = 1.
ax +bm = 1ax ≡ 1−bm ≡ 1 (mod m).
So a multiplicative inverse of x if gcd(a,x) = 1!!Example: For x = 12 and y = 35 , gcd(12,35) = 1.
(3)12+(−1)35 = 1.
a = 3 and b =−1.The multiplicative inverse of 12 (mod 35) is 3.
![Page 124: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/124.jpg)
Extended GCD
Euclid’s Extended GCD Theorem: For any x ,y there are integersa,b such that
ax +by = gcd(x ,y) = d where d = gcd(x ,y).
“Make d out of sum of multiples of x and y .”
What is multiplicative inverse of x modulo m?
By extended GCD theorem, when gcd(x ,m) = 1.
ax +bm = 1ax ≡ 1−bm ≡ 1 (mod m).
So a multiplicative inverse of x if gcd(a,x) = 1!!Example: For x = 12 and y = 35 , gcd(12,35) = 1.
(3)12+(−1)35 = 1.
a = 3 and b =−1.
The multiplicative inverse of 12 (mod 35) is 3.
![Page 125: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/125.jpg)
Extended GCD
Euclid’s Extended GCD Theorem: For any x ,y there are integersa,b such that
ax +by = gcd(x ,y) = d where d = gcd(x ,y).
“Make d out of sum of multiples of x and y .”
What is multiplicative inverse of x modulo m?
By extended GCD theorem, when gcd(x ,m) = 1.
ax +bm = 1ax ≡ 1−bm ≡ 1 (mod m).
So a multiplicative inverse of x if gcd(a,x) = 1!!Example: For x = 12 and y = 35 , gcd(12,35) = 1.
(3)12+(−1)35 = 1.
a = 3 and b =−1.The multiplicative inverse of 12 (mod 35) is 3.
![Page 126: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/126.jpg)
Make d out of x and y ..?
gcd(35,12)
gcd(12, 11) ;; gcd(12, 35%12)gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11
= 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 127: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/127.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11
= 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 128: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/128.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)
gcd(1,0)1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11
= 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 129: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/129.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11
= 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 130: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/130.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?
35−b3512c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11
= 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 131: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/131.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11
= 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 132: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/132.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?
12−b1211c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11
= 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 133: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/133.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11
= 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 134: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/134.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11
= 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 135: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/135.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11
= 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 136: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/136.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.
1 = 12− (1)11
= 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 137: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/137.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11
= 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 138: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/138.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11 = 12− (1)(35− (2)12)
= (3)12+(−1)35
Get 11 from 35 and 12 and plugin....
Simplify. a = 3 and b =−1.
![Page 139: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/139.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11 = 12− (1)(35− (2)12) = (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify.
a = 3 and b =−1.
![Page 140: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/140.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11 = 12− (1)(35− (2)12) = (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify.
a = 3 and b =−1.
![Page 141: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/141.jpg)
Make d out of x and y ..?
gcd(35,12)gcd(12, 11) ;; gcd(12, 35%12)
gcd(11, 1) ;; gcd(11, 12%11)gcd(1,0)
1
How did gcd get 11 from 35 and 12?35−b35
12c12 = 35− (2)12 = 11
How does gcd get 1 from 12 and 11?12−b12
11c11 = 12− (1)11 = 1
Algorithm finally returns 1.
But we want 1 from sum of multiples of 35 and 12?
Get 1 from 12 and 11.1 = 12− (1)11 = 12− (1)(35− (2)12) = (3)12+(−1)35
Get 11 from 35 and 12 and plugin.... Simplify. a = 3 and b =−1.
![Page 142: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/142.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Claim: Returns (d ,a,b): d = gcd(a,b) and d = ax +by .Example:
a−bx/yc ·b =
1−b11/1c ·0 = 10−b12/11c ·1 =−11−b35/12c · (−1) = 3
ext-gcd(35,12)ext-gcd(12, 11)
ext-gcd(11, 1)ext-gcd(1,0)return (1,1,0) ;; 1 = (1)1 + (0) 0
return (1,0,1) ;; 1 = (0)11 + (1)1return (1,1,-1) ;; 1 = (1)12 + (-1)11
return (1,-1, 3) ;; 1 = (-1)35 +(3)12
![Page 143: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/143.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Claim: Returns (d ,a,b): d = gcd(a,b) and d = ax +by .
Example:
a−bx/yc ·b =
1−b11/1c ·0 = 10−b12/11c ·1 =−11−b35/12c · (−1) = 3
ext-gcd(35,12)ext-gcd(12, 11)
ext-gcd(11, 1)ext-gcd(1,0)return (1,1,0) ;; 1 = (1)1 + (0) 0
return (1,0,1) ;; 1 = (0)11 + (1)1return (1,1,-1) ;; 1 = (1)12 + (-1)11
return (1,-1, 3) ;; 1 = (-1)35 +(3)12
![Page 144: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/144.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Claim: Returns (d ,a,b): d = gcd(a,b) and d = ax +by .Example:
a−bx/yc ·b =
1−b11/1c ·0 = 10−b12/11c ·1 =−11−b35/12c · (−1) = 3
ext-gcd(35,12)
ext-gcd(12, 11)ext-gcd(11, 1)
ext-gcd(1,0)return (1,1,0) ;; 1 = (1)1 + (0) 0
return (1,0,1) ;; 1 = (0)11 + (1)1return (1,1,-1) ;; 1 = (1)12 + (-1)11
return (1,-1, 3) ;; 1 = (-1)35 +(3)12
![Page 145: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/145.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Claim: Returns (d ,a,b): d = gcd(a,b) and d = ax +by .Example:
a−bx/yc ·b =
1−b11/1c ·0 = 10−b12/11c ·1 =−11−b35/12c · (−1) = 3
ext-gcd(35,12)ext-gcd(12, 11)
ext-gcd(11, 1)ext-gcd(1,0)return (1,1,0) ;; 1 = (1)1 + (0) 0
return (1,0,1) ;; 1 = (0)11 + (1)1return (1,1,-1) ;; 1 = (1)12 + (-1)11
return (1,-1, 3) ;; 1 = (-1)35 +(3)12
![Page 146: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/146.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Claim: Returns (d ,a,b): d = gcd(a,b) and d = ax +by .Example:
a−bx/yc ·b =
1−b11/1c ·0 = 10−b12/11c ·1 =−11−b35/12c · (−1) = 3
ext-gcd(35,12)ext-gcd(12, 11)
ext-gcd(11, 1)
ext-gcd(1,0)return (1,1,0) ;; 1 = (1)1 + (0) 0
return (1,0,1) ;; 1 = (0)11 + (1)1return (1,1,-1) ;; 1 = (1)12 + (-1)11
return (1,-1, 3) ;; 1 = (-1)35 +(3)12
![Page 147: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/147.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Claim: Returns (d ,a,b): d = gcd(a,b) and d = ax +by .Example:
a−bx/yc ·b =
1−b11/1c ·0 = 10−b12/11c ·1 =−11−b35/12c · (−1) = 3
ext-gcd(35,12)ext-gcd(12, 11)
ext-gcd(11, 1)ext-gcd(1,0)
return (1,1,0) ;; 1 = (1)1 + (0) 0return (1,0,1) ;; 1 = (0)11 + (1)1
return (1,1,-1) ;; 1 = (1)12 + (-1)11return (1,-1, 3) ;; 1 = (-1)35 +(3)12
![Page 148: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/148.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Claim: Returns (d ,a,b): d = gcd(a,b) and d = ax +by .Example: a−bx/yc ·b =
1−b11/1c ·0 = 10−b12/11c ·1 =−11−b35/12c · (−1) = 3
ext-gcd(35,12)ext-gcd(12, 11)
ext-gcd(11, 1)ext-gcd(1,0)return (1,1,0) ;; 1 = (1)1 + (0) 0
return (1,0,1) ;; 1 = (0)11 + (1)1return (1,1,-1) ;; 1 = (1)12 + (-1)11
return (1,-1, 3) ;; 1 = (-1)35 +(3)12
![Page 149: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/149.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Claim: Returns (d ,a,b): d = gcd(a,b) and d = ax +by .Example: a−bx/yc ·b =1−b11/1c ·0 = 1
0−b12/11c ·1 =−11−b35/12c · (−1) = 3
ext-gcd(35,12)ext-gcd(12, 11)
ext-gcd(11, 1)ext-gcd(1,0)return (1,1,0) ;; 1 = (1)1 + (0) 0
return (1,0,1) ;; 1 = (0)11 + (1)1
return (1,1,-1) ;; 1 = (1)12 + (-1)11return (1,-1, 3) ;; 1 = (-1)35 +(3)12
![Page 150: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/150.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Claim: Returns (d ,a,b): d = gcd(a,b) and d = ax +by .Example: a−bx/yc ·b =
1−b11/1c ·0 = 1
0−b12/11c ·1 =−1
1−b35/12c · (−1) = 3
ext-gcd(35,12)ext-gcd(12, 11)
ext-gcd(11, 1)ext-gcd(1,0)return (1,1,0) ;; 1 = (1)1 + (0) 0
return (1,0,1) ;; 1 = (0)11 + (1)1return (1,1,-1) ;; 1 = (1)12 + (-1)11
return (1,-1, 3) ;; 1 = (-1)35 +(3)12
![Page 151: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/151.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Claim: Returns (d ,a,b): d = gcd(a,b) and d = ax +by .Example: a−bx/yc ·b =
1−b11/1c ·0 = 10−b12/11c ·1 =−1
1−b35/12c · (−1) = 3
ext-gcd(35,12)ext-gcd(12, 11)
ext-gcd(11, 1)ext-gcd(1,0)return (1,1,0) ;; 1 = (1)1 + (0) 0
return (1,0,1) ;; 1 = (0)11 + (1)1return (1,1,-1) ;; 1 = (1)12 + (-1)11
return (1,-1, 3) ;; 1 = (-1)35 +(3)12
![Page 152: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/152.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Claim: Returns (d ,a,b): d = gcd(a,b) and d = ax +by .Example:
a−bx/yc ·b =
1−b11/1c ·0 = 10−b12/11c ·1 =−11−b35/12c · (−1) = 3
ext-gcd(35,12)ext-gcd(12, 11)
ext-gcd(11, 1)ext-gcd(1,0)return (1,1,0) ;; 1 = (1)1 + (0) 0
return (1,0,1) ;; 1 = (0)11 + (1)1return (1,1,-1) ;; 1 = (1)12 + (-1)11
return (1,-1, 3) ;; 1 = (-1)35 +(3)12
![Page 153: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/153.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Theorem: Returns (d ,a,b), where d = gcd(a,b) and
d = ax +by .
![Page 154: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/154.jpg)
Extended GCD Algorithm.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Theorem: Returns (d ,a,b), where d = gcd(a,b) and
d = ax +by .
![Page 155: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/155.jpg)
Correctness.
Proof: Strong Induction.1
Base: ext-gcd(x ,0) returns (d = x ,1,0) with x = (1)x +(0)y .
Induction Step: Returns (d ,A,B) with d = Ax +ByInd hyp: ext-gcd(y , mod (x ,y)) returns (d∗,a,b) with
d∗ = ay +b( mod (x ,y))
ext-gcd(x ,y) calls ext-gcd(y , mod (x ,y)) so
d = d∗ = ay +b · ( mod (x ,y))
= ay +b · (x−bxycy)
= bx +(a−bxyc ·b)y
And ext-gcd returns (d ,b,(a−b xy c ·b)) so theorem holds!
1Assume d is gcd(x ,y) by previous proof.
![Page 156: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/156.jpg)
Correctness.
Proof: Strong Induction.1
Base: ext-gcd(x ,0) returns (d = x ,1,0) with x = (1)x +(0)y .
Induction Step: Returns (d ,A,B) with d = Ax +ByInd hyp: ext-gcd(y , mod (x ,y)) returns (d∗,a,b) with
d∗ = ay +b( mod (x ,y))
ext-gcd(x ,y) calls ext-gcd(y , mod (x ,y)) so
d = d∗ = ay +b · ( mod (x ,y))
= ay +b · (x−bxycy)
= bx +(a−bxyc ·b)y
And ext-gcd returns (d ,b,(a−b xy c ·b)) so theorem holds!
1Assume d is gcd(x ,y) by previous proof.
![Page 157: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/157.jpg)
Correctness.
Proof: Strong Induction.1
Base: ext-gcd(x ,0) returns (d = x ,1,0) with x = (1)x +(0)y .
Induction Step: Returns (d ,A,B) with d = Ax +ByInd hyp: ext-gcd(y , mod (x ,y)) returns (d∗,a,b) with
d∗ = ay +b( mod (x ,y))
ext-gcd(x ,y) calls ext-gcd(y , mod (x ,y)) so
d = d∗ = ay +b · ( mod (x ,y))
= ay +b · (x−bxycy)
= bx +(a−bxyc ·b)y
And ext-gcd returns (d ,b,(a−b xy c ·b)) so theorem holds!
1Assume d is gcd(x ,y) by previous proof.
![Page 158: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/158.jpg)
Correctness.
Proof: Strong Induction.1
Base: ext-gcd(x ,0) returns (d = x ,1,0) with x = (1)x +(0)y .
Induction Step: Returns (d ,A,B) with d = Ax +ByInd hyp: ext-gcd(y , mod (x ,y)) returns (d∗,a,b) with
d∗ = ay +b( mod (x ,y))
ext-gcd(x ,y) calls ext-gcd(y , mod (x ,y)) so
d = d∗ = ay +b · ( mod (x ,y))
= ay +b · (x−bxycy)
= bx +(a−bxyc ·b)y
And ext-gcd returns (d ,b,(a−b xy c ·b)) so theorem holds!
1Assume d is gcd(x ,y) by previous proof.
![Page 159: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/159.jpg)
Correctness.
Proof: Strong Induction.1
Base: ext-gcd(x ,0) returns (d = x ,1,0) with x = (1)x +(0)y .
Induction Step: Returns (d ,A,B) with d = Ax +ByInd hyp: ext-gcd(y , mod (x ,y)) returns (d∗,a,b) with
d∗ = ay +b( mod (x ,y))
ext-gcd(x ,y) calls ext-gcd(y , mod (x ,y)) so
d = d∗ = ay +b · ( mod (x ,y))
= ay +b · (x−bxycy)
= bx +(a−bxyc ·b)y
And ext-gcd returns (d ,b,(a−b xy c ·b)) so theorem holds!
1Assume d is gcd(x ,y) by previous proof.
![Page 160: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/160.jpg)
Correctness.
Proof: Strong Induction.1
Base: ext-gcd(x ,0) returns (d = x ,1,0) with x = (1)x +(0)y .
Induction Step: Returns (d ,A,B) with d = Ax +ByInd hyp: ext-gcd(y , mod (x ,y)) returns (d∗,a,b) with
d∗ = ay +b( mod (x ,y))
ext-gcd(x ,y) calls ext-gcd(y , mod (x ,y)) so
d = d∗ = ay +b · ( mod (x ,y))
= ay +b · (x−bxycy)
= bx +(a−bxyc ·b)y
And ext-gcd returns (d ,b,(a−b xy c ·b)) so theorem holds!
1Assume d is gcd(x ,y) by previous proof.
![Page 161: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/161.jpg)
Correctness.
Proof: Strong Induction.1
Base: ext-gcd(x ,0) returns (d = x ,1,0) with x = (1)x +(0)y .
Induction Step: Returns (d ,A,B) with d = Ax +ByInd hyp: ext-gcd(y , mod (x ,y)) returns (d∗,a,b) with
d∗ = ay +b( mod (x ,y))
ext-gcd(x ,y) calls ext-gcd(y , mod (x ,y)) so
d = d∗ = ay +b · ( mod (x ,y))
= ay +b · (x−bxycy)
= bx +(a−bxyc ·b)y
And ext-gcd returns (d ,b,(a−b xy c ·b)) so theorem holds!
1Assume d is gcd(x ,y) by previous proof.
![Page 162: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/162.jpg)
Correctness.
Proof: Strong Induction.1
Base: ext-gcd(x ,0) returns (d = x ,1,0) with x = (1)x +(0)y .
Induction Step: Returns (d ,A,B) with d = Ax +ByInd hyp: ext-gcd(y , mod (x ,y)) returns (d∗,a,b) with
d∗ = ay +b( mod (x ,y))
ext-gcd(x ,y) calls ext-gcd(y , mod (x ,y)) so
d = d∗ = ay +b · ( mod (x ,y))
= ay +b · (x−bxycy)
= bx +(a−bxyc ·b)y
And ext-gcd returns (d ,b,(a−b xy c ·b)) so theorem holds!
1Assume d is gcd(x ,y) by previous proof.
![Page 163: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/163.jpg)
Correctness.
Proof: Strong Induction.1
Base: ext-gcd(x ,0) returns (d = x ,1,0) with x = (1)x +(0)y .
Induction Step: Returns (d ,A,B) with d = Ax +ByInd hyp: ext-gcd(y , mod (x ,y)) returns (d∗,a,b) with
d∗ = ay +b( mod (x ,y))
ext-gcd(x ,y) calls ext-gcd(y , mod (x ,y)) so
d = d∗ = ay +b · ( mod (x ,y))
= ay +b · (x−bxycy)
= bx +(a−bxyc ·b)y
And ext-gcd returns (d ,b,(a−b xy c ·b)) so theorem holds!
1Assume d is gcd(x ,y) by previous proof.
![Page 164: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/164.jpg)
Review Proof: step.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Recursively: d = ay +b(x−b xy c ·y) =⇒ d = bx− (a−b x
y cb)y
Returns (d ,b,(a−b xy c ·b)).
![Page 165: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/165.jpg)
Review Proof: step.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Recursively: d = ay +b(x−b xy c ·y)
=⇒ d = bx− (a−b xy cb)y
Returns (d ,b,(a−b xy c ·b)).
![Page 166: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/166.jpg)
Review Proof: step.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Recursively: d = ay +b(x−b xy c ·y) =⇒ d = bx− (a−b x
y cb)y
Returns (d ,b,(a−b xy c ·b)).
![Page 167: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/167.jpg)
Review Proof: step.
ext-gcd(x,y)if y = 0 then return(x, 1, 0)
else(d, a, b) := ext-gcd(y, mod(x,y))return (d, b, a - floor(x/y) * b)
Recursively: d = ay +b(x−b xy c ·y) =⇒ d = bx− (a−b x
y cb)y
Returns (d ,b,(a−b xy c ·b)).
![Page 168: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/168.jpg)
Wrap-up
Conclusion: Can find multiplicative inverses in O(n) time!
Very different from elementary school: try 1, try 2, try 3...
2n/2
Inverse of 500,000,357 modulo 1,000,000,000,000? ≤ 80divisions.
versus 1,000,000
Internet Security.Public Key Cryptography: 512 digits.
512 divisions vs.(10000000000000000000000000000000000000000000)5 divisions.
Next lecture!
![Page 169: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/169.jpg)
Wrap-up
Conclusion: Can find multiplicative inverses in O(n) time!
Very different from elementary school: try 1, try 2, try 3...
2n/2
Inverse of 500,000,357 modulo 1,000,000,000,000? ≤ 80divisions.
versus 1,000,000
Internet Security.Public Key Cryptography: 512 digits.
512 divisions vs.(10000000000000000000000000000000000000000000)5 divisions.
Next lecture!
![Page 170: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/170.jpg)
Wrap-up
Conclusion: Can find multiplicative inverses in O(n) time!
Very different from elementary school: try 1, try 2, try 3...
2n/2
Inverse of 500,000,357 modulo 1,000,000,000,000? ≤ 80divisions.
versus 1,000,000
Internet Security.Public Key Cryptography: 512 digits.
512 divisions vs.(10000000000000000000000000000000000000000000)5 divisions.
Next lecture!
![Page 171: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/171.jpg)
Wrap-up
Conclusion: Can find multiplicative inverses in O(n) time!
Very different from elementary school: try 1, try 2, try 3...
2n/2
Inverse of 500,000,357 modulo 1,000,000,000,000?
≤ 80divisions.
versus 1,000,000
Internet Security.Public Key Cryptography: 512 digits.
512 divisions vs.(10000000000000000000000000000000000000000000)5 divisions.
Next lecture!
![Page 172: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/172.jpg)
Wrap-up
Conclusion: Can find multiplicative inverses in O(n) time!
Very different from elementary school: try 1, try 2, try 3...
2n/2
Inverse of 500,000,357 modulo 1,000,000,000,000? ≤ 80divisions.
versus 1,000,000
Internet Security.Public Key Cryptography: 512 digits.
512 divisions vs.(10000000000000000000000000000000000000000000)5 divisions.
Next lecture!
![Page 173: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/173.jpg)
Wrap-up
Conclusion: Can find multiplicative inverses in O(n) time!
Very different from elementary school: try 1, try 2, try 3...
2n/2
Inverse of 500,000,357 modulo 1,000,000,000,000? ≤ 80divisions.
versus 1,000,000
Internet Security.Public Key Cryptography: 512 digits.
512 divisions vs.(10000000000000000000000000000000000000000000)5 divisions.
Next lecture!
![Page 174: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/174.jpg)
Wrap-up
Conclusion: Can find multiplicative inverses in O(n) time!
Very different from elementary school: try 1, try 2, try 3...
2n/2
Inverse of 500,000,357 modulo 1,000,000,000,000? ≤ 80divisions.
versus 1,000,000
Internet Security.Public Key Cryptography: 512 digits.
512 divisions vs.(10000000000000000000000000000000000000000000)5 divisions.
Next lecture!
![Page 175: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/175.jpg)
Wrap-up
Conclusion: Can find multiplicative inverses in O(n) time!
Very different from elementary school: try 1, try 2, try 3...
2n/2
Inverse of 500,000,357 modulo 1,000,000,000,000? ≤ 80divisions.
versus 1,000,000
Internet Security.
Public Key Cryptography: 512 digits.512 divisions vs.(10000000000000000000000000000000000000000000)5 divisions.
Next lecture!
![Page 176: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/176.jpg)
Wrap-up
Conclusion: Can find multiplicative inverses in O(n) time!
Very different from elementary school: try 1, try 2, try 3...
2n/2
Inverse of 500,000,357 modulo 1,000,000,000,000? ≤ 80divisions.
versus 1,000,000
Internet Security.Public Key Cryptography: 512 digits.
512 divisions vs.(10000000000000000000000000000000000000000000)5 divisions.
Next lecture!
![Page 177: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/177.jpg)
Wrap-up
Conclusion: Can find multiplicative inverses in O(n) time!
Very different from elementary school: try 1, try 2, try 3...
2n/2
Inverse of 500,000,357 modulo 1,000,000,000,000? ≤ 80divisions.
versus 1,000,000
Internet Security.Public Key Cryptography: 512 digits.512 divisions vs.
(10000000000000000000000000000000000000000000)5 divisions.
Next lecture!
![Page 178: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/178.jpg)
Wrap-up
Conclusion: Can find multiplicative inverses in O(n) time!
Very different from elementary school: try 1, try 2, try 3...
2n/2
Inverse of 500,000,357 modulo 1,000,000,000,000? ≤ 80divisions.
versus 1,000,000
Internet Security.Public Key Cryptography: 512 digits.512 divisions vs.(10000000000000000000000000000000000000000000)5 divisions.
Next lecture!
![Page 179: Inverses - EECS Instructional Support Group Home Pagecs70/fa16/static/slides/lec-9.pdfRefresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5)=10 =1 mod](https://reader030.vdocuments.us/reader030/viewer/2022041208/5d6645c888c9937a098bb0bf/html5/thumbnails/179.jpg)
Wrap-up
Conclusion: Can find multiplicative inverses in O(n) time!
Very different from elementary school: try 1, try 2, try 3...
2n/2
Inverse of 500,000,357 modulo 1,000,000,000,000? ≤ 80divisions.
versus 1,000,000
Internet Security.Public Key Cryptography: 512 digits.512 divisions vs.(10000000000000000000000000000000000000000000)5 divisions.
Next lecture!