150 likes | 281 Views
MAT 320 Spring 2008 Section 1.2. The Euclidean Algorithm. How the Algorithm Works. Start with two integers for which you want to find the GCD. Apply the division algorithm, dividing the smaller number into the larger. Example: a = 320, b = 296. 320 = 296 · 1 + 24
E N D
MAT 320 Spring 2008 Section 1.2 The Euclidean Algorithm
How the Algorithm Works • Start with two integers for which you want to find the GCD. Apply the division algorithm, dividing the smaller number into the larger. • Example: a = 320, b = 296. • 320 = 296 · 1 + 24 • The first quotient is q0 and the first remainder is r0.
How the Algorithm Works (cont.) • If you get a remainder of 0, stop. If not, the divisor from the previous step becomes the dividend of the next step. The remainder from the previous step becomes the divisor of the previous step. • 320 = 296 · 1 + 24 • 296 = 24 · 12 + 8 • Continue until you get a remainder of 0.
The Completed Algorithm • 320 = 296 · 1 + 24 • 296 = 24 · 12 + 8 • 24 = 8 · 3 + 0 • We get a remainder of 0, so we stop. The last nonzero remainder is the GCD, so (320, 296) is equal to 8.
Another Example • Compute (346, 592). • 592 = 346 · 1 + 246 • 346 = 246 · 1 + 100 • 246 = 100 · 2 + 46 • 100 = 46 · 2 + 8 • 46 = 8 · 5 + 6 • 8 = 6 · 1 + 2 • 6 = 2 · 3 + 0 • So (346, 592) = 2.
The Euclidean Algorithm and Bézout’s Theorem • We can use the Euclidean Algorithm to find the integers U and V from Bézout’s Theorem. • As an example, let’s use the Euclidean Algorithm to show that (324, 148) = 4. • 324 = 148 · 2 + 28 • 148 = 28 · 5 + 8 • 28 = 8 · 3 + 4 • 8 = 4 · 2 + 0
Finding U and V • We want to find integers U and V such that 4 = 324U + 148V. • Take all of the equations (except the last one) and solve for the remainder. • 28 =324 – 148 · 2 • 8 = 148 – 28 · 5 • 4= 28 – 8 · 3
Back-Substitution • Notice that the last equation expresses 4 as a linear combination of 28 and 8. • 4= 28 · 1 + 8 · (-3) • This is not what we want, however. So we use the previous equation (which has been solved for 8) to substitute.
Back-Substitution (cont.) • 4= 28 · 1 + (148 – 28 · 5) · (-3) • Now we want to rearrange this so that 4 is expressed as a linear combination of 28 and 148 (still not quite what we want, but getting closer) • We get 4 = 28 · 16 + 148 · (-3)
Back-Substitution (cont.) • Now use the previous equation (which has been solved for 28) to substitute. • We get 4 = (324 – 148 · 2) · 16 + 148 · (-3) • Once again, multiply out and rearrange until we get 4 expressed as a linear combination of 324 and 148. • 4 = 324 · 16 + 148 · (-35)
Another Example • Use the Euclidean Algorithm to show that(15, 36) = 3. • Use back-substitution to find integers U and V so that 3 = 15U + 36V.