Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3.

Similar presentations


Presentation on theme: "The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3."— Presentation transcript:

1 The Integers

2 The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3 remainder 7”. In other words, the quotient is 3 and the remainder is 7. It is also true that 58 = 2(17) + 24, but 24 > 17, and remainder must always be < divisor. (otherwise the “quotient” is not a quotient).

3 Quotient and Remainder are Unique

4 Representation is Unique Proof (Continue): Now we need to show that q, r are unique. Assume, for the sake of contradiction, that there are two such presentations for a, that is: a = q b+r, a = m b + n, where 0  r < b, 0  n < b. Then q b+r = m b + n implies b(q-m) = n – r. Next, since q  m, we have b(q-m) is an integral multiple of b. But since 0  r < b, 0  n < b we have –b < (n – r) < b always! Then |b(q-m)| is at least b, and (n-r) is at most b-1. So they cannot be equal: contradiction! Conclusion: a cannot have two presentations as above.

5 Proof of Uniqueness Remark: The standard approach in uniqueness proofs is to assume by contradiction that there are two forms, and then apply a sequence of arguments leading to a contradiction. Here we assumed a is two forms: a = q b+r and a = m b + n, and then concluded this results in a contradiction.

6 Quotient and Remainder

7 An Extension to Integer Numbers The property a = q b+r, 0  r < b can be extended to all integers (so far we discussed only natural numbers). Exception: b cannot be 0, why? Theorem (The Division Algorithm): Given integer numbers a and b, b  0, there are unique integers q and r, with 0  r < |b|, s.t., a = q b+r Proof: By case analysis. We already showed the case where a, b are both positive. If a=0, then q = r = 0 is the only solution. Consider next the other cases:

8 An Extension to Integer Numbers: Proof Proof (continue): Case 1: b > 0, a < 0. In this case, since –a > 0, we have unique integers q, r s.t., (-a) = q b + r, 0  r < b a = (-q) b – r. Recall that our goal is to have a non-negative remainder term. Therefore, if r = 0, we just have a = (-q) b. Otherwise, r > 0, then write a as follows: a = (-q -1)b + (b-r). Here (-q-1) is an integer, and 0 < b-r < b = |b|. Thus we have the desired form.

9 An Extension to Integer Numbers: Proof Proof (continue): Case 2: b 0. In this case, since –b > 0, we have unique integers q, r s.t., a = q(-b) + r, 0  r < |b|. [Here we apply the Theorem on the natural numbers if a > 0, and case 1 of this proof if a < 0.] Thus a has the desired form and we are done! QED Remarks: 1.The proof indeed covers all cases of all values of a, b (recall that b  0 always). 2.This proof is strongly relying on the same Theorem for natural number (proved before).

10 Example

11 The Sign of b

12 Divisibility and the Euclidean Algorithm

13 Three consecutive integers Problem: Given three consecutive integers a, a+1, a+2, prove that one of them must be divisible by 3. proof: By the division algorithm we have: a = 3 q + r, where 0  r < 3. That is, there are three possible values for r, r = 0, 1, 2. We follow each of these cases: Case 1, r = 0: here we have a = 3 q is divisible by 3. Case 2, r = 1: here we have a = 3 q +1, and thus a+2 = 3 q + 3 is divisible by 3. Case 3, r = 2: here we have a = 3 q +2, and thus a+1 = 3 q + 3 is divisible by 3.

14 Division and Partial Orders Let us define a binary relation on the natural numbers: R = { (a,b)  a, b  and a | b } [That is, we consider only those pairs (a,b) of naturals s.t. a divides b.] Proposition: The binary relation R is a partial order. proof: For partial orders, one needs to show reflexivisity, antisymmetry, and transitivity.

15 Division and Partial Orders Proof (continue): R is reflexive: For any a , a | a, since a/a = 1. R is antisymmetric: Suppose we are given a pair a, b , s.t. a | b and b | a. Then a = m b, for some natural number m, and b = q a, for some natural number q. a = m b = m (q a) = (m q) a. Since a > 0 we must have m q = 1, but since m, q are natural numbers then we must have m = q =1. Thus a = m b = b.

16 Division and Partial Orders Proof (continue): R is transitive: Suppose a, b, c , s.t. a | b and b | c. Then b = q a, for some natural number q, and c = m b, for some natural number m. c = m b = m (q a) = (m q) a, and (m q) is a natural number. We thus conclude a | c. QED Remark: The proposition implies that ( , | ) is a partially ordered set (POSET).

17 Division and Partial Orders Example: A = {1, 2, 3, 4, 5, 6}. In the poset (A, | ) what are the maximal elements? - 4 is maximal because there is no other a  A s.t. 4 | a. -5, 6 are also maximal since they do not divide any other number. However, 4 does not divide 5 nor 6 and thus it is NOT maximum. -3 is NOT maximal as 3 | 6. -2 is NOT maximal as 2 | 4, 2 | 6. -1 is minimum, as 1 divides each number in A.

18 Division and Partial Orders Proposition: Suppose a, b, c are integers such that c | a, a | b. Then c | (xa +yb), for any integers x, y. Proof: Since c | a we have a = q c, for some integer q. Since c | b we also have b = m c, for some integer m. Thus xa +yb = x (q c) + y (m c) = (xq + ym) c. Since (xq + ym) is an integer, we indeed have c | (xa +yb).

19 The greatest common divisor Definition: Let a, b be integers, s.t. at least one of them is not 0. An integer g is the greatest common divisor (gcd) of a and b iff g is the largest common divisor of a and b, that is: 1.g | a, g | b. 2.If c is any integer s.t. c | a, c | b, then c  g. We write g = gcd(a,b) to imply that g is the greatest common divisor of a and b. In this notation, a  b.

20 The greatest common divisor Examples: 1.gcd(15, 3) = 3. 2.gcd(-24, 18) = 6. 3.gcd(756, 210) = 42. 4.gcd(-756, 210) = 42. 5.gcd(-756, -210) = 42 If a, b are integers and a | b, we have gcd(b, a) = a. Suppose a is non zero, then gcd(a, 0) = a. Why? Claim: dcg(a, b)  1 always! (when one of a, b is nonzero) [1 is always a common divisor.]

21 The Euclidean Algorithm In general, an algorithm is a computational procedure that computes/reports an output given an input. Given two integers a, b, we would like to computer their gcd. This computation relies on the following key property: Based on the Division algorithm, we have a = q b + r, (recall a  b ) Lemma (proved below) : gcd(a, b) = gdc(b, r)

22 The Euclidean Algorithm We first discuss the consequences of the lemma, and only then prove it. This lemma implies that we can reduce the problem to a pair of smaller numbers, intuitively, this should make the problem easier, and it does! Example: 58 = 3 (17) + 7, therefore gcd(58,17) = gcd(17,7). On the next iteration, we have 17 = 2(7) + 3, then gcd(17,7) = gcd(7,3). Next, we have 7 = 2(3) + 1, then gcd(7,3) = gcd(3,1) = 1.

23 The Euclidean Algorithm Lemma (proved now) : If a = q b + r, for naturals a, b, q, and r. Assume a  b. Then gcd(a, b) = gdc(b, r). Proof: By assumption, none of a, b are zero. This in particular implies that both g 1 = gcd(a, b), and g 2 = gcd(b, r) are well defined (i.e., we do not divide by 0). By definition, g 2 | b and g 2 | r so g 2 | (q b + r), (why?) and therefore g 2 | a. Thus g 2 is a common divisor of a and b.

24 The Euclidean Algorithm Proof (continue): But since g 1 is the largest common divisor of a, b we must have g 2  g 1. Similarly, since g 1 | a and g 1 | b, we have g 1 | (a – q b) (Why?) That is, g 1 | r. So g 1 divides both r and b. Once again, since g 2 is the greatest common divisor of b and r: g 1  g 2. Then we conclude: g 1 = g 2.

25 The Euclidean Algorithm First, observe that it is sufficient to assume a, b are natural numbers, as we can change the sign of the gcd if exactly one of a or b is negative. [For example, gcd(756, 210) = 42, gcd(-756, 210) = 42, etc. ] Input: Two natural numbers a, b, with a  b. Output: gcd(a, b). We need to describe a procedure to compute gcd(a, b)

26 The Euclidean Algorithm: The actual procedure procedure to compute gcd(a, b): Write a = q 1 b + r 1, with 0  r 1 < b. If r 1  0, write b = q 2 r 1 + r 2, with 0  r 2 < r 1. If r 2  0, write r 1 = q 3 r_2 + r 3, with 0  r 3 < r 2. If r 3  0, write r 2 = q 4 r 3 + r 4, with 0  r 4 < r 3. Continue in this manner until some remainder r k = 0. Then gcd(a, b) is r k-1 (the last non-zero reminder). But why does the process must converge?

27 The Euclidean Algorithm: Convergence Why do we always end up with a remainder 0? In the process, we always have r 1 > r 2 > r 3 > r 4 > … That is, at every iteration the value of r k decreases by at least one, but all remainders are non-negative. Therefore, sooner or later one of the remainders r k will become 0. [This is called the “Well-Ordering Principle”.] At that step, we have r k-2 = q k r k-1 + r k, Then since r k = 0 we have gcd(a, b) = gcd(r k-2, r k-1 ) = r k-1.

28 The Euclidean Algorithm: Convergence More specifically, since r k = 0 we have gcd(a, b) = gcd(n, r 1 ) = gcd (r 1, r 2 ) = gcd (r 2, r 3 ) = … gcd(r k-2, r k-1 ) = gcd(r k-1, 0) = r k-1. Problem: Find gcd(630, 196). Solution: 630 = 3(196) + 42. 196 = 4(42) + 28. 42 = 1(28) + 14. 28 = 2(14) + 0 The last non-zero reminder is 14, and thus gcd(630, 196)=14.

29 The Euclidean Algorithm Same Problem: Find gcd(630, 196). We now write the same equations slightly differently, expressing each remainder in terms of a and b. 42 = 630 – 3(196) : r 1 = a – 3b 28 = 196 – 4(42) : r 2 = b – 4r 1 = b – 4(a – 3b) = -4a + 13b 14 = 42 – 28 : r 3 = r 1 - r 2 = (a – 3b) – (-4a + 13b) = 5a – 16b Then we have: gcd(630, 196) = 14 = 5a – 16b = 5(630) – 16(196).

30 The Euclidean Algorithm This example shows that gcd(a, b) can be expressed as an integral linear combination of a and b. That is, each remainder can be written as: m a + n b, for some integers m, n. In particular, this is the form of the greatest common divisor. In our example we have: gcd(630, 196) = 14 = 5a – 16b = 5(630) – 16(196). More examples: gcd(1800, 756) = 36 and here gcd(1800, 756) = 36 = 8(1800) – 19(756). (Check!)

31 The Euclidean Algorithm This example shows that gcd(a, b) can be expressed as an integral linear combination of a and b. That is, each remainder can be written as: m a + n b, for some integers m, n. In particular, this is the form of the greatest common divisor. In our example we have: gcd(630, 196) = 14 = 5a – 16b = 5(630) – 16(196). More examples: gcd(1800, 756) = 36 and here gcd(1800, 756) = 36 = 8(1800) – 19(756). (Check!)

32 The Euclidean Algorithm This principle is summarized in the following theorem: Theorem [An important property!]: The greatest common divisor of integers a, b is an integral linear combination of them. That is, there are integers m, n such that: gcd(a, b) = m a + n b Remark: The sign of n, m is determined by the sign of a, b. If a, b, are naturals then n must be negative. If, for example, only b is negative, then m, n are positive etc. gcd(1800, 756) = 36 = 8(1800) - 19(756) gcd(1800, -756) = 36 = 8(1800) + 19(-756)

33 The Euclidean Algorithm Definition (Relatively prime): Two non-zero integers a, b are relatively prime iff gcd(a, b) = 1, that is, 1 is the only positive integer that divides both of them. Example: gcd(15, 4) = 1, gcd(21, 6) = 1. Note that a, b, are not necessarily prime, only their dcg is 1. Corollary of previous therem: Let a, b, x be integers with a | b x. If a, b are relatively prime, then a | x.

34 The Euclidean Algorithm Proof: Since a, b, are relatively primes, gcd(a, b) = 1. Then, by previous theorem, there are integers, m, n s.t.: 1 = m a + n b. Multiplying by x: x = x m a + x n b. Clearly, a | (x m a). We also have a | (x n b), as we assumed a | b x (and x n b = n (b x).) So a | (x m a) + (x n b), but the latter is x, thus: a | x. QED

35 The Euclidean Algorithm Problem: Suppose a, b, c are three non-zero integers, with a and c being relatively prime. Show that gcd(a, bc) = gcd(a, b). Solution: Let g 1 = gcd(a, bc), g 2 = gcd(a, b). Since g 2 | b we have g 2 | bc, and since also g 2 | a, we have g 2 is a divisor of a, and bc. Thus g 2  g 1. Next we show g 2  g 1. Since gcd(a, c) = 1 (a, c are relatively primes), there are integers m, n s.t. 1 = m a + n c.

36 The Euclidean Algorithm Solution (continue): 1 = m a + n c. Multiplying by b, we obtain: b = b m a + b n c. By definition, g 1 | a, g 1 | b c, then we must have g 1 | b m a + b n c (similarly to the corollary above). Thus g 1 | b. Thus g 1 is a divisor of a and b and we indeed have g 1  g 2. Therefore g 1 = g 2. QED

37 gcd and glb in Posets Consider the partial ordered set (N, | ) [That is, all ordered pairs of natural numbers (a,b) s.t. a | b. We showed that it is reflexive, anti-symmetric, and transitive.] Greatest lower bound: A greatest lower bound (glb, for short) of two elements a, b  N (in the poset (N, | ) ) is an element g  N, s.t. 1.g | a, and g | b. 2.If c | a, and c | b for some c  N, then c | g. What is the meaning of g in this case? - This is exactly gcd(a, b) ! In fact, it is divisible by any other common divisor of a and b.

38 The least common Multiple We now would like to consider the smallest positive integer l that is divisible by two integer numbers a, b: this is the least common multiple. Least common multiple: A least common multiple (lcm) of two integers a, b is an element l  N, s.t. 1.a | l, and b | l. 2.If there is m  N s.t. a | m, and b | m then m  l. Examples: lcm(4, 14) = 28, lcm(-6, 21) = 42, lcm(-5, -25) = 25.

39 The least common Multiple For two integers a, b, we have that |a| |b| is always a common multiple of a and b. Therefore lcm(a, b) always exists and lcm(a, b)  |a| |b|. Lemma: For any two integers a, b : gcd(a, b) lcm(a, b) = |a| |b|. Proof sketch: When gcd(a, b) = 1, it is clear that lcm(a, b) = |a| |b|, as a, b are relatively primes (e.g., think about lcm(5, 7)=35 ). In this case, We indeed have gcd(a, b) lcm(a, b) = lcm(a, b) = |a| |b|.

40 The least common Multiple Proof sketch (continue): When gcd(a, b) > 1, we make two observations: b / gcd(a,b) and b do not have any common divisor greater than 1. That is: gcd(a, b / gcd(a,b) ) = 1. (*) Indeed, if gcd(a, b / gcd(a,b) ) = g > 1 then a, b are both divided by g  gcd(a, b), which is impossible, as gcd(a, b) is the greatest common divisor. lcm (a, b) = lcm (a, b / gcd(a,b) ) (we do not prove this part).

41 The least common Multiple Proof sketch (continue): Putting these observations together, let c = b / gcd(a,b). Then: lcm(a, b) = lcm(a, c). Since gcd(a, c) = 1 (shown in (*) ), we obtain lcm (a, c) = |a| |c| = |a| |b| / gcd(a,b) Thus, we obtain: lcm (a, b) = |a| |b| / gcd(a,b) QED

42 The least common Multiple The lemma gives an easy way to compute lcm(a, b): Just compute gcd(a, b), and then extract |a| |b| / gcd(a, b). Examples: gcd(6, 12) = 3, thus lcm(6, 21) = 6(21)/3 = 6(7) = 42. gcd(630, -196) = 14, thus lcm(630, -196) = 630 (196)/14 = 8820.

43 The least common Multiple gcd(630, -196) = 14, thus lcm(630, -196) = 630 (196)/14 = 8820. Claim (w/o proof): Let a, b be integers lcm(a, b) is a divisor of all multiples of a and b. That is, least common multiple actually divides any other common multiple of a, b. Examples: lcm(6, 21) = 6(21)/3 = 6(7) = 42, and 6(21)/42 = 3. lcm(8, 12) = 8(12)/4 = 24, and 8(12)/24 = 4, but also 48 is a common multiple, and then 48/24 = 2.

44 lub and lcm in Posets Consider the partial ordered set (N, | ) as above. Least upper bound: A least upper bound (lub, for short) of two elements a, b  N (in the poset (N, | ) ) is an element l  N, s.t. 1.a | l, and b | l. 2.If a | m, and b | m for some m  N, then l | m. What is the meaning of l in this case? - This is exactly lub(a, b) ! Due to the claim that lcm(a,b) divides any other (larger) common multiple of a and b.

45 The Poset (N, | ) is a lattice Recall that a partial ordered set is a lattice if every two elements have a glb and a lub. Thus: Proposition: The Poset (N, | ) is a lattice. [Any pair of elements a, b  N have a gcd (glb) and a lcm (lub).]


Download ppt "The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3."

Similar presentations


Ads by Google