当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

《Mathematics for Computer》Notes for recitation 6

资源类别:文库,文档格式:PDF,文档页数:6,文件大小:145.19KB,团购合买
1 The pulverizer We saw in lecture that the greatest common divisor(GCD)of two numbers can be written as a linear combination of them. That is, no matter which pair of integers a and b we are given, there is always a pair of integer coefficients s and t such that
点击下载完整版文档(PDF)

6.042/18.] Mathematics for Computer Science February 18, 2005 Srini devadas and Eric Lehman Notes for recitation 6 1 The pulverizer We saw in lecture that the greatest common divisor(GCD)of two numbers can be written as a linear combination of them. That is, no matter which pair of integers a and b we are given, there is always a pair of integer coefficients s and t such that gcd(a, b)=sa+tb However, the proof was nonconstructive: it didnt suggest a way for finding such s and t That job is tackled by a mathematical tool that dates to sixth-century India, where it was called kutta, which means"The Pulverizer". Today the Pulverizer is more commonly known as"the extended Euclidean GCD algorithm", but thats lame Were sticking with Euclids algorithm for finding the GCD of two numbers relies on repeated application of the equation gcd(a, b)=gcd(b, a rem b) hich was proved in lecture(see the notes"Number Theory I"). For example, we can compute the god of 259 and 70 as follows: gcd(259,70)=gcd(70,49) since 259 rem 70=49 gcd(49,21 since 70 rem 49=21 gcd(21,7) since 49 rem 21=7 gcd(7,0) since 21 rem 7=0 The Pulverizer goes through the same steps, but requires some extra bookkeeping along the way: as we compute ged(a, b), we keep track of how to write each of the remainders (49, 21, and 7, in the example)as a linear combination of a and b(this is worthwhile, because our objective is to write the last nonzero remainder, which is the GCD, as such a In fact, we proved that among all positive linear combinations of the numbers their GCD is the smallest

6.042/18.062J Mathematics for Computer Science February 18, 2005 Srini Devadas and Eric Lehman Notes for Recitation 6 1 The Pulverizer We saw in lecture that the greatest common divisor (GCD) of two numbers can be written as a linear combination of them.1 That is, no matter which pair of integers a and b we are given, there is always a pair of integer coefficients s and t such that gcd(a, b) = sa + tb. However, the proof was nonconstructive: it didn’t suggest a way for finding such s and t. That job is tackled by a mathematical tool that dates to sixth­century India, where it was called kuttak, which means “The Pulverizer”. Today, the Pulverizer is more commonly known as “the extended Euclidean GCD algorithm”, but that’s lame. We’re sticking with “Pulverizer”. Euclid’s algorithm for finding the GCD of two numbers relies on repeated application of the equation: gcd(a, b) = gcd(b, a rem b) which was proved in lecture (see the notes “Number Theory I”). For example, we can compute the GCD of 259 and 70 as follows: gcd(259, 70) = gcd(70, 49) since 259 rem 70 = 49 = gcd(49, 21) since 70 rem 49 = 21 = gcd(21, 7) since 49 rem 21 = 7 = gcd(7, 0) since 21 rem 7 = 0 = 7. The Pulverizer goes through the same steps, but requires some extra bookkeeping along the way: as we compute gcd(a, b), we keep track of how to write each of the remainders (49, 21, and 7, in the example) as a linear combination of a and b (this is worthwhile, because our objective is to write the last nonzero remainder, which is the GCD, as such a 1In fact, we proved that among all positive linear combinations of the numbers their GCD is the smallest

Recitation 6 linear combination). For our example, here is this extra bookkeeping t rem y 259-3·70 70-1·(259-3·70) 1·259+4·70 (259-3:70)-2·(-1·259+4.70) 3·259-11·70 21 We began by initializing two variables, a and y=b In the first two columns above, we carried out Euclids algorithm. At each step, we computed a rem y, which can be written form a-q y (Remember that the Division Algorithm says =q y+r, where r is the remainder. We get r=r-q y by rearranging terms. Then we replaced a and y in this equation with equivalent linear combinations of a and b, which we already had computed. After simplifying, we were left with a linear combination of a and b that was equal to the remainder as desired. The final solution is boxed

Recitation 6 2 linear combination). For our example, here is this extra bookkeeping: x y (x rem y) = x − q · y 259 70 49 = 259 − 3 · 70 70 49 21 = 70 − 1 · 49 = 70 − 1 · (259 − 3 · 70) = −1 · 259 + 4 · 70 49 21 7 = 49 − 2 · 21 = (259 − 3 · 70) − 2 · (−1 · 259 + 4 · 70) = 3 · 259 − 11 · 70 21 7 0 We began by initializing two variables, x = a and y = b. In the first two columns above, we carried out Euclid’s algorithm. At each step, we computed x rem y, which can be written in the form x − q · y. (Remember that the Division Algorithm says x = q · y + r, where r is the remainder. We get r = x − q · y by rearranging terms.) Then we replaced x and y in this equation with equivalent linear combinations of a and b, which we already had computed. After simplifying, we were left with a linear combination of a and b that was equal to the remainder as desired. The final solution is boxed

Recitation 6 2 Problem: The pulverizer! There is a pond. Inside the pond there are n pebbles, arranged in a cycle. A frog itting on one of the pebbles. Whenever he jumps, he lands exactly k pebbles away in the clockwise direction, where<k< n. The frogs meal, a delicious worm, lies on the pebble right next to his, in the clockwise direction (a) Describe a situation where the frog cant reach the worm Solution. If k: I n(say k=3 and n=6), then no number of jumps will lead the frog to the worm, as the frog will be returning to his original pebble ad infinitum (b) In a situation where the frog can actually reach the worm, explain how to use the Pulverizer to find how many jumps the frog will need Solution. Suppose the frog can reach the worm. When he actually reaches it, he has call it c. Then, the distance that the frog has covered is both j.k and c.n+ l, so thar hes jumped a number of times, say j, and he has travelled around the cycle a number of tin +1 But this means that 1 can be written as a linear combination of n and k: (-c)n+jk=1 Since 1 is positive, we conclude that it is a positive linear combination of n and k. And since it is the smallest positive integer, we also conclude that it is the smallest positive linear combination of n and k. But we have proved in lecture that the smallest positive linear combination of two integers is their gCd. so, the gcd of n and k is 1 ged(n, k)=1 and we can use the pulverizer to find -c and (c)Compute the number of jumps if n= 50 and k= 21. anything strange? Solution. We go through the steps as described in Section 1(see the table below)to get that1=8:50-19·21,or1=-(-8)·50+(-19)·21. Hence,c=-8and 19, which makes little sense. What does it mean for the frog to make -19 jumps? The point is that the Pulverizer is guaranteed to give us the integers coefficients of a linear combination that equals the GCD, but it promises nothing about the signs of those coefficients-which, in this case we wanted them to be -and + To get coefficients of the desired sign, we have to think more(and much less after the next lecture) Y. So, we know 1=8 50-19. 21. Or, to obtain meaningful signs for the numbers, 21=8. 50-1. That is, after 19 jumps the frog will have covered 8 full cycles but I pebble. So, he will be right next to his original pebble, but in the counter-clockwise direction. Given this, how can he reach the pebble he is after

Recitation 6 3 2 Problem: The Pulverizer! There is a pond. Inside the pond there are n pebbles, arranged in a cycle. A frog is sitting on one of the pebbles. Whenever he jumps, he lands exactly k pebbles away in the clockwise direction, where 0 < k < n. The frog’s meal, a delicious worm, lies on the pebble right next to his, in the clockwise direction. (a) Describe a situation where the frog can’t reach the worm. Solution. If k | n (say k = 3 and n = 6), then no number of jumps will lead the frog to the worm, as the frog will be returning to his original pebble ad infinitum. (b) In a situation where the frog can actually reach the worm, explain how to use the Pulverizer to find how many jumps the frog will need. Solution. Suppose the frog can reach the worm. When he actually reaches it, he has jumped a number of times, say j, and he has travelled around the cycle a number of times, call it c. Then, the distance that the frog has covered is both j · k and c · n + 1, so that jk = cn + 1. But this means that 1 can be written as a linear combination of n and k: (−c)n + jk = 1. Since 1 is positive, we conclude that it is a positive linear combination of n and k. And since it is the smallest positive integer, we also conclude that it is the smallest positive linear combination of n and k. But we have proved in lecture that the smallest positive linear combination of two integers is their GCD. So, the GCD of n and k is 1: gcd(n, k) = 1 and we can use the Pulverizer to find −c and j. (c) Compute the number of jumps if n = 50 and k = 21. Anything strange? Solution. We go through the steps as described in Section 1 (see the table below) to get that 1 = 8 · 50 − 19 · 21, or 1 = −(−8) · 50 + (−19) · 21. Hence, c = −8 and j = −19, which makes little sense. What does it mean for the frog to make −19 jumps? The point is that the Pulverizer is guaranteed to give us the integers coefficients of a linear combination that equals the GCD, but it promises nothing about the signs of those coefficients —which, in this case we wanted them to be − and +. To get coefficients of the desired sign, we have to think more (and much less after the next lecture). So, we know 1 = 8 · 50 − 19 · 21. Or, to obtain meaningful signs for the numbers, 19 · 21 = 8 · 50 − 1. That is, after 19 jumps the frog will have covered 8 full cycles but 1 pebble. So, he will be right next to his original pebble, but in the counter­clockwise direction. Given this, how can he reach the pebble he is after?

Recitation 6 Well, if he makes 19 more jumps, he will land 2 pebbles away from his original position in the counter-clockwise direction. Another 19 jumps will lead him 3 pebbles away, and so on. After a total of 49 sets of 19 jumps, he will be 49 pebbles away from its original position in the counter-clockwise direction, which is of course the worms pebble. Then, the frog will have made 49* 19=931 jumps Here is the table produced by the Pulverizer: r rem 21 50-2.21 21 5=21-2.8 21-2·(50-2·21) 2·50+5.21 8-1.5 (50-2·21)-1·(-2.50+5·21) +5·21)-1·(3·50-7·21) 5·50+12.21 3-1·2 (3·50-7·21)-1.(-5:50+12.21) 8·50-19.21

Recitation 6 4 Well, if he makes 19 more jumps, he will land 2 pebbles away from his original position in the counter­clockwise direction. Another 19 jumps will lead him 3 pebbles away, and so on. After a total of 49 sets of 19 jumps, he will be 49 pebbles away from its original position in the counter­clockwise direction, which is of course the worm’s pebble. Then, the frog will have made 49 ∗ 19 = 931 jumps. Here is the table produced by the Pulverizer: x y (x rem y) = x − q · y 50 21 8 = 50 − 2 · 21 21 8 5 = 21 − 2 · 8 = 21 − 2 · (50 − 2 · 21) = −2 · 50 + 5 · 21 8 5 3 = 8 − 1 · 5 = (50 − 2 · 21) − 1 · (−2 · 50 + 5 · 21) = 3 · 50 − 7 · 21 5 3 2 = 5 − 1 · 3 = (−2 · 50 + 5 · 21) − 1 · (3 · 50 − 7 · 21) = −5 · 50 + 12 · 21 3 2 1 = 3 − 1 · 2 = (3 · 50 − 7 · 21) − 1 · (−5 · 50 + 12 · 21) = 8 · 50 − 19 · 21 2 1 0

Recitation 6 3 Problem: The Fibonacci numbers. Again. Give an inductive proof that the Fibonacci numbers Fn and Fn+i are relatively prime for all n>0. Recall that the fibonacci numbers are defined as follows: Fo=0 Fi=1 Fn= Fn-1+ Fn-2(for n> 2) Solution. We use induction on n. Let P(n) be the proposition that Fn and Fn+1 are latively prime Base case P(O)is true because Fo=0 and Fi=l are relatively prime Inductive step: We show that, for all n 20, P(n)implies P(n+1). So, fix some n 20 and assume that P(n) is true, that is, Fn and Fn+1 are relatively prime. We will show that Fn+ and Fn+2 are relatively prime as well. We will do this by contradiction Suppose Fn+1 and Fn+2 are not relatively prime. Then they have a common divisor d> 1. But then d also divides the linear combination Fn+2-Fn+1, which actually equals Hence, d> l divides both Fn and Fn+1. Which implies Fn, Fn+1 are not relatively prime, a contradiction to the inductive hypothesis Therefore, Fn+1 and Fn+2 are relatively prime. That is, P(n+1)is true The theorem follows by induction

Recitation 6 5 3 Problem: The Fibonacci numbers. Again. Give an inductive proof that the Fibonacci numbers Fn and Fn+1 are relatively prime for all n ≥ 0. Recall that the Fibonacci numbers are defined as follows: F0 = 0 F1 = 1 Fn = Fn−1 + Fn−2 (for n ≥ 2). Solution. We use induction on n. Let P(n) be the proposition that Fn and Fn+1 are relatively prime. Base case: P(0) is true because F0 = 0 and F1 = 1 are relatively prime. Inductive step: We show that, for all n ≥ 0, P(n) implies P(n + 1). So, fix some n ≥ 0 and assume that P(n) is true, that is, Fn and Fn+1 are relatively prime. We will show that Fn+1 and Fn+2 are relatively prime as well. We will do this by contradiction. Suppose Fn+1 and Fn+2 are not relatively prime. Then they have a common divisor d > 1. But then d also divides the linear combination Fn+2 − Fn+1, which actually equals Fn. Hence, d > 1 divides both Fn and Fn+1. Which implies Fn, Fn+1 are not relatively prime, a contradiction to the inductive hypothesis. Therefore, Fn+1 and Fn+2 are relatively prime. That is, P(n + 1) is true. The theorem follows by induction

Recitation 6 4 Problem: The power of 3 Let n be a number whose decimal expansion consists of 3" identical digits. Show b induction that 3"N. For example 32|777 Recall that 3 divides a number iff it divides the sum of its digits Solution. We proceed by induction on n. Let P(n) be the proposition that 3n| M where the decimal expansion of N consists of 3" identical digits Base case. P(O)is true because 3=1 divides every number Inductive step. Now we show that, for all n20, P(n) implies P(n+1). Fix any n 20 and assume P(n)is true. Consider a number whose decimal expansion consists of 3 n+i copies aaaaaa aad:: aag:y aaaaaa. aag 1000...001000..001 Now 3 divides the first term by the assumption P(n), and 3 divides the second term since the digits sum to 3. Therefore, the whole expression is divisible by 3"+. This proves P(n+1) By the principle of induction P(n)is true for all n>0

� �� Recitation 6 6 4 Problem: The power of 3. Let N be a number whose decimal expansion consists of 3n identical digits. Show by induction that 3n | N. For example: 32 777777777� | 32 = 9 digits Recall that 3 divides a number iff it divides the sum of its digits. Solution. We proceed by induction on n. Let P(n) be the proposition that 3n | N, where the decimal expansion of N consists of 3n identical digits. Base case. P(0) is true because 30 = 1 divides every number. Inductive step. Now we show that, for all n ≥ 0, P(n) implies P(n + 1). Fix any n ≥ 0 and assume P(n) is true. Consider a number whose decimal expansion consists of 3n+1 copies of the digit a: aaaaaa . . . aaaaaa = aaa . . . aaa aaa . . . aaa aaa . . . aaa � �� � � �� � � �� � � �� � 3n+1 digits 3n digits 3n digits 3n digits = aaa . . . aaa 1 000 . . . 001 000 . . . 001 � �� � � · � �� � � �� 3n digits 3n digits 3n digits Now 3n divides the first term by the assumption P(n), and 3 divides the second term since the digits sum to 3. Therefore, the whole expression is divisible by 3n+1. This proves P(n + 1). By the principle of induction P(n) is true for all n ≥ 0

点击下载完整版文档(PDF)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
已到末页,全文结束
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有