Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
66 views

Generating Functions

1. Generating functions provide a global perspective to study local properties of sequences and probabilities by encoding information about a sequence in the coefficients of a formal power series. 2. The generalized binomial theorem and identities for differentiating geometric series are useful tools when working with generating functions. 3. Generating functions can be used to solve complicated counting problems by constructing a generating function to model the constraints and reading off the desired count from the appropriate coefficient.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Generating Functions

1. Generating functions provide a global perspective to study local properties of sequences and probabilities by encoding information about a sequence in the coefficients of a formal power series. 2. The generalized binomial theorem and identities for differentiating geometric series are useful tools when working with generating functions. 3. Generating functions can be used to solve complicated counting problems by constructing a generating function to model the constraints and reading off the desired count from the appropriate coefficient.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Generating Functions

Karen Ge

May 22, 2017

Abstract
Generating functions gives us a global perspective when we need
to study a local property. We define generating functions and present
its applications in algebra and combinatorics. We also introduce the
Snake Oil Method, a powerful tool to evaluate combinatorial sums
using generating functions.
Keywords: generating functions, generalized binomial theorem, com-
binatorics, snake oil method

1 Motivation
Why generating functions? Generating functions gives us a global perspec-
tive when we need to study a local property. It also gives us a simple way
to encode and manipulate probabilities. It provides us a different angle
and often helps us uncover the secrets that we were oblivious to previously.
Quoting [3], “A generating function is a clothesline on which we hang up a
sequence of numbers for display.” Our first example illustrates the idea of
using the coefficients of a polynomial to describe probabilities.
Example 1. Compute the probability that you get exactly three 1’s after
rolling a standard 6-sided die five times. Then compute the probability that
you get three 1’s, one 2, and one 3 after rolling five times.

Solution. For the first part, we see that rolling a 1 has a 16 chance of
occurring and any other number has a 65 chance of coming up. There are
5

3 ways to choose which three of the rolls in the sequence are 1’s. So the
5 1 3 5 2

total probability is 3 ( 6 ) ( 6 ) .
For the second part, there are 53 ways to choose which three of the rolls are


1’s, 2 ways to choose which of the remaining two rolls is a 2. The probability
of any specific number coming up is again 16 . So the probability is 53 ·2·( 16 )5 .


1
Now we illustrate how expanding a polynomial can help us solve this and
similar problems. For the first part, we realize that there are two results we
care about: rolling 1 or rolling anything else. To separate these probabilities
in our polynomial, we make the coefficient of x be 16 and the coefficient of
y be 65 . Since the terms of the expansion should have total degree 5, we
consider raising ( x6 + 5y 3 2
6 ) to the 5th power. Then the coefficient of x y
corresponds tothe probability that rolling a die 5 times results in three 1’s.
Indeed, it is 53 ( 61 )3 ( 65 )2 , as computed earlier.
For the second part, there are three results we care about: rolling 1, rolling
2, or rolling 3. Then we consider the trinomial

a b c
( + + )5 .
6 6 6
5
The coefficient of a3 bc is · 2 · ( 61 )5 , as predicted.

3
Similarly, as a polynomial with infinite degree, a generating function can en-
code information about a combinatorial sequence in its coefficients. Given
aPsequence A = {a0 , a1 , a2 , ...}, we define a formal power series G(x) =
∞ n
n=0 an x . Note that G(x) is like a polynomial, except that it may have
infinitely many terms. Note also that ai , the ith member of A, is the coef-
ficient of the term xi of G(x). We call G(x) the generating function for
the sequence A = {a0 , a1 , a2 , ...}.
Before we explore further, let’s establish some useful identities.

2 Generalized Binomial Theorem


We all know the binomial theorem
     
n n 2 n
(1 + x)n = 1 + x+ x + ··· + xn−1 + xn .
1 2 n−1
Its generalized form is quite useful when combined with generating functions.

Theorem 1 (Generalized Binomial Theorem). Let r be any real number.


We have
∞    
r
X r n r r(r − 1) · · · (r − n + 1)
(1 + x) = x , where = .
n n n!
n=0

2
When r = −1 in Theorem 1, we get
1
= 1 − x + x2 − x3 + · · · .
1+x
We can also differentiate the geometric series repeatedly, and get

1 X
= xn ,
1−x
n=0

1 X
= nxn−1 ,
(1 − x)2
n=1

2 X
= n(n − 1)xn−2 ,
(1 − x)3
n=2
···

Therefore,
∞  
1 X n+2 n
= x .
(1 − x)3 2
n=0

We will use those identities in the next sections.

3 Counting
You might say that we do not have to use 5th degree polynomials to solve
Example 1. That may be true, but generating functions can be used to
solve complicated counting problems that are out of the reach of traditional
methods. Let’s look at an example.

Example 2. In how many ways can we fill a bag with n fruits chosen from
apples, bananas, oranges, and pears, subject to the following constraints?

• The number of apples must be even.

• There can be at most six bananas.

• The number of oranges is divisible by 7.

• There can be at most one pear.

3
Solution. Let’s use the method of divide and conquer and construct a
generating function for selecting each type of fruit. First we select apples.
We can select a set of 0 apples in 1 way, a set of 1 apple in 0 ways, a set of
2 apples in 1 way, and so on. Thus
1
A(x) = 1 + x2 + x4 + · · · = .
1 − x2
We can select a set of 0 bananas in one way, a set of 1 bananas in one way,
.... Since there are at most six bananas, we have

1 − x7
B(x) = 1 + x + x2 + x3 + x4 + x5 + x6 = .
1−x
The generating function for selecting oranges is similar to that for selecting
apples, namely,
1
O(x) = 1 + x7 + x14 + · · · = .
1 − x7
Finally, we can only select zero or one pear. So P (x) = 1 + x.
The generating function G(x) for selecting from among all kinds of fruit is

1 1 − x7 1 1
G(x) = A(x)B(x)O(x)P (x) = (1 + x) = .
1 − x2 1 − x 1 − x7 (1 − x)2
Since
1 d 1 
2
=
(1 − x) dx 1 − x
d
= (1 + x + x2 + x3 + x4 + · · · )
dx
= 1 + 2x + 3x2 + 4x3 + · · · ,

the coefficient of xn in G(x) is n + 1. Thus the number of ways to form a


bag of n fruits is n + 1 .
Here is another example.
Example 3. A set of playing cards has 32 cards in total. 30 of them are
colored red, yellow, or blue, with 10 cards of each color, and given the num-
bers 1, 2, 3, ..., 10, respectively. The two remaining cards are both jokers
and are designated with the number 0. A card with the number k counts for
2k points. Let a good group be a group of cards where the sum of the points
of the cards is 2017. Calculate the number of good groups.

4
Solution. Let G(x) = ∞ n
P
n=0 an x , where an is the number of groups of
cards with sum of points equal to n. We see that

G(x) = (1 + x)2 (1 + x2 )3 (1 + x4 )3 · · · (1 + x1024 )3 .

Multiplying both sides of the equation by (1 − x2 )3 and simplifying, we get

(1 + x)2 (1 − x2048 )3
G(x) = .
(1 − x2 )3
From the last section, we know that
∞  
1 X n + 2 2n
= x .
(1 − x2 )3 2
n=0

Since we are asked to find the coefficient of x2017 , we do not need to care
about (1 − x2048 )3 . That is, we want the coefficient of x2017 in

(1 + x)2
   
2
 3 2 4 4 
= (1 + 2x + x ) 1 + x + x + · · · .
(1 − x2 )3 2 2

The only way we can 2017 term is to pick the 2x term from (1 + x)2
 make a x
1010 2016
and pick the 2 x term from (1 − x2 )−3 . Thus its coefficient is
 
1010
2 = 1019090 .
2

4 Recurrences
Generating functions are also very useful in solving recurrence relations, as
we will see in the next example.

Example 4. Given a sequence A = {a0 , a1 , a2 , ...} such that

a0 = 0, a1 = 1, and an = an−1 + 2an−2

for all n ≥ 2, find a closed form formula for an .

Solution. Computing the first few terms, we get A = {0, 1, 1, 3, 5, 11, ...}.
Let G(x) = ∞ n be the generating function for the sequence.
P
a
n=0 n x

5
Now let’s see where the given recurrence relation might lead us to. We
rewrite G(x) with an = an−1 + 2an−2 in mind.

G(x) = x + x2 + 3x3 + 5x4 + 11x5 + · · ·


xG(x) = x2 + x3 + 3x4 + 5x5 + · · ·
2x2 G(x) = 2x3 + 2x4 + 6x5 + · · ·

Note that xG(x) + 2x2 G(x) = x2 + 3x3 + 5x4 + 11x5 + · · · . Thus


x
G(x) − xG(x) − 2x2 G(x) = x or G(x) = .
1 − x − 2x2
Next we use partial fractions to make G(x) more manageable. We get
x 1 1
G(x) = 2
= − .
1 − x − 2x 3(1 − 2x) 3(1 + x)
Since
1
= 1 + (2x) + (2x)2 + (2x)3 + · · · ,
1 − 2x
1
= 1 + (−x) + (−x)2 + (−x)3 + · · · ,
1+x
the nth term of our sequence A is

1 1 2n − (−1)n
an = 2n − (−1)n = .
3 3 3

1
Example 5. Note that 89 = 0.011235955056.... Prove that

1 X Fn
= ,
89 10n+1
n=1

where Fn is the nth term of the Fibonacci sequence defined by F0 = 0, F1 = 1,


and Fn+2 = Fn + Fn+1 for n ≥ 2.

Proof. Let G(x) = ∞ n


P
n=0 Fn x be the generating function for Fn . Similar
to the solution to Example 4, we can get
x
G(x) = = F0 + F1 x + F2 x2 + F3 x3 + · · · . (∗)
1 − x − x2

6
1
Plugging x = 10 into (∗), we get

10 F1 F2 F3
= + + + ··· ,
89 10 100 1000
and the result follows.

5 Snake Oil Method


When each term an of Pa sequence A = {a0 , a1 , a2 , ...} is itself a sum, generat-
ing function G(x) = ∞ a
n=0 n x n is especially helpful. Then we have a double

sum to work with and swapping the order of summation usually helps. Her-
bert Wilf [3] coined the name Snake Oil Method, a cure for everything.
In his own words, “don’t try to evaluate the sum that you’re looking at.
Instead, find the generating function for the whole parameterized family of
them, then read off the coefficients.” Let’s look at an example.

Example 6. For n ≥ 0, compute


X k 
.
n−k
k≥0

Solution. Here the free variable is n. So we define a generating function


X  X  k 
G(x) = xn .
n
n − k
k≥0

Next we interchange the sums, and get


XX k  X X k 
n
G(x) = x = xk xn−k .
n
n − k n
n − k
k≥0 k≥0

Let r = n − k, we get
X X k  X
k
G(x) = x xr = xk (1 + x)k
r
r
k≥0 k≥0
X 1
= (x + x2 )k = .
1 − x − x2
k≥0

7
x
From Example 5, we know that 1−x−x 2 is the generating function for the
Fibonacci sequence. Thus
X k 
= Fn+1 (n = 0, 1, 2, ...).
n−k
k≥0

6 Exercises
1. Let a0 = 1, a1 = 1, and an = 4an−1 − 4an for n ≥ 2. Use generating
functions to find a formula for an in terms of n.
2. Find the number an of ways n dollars can be changed into 1-dollar or
2-dollar coins regardless of the order. For example, when n = 3, there
are 2 ways, namely three 1-dollar coins or one 1-dollar coin and one
2-dollar coin.
3. Let n be a positive integer. Find the number an of polynomials P (x)
with coefficients in {0, 1, 2, 3} such that P (2) = n.
4. Let a0 , a1 , a2 , ... be an increasing sequence of nonnegative integers
such that every nonnegative integer can be expressed uniquely in the
form ai + 2aj + 4ak , where i, j and k are not necessarily distinct.
Determine a1998 .
5. Assume that for some positive integer n there are sequences of positive
numbers a1 , a2 , ..., an and b1 , b2 , ..., bn such that the sums
a1 + a2 , a1 + a3 , ..., an−1 + an and
b1 + b2 , b1 + b3 , ..., bn−1 + bn

are same up to permutation. Prove that n is a power of two.


6. For n ≥ 0, compute
X n + k 
2n−k .
2k
k≥0

7. Prove that, for m, n ≥ 0,


X mn + k  X mn
= 2k
k m k k
k≥0 k≥0

without evaluating either of the two sums.

8
References
[1] Evan Chen, Summation, web.evanchen.cc/handouts/Summation/
Summation.pdf

[2] Albert Meyer and Ronitt Rubinfeld, Generating Functions, MIT


6.042J/18.062J

[3] Herbert Wilf, generatingfunctionology, https://www.math.upenn.


edu/~wilf/gfologyLinked2.pdf

You might also like