
Textbook ? • 12 students said they needed the textbook, but only one student bought the text from Triangle. COS 341 Discrete Mathematics • If you don’t have the book, please get it from Triangle. Exponential Generating • We will have to pay for the copies that aren’t taken ! Functions and Recurrence Relations 1 2 Derangements (or Hatcheck lady revisited) Derangements 1 x dnn : number of permutations on objects without a fixed poin t = Dx()⋅e 1− x Dx( ) : exponential generating function for number of derangement s 1 Dx()= e−x A permutation on []n can be constructed by picking 1− x ∞ xn ∞ a subset Kn of [], constructing a derangement of K and = (1)− nn x ∑∑ fixing the elements of [nK]- . nn==00n! n k Every permutation of [n] arises exactly once this way. dn n (−1) ==coefficient of x ∑ nk!! ∞ n!1 k=0 EGF for all permutations == xn n k ∑ (1)− n=0 nx! 1− dn= ! ∞ n ∑ 1 x k=0 k! EGF for permutations with all elements fixed == xn ∑ n! e n=0 Different proof in Matousek 10.2, problem 17 1 = Dx()⋅ex 1− x 3 4 1 Example Example How many sequences of n letters can be formed from How many sequences of n letters can be formed from A, B, and C such that the number of A's is odd and the A, B, and C such that the number of A's is odd and the number of B's is odd ? number of B's is odd ? xn eex − −x eee3x −2 xx+ − EGF for A's = ∑ = required EGF = n odd n! 2 4 eex − −x 13nn−2+ (1)− EGF for B's = coefficient of xn = 2 n!4 ∞ n x x EGF for C's = ∑ = e 3(1)nn−2+ − n=0 n! required number = 4 xx− 2 3x xx− ee− x eee−2 + required EGF = e = 2 4 5 6 Recurrence relations Reproducing rabbits A recurrence relation for the sequence {an} is an Suppose a newly-born pair of rabbits, one male, one equation that expressed an in terms of one or more of the female, are placed on an island. A pair of rabbits does previous terms of the sequence, for all integers n ≥ n0 not breed until they are 2 months old. After they are A sequence is called a solution of a recurrence relation two months old, each pair of rabbits produces another if its terms satisfy the recurrence relation. pair each month. aa= − a n≥ 2 Suppose that our rabbits never die and that the female nn−−1 n2 always produces one new pair (one male, one female) == Initial conditions aa013, 5 every month from the second month on. The puzzle a2 = 53− = 2 that Fibonacci posed was... a3 = 25− = − 3 How many rabbits will there be in one year ? 7 8 2 In the beginning … Enter recurrence relations Let fnn be the number of rabbits after months. ff12==1, 1 fnnn= ff−−12+ Number of pairs 2 months old Number of existing pairs 9 Fibonacci sequence 10 Towers of Hanoi Towers of Hanoi Let Hn be the number of moves required to solve the problem with n disks. H1 = 1 HHnn=+ 2−1 1 N disks are placed on first peg in order of size. The goal is to move the disks from the first peg to the second peg Only one disk can be moved at a time A larger disk cannot be placed on top of a smaller disk 11 12 3 Towers of Hanoi solution The end of the world ? An ancient legend says that there is a tower in Hanoi where HH=+2− 1 nn1 the monks are transferring 64 gold disks from one peg to 2 another according to the rules of the puzzle. =++=++2(2HHnn−−22 1) 1 2 2 1 =+++=+++2(2232HH 1) 2 1 2 2 2 1 The monks work day and night, taking 1 second to transfer nn−−33 each disk. The myth says that the world will end when they # finish the puzzle. # How long will this take ? =+++++22221nnn−−−123H " 1 264 − 1= 18,446,744,073,709,551,615 =+++++222nn−−123 n −" 21 It will take more than 500 billion years to solve the puzzle ! = 21n − 13 14 More recurrence relations A familiar sequence ? How many bit strings of length n do not have 2 consecutive 0’s ? How many bit strings of length n do not have 2 consecutive 0’s ? Let ann be the number of such bit strings of length . Let ann be the number of such bit strings of length . aann=+ −−12 a n Any bit string of length n-1 End with 1: 1 an−1 with no two consecutive 0’s a1 = 2 = f3 a2 = 3 = f4 Any bit string of length n-2 End with 0: an−2 =+= = f with no two consecutive 0’s 1 0 a3 325 5 a4 =+=538= f6 aann=+ −−12 a n afnn= +2 15 16 4 How many ways can you multiply ? How many ways can you multiply ? In how many ways can you parenthesize the Let Cn be the number of ways of parenthesizing product of nxxxx+1 numbers 012⋅⋅⋅" n ? the product xxx012⋅⋅⋅" xn e.g. ((x ⋅⋅⋅xxx ) ) , 01 2 3 ()()x ⋅⋅xxx"" ⋅ ⋅ x 01 kk +1 n (x ⋅⋅ (xx ))) ⋅ x , 012 3 Ck Cnk−−1 (xx01⋅⋅⋅ ) ( xx 23 ), n−1 CCC= ⋅ xxxx⋅⋅⋅(( ) ), nknk∑ −−1 0123 k=0 xxxx0123⋅⋅⋅( ( )). th Let Cn be the number of ways of parenthesizing n Catalan number a product of n +1 numbers. CC==1, 1 C3 = 5 17 01 18 Solving recurrence relations Solving recurrence relations A linear homogeneous recurrence relation of degree k with acacann=+11−− 2 n 2 ++" ca knk − constant coefficients is a recurrence relation of the form n Try arn = acacann=+11−− 2 n 2 ++" ca knk − rcrcrnn=+−−12 n ++" cr nk − where cc1,… kk are real numbers and c≠ 0 12 k nn−−12 n nk − rcrcr−−12 −−" crk = 0 rcrcrkk−−−−12 k −−−" cr k − 1 c= 0 aann= −5 12kk− 1 2 aann=+−−12 a n ana= ⋅ nn−1 Characteristic equation 19 20 5 Solving recurrence relations Solving recurrence relations fnn=+ff−−12 n acaca21122=+nn−− Let rr, be the roots of the characteristic equation Let rr, be the roots of the characteristic equation 12 12 2 2 rr−−10= rcrc−−12= 0 r1 =+()15/2 Then the solution to the recurrence relation is nn r2 = ()15− / 2 of the form arrn = α 11+α 2 2 Then the solution to the recurrence relation is nn 15+ 15− = α +α of the form fn 2 2 21 1222 Solving recurrence relations fnn=+ff−−12 n nn 11+ 5 11− 5 = − fn 5522 23 6.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages6 Page
-
File Size-