* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download full - CS.Duke
Survey
Document related concepts
Vincent's theorem wikipedia , lookup
Georg Cantor's first set theory article wikipedia , lookup
Mathematical proof wikipedia , lookup
Mathematics of radio engineering wikipedia , lookup
Wiles's proof of Fermat's Last Theorem wikipedia , lookup
Fundamental theorem of algebra wikipedia , lookup
Collatz conjecture wikipedia , lookup
Elementary mathematics wikipedia , lookup
Factorization wikipedia , lookup
Fermat's Last Theorem wikipedia , lookup
Quadratic reciprocity wikipedia , lookup
Factorization of polynomials over finite fields wikipedia , lookup
Transcript
CompSci 230 Discrete Math for Computer Science Announcements • Homework 4 out October 22, 2013 Prof. Rodger Slide ideas from Rosen and Benjamin 1 2 Chap. 4.3 - Greatest Common Divisor Chap. 4.3 - Greatest Common Divisor Definition: Let a and b be integers, not both zero. The largest integer d such that d | a and also d | b is called the greatest common divisor of a and b. The greatest common divisor of a and b is denoted by gcd(a,b). Definition: Let a and b be integers, not both zero. The largest integer d such that d | a and also d | b is called the greatest common divisor of a and b. The greatest common divisor of a and b is denoted by gcd(a,b). Examples: gcd(12, 30) = 6 gcd(12, -30) = 6 gcd(16, 9) = 1 gcd(7, 63) = 7 gcd(7, 0) = 7 relatively prime 3 Examples: gcd(12, 30) = 6 gcd(12, -30) = 6 gcd(16, 9) = 1 gcd(7, 63) = 7 gcd(7, 0) = 7 relatively prime 4 Greatest Common Divisor Greatest Common Divisor Definition: The integers a and b are relatively prime if their greatest common divisor is . Example: Definition: The integers a and b are relatively prime if their greatest common divisor is . Example: Definition: The integers a1, a2, …, an are pairwise relatively prime if gcd(ai, aj)= whenever i j n. Definition: The integers a1, a2, …, an are pairwise relatively prime if gcd(ai, aj)= whenever i j n. Example: Are Solution: Yes and Example: Are Yes Example: Are Solution: No, and Example: Are No, 5 6 What numbers can be created using 12 and 30 as building blocks? What numbers can be created using 12 and 30 as building blocks? • That means 12s + 30t • Can you create any positive integer using this formula? • Can you create 4? • That means 12s + 30t • Can you create any positive integer using this formula? • Can you create 4? – 4 = 12x + 30 y – = 6(2x + 5y) – NO, must be a multiple of 6 4 = 12s + 30 t = 6(2s + 5t) NO, must be a multiple of 6 7 8 Can you create 6 using 12s + 30t? Can you create 6 using 12s + 30t? 6 = 12s + 30 t = 12(3) + 30(-1) = 36 – 30 = 6, yes! Can you create any multiple of 6 using 12 and 30? 6 = 12s + 30 t = 12(3) + 30(-1) = 36 – 30 = 6, yes! Can you create any multiple of 6 using 12 and 30? Yes 12(3m) + 30(-m) = 6m Yes 12(3m) + 30(-m) = 6m 9 10 Can you create any number using 16 and 9 as building blocks? Can you create any number using 16 and 9 as building blocks? 16s + 9t 16s + 9t Can you create the number 1? 16(4) + 9(-7) = 64 – 63 = 1 Yes, can create any number with 16 and 9 Can you create the number 1? 16(4) + 9(-7) = 64 – 63 = 1 Yes, can create any number with 16 and 9 To create any number m: To create any number m: 16(4m) + 9(-7m) = m 16(4m) + 9(-7m) = m B zout showed back in 18th century B zout showed back in 18th century • If a and b are relatively prime, then there exists integers x and y such that ax+by=1 • If a and b are relatively prime, then there exists integers s and t such that as+bt=1 11 12 gcds as Linear Combinations gcds as Linear Combinations Étienne Bézout (1730‐1783) Étienne Bézout (1730‐1783) B zout’s Theorem: If a and b are positive integers, then there exist integers s and t such that gcd(a,b) = sa + tb. ) (proof in exercises of Section Idea: gcd(a,b) = g a/g and b/g are relatively prime g is the largest that divides both of them Thus, there exists s and t such that (a/g)s + (b/g)t = 1 B zout’s Theorem: If a and b are positive integers, then there exist integers s and t such that gcd(a,b) = sa + tb. ) (proof in exercises of Section Idea: gcd(a,b) = g a/g and b/g are relatively prime g is the largest that divides both of them Thus, there exists s and t such that (a/g)s + (b/g)t = 1 Definition: If a and b are positive integers, then integers s and t such that gcd(a,b) = sa + tb are called B zout coefficients of a and b. The equation gcd(a,b) 13= sa + tb is called B zout’s identity. Definition: If a and b are positive integers, then integers s and t such that gcd(a,b) = sa + tb are called B zout coefficients of a and b. The equation gcd(a,b) 14= sa + tb is called B zout’s identity. Euclidean Algorithm Euclidean Algorithm Euclid (325 B.C.E. – 265 B.C.E.) • The Euclidian algorithm is an efficient method for computing the greatest common divisor of two integers. It is based on the idea that gcd(a,b) is equal to gcd(a,c) when a b and c is the remainder when a is divided by b. Example: Find gcd( , • 287 91∙3 14 • 91 14∙6 7 • 14 7∙2 0 ): Divide 287 by 91 Divide 91 by 14 Divide 14 by 7 Stopping condition gcd( , ) = gcd( , ) = gcd( , ) = 15 • The Euclidean algorithm expressed in pseudocode is: procedure gcd(a, b: positive integers) x := a y := b while y r := x mod y x := y y := r return x {gcd(a,b) is x} 16 Correctness of Euclidean Algorithm Correctness of Euclidean Algorithm Lemma : Let a = bq + r, where a, b, q, and r are integers. Then gcd(a,b) = gcd(b,r). Proof: Lemma : Let a = bq + r, where a, b, q, and r are integers. Then gcd(a,b) = gcd(b,r). Proof: – Suppose that d divides both a and b. Then d also divides a bq = r (by Theorem of Section ). Hence, any common divisor of a and b must also be any common divisor of b and r. – Suppose that d divides both b and r. Then d also divides bq + r = a. Hence, any common divisor of a and b must also be a common divisor of b and r. – Therefore, gcd(a,b) = gcd(b,r). – Suppose that d divides both a and b. Then d also divides a bq = r (by Theorem of Section ). Hence, any common divisor of a and b must also be any common divisor of b and r. – Suppose that d divides both b and r. Then d also divides bq + r = a. Hence, any common divisor of a and b must also be a common divisor of b and r. – Therefore, gcd(a,b) = gcd(b,r). 17 18 Correctness of Euclidean Algorithm • Suppose that a and b are positive r0 integers with a b. r1 Let r0 = a and r1 = b. Successive applications of the division algorithm yields: = r 1 q1 + r 2 = r 2 q2 + r 3 ∙ ∙ ∙ rn‐2 = rn‐1qn‐1 + r2 rn‐1 = rnqn . 0 0 0 r 2 < r 1, r 3 < r 2, Correctness of Euclidean Algorithm • rn < rn‐1, • Suppose that a and b are positive r0 integers with a b. r1 Let r0 = a and r1 = b. Successive applications of the division algorithm yields: = r 1 q1 + r 2 = r 2 q2 + r 3 ∙ ∙ ∙ rn‐2 = rn‐1qn‐1 + r2 rn‐1 = rnqn . 0 0 0 r 2 < r 1, r 3 < r 2, rn < rn‐1, Eventually, a remainder of zero occurs in the sequence of terms: a = r0> r1 > r2 ∙∙∙ 0.Thesequencecan’tcontainmorethana terms. • ByLemma1 gcd(a,b) = gcd(r0,r1) = ∙∙∙ gcd rn‐1,rn gcd rn ,0 rn. • Hencethegreatestcommondivisoristhelastnonzeroremainderin thesequenceofdivisions. • Eventually, a remainder of zero occurs in the sequence of terms: a = r0> r1 > r2 ∙∙∙ 0.Thesequencecan’tcontainmorethana terms. • ByLemma1 gcd(a,b) = gcd(r0,r1) = ∙∙∙ gcd rn‐1,rn gcd rn ,0 rn. • Hencethegreatestcommondivisoristhelastnonzeroremainderin thesequenceofdivisions. 19 20 Finding gcds as Linear Combinations Finding gcds as Linear Combinations Example: Express gcd(252,198) = 18asalinearcombination of252and198. Solution: First use the Euclidean algorithm to show gcd(252,198) = 18 Example: Express gcd(252,198) = 18asalinearcombination of252and198. Solution: First use the Euclidean algorithm to show gcd(252,198) = 18 i. ii. iii. iv. 252 1∙198 54 198 3 ∙54 36 54 1 ∙36 18 36 2 ∙18 i. ii. iii. iv. – Nowworkingbackwards,fromiii andi above – Nowworkingbackwards,fromiii andi above • 18 54 1 ∙36 • 36 198 3 ∙54 • 18 54 1 ∙36 • 36 198 3 ∙54 – Substitutingthe2nd equationintothe1st yields: • 18 54 1 ∙ 198 3 ∙54 252 1∙198 54 198 3 ∙54 36 54 1 ∙36 18 36 2 ∙18 – Substitutingthe2nd equationintothe1st yields: 4 ∙54 1 ∙198 • 18 54 1 ∙ 198 3 ∙54 – Substituting54 252 1 ∙198 fromi yields: 4 ∙54 1 ∙198 – Substituting54 252 1 ∙198 fromi yields: • 18 4 ∙ 252 1 ∙198 1 ∙198 4 ∙252 5 ∙198 • 18 4 ∙ 252 1 ∙198 1 ∙198 4 ∙252 5 ∙198 • This method illustrated above is a two pass method. It first uses the Euclidian algorithm to find the gcd and then works backwards to express the gcd as a linear combination of the original two integers. • This method illustrated above is a two pass method. It first uses the Euclidian algorithm to find the gcd and then works backwards to express the gcd as a linear combination of the original two integers. 21 Euclid’s algorithm 22 Euclid’s algorithm • It is smart! • It is smart! – It not only finds the gcd, it also finds the s and t that gives you the gcd! • It is fast! – It not only finds the gcd, it also finds the s and t that gives you the gcd! • It is fast! – If a>b, then finds gcd(a,b) in steps – Slightly less than the number of digits in b – If a and b are 100 digit numbers, finds the gcd in under 500 steps – If a>b, then finds gcd(a,b) in steps – Slightly less than the number of digits in b – If a and b are 100 digit numbers, finds the gcd in under 500 steps 23 24 What are the worse numbers to try? • How about gcd(99, 98)? What are the worse numbers to try? • How about gcd(99, 98)? gcd(99,98) = 1 gcd(99,98) = 1 • How about gcd(99,50)? • How about gcd(99,50)? gcd(99,50) = gcd(50,49) = gcd(49,1) = 1 gcd(99,50) = gcd(50,49) = gcd(49,1) = 1 • How about gcd(89,55)? • How about gcd(89,55)? gcd(89,55) = gcd(55,34) = gcd(34,21) = gcd(21,13) = gcd(13,8) = gcd(8,5) = gcd(5,3) = gcd(3,2) = gcd(2,1) = 1 Recognize Fibonnaci numbers? gcd(89,55) = gcd(55,34) = gcd(34,21) = gcd(21,13) = gcd(13,8) = gcd(8,5) = gcd(5,3) = gcd(3,2) = gcd(2,1) = 1 25 Recognize Fibonnaci numbers? 26 Primes Primes Definition: A positive integer p greater than is called prime if the only positive factors of p are and p. A positive integer that is greater than and is not prime is called composite. Definition: A positive integer p greater than is called prime if the only positive factors of p are and p. A positive integer that is greater than and is not prime is called composite. Example: is prime only factors are and , is composite because it is divisible by . What about 1? Neither prime or composite It is a unit! It divides everything 27 Example: is prime only factors are and , is composite because it is divisible by . What about 1? Neither prime or composite It is a unit! It divides everything 28 The Fundamental Theorem of Arithmetic The Fundamental Theorem of Arithmetic Theorem: Every positive integer greater than can be written uniquely as a prime or as the product of two or more primes where the prime factors are written in order of nondecreasing size. Examples: 2 Theorem: Every positive integer greater than can be written uniquely as a prime or as the product of two or more primes where the prime factors are written in order of nondecreasing size. Examples: 2 2910 10 The Sieve of Erastosthenes Erastothenes (276‐194 B.C.) • The Sieve of Erastosthenes can be used to find all primes not exceeding a specified positive integer. For example, begin with the list of integers between and . a. Delete all the integers, other than 2, divisible by 2. b. Delete all the integers, other than 3, divisible by 3. c. Next, delete all the integers, other than 5, divisible by 5. d. Next, delete all the integers, other than 7, divisible by 7. e. Since all the remaining integers are not divisible by any of the previous integers, other than 1, the primes are: continued → 31 32 Infinitude of Primes The Sieve of Erastosthenes Euclid (325 B.C.E. – 265 B.C.E.) Theorem: There are infinitely many primes. (Euclid) If an integer n is a composite integer, then it has a prime divisor less than or equal to √n. To see this, note that if n = ab, then a √n or b √n. Trial division, a very inefficient method of determining if a number n is prime, is to try every integer i √n and see if n is divisible by i. Proof: Assume finitely many primes: p1, p2, ….., pn – Let q = p1p2··· pn + 1 – Either q is prime or by the fundamental theorem of arithmetic it is a product of primes. • But none of the primes pj divides q since if pj | q, then pj divides q p1p2··· pn = 1 . • Hence, there is a prime not on the list p1, p2, ….., pn. It is either q, or if q is composite, it is a prime factor of q. This contradicts the assumption that p1, p2, ….., pn are all the primes. – Consequently, there are infinitely many primes. In previous example, why did we use only 2, 3, 5 and 7? 33 Mersenne Primes Marin Mersenne (1588-1648) Definition: Prime numbers of the form 2p 1 ,where p is prime, are called Mersenne primes. – 22 1 3,23 1 7, 25 1 37,and 27 1 127 areMersenne primes. – 211 1 2047 is not a Mersenne prime since2047 23∙89. – Thereisanefficienttestfordeterminingif 2p 1 is prime. – ThelargestknownprimenumbersareMersenne primes. – Asofmid2011,47Mersenne primeswereknown,the largestis243,112,609 1,whichhasnearly13million decimaldigits. – TheGreat Internet Mersenne Prime Search GIMPS isa distributedcomputingprojecttosearchfornew Mersenne Primes. http://www.mersenne.org/ 35 This proof was given by Euclid The Elements. The proof is considered to be one of the most beautiful in all mathematics. It is the first proof in The Book, inspired by the famous mathematician Paul Erdős’ imagined collection of perfect proofs maintained by God. Paul Erdős (1913-1996) 34 Distribution of Primes • Mathematicians have been interested in the distribution of prime numbers among the positive integers. In the nineteenth century, the prime number theorem was proved which gives an asymptotic estimate for the number of primes not exceeding x. Prime Number Theorem: The ratio of the number of primes not exceeding x and x/ln x approaches as x grows without bound. (ln x is the natural logarithm of x) – The theorem tells us that the number of primes not exceeding x, can be approximated by x/ln x. – The odds that a randomly selected positive integer less than n is prime are approximately (n/ln n)/n = 1/ln n. 36 Conjectures about Primes Generating Primes Many conjectures about them are unresolved, including: • Goldbach’s Conjecture:Everyevenintegern,n 2,isthe sumoftwoprimes.Ithasbeenverifiedbycomputerforall positiveevenintegersupto1.6∙1018.Theconjectureis believedtobetruebymostmathematicians. • Finding large primes with hundreds of digits is important in cryptography. • There is no simple function f(n) such that f(n) is prime for all positive integers n. • Consider – f(n) = n2 n + f( ) = 2 is prime for all integers • Thereareinfinitelymanyprimesoftheformn2 1,wheren isapositiveinteger.Butithasbeenshownthatthereare infinitelymanyprimesoftheformn2 1,wheren isa positiveintegerortheproductofatmosttwoprimes. . • Fortunately, we can generate large integers which are almost certainly primes. See Chapter . 37 • The Twin Prime Conjecture:Thetwinprimeconjectureisthat thereareinfinitelymanypairsoftwinprimes.Twinprimes arepairsofprimesthatdifferby2.Examplesare3and5,5 and7,11and13,etc.Thecurrentworld’srecordfortwin primes asofmid2011 consistsofnumbers 65,516,468,355∙2333,333 1,whichhave100,355decimal digits. 38 Finding the Greatest Common Divisor Using Prime Factorizations Finding the Greatest Common Divisor Using Prime Factorizations • Suppose the prime factorizations of a and b are: • Suppose the prime factorizations of a and b are: where each exponent is a nonnegative integer, and where all primes occurring in either prime factorization are included in both. Then: • This formula is valid since the integer on the right (of the equals sign) divides both a and b. No larger integer can divide both a and b. • where each exponent is a nonnegative integer, and where all primes occurring in either prime factorization are included in both. Then: • This formula is valid since the integer on the right (of the equals sign) divides both a and b. No larger integer can divide both a and b. • 23 Example: 120 = ∙3∙5500 = gcd(120,500) = 2min 3,2 ∙3min 1,0 ∙5min 1,3 22 ∙30 ∙51 20 • Finding the gcd of two positive integers using their prime factorizations is not efficient because there is no efficient algorithm for finding the prime factorization of a positive integer. 22 ∙53 39 Example: 120 = 23 ∙3∙5500 = 22 ∙53 gcd(120,500) = 2min 3,2 ∙3min 1,0 ∙5min 1,3 22 ∙30 ∙51 20 • Finding the gcd of two positive integers using their prime factorizations is not efficient because there is no efficient algorithm for finding the prime factorization of a positive integer. 40 Least Common Multiple Least Common Multiple Definition: The least common multiple of the positive integers a and b is the smallest positive integer that is divisible by both a and b. It is denoted by lcm(a,b). • The least common multiple can also be computed from the prime factorizations. This number is divided by both a and b and no smaller number is divided by a and b. Example: lcm(30, 35) = 5*2*3, 7*5 5*2*3*7 = 210 Example: lcm( 3 5 2, max 3,4 4 3) max 5,3 = max 2,0 4 41 LCM and GCD relation Theorem : Let a and b be positive integers. Then ab = gcd(a,b) a,b Example: lcm(30, 35) = 5*2*3, 7*5 5*2*3*7 = 210 3 5 2, max 3,4 2 42 Least Common Multiple Example: lcm( 5 4 3) max 5,3 = max 2,0 4 5 2 43 Proof: Notethatmin x,y max x,y x y oneusesthelargerexponentandtheotheronethe smallerexponent,butyougetallfactorsback. 44 LCM and GCD relation Consequences of Bézout’s Theorem Theorem : Let a and b be positive integers. Then ab = gcd(a,b) a,b Lemma 2: If a, b, and c are positive integers such that gcd(a, b) = 1 and a | bc, then a | c. Proof: Assume gcd(a, b) = 1 and a | bc – Since gcd(a, b) = 1, by Bézout’s Theorem there are integers s and t such that sa + tb = 1. – Multiplying both sides of the equation by c, yields sac + tbc = c. – From Theorem 1 of Section 4.1: a | tbc part ii) and a divides sac + tbc since a | sac and a|tbc (part i) – We conclude a | c, since sac + tbc = c. Lemma 3: If p is prime and p | a1a2∙∙∙an, then p | ai for some i. (proof uses mathematical induction; see Exercise 64 of Section 5.1) Proof: Notethatmin x,y max x,y x y oneusesthelargerexponentandtheotheronethe smallerexponent,butyougetallfactorsback. • Lemma 3 is crucial in the proof of the uniqueness of prime factorizations. 45 46 Consequences of Bézout’s Theorem Uniqueness of Prime Factorization Lemma 2: If a, b, and c are positive integers such that gcd(a, b) = 1 and a | bc, then a | c. Proof: Assume gcd(a, b) = 1 and a | bc • We will prove that a prime factorization of a positive integer where the primes are in nondecreasing order is unique. (This is part of the fundamental theorem of arithmetic. The other part, which asserts that every positive integer has a prime factorization into primes, will be proved in Section 5.2.) Proof: (by contradiction) Suppose that the positive integer n can be written as a product of primes in two distinct ways: n = p1p2 ∙∙∙ ps and n = q1q2 ∙∙∙ pt. – Since gcd(a, b) = 1, by Bézout’s Theorem there are integers s and t such that sa + tb = 1. – Multiplying both sides of the equation by c, yields sac + tbc = c. – From Theorem 1 of Section 4.1: a | tbc – Remove all common primes from the factorizations to get part ii) and a divides sac + tbc since a | sac and a|tbc (part i) – We conclude a | c, since sac + tbc = c. – By Lemma 3, it follows that divides contradicting the assumption that and primes. Lemma 3: If p is prime and p | a1a2∙∙∙an, then p | ai for some i. (proof uses mathematical induction; see Exercise 64 of Section 5.1) • Lemma 3 is crucial in the proof of the uniqueness of prime factorizations. , for some k, are distinct – Hence, there can be at most one factorization of n into primes in nondecreasing order. 47 48 Dividing Congruences by an Integer Dividing Congruences by an Integer • Dividing both sides of a valid congruence by an integer does not always produce a valid congruence (see ). Section • Dividing both sides of a valid congruence by an integer does not always produce a valid congruence (see ). Section • But • But Theorem 7 c ac a b bc (mod m) and gcd(c,m) = Proof: Since ac bc (mod m), m | ac bc = c(a b) by Lemma and the fact that gcd(c,m) = , it follows that m | a b. m Hence, a b 49 Theorem 7 c ac a b bc (mod m) and gcd(c,m) = Proof: Since ac bc (mod m), m | ac bc = c(a b) by Lemma and the fact that gcd(c,m) = , it follows that m | a b. m Hence, a b 50