Math.3336: Discrete Mathematics Advanced Counting Techniques Instructor: Dr. Blerina Xhabli Department of Mathematics, University of Houston https://www.math.uh.edu/ blerina Email: blerina@math.uh.edu Spring 2019 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 1/18
Course Information/Office Hours Instructor: Dr. Blerina Xhabli Office hours: TuTh 10:30am 12:00pm (PGH 202) Tutor/Grader: An Vu Office hours: MonWed 2:30pm 4:00pm (Fleming #11) Class meets every TuTh 1:00 pm - 2:30 pm Course webpage: http://www.math.uh.edu/ blerina/ The class webpage contains contact info, office hours, slides from lectures, and important announcements. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 2/18
Assignments to work on Homework #10 due Thursday, 4/25, 11:59pm No credit unless turned in by 11:59pm on due date Late submissions not allowed, but lowest homework score dropped when calculating grades Homework will be submitted online in your CASA accounts. You can find the instructions on how to upload your homework in our class webpage. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 3/18
Chapter 8 Advanced Counting Techniques Chapter 8 Overview Applications of Recurrence Relations Section 8.1 Solving Linear Recurrence Relations Section 8.2 Homogeneous Recurrence Relations Nonhomogeneous Recurrence Relations Divide-and-Conquer Algorithms and Recurrence Relations Section 8.3 Generating Functions Section 8.4 Inclusion-Exclusion Section 8.5 Applications of Inclusion-Exclusion Section 8.6 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 4/18
Section 8.1 Applications of Recurrence Relations Recall the Recursively Defined Sequences: In previous lectures, we looked at recursively-defined sequences Example: What sequence is this? 1, 2, 3, 4, 5, 6, 7, 8,... a 0 = 1 a n = a n 1 + 1 Another example: Fibonacci numbers 1, 1, 2, 3, 5, 8, 13, 21, 34, 55,... f 0 = 1 f 1 = 1 f n = f n 1 + f n 2 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 5/18
Recurrence Relations Recursively defined sequences are often referred to as recurrence relations The base cases in the recursive definition are called initial values of the recurrence relation Example: Write recurrence relation representing number of bacteria in n th hour if colony starts with 5 bacteria and doubles every hour? a 0 = 5 a n = 2 a n 1 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 6/18
Closed Form Solutions Recurrence relations are often very natural to define, but we usually need to find closed form solution. Closed form solution defines n th number in the sequence as a function of n What is closed form solution to the following recurrence? a 0 = 0 a n = a n 1 + n Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 7/18
Closed Form Solutions of Recurrence Relations Given an arbitrary recurrence relation, is there a mechanical way to obtain the closed form solution? Not for arbitrary, but for a subclass of recurrence relations A linear homogeneous recurrence relation with constant coefficients is a recurrence relation of the form: a n = c 1 a n 1 + c 2 a n 2 +... + c k a n k where each c i is a constant and c k is non-zero The value of k is called the degree of the recurrence relation The recurrence relation for Fibonacci numbers is a degree 2 linear homogeneous recurrence Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 8/18
Examples and Non-Examples Which of these are linear homogenous recurrence relations with constant coefficients? a n = a n 1 + 2a n 5 yes a n = 2a n 2 + 5 no, not homogeneous a n = a n 1 + n no, not homogeneous a n = a n 1 a n 2 no, non-linear a n = n a n 1 linear homogenous but not constant coeff. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 9/18
Characteristic Polynomial Cook-book recipe for solving linear homogenous recurrence relations with constant coefficients Definition: The characteristic equation of a recurrence relation of the form a n = c 1 a n 1 + c 2 a n 2 +... c k a n k is r k = c 1 r k 1 + c 2 r k 2 +... + c k i.e., Replace a n i with r n i (n k) Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 10/18
Characteristic Equation Examples What are the characteristic equations for the following recurrence relations? f n = f n 1 + f n 2 r 2 = r + 1 a n = 2a n 1 r = 2 a n = 2a n 1 + 5a n 3 r 3 = 2r 2 + 5 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 11/18
Characteristic Roots The characteristic roots of a linear homogeneous recurrence relation are the roots of its characteristic equation. What are the characteristic roots of the following recurrence relations? a n = 2a n 1 + 3a n 2 r 1 = 3, r 2 = 1 f n = f n 1 + f n 2 r 1 = 1+ 5 2, r 2 = 1 5 2 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 12/18
Theorem I: Solving Linear Homogenous Recurrence Relations Let a n = c 1 a n 1 + c 2 a n 2 +... + c k a n k be a recurrence relation with k distinct characteristic roots r 1,..., r k. Then the closed form solution for a n is of the form: a n = α 1 r n 1 + α 2 r n 2 +... + α k r n k Furthermore, given k initial conditions, the constants α 1,..., α k are uniquely determined Note: Won t do the formal proof because requires a good amount of linear algebra. In class, we demonstrated the basic needed tools behind the proof. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 13/18
Example I Find a closed form solution for the recurrence a n = a n 1 + 2a n 2 with initial conditions a 0 = 2 and a 1 = 7 Characteristic equation: r 2 r 2 = 0 Characteristic roots: r 1 = 2, r 2 = 1 Thus, the general solution is a n = α 1 2 n + α 2 ( 1) n. Coefficients: α 1 = 3, α 2 = 1 { a0 = α 1 2 0 + α 2 ( 1) 0 { = 2 a 1 = α 1 2 1 + α 2 ( 1) 1 = 7 α1 + α 2 = 2 2α 1 α 2 = 7 Closed-form solution: a n = 3 2 n ( 1) n Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 14/18
Example II Derive the closed form solution for the Fibonacci sequence f n = f n 1 + f n 2 with initial conditions f 0 = 0 and f 1 = 1 From earlier, characteristic equation has two distinct roots at r 1 = 1+ 5 2, r 2 = 1 5 2 Hence, solution is of the form: ( 1 + ) n ( 5 1 ) n 5 f n = α 1 + α 2 2 2 Compute α 1, α 2 using initial conditions f 0 = 0 and f 1 = 1 in the general solution above: α 1 = 1 5, α 2 = 1 5 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 15/18
Towers of Hanoi Given 3 pegs where first peg contains n disks Goal: Move all the disks to a different peg (e.g., second one) Rule 1: Larger disks cannot rest on top of smaller disks Rule 2: Can only move the top-most disk at a time Question: How many steps does it take to move all n disks? Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 16/18
A Recursive Solution Solve recursively T n is number of steps to move n disks Base case: n = 1, move disk from first peg to second: T 1 = 1 Induction: Suppose we can move n 1 disks in T n 1 steps; how many steps does it take to move T n disks? Idea: First move the topmost n 1 disks to peg 3; can be done in T n 1 steps Now, move bottom-most disk to peg 2 takes just 1 step Finally, recursively move n 1 disks in peg 3 to peg 2 can be done in T n 1 steps Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 17/18
Towers of Hanoi, cont. Initial condition: T 1 = 1 Recurrence relation: T n = 2T n 1 + 1 Now we will find closed form solution for T n : We can use an iterative approach to solve this recurrence relation by repeatedly expressing T n in terms of the previous terms of the sequence: T n = 2T n 1 + 1 = 2(2T n 2 + 1) + 1 = 2 2 T n 2 + 2 + 1 = 2 2 (2T n 3 + 1) + 2 + 1 = 2 3 T n 3 + 2 2 + 2 + 1. = 2 n 1 T 1 + 2 n 2 + 2 n 3 + + 2 + 1 substitute T 1 = 1 = 2 n 1 + 2 n 2 + 2 n 3 + + 2 + 1 geometric series = 2 n 1 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Advanced Counting Techniques 18/18