Chapter 7 Advanced Counting Techniques

Slides:



Advertisements
Similar presentations
Chapter Recurrence Relations
Advertisements

Fall 2002CMSC Discrete Structures1 Now it’s Time for… RecurrenceRelations.
Chapter 6 Advanced Counting 6.1 Recurrence Relations.
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
CS 2210 (22C:19) Discrete Structures Advanced Counting
Chapter Recurrence Relations
1 Copyright M.R.K. Krishna Rao Solving Recurrence Relations Steps for solving a linear homogeneous recurrence relation of degree 2 : Step #1.
CSE115/ENGR160 Discrete Mathematics 04/19/12 Ming-Hsuan Yang UC Merced 1.
Transparency No. 5-1 Discrete Mathematics Chapter 5 Advanced Counting Techniques.
Discrete Structures Chapter 6 Recurrence Relations
Recursion.
1 Section 6.1 Recurrence Relations. 2 Recursive definition of a sequence Specify one or more initial terms Specify rule for obtaining subsequent terms.
6.Advanced Counting Techniques 1 Copyright M.R.K. Krishna Rao 2003 Ch 6. Recurrence Relations A recurrence relation for the sequence {a n } is an equation.
Applied Discrete Mathematics Week 9: Relations
Advanced Counting Techniques
Jessie Zhao Course page: 1.
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Chap. 7 (c) , Michael P. Frank1 Chapter 7: Advanced Counting Techniques.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
4.6.2 Exponential generating functions
Chapter 8 With Question/Answer Animations 1. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Recurrence Relation. Outline  What is a recurrence relation ?  Solving linear recurrence relations  Divide-and-conquer algorithms and recurrence relations.
CSE 2813 Discrete Structures Recurrence Relations Section 6.1.
Module #20 - Recurrences 1 Ch. 7 Recurrence Relations Rosen 6 th ed., §§7.1.
R. Johnsonbaugh Discrete Mathematics 7 th edition, 2009 Chapter 7 Recurrence Relations Instructor Tianping Shuai.
15.1 CompSci 102© Michael Frank Today’s topics Recurrence relationsRecurrence relations –Stating recurrences –LiHoReCoCo Reading: Sections Reading:
Module #17: Recurrence Relations Rosen 5 th ed., §
Solving Second-Order Recursive Relations Lecture 36 ½ Section 8.3 Wed, Apr 19, 2006.
RECURRENCE Sequence Recursively defined sequence
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/18 Module.
Chapter 7 Advance Counting Techniques. Content Recurrence relations Generating function The principle of inclusion-exclusion.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Recurrence.
Chapter 8 With Question/Answer Animations. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
after UCI ICS/Math 6A, Summer AdvancedCounting -1 Recurrence Relations (RRs) A “Recurrence Relation”
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Chapter 8 Recursion. 8.3 More Recurrence Second-Order Recurrence Definition – A second-order linear homogeneous recurrence relation with constant coefficients.
CHAPTER TWO RECURRENCE RELATION
7.2 Solving Linear Recurrence Relations Some of these recurrence relations can be solved using iteration or some other ad hoc technique. However, one important.
Discrete Mathematics Chapter 6 Advanced Counting Techniques.
ADVANCED ALGORITHMS REVIEW OF ANALYSIS TECHNIQUES (UNIT-1)
Recurrence Relations. Outline Recurrence relationsSolving recurrence relationsRecurrence and Divide-and-conquer algorithmsGenerating functions
Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar Dr Nazir A. Zafar Advanced Algorithms Analysis and Design.
Mathematical Induction And Recursion Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Advanced Counting Techniques
Discrete Math For Computing II. Contact Information B. Prabhakaran Department of Computer Science University of Texas at Dallas Mail Station EC 31, PO.
CSE15 Discrete Mathematics 03/01/17
CMSC Discrete Structures
Advanced Counting Techniques
Modeling with Recurrence Relations
Applied Discrete Mathematics Week 11: Relations
A0=0 a1=2 an a2=6 an-1 a3=12 a4=20 a2 a1 a0.
Introduction to Recurrence Relations
UNIT-6 Recurrence Relations
Recurrence Relations.
Discrete Math (2) Haiming Chen Associate Professor, PhD
Module #17: Recurrence Relations
4.6.2 Exponential generating functions
Module #17: Recurrence Relations
Recursion and Recurrence Relations
CS 2210 Discrete Structures Advanced Counting
CMSC Discrete Structures
Solving Recurrence Relations
Applied Discrete Mathematics Week 7: Computation
4.7 Recurrence Relations P13, P100
CMSC Discrete Structures
Recurrence Relations Discrete Structures.
Recurrence Relations (RRs)
Recurrence Relations.
Recurrence Relations Rosen 5th ed., §6.2 5/22/2019
ICS 253: Discrete Structures I
Presentation transcript:

Chapter 7 Advanced Counting Techniques Discrete Mathematics Chapter 7 Advanced Counting Techniques

7.1 Recurrence Relations(遞迴關係) Example 1. Let {an} be a sequence that satisfies the recurrence relation an=an-1-an-2 for n=2,3,…, and suppose that a0=3,and a1=5. Here a0=3 and a1=5 are the initial conditions. By the recurrence relation, a2 = a1-a0 = 2 a3 = a2-a1 = -3 a4 = a3-a2 = -5 : Q1: Applications ? Q2: Are there better ways for computing the terms of {an}?

※Modeling with Recurrence Relations We can use recurrence relations to model (describe) a wide variety of problems. Example 3. Compound Interest (複利) Suppose that a person deposits(存款) $10000 in a saving account at a bank yielding 11% per year with interest compounded annually. How much will be in the account after 30 years ? Sol : Let Pn denote the amount in the account after n years. Pn=Pn-1 + 0.11Pn-1=1.11  Pn-1, ∴ P30=1.11  P29=(1.11)2  P28=…=(1.11)30  P0 =228922.97 P0=10000

Example 5. (The Tower of Hanoi) The rules of the puzzle allow disks to be moved one at a time from one peg to another as long as a disk is never placed on top of a smaller disk. Let Hn denote the number of moves needed to solve the Tower of Hanoi problem with n disks. Set up a recurrence relation for the sequence {Hn}. Sol : Hn=2Hn-1+1, ( n-1個 disk 先從peg 1→peg 3, 第 n 個 disk 從 peg 1→peg 2, n-1個 disk 再從 peg 3→peg 2) 目標 : n 個disk都從 peg 1 移到 peg 2 peg 1 peg 2 peg 3 H4 moves H1=1

上例中 Hn=2Hn-1+1, H1=1 ∴Hn=2Hn-1+1 =2(2Hn-2+1)+1 =22Hn-2+2+1 =22(2Hn-3+1)+2+1 =23Hn-3+(22+2+1) : =2n-1H1+(2n-2+2n-3+…+1) =2n-1+2n-2+…+1 = =2n-1

Example 6. Find a recurrence relation and give initial conditions for the number of bit strings of length n that do not have two consecutive 0s. How many such bit strings are there of length 5 ? Sol : n-2 n-1 n 1 2 n-3 … ∴ an = an-1+an-2, n  3 a1=2 (string : 0,1) a2=3 (string : 01,10,11) 1 an-1 種 an-2 種 1 ∴ a3=a2+a1=5, a4=8, a5=13

Example 7. (Codeword enumeration) A computer system considers a string of decimal digits a valid codeword if it contains an even number of 0 digits. Let an be the number of valid n-digit codewords. Find a recurrence relation for an. Sol : ∴ an = 9an-1 + (10n-1-an-1) = 8an-1 + 10n-1 , n2 a1 = 9 n-1 n 1 2 3 … an-1 種 1~9 10n-1 - an-1 種

求an通解 : Exercise : 3,23,25,27,29,41 (41推廣成n)

7.2 Solving Recurrence Relations Def 1. A linear homogeneous recurrence relation of degree k (i.e., k terms) with constant coefficients is a recurrence relation of the form where ciR and ck≠0 an = c1an-1+c2an-2+…+ckan-k Example 1 and 2. fn = fn-1 + fn-2 an = an-5 an = an-1 + an-22 an = nan-1 Hn = 2Hn-1 + 1 (True, deg=2) (True, deg=5) (False, 不是linear) (False , 不是linear, not constant coeff. ) (False, 不是homogeneous)

Theorem 1. Let an = c1an-1+ c2an-2 be a recurrence relation with c1,c2R. If r2 - c1r - c2= 0 (稱為characteristic equation) has two distinct roots r1 and r2. Then the solution of an is an = a1r1n + a2r2n , for n=0,1,2,…, where a1 , a2 are constants. (a1 , a2可利用 a0, a1算出)

What’s the solution of the recurrence relation an = an-1 + 2an-2 Example 3. What’s the solution of the recurrence relation an = an-1 + 2an-2 with a0=2 and a1=7 ? Sol : The characteristic equation is r2 – r - 2=0. Its two roots are r1= 2 and r2 = -1. Hence an=a12n +a2 (-1)n . ∵a0 = a1+a2 = 2, a1=2a1-a2=7 ∴a1 = 3, a2 = -1  an = 32n - (-1)n. 驗算:a2 = a1 + 2a0 =11 a2= 322 - 1 =11

Example 4. Find an explicit formula for the Fibonacci numbers. Sol : fn = fn-1 + fn-2 , n  2, f0=0 , f1=1. The characteristic equation is r2 - r - 1=0. Its two roots are , . So we have

Thm 2. Let an = c1an-1+c2an-2 be a recurrence relation with c1,c2R. If r2 - c1r - c2= 0 has only one root r0 . Then the solution of an is an = a1  r0n + a2  n  r0n for n=0,1,2,…, where a1 and a2 are constants.

What’s the solution of an= 6an-1 - 9an-2 with a0=1 and a1=6 ? Sol : Example 5. What’s the solution of an= 6an-1 - 9an-2 with a0=1 and a1=6 ? Sol : The root of r2 - 6r + 9 = 0 is r0 = 3. Hence an = a1.3n +a2.n.3n . ∵a0 = a1 = 1 a1 = 3a1 + 3a2 = 6 ∴ a1 = 1 and a2 = 1  an = 3n + n.3n 驗算:a2 = 6a1 - 9a0 =27 a2= 32 +2  32 =27

Thm 3. Let an = c1an-1 + c2an-2 + … + ckan-k be a recurrence relation with c1, c2, …, ck  R. If rk - c1rk-1 - c2rk-2 -…- ck = 0 has k distinct roots r1, r2,…, rk. Then the solution of an is an = a1r1n +a2r2n + …+akrkn, for n = 0, 1, 2, … where a1, a2,…ak are constants.

Find the solution of an = 6an-1 - 11an-2 + 6an-3 Example 6 (k = 3) Find the solution of an = 6an-1 - 11an-2 + 6an-3 with initial conditions a0=2, a1=5 and a2=15 . Sol : The roots of r3 - 6r2 + 11r – 6 = 0 are r1 = 1, r2 = 2, and r3 = 3 ∴an = a1  1n + a2 2n + a3 3n ∵a0 = a1 + a2 + a3 = 2 a1 = a1 + 2a2 + 3a3 = 5 a2 = a1 + 4a2 + 9a3 = 15 ∴an = 1 - 2n + 2  3n a1 = 1, a2 = -1, a3 = 2 驗算:a3 = 6a2 - 11a1+ 6a0 =47 a3= 1 - 23 + 2  33 =47

Thm 4. Let an = c1an-1 + c2an-2 + … + ckan-k be a recurrence relation with c1, c2, …, ck R. If rk - c1rk-1 - c2rk-2 - … - ck = 0 has t distinct roots r1, r2, …, rt with multiplicities m1, m2, …, mt respectively, where mi  1,i, and m1+ m2 +…+ mt = k, then (接下一頁)

where ai,j are constants. (1  i  t , 0  j  mi-1)

驗算:a3 = - 3a2 - 3a1- a0 =8 a3= (1+33-232)(-1)3 =8 Example 8. Find the solution to the recurrence relation an = -3an-1 - 3an-2 - an-3 with initial conditions a0 = 1, a1 = -2 and a2 = -1. Sol : r3 + 3r2 + 3r + 1 = 0 has a single root r0 = -1 of multiplicity three. ∴ an = (a1+a2n+a3n2) r0n = (a1+a2n+a3n2)(-1)n ∵ a0 = a1 = 1 a1 = (a1+a2+a3)  (-1) = -2 a2 = (a1+a2+a3) = -1 ∴a1 = 1, a2 = 3, a3 = -2  an = (1+3n-2n2)  (-1)n 驗算:a3 = - 3a2 - 3a1- a0 =8 a3= (1+33-232)(-1)3 =8 Exercise : 3,13,15,19

7.4 Generating Functions. Def 1. The generating function for the sequence {an} is the infinite power series. G(x) = a0 + a1x +… + anxn +… = (若 {an} 是finite,可視為是infinite,但後面的term 都等於0)

Example 2. What is the generating function for the sequence 1,1,1,1,1,1 ? Sol : (expansion,展開式) (closed form)

Example 3. Let mZ+ and ,for k = 0, 1, …, m. What is the generating function for the sequence a0, a1,…, am ? Sol : G(x) = a0 + a1x + a2x2 + … + amxm = (1+x)m (by 二項式定理)

Example 5. The function f (x) = is the generating function of the sequence 1, a, a2, …, since = 1 + ax + a2x2 + …= when |ax| < 1 for a≠0

Let uR and kZ+∪{0}. Then the extended Def 2. Let uR and kZ+∪{0}. Then the extended binomial coefficient is defined by (The Binomial Theorem, 二項式定理) Let x,y be variables, and let n be a positive integer, Then

Example 7. Find and Sol :

Thm 2. (The Extended Binomial Theorem) Let xR with |x|<1 and let uR, then

Find the generating functions for (1+x)-n and (1-x)-n where nZ+ Example 9. Find the generating functions for (1+x)-n and (1-x)-n where nZ+ Sol : By the Extended Binomial Theorem, Def 2. By replacing x by –x we have

※Using Generating Functions to solve Recurrence Relations. Example 16. Solving the recurrence relation ak = 3ak-1 for k=1,2,3,… and initial condition a0 = 2. Sol : 另法: (by 7.2公式 ) r – 3 = 0  r = 3  an = a  3n ∵ a0 = 2 = a ∴ an = 2  3n

generating function for {ak}. First note that ak xk = 3ak-1 xk  Let be the generating function for {ak}. First note that ak xk = 3ak-1 xk  G(x) - a0 = 3x  G(x) ∵a0 = 2  G(x) - 3x  G(x) = G(x)(1-3x) = 2 ∴ ak = 2  3k Exercise : 5,7,11,33

7.5 Inclusion-Exclusion 排容原理 A,B,C,D : sets A B C |A|+|B|+|C| 時 各部分被計算的次數 1 2 1 2 1 1 2 3 -|AB|-|AC|-|BC|後 1 2 1 1 +|ABC|後

Theorem 1. A1, A2, …, An : sets Exercise : 17

7.6 Applications of Inclusion and Exclusion Example 2. How many onto functions are there form set A={1, 2, 3, 4, 5, 6} to set B={a, b, c} ? Sol : f : A → B f (1)= {a, b, c} f (2)= ︰ ︰ f (6)= 不同的填法造出不同的函數 如何使a,b,c都出現 ? # of onto functions = (所有函數個數) - (a,b,c中有一個沒被對應) + (a,b,c中二個沒被對應) - (a,b,c都沒被對應) =

Thm 1. |A| = m , |B| = n There are onto functions f : A → B. pf : A = {a1, a2, …, am}. B = {b1, b2, …, bn} f (a1)= f (a2)= ︰ ︰ f (am)= b1, b2, …, bn

※Derangements 亂序 Def. A derangement is a permutation of objects that leaves no object in its original position.

Example 5. derangements of 12345 : 21453, 23451, 34512, … Def. Let Dn denote the number of derangements of n objects. D4 = (所有4個元素的permutation數) - (4個元素有一個在原位置的permutation數) + (4元素中有二個在原位置的個數) - (4個元素中有三個在原位置的個數) + (4元素都在原位置的個數) =

Theorem 2. (亂序公式) Exercise : 8 參考:12,13