16
Generating Function October 21, 2014

Generating Function October 21, 2014 Generating Functions Given an infinite sequence, its ordinary generating function is the power series: G(x) = g

Embed Size (px)

Citation preview

  • Slide 1
  • Slide 2
  • Generating Function October 21, 2014
  • Slide 3
  • Generating Functions Given an infinite sequence, its ordinary generating function is the power series: G(x) = g 0 + g 1 x + g 2 x 2 + g 3 x 3 + We will use a double-sided arrow to denote the correspondence between a sequence and its generating function. g 0 + g 1 x + g 2 x 2 + g 3 x 3 +
  • Slide 4
  • Examples 0 + 0x + 0x 2 + = 0 0 + 0x + 1x 2 + = x 2 1 + 2x + 1x 2 + 0x 3 = (1+x) 2 1 + x + x 2 + x 3 = 1/(1-x) 1 - x + x 2 - x 3 = 1/(1+x) 1 + ax + a 2 x 2 + a 3 x 3 = 1/(1-ax) 1 + x 2 + x 4 = 1/(1-x 2 )
  • Slide 5
  • Operations on Generation Functions Scaling: Given G(x) Then, c G(x) Addition: Given G(x) and F(x) Then, G(x)+F(x)
  • Slide 6
  • Operations on Generation Functions Right Shift: Given G(x) Then, x k G(x) Differentiation: Given G(x) Then, G(x) k zeroes
  • Slide 7
  • Class Discussion Give a closed form generating function for the sequence 1 + x + x 2 + x 3 + = 1/(1-x) = f(x) 1 + 2x + 3x 2 + = f(x) x + 2x 2 + 3x 3 + = xf(x) = g(x) 1 + 2 2 x + 3 2 x 2 + = g(x) x + 2 2 x 2 + 3 2 x 3 + = g(x) But you need to work out g(x).
  • Slide 8
  • Fibonacci Sequence Fibonacci numbers: f 0 = 0 f 1 = 1 f n = f n-1 + f n-2 (n 2) What is the generating function of the Fibonacci sequence? Suppose: F(x)
  • Slide 9
  • Fibonacci Sequence x xF(x) x 2 F(x) Then, x + xF(x) + x 2 F(x) Therefore, F(x) = x + xF(x) + x 2 F(x) F(x) = x / (1 - x - x 2 )
  • Slide 10
  • Fibonacci Numbers x / (1 x x 2 ) We can get a closed form for the n th Fibonacci number by finding the coefficient of x n on the right hand side. We can show that: F(x) = 1/5 0.5 (1/(1- 1 x) 1/(1- 2 x)) where 1 = 0.5(1 + 5 0.5 ) and 2 = 0.5(1 - 5 0.5 )
  • Slide 11
  • Fibonacci Numbers The coefficient of x n in F(x) is: 1/5 0.5 1 n - 1/5 0.5 2 n Therefore,
  • Slide 12
  • Counting We can use generating function to count. Consider the following problem: Suppose there are 4 types of fruits: apples, bananas, oranges and pears. In how many ways can we fill a bag with n fruits subject to the following constraints: The number of apples must be even. The number of bananas must be a multiple of 5. There can be at most 4 oranges. There can be at most 1 pear. Sources from Prof. Albert R. Meyer
  • Slide 13
  • Counting No. of apples must be even: 1/(1-x 2 ) No. of bananas must be a multiple of 5: 1/(1-x 5 ) At most four oranges: (1-x 5 )/(1-x) At most one pear: 1 + x
  • Slide 14
  • Counting No. of ways to pick n fruits satisfying the constraints can be represented by the generating function: 1/(1-x 2 ) 1/(1-x 5 ) (1-x 5 )/(1-x) (1+x) = 1/(1-x) 2 = 1 + 2x + 3x 2 + 4x 3 + Therefore, no. of ways to pick n fruits satisfying all the constraints is n+1.
  • Slide 15
  • Counting Convolution Rule: Let A(x) be the generating function for selecting items from set A, and let B(x) be the generating function for selecting items from set B. If A and B are disjoint, then the generating function for selecting items from the union A B is the product A(x) B(x). In the previous example, A can be the set of apples and B the set of bananas.
  • Slide 16
  • Class Discussion A woman has a large supply of 1-, 2- and 3- cents stamps. Let a r denote the number of ways to make up a postage of r cents. Give a generating function for. How many ways can she pick the stamps so as to make up a postage of r cents? (1+x+x 2 +x 3 +..) (1+x 2 +x 4 +..) (1+x 3 +x 6 +..) = (1-x) -1 (1-x 2 ) -1 (1-x 3 ) -1
  • Slide 17
  • Class Discussion The lifespan of a rabbit is 10 years. Suppose there are 2 newborn rabbits this year and the number of newborns each year is two times that in the previous year. Find the number of rabbits there are in the r th year.