Geeratig Fuctios II Misha Lavrov ARML Practice 5/4/2014
Warm-up problems 1. Solve the recursio a +1 = 2a, a 0 = 1 by usig commo sese. 2. Solve the recursio b +1 = 2b + 1, b 0 = 1 by usig commo sese ad trickery. 3. Solve the recursio c +1 = 2c +, c 0 = 1 by usig commo sese, trickery, ad persistece. 4. Solve the recursio d +2 = d + d +1 + 2, d 0 = d 1 = 1 by usig commo sese, trickery, persistece, ad a familiarity with the Fiboacci umbers.
Warm-up solutios 1. a = 2. 2. b = 2 +1 1. 3. c = 2 +1 1. 4. d = 2 F, where F is the th Fiboacci umber (with F 0 = 0 ad F 1 = 1).
Formal itroductio to geeratig fuctios If we have a sequece a 0, a 1, a 2, a 3,... that we like very much, we make a geeratig fuctio for it by computig the sum A(x) = a k x k. k=0 Ofte there is some ice expressio for what this sum is. For example, if the sequece is ( ( 0), ( 1), 2),..., we get the geeratig fuctio (1 + x).
Formal itroductio to geeratig fuctios If we have a sequece a 0, a 1, a 2, a 3,... that we like very much, we make a geeratig fuctio for it by computig the sum A(x) = a k x k. k=0 Ofte there is some ice expressio for what this sum is. For example, if the sequece is ( ( 0), ( 1), 2),..., we get the geeratig fuctio (1 + x). Reasos to use geeratig fuctios: We get short descriptios of complicated sequeces. We ca maipulate sequeces i useful ways with simple algebra.
Recurreces If you lack commo sese, trickery, ad persistece, you ca use geeratig fuctios to solve recurreces. For example, take the recurrece a +1 = 2a + 1 with a 0 = 1. a +1 = 2a + 1
Recurreces If you lack commo sese, trickery, ad persistece, you ca use geeratig fuctios to solve recurreces. For example, take the recurrece a +1 = 2a + 1 with a 0 = 1. a +1 = 2a + 1 a +1 x = 2a x + =0 =0 =0 x
Recurreces If you lack commo sese, trickery, ad persistece, you ca use geeratig fuctios to solve recurreces. For example, take the recurrece a +1 = 2a + 1 with a 0 = 1. a +1 = 2a + 1 a +1 x = 2a x + =0 A(x) a 0 x =0 =0 = 2A(x) + 1 1 x x
Recurreces If you lack commo sese, trickery, ad persistece, you ca use geeratig fuctios to solve recurreces. For example, take the recurrece a +1 = 2a + 1 with a 0 = 1. a +1 = 2a + 1 a +1 x = 2a x + =0 =0 =0 A(x) a 0 = 2A(x) + 1 x 1 x 1 A(x) = (1 x)(1 2x). x
Recurreces If you lack commo sese, trickery, ad persistece, you ca use geeratig fuctios to solve recurreces. For example, take the recurrece a +1 = 2a + 1 with a 0 = 1. a +1 = 2a + 1 a +1 x = 2a x + =0 =0 =0 A(x) a 0 = 2A(x) + 1 x 1 x 1 A(x) = (1 x)(1 2x). This splits up as A(x) = 2 1 2x 1 1 x, so a = 2 2 1. x
Addig up Fiboacci umbers The geeratig fuctio for the Fiboacci umbers is x F (x) =. Suppose we wat to compute 1 x x 2 S = F 0 + F 1 + F 2 + + F. How ca we do this usig geeratig fuctios?
Addig up Fiboacci umbers The geeratig fuctio for the Fiboacci umbers is x F (x) =. Suppose we wat to compute 1 x x 2 S = F 0 + F 1 + F 2 + + F. How ca we do this usig geeratig fuctios? Let S(x) = =0 S x. The: ( ) S(x) = F k x = = =0 k=0 k=0 =k = 1 1 x F k x = k=0 k=0 0 k F k x k 1 x F k x F k x k = 1 1 x F (x) = x (1 x)(1 x x 2 ).
Addig up Fiboacci umbers x (1 x)(1 x x 2 ). We ca use partial partial fractios o S(x) = Write: x (1 x)(1 x x 2 ) = A 1 x + Bx + C 1 x x 2.
Addig up Fiboacci umbers x (1 x)(1 x x 2 ). We ca use partial partial fractios o S(x) = Write: x (1 x)(1 x x 2 ) = A 1 x + Bx + C 1 x x 2. By settig x to a few trial values, we get: 0 = A + C (x = 0) 1 2 = 1 2A B + C (x = 1) 4 = 2A + 2B + 4C (x = 1 2 )
Addig up Fiboacci umbers x (1 x)(1 x x 2 ). We ca use partial partial fractios o S(x) = Write: x (1 x)(1 x x 2 ) = A 1 x + Bx + C 1 x x 2. By settig x to a few trial values, we get: 0 = A + C (x = 0) 1 2 = 1 2A B + C (x = 1) 4 = 2A + 2B + 4C (x = 1 2 ) We get A = 1, B = C = 1, so S(x) = x + 1 1 x x 2 1 1 x = F (x) + F (x) x Therefore S = F + F +1 1 = F +2 1. 1 1 x.
Covolutios, agai There is aother reaso why F (x) 1 x ca write this as: gave us the partial sums. We (F 0 + F 1 x + F 2 x 2 + F 3 x 3 + )(1 + x + x 2 + x 3 + ).
Covolutios, agai There is aother reaso why F (x) 1 x ca write this as: gave us the partial sums. We (F 0 + F 1 x + F 2 x 2 + F 3 x 3 + )(1 + x + x 2 + x 3 + ). Whe we multiply this out, we get the followig x terms: (F x ) 1 + (F 1 x 1 ) x + + (F 1 x) x 1 + F 0 x. The total coefficiet of x is F + F 1 + + F 1 + F 0.
Exercises 1. Fid the coefficiet of x 100 i (1+x)10 1 x. 2. Solve the recurrece a = a 0 + a 1 + + a 1, with a 0 = 1. 3. Compute the sum F 0 + F 2 + F 4 + + F 2 2 + F 2.
Exercises 1. The coefficiet of x 100 (ad ay x for 10) is 2 10 = 1024. 2. a = 2 1 for 1. The geeratig fuctio (if you took that approach) is A(x) = 1 x 1 2x = 1/2 1 2x + 1 2. 3. F 0 + F 2 + F 4 + + F 2 2 + F 2 = F 2+1 1. I geeratig fuctio laguage: F (x) 1 x 2 = F (x) 1 x 1 x 2. This also implies that F 1 + F 3 + F 5 + + F 2 1 = F 2.
Complete sums of geeratig fuctios 1. How ca we fid ( 0) + ( 1) + + ( ) usig geeratig fuctios?
Complete sums of geeratig fuctios 1. How ca we fid ( 0) + ( 1) + + ( ) usig geeratig fuctios? ( The fuctio f (x) = (1 + x) is the g.f. for the fiite sequece ) ( 0, ) ( 1,..., ). We ca fid the sum by settig x = 1, gettig (1 + 1) = 2.
Complete sums of geeratig fuctios 1. How ca we fid ( 0) + ( 1) + + ( ) usig geeratig fuctios? ( The fuctio f (x) = (1 + x) is the g.f. for the fiite sequece ) ( 0, ) ( 1,..., ). We ca fid the sum by settig x = 1, gettig (1 + 1) = 2. 2. How ca we fid ( ( 0) + ( 2) + ) ( 4 + + ( mod 2)) usig geeratig fuctios?
Complete sums of geeratig fuctios 1. How ca we fid ( 0) + ( 1) + + ( ) usig geeratig fuctios? ( The fuctio f (x) = (1 + x) is the g.f. for the fiite sequece ) ( 0, ) ( 1,..., ). We ca fid the sum by settig x = 1, gettig (1 + 1) = 2. 2. How ca we fid ( ( 0) + ( 2) + ) ( 4 + + ( mod 2)) usig geeratig fuctios? Settig x = 1 coverts ( ) k x k ito just ( k) for all k. But settig x = 1 coverts ( ) k x k ito ( ( k) for eve k, ad ) k for all k. f (1)+f ( 1) Therefore 2 will preserve the eve terms ad cacel the odd terms, givig us (1+1) +(1 1) 2 = 2 1.
Aother dice problem If you roll 10 stadard dice, what is the probability that the total is divisible by 5?
Aother dice problem If you roll 10 stadard dice, what is the probability that the total is divisible by 5? We ca solve this i a similar way. Let ω = e 2πi/5 : a complex umber satisfyig ω 5 = 1. Sice x 5 1 factors as (x 1)(x 4 + x 3 + x 2 + x + 1), ad ω 1, we also have 1 + ω + ω 2 + ω 3 + ω 4 = 0. Let f (x) be a geeratig fuctio. What is f (1)+f (ω)+ +f (ω4 ) 5?
Aother dice problem If you roll 10 stadard dice, what is the probability that the total is divisible by 5? We ca solve this i a similar way. Let ω = e 2πi/5 : a complex umber satisfyig ω 5 = 1. Sice x 5 1 factors as (x 1)(x 4 + x 3 + x 2 + x + 1), ad ω 1, we also have 1 + ω + ω 2 + ω 3 + ω 4 = 0. Let f (x) be a geeratig fuctio. What is f (1)+f (ω)+ +f (ω4 ) 5? Each x becomes 1+ω +ω 2 +ω 3 +ω 4 5. If is a multiple of 5, this becomes 1+1+1+1+1 5 = 1. Otherwise, the umerator is a permutatio of 1 + ω + ω 2 + ω 3 + ω 4 = 0. If we do this for the probability geeratig fuctio of rollig 10 dice, we get the aswer we wat.
Aother dice problem: Solutio The probability geeratig fuctio of oe die roll is x+x 2 +x 3 +x 4 +x 5 +x 6 6. So the p.g.f. for rollig 10 dice is ( x + x 2 + x 3 + x 4 + x 5 + x 6 ) 10 f (x) =. 6
Aother dice problem: Solutio The probability geeratig fuctio of oe die roll is x+x 2 +x 3 +x 4 +x 5 +x 6 6. So the p.g.f. for rollig 10 dice is ( x + x 2 + x 3 + x 4 + x 5 + x 6 ) 10 f (x) =. 6 Next, we compute f (1), f (ω), f (ω 2 ), f (ω 3 ), ad f (ω 4 ). The first is easy: f (1) = 1. We ca simplify ω + ω 2 + ω 3 + ω 4 + ω 5 + ω 6 to just ω + ω 2 (1 + ω + ω 2 + ω 3 + ω 4 ) = ω. So f (ω) = ( ) ω 10 6 = 1. The 6 10 same thig happes for ω 2, ω 3, ad ω 4.
Aother dice problem: Solutio The probability geeratig fuctio of oe die roll is x+x 2 +x 3 +x 4 +x 5 +x 6 6. So the p.g.f. for rollig 10 dice is ( x + x 2 + x 3 + x 4 + x 5 + x 6 ) 10 f (x) =. 6 Next, we compute f (1), f (ω), f (ω 2 ), f (ω 3 ), ad f (ω 4 ). The first is easy: f (1) = 1. We ca simplify ω + ω 2 + ω 3 + ω 4 + ω 5 + ω 6 to just ω + ω 2 (1 + ω + ω 2 + ω 3 + ω 4 ) = ω. So f (ω) = ( ) ω 10 6 = 1. The 6 10 same thig happes for ω 2, ω 3, ad ω 4. Therefore the probability we wat is 1 + 1 6 10 + 1 6 10 + 1 6 10 + 1 6 10 5 = 1 5 + 4 5 6 10.
Exercises 1. Compute ( ) ( 99 0 + 99 ) ( 3 + 99 ) ( 6 + + 99). 2. Compute ( ) ( 99 1 + 99 ) ( 4 + 99 ) ( 7 + + 99 97). 3. Usig the g.f. 1 (1 x) 2 = 1 + 2x + 3x 2 + 4x 3 +, fid the sum =0 2.
Solutios 1. Let f (x) = (1 + x) 99. The we take f (1)+f (e 2πi/3 )+f (e 4πi/3 ) 3 = 299 2 3. 2. Here, we do the same thig to f (x) = x 2 (1 + x) 99, ad get 2 99 +1 3. 1 3. Takig gives us 4, but this is actually the sum (1 1 )2 2 =0 +1 2. So we subtract off =0 1 2 = 2, ad get a total of 2.
Bous problem Let T be the umber of triagles you ca make with iteger sides ad perimeter. Fid the geeratig fuctio T (x) = =0 T x.
Bous problem Let T be the umber of triagles you ca make with iteger sides ad perimeter. Fid the geeratig fuctio T (x) = =0 T x. This amouts to choosig a, b, c such that a b c ad c < a + b. But that is equivalet to choosig p = b a, q = c b, ad r = a + b c such that p 0, q 0, ad r > 0. This yields the geeratig fuctio T (u, v, w) = 1 1 u 1 1 v w 1 w. Give p, q, r, the perimeter is 2p + 4q + 3r = 2(b a) + 4(c b) + 3(a + b c) = a + b + c. So we substitute u = x 2, v = x 4, w = x 3 to get T (x) = x 3 (1 x 2 )(1 x 3 )(1 x 4 ).