GCDs & linear gcd(a,b) is an integer combinations: linear - - PowerPoint PPT Presentation

gcd s linear
SMART_READER_LITE
LIVE PREVIEW

GCDs & linear gcd(a,b) is an integer combinations: linear - - PowerPoint PPT Presentation

GCD is a linear combination Mathematics for Computer Science MIT 6.042J/18.062J Theorem: GCDs & linear gcd(a,b) is an integer combinations: linear combination of a and b . The Pulverizer gcd(a,b) = sa + tb Albert R Meyer March 6,


slide-1
SLIDE 1

Albert R Meyer March 6, 2015

Mathematics for Computer Science

MIT 6.042J/18.062J

GCD’s & linear combinations: The Pulverizer

pulverizer.1

Albert R Meyer March 6, 2015 Albert R Meyer March 6, 2015

GCD is a linear combination

Corollary:

The multiples of gcd(a,b) are exactly the linear combinations of a and b.

pulverizer.3

Albert R Meyer March 6, 2015

gcd(a,b) = sa+tb

Proof: Show how to find

coefficients s,t.

Method: apply Euclidean

algorithm, finding coefficients as you go.

pulverizer.4

1

GCD is a linear combination

Theorem:

gcd(a,b) is an integer linear combination of a and b.

gcd(a,b) = sa+tb

pulverizer.2

slide-2
SLIDE 2

Albert R Meyer March 6, 2015

Extending Euclid

In Euclid have gcd(x,y) = gcd(a,b) . Track coeff’s c,d,e,f ca+db= x and ea+fb= y

pulverizer.5

Albert R Meyer March 6, 2015

Extending Euclid

In Euclid have gcd(x,y) = gcd(a,b) . Track coeff’s c,d,e,f ca+db= x and ea+fb= y to start:

x = a = 1a+0b

pulverizer.6

Albert R Meyer March 6, 2015

Extending Euclid

In Euclid have gcd(x,y) = gcd(a,b) . Track coeff’s c,d,e,f ca+db= x and ea+fb= y to start:

y = b = 0a+1b

pulverizer.7

Albert R Meyer March 6, 2015

Extending Euclid

xnext = y = ea+fb ynext = rem(x,y) =

x-qy = ca+db - q(ea+fb)

pulverizer.8

2

slide-3
SLIDE 3

Albert R Meyer March 6, 2015

Extending Euclid

xnext = y = ea+fb ynext = rem(x,y) =

x-qy =

(c-

pulverizer.9

  • qe)a+(d-qf)b

Albert R Meyer March 6, 2015 Albert R Meyer March 6, 2015

the Pulverizer s = -6, t = 11

Albert R Meyer March 6, 2015

gcd(899,493) = -

  • 6·899 + 11·493

get positive coeff. for 899?:

=(-6+493k)·899 + (11-899k)·493

let k be 1:

= 487·899 - 888·493

pulverizer.12

Finding s>0 and t

3

Finding s and t

Example: a = 899, b=493

899 = 1·493 + 406 so 406 = 1·a + -1·b 493 = 1·406 + 87 so 87 = 1·b – 1·406 = -1·a + 2·b 406 = 4·87 + 58 so 58 = 1·406 - 4·87 = 5·a + -9·b 87 = 1·58 + 29 so 29 = 1·87 – 1·58 = -6·a + 11·b 58 = 2·29 + 0 done, gcd = 29

pulverizer.10

Finding s and t

Example: a = 899, b=493

899 = 1·493 + 406 so 406 = 1·a + -1·b 493 = 1·406 + 87 so 87 = 1·b – 1·406 = -1·a + 2·b 406 = 4·87 + 58 so 58 = 1·406 - 4·87 = 5·a + -9·b 87 = 1·58 + 29 so 29 = 1·87 – 1·58 = -6·a + 11·b 58 = 2·29 + 0 done, gcd = 29

pulverizer.11

slide-4
SLIDE 4

Albert R Meyer March 6, 2015

Pulverizer is efficient

Same number of transitions as Euclid

pulverizer.13

Albert R Meyer March 6, 2015

Pulverizer is efficient

Same number of transitions as Euclid, a few more adds/mults

per transition. So halts after at most

10log

  • perations

2 b

pulverizer.14

4

slide-5
SLIDE 5

MIT OpenCourseWare https://ocw.mit.edu

6.042J / 18.062J Mathematics for Computer Science

Spring 2015 For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.