Download Discrete Mathematics Lecture 16: Representation of Integers and Induction and more Slides Discrete Mathematics in PDF only on Docsity! CSci 2011 Discrete Mathematics Lecture 16 Docsity.com Representation of Integers Positive integer n can be uniquely written as n = akbk+ ak-1bk-1+ … + a1b + a0 k ∈ N, 0 < ai < b The base b expansion of n is denoted by (akak-1… a1a0)b. b = 2 Binary representation b = 16 Hexadecimal representation (245)8 = 2 82 + 4 8 + 5 = 165 = (11110101)2 = (F5)16 Docsity.com Square-and-Multiply 213mod 17 = 223+22+1mod 17 =(((22)2)2) ((22)2) 2 INPUT: a ∈ Zn, and k < n where k = Σti=0ki2i OUTPUT: ak mod n. Algorithm Set b = 1. If k = 0 then return(b). Set A = a. If k0 = 1 then set b = a. For i from 1 to t do the following: Set A = A2 mod n. If ki = 1 then set b = A b mod n. Return(b). Docsity.com Square-and-Multiply a = 2 k = 13 n = 17 k = Σti=0ki2i Set A = a. If k0 = 1 then set b = a. For i from 1 to t Set A = A2 mod n. If ki = 1, set b = Ab mod n. i ki b A 2 0 1 2 2 1 0 22 2 1 (22)2 2 (22)2 (22)2 3 1 ((22)2)2 2 (22)2 ((22)2)2 Docsity.com ch 4.1, 4.2 Mathematical Induction Docsity.com Induction Example Induction Hypothesis P(k) = ∑ki=12i-1= k2 Inductive Steps P(k+1) = ∑k+1i=12i-1 = ki=12i-1 + (2 (k+1) -1) = k2 + (2k +1) = (k+1)2 Docsity.com What did we show Base case: P(1) If P(k) was true, then P(k+1) is true i.e., P(k) → P(k+1) We know it’s true for P(1) Because of P(k) → P(k+1), if it’s true for P(1), then it’s true for P(2) Because of P(k) → P(k+1), if it’s true for P(2), then it’s true for P(3) Because of P(k) → P(k+1), if it’s true for P(3), then it’s true for P(4) Because of P(k) → P(k+1), if it’s true for P(4), then it’s true for P(5) And onwards to infinity Thus, it is true for all possible values of n In other words, we showed that: [P(1) ∧ ∀ k (P(k) → P(k+1))] → ∀ n P(n) Docsity.com Second induction example Show the sum of the first n positive even integers is n2 + n Rephrased: ∀ n P(n) where P(n) = ∑ni=1 2 i = n2 + n The three parts: Base case Inductive hypothesis Inductive step Docsity.com More Examples Prove thatt if h> -1, then 1+nh ≤ (1+h)n for all non-negative integer n. Prove that n2 ≡ 1 mod 8 for all odd integer n. Docsity.com Strong induction Weak mathematical induction assumes P(k) is true, and uses that (and only that!) to show P(k+1) is true Strong mathematical induction assumes P(1), P(2), …, P(k) are all true, and uses that to show that P(k+1) is true. [P(1) ∧ P(2) ∧ p(3) ∧ … ∧ P(k) ] → P(k+1) Docsity.com Strong induction example 1 Show that any number > 1 can be written as the product of primes Base case: P(2) 2 is the product of 2 (remember that 1 is not prime!) Inductive hypothesis: P(1), P(2), P(3), …, P(k) are all true Inductive step: Show that P(k+1) is true Docsity.com