Section 8.5 Generating Functions
This section contains an introduction to the topic of generating functions and how they are used to solve recurrence relations, among other problems. Methods that employ generating functions are based on the concept that you can take a problem involving sequences and translate it into a problem involving generating functions. Once you’ve solved the new problem, a translation back to sequences gives you a solution of the original problem.
Subsection 8.5.1 Definition
Example 8.5.2. First Examples.
- If
thenWe can get a closed form expression for by observing that Therefore, - Finite sequences have generating functions. For example, the sequence of binomial coefficients
has generating functionby application of the binomial formula. - If
Note that the index that is used in the summation has no significance. Also, note that the lower limit of the summation could start at 1 since
Subsection 8.5.2 Solution of a Recurrence Relation Using Generating Functions
-
Translate the recurrence relation into an equation about generating functions.Let
with and Therefore, -
Solve for the generating function of the unknown sequence,Close examination of the three sums above shows:
- since
and -
Therefore,
-
Determine the sequence whose generating function is the one we got in Step 2.For our example, we need to know one general fact about the closed form expression of an exponential sequence (a proof will be given later):Now, in order to recognize
in our example, we must write our closed form expression for as a sum of terms like above. Note that the denominator of can be factored:If you look at this last expression for closely, you can imagine how it could be the result of addition of two fractions,where and are two real numbers that must be determined. Starting on the right of (8.5.2), it should be clear that the sum, for any and would look like the left-hand side. The process of finding values of and that make (8.5.2) true is called the partial fractions decomposition of the left-hand side:Therefore,andWe can apply (8.5.1) to each term of is the generating function for is the generating function for
Therefore,
From this example, we see that there are several skills that must be mastered in order to work with generating functions. You must be able to:
- Manipulate summation expressions and their indices (in Step 2).
- Solve algebraic equations and manipulate algebraic expressions, including partial function decompositions (Steps 2 and 3).
- Identify sequences with their generating functions (Steps 1 and 3).
We will concentrate on the last skill first, a proficiency in the other skills is a product of doing as many exercises and reading as many examples as possible.
First, we will identify the operations on sequences and on generating functions.
Subsection 8.5.3 Operations on Sequences
Definition 8.5.3. Operations on Sequences.
If one imagines a sequence to be a matrix with one row and an infinite number of columns, and are exactly as in matrix addition and scalar multiplication. There is no obvious similarity between the other operations and matrix operations.
The pop and push operations can be understood by imagining a sequence to be an infinite stack of numbers with at the top, next, etc., as in Figure 8.5.4a. The sequence is obtained by “popping” S(0) from the stack, leaving a stack as in Figure 8.5.4b, with S(1) at the top, S(2) next, etc. The sequence is obtained by placing a zero at the top of the stack, resulting in a stack as in Figure 8.5.4c. Keep these figures in mind when we discuss the pop and push operations.

Stack interpretation of pop and push operation
Example 8.5.5. Some Sequence Operations.
If and
Note that
Definition 8.5.6. Multiple Pop and Push.
Subsection 8.5.4 Operations on Generating Functions
Definition 8.5.7. Operations on Generating Functions.
If and are generating functions and is a real number, then the sum scalar product product and monomial product are generating functions, where
Example 8.5.8. Some operations on generating functions.
If and then
Now we establish the connection between the operations on sequences and generating functions. Let and be sequences and let be a real number.
In words, (8.5.13) says that the generating function of the sum of two sequences equals the sum of the generating functions of those sequences. Take the time to write out the other four identities in your own words. From the previous examples, these identities should be fairly obvious, with the possible exception of the last two. We will prove (8.5.16) as part of the next theorem and leave the proof of (8.5.17) to the interested reader. Note that there is no operation on generating functions that is related to sequence multiplication; that is, cannot be simplified.
Theorem 8.5.9. Generating functions related to Pop and Push.
If
Proof.
We prove (a) by induction and leave the proof of (b) to the reader.
Basis:
Therefore, part (a) is true for
Induction: Suppose that for some the statement in part (a) is true:
by the induction hypothesis. Now write in the last expression above as so that it fits into the finite summation:
Therefore the statement is true for
Subsection 8.5.5 Closed Form Expressions for Generating Functions
The most basic tool used to express generating functions in closed form is the closed form expression for the geometric series, which is an expression of the form It can either be terminated or extended infinitely.
Restrictions: and represent constants and the right sides of the two equations apply under the following conditions:
must not equal 1 in the finite case. Note that if- In the infinite case, the absolute value of
must be less than 1.
These restrictions don’t come into play with generating functions. We could derive (8.5.18) by noting that if then (See Exercise 10 of Section 8.3). An alternative derivation was used in Section 8.4. We will take the same steps to derive (8.5.19). Let Then
Example 8.5.10. Generating Functions involving Geometric Sums.
- If
is an infinite geometric series with and Therefore, - If
0, then - If
then -
Let
ThenGiven a choice between the last form of and the previous sum of three fractions, we would prefer leaving it as a sum of three functions. As we saw in an earlier example, a partial fractions decomposition of a fraction such as the last expression requires some effort to produce. - If
then can be determined by multiplying the numerator and denominator by 1/2 to obtain We recognize this fraction as the sum of the infinite geometric series with and Therefore - If
, then we expand to . Therefore and, since there are no higher-powered terms, A more concise way of describing is since is interpreted as 0 of
Table 8.5.11 lists some closed form expressions for the generating functions of some common sequences.
Example 8.5.12. Another Complete Solution.
Solve with and The solution will be derived using the same steps that were used earlier in this section, with one variation.
- Translate to an equation about generating functions. First, we change the index of the recurrence relation by substituting
for The result is Now, if then is the zero sequence, which has a zero generating function. Furthermore, Therefore, - We want to now solve the following equation forMultiply by
:Expand and collect all terms involving on one side of the equation:Therefore, - Determine S from its generating function.
thus a partial fraction decomposition of would be:Therefore, and The solution of this set of equations is andIn conclusion, since
Example 8.5.13. An Application to Counting.
Let and let be the set of all strings of length zero or more that can be made using each of the elements of zero or more times. By the generalized rule of products, there are such strings that have length Suppose that is the set of strings of length with the property that all of the ’s and ’s precede all of the ’s, ’s, and ’s. Thus but Let A closed form expression for can be obtained by recognizing as the convolution of two sequences. To illustrate our point, we will consider the calculation of
Note that if a string belongs to it starts with characters from and is followed by characters from Let be the number of strings of ’s and ’s with length and let be the number of strings of ’s, ’s, and ’s with length By the generalized rule of products, and Among the strings in are the ones that start with two ’s and ’s and end with ’s, ’s, and ’s. There are such strings. By the law of addition,
Note that the sixth term of R is the sixth term of the convolution of with Think about the general situation for a while and it should be clear that Now, our course of action will be to:
- Determine the generating functions of
and - Multiply
and to obtain and - Determine
on the basis of
, and-
To recognize
from we must do a partial fractions decomposition:Therefore, and The solution of this pair of equations is and Since which is the sum of the generating functions of andFor example, Naturally, this equals the sum that we get from To put this number in perspective, the total number of strings of length 6 with no restrictions is and Therefore approximately 13 percent of the strings of length 6 satisfy the conditions of the problem.
Subsection 8.5.6 Extra for Experts
The remainder of this section is intended for readers who have had, or who intend to take, a course in combinatorics. We do not advise that it be included in a typical course. The method that was used in the previous example is a very powerful one and can be used to solve many problems in combinatorics. We close this section with a general description of the problems that can be solved in this way, followed by some examples.
Consider the situation in which are actions that must be taken, each of which results in a well-defined outcome. For each define to be the set of possible outcomes of . We will assume that each outcome can be quantified in some way and that the quantification of the elements of is defined by the function Thus, each outcome has a non-negative integer associated with it. Finally, define a frequency function such that is the number of elements of that have a quantification of
Now, based on these assumptions, we can define the problems that can be solved. If a process is defined as a sequence of actions as above, and if the outcome of which would be an element of is quantified by
then the frequency function, for is the convolution of the frequency functions for which has a generating function equal to the product of the generating functions of the frequency functions That is,
Example 8.5.14. Rolling Two Dice.
Suppose that you roll a die two times and add up the numbers on the top face for each roll. Since the faces on the die represent the integers 1 through 6, the sum must be between 2 and 12. How many ways can any one of these sums be obtained? Obviously, 2 can be obtained only one way, with two 1’s. There are two sequences that yield a sum of 3: 1-2 and 2-1. To obtain all of the frequencies with which the numbers 2 through 12 can be obtained, we set up the situation as follows. For is the rolling of the die for the time. and is defined by Since each number appears on a die exactly once, the frequency function is if and otherwise. The process of rolling the die two times is quantified by adding up the that is, . The generating function for the frequency function of rolling the die two times is then
Now, to get just read the coefficient of For example, the coefficient of is 4, so there are four ways to roll a total of 5.
To apply this method, the crucial step is to decompose a large process in the proper way so that it fits into the general situation that we’ve described.
Example 8.5.15. Distribution of a Committee.
Suppose that an organization is divided into three geographic sections, A, B, and C. Suppose that an executive committee of 11 members must be selected so that no more than 5 members from any one section are on the committee and that Sections A, B, and C must have minimums of 3, 2, and 2 members, respectively, on the committee. Looking only at the number of members from each section on the committee, how many ways can the committee be made up? One example of a valid committee would be 4 A’s, 4 B’s, and 3 C’s.
Let be the action of deciding how many members (not who) from Section A will serve on the committee. and The frequency function, , is defined by if , with otherwise. is then . Similarly, Since the committee must have 11 members, our answer will be the coefficient of in which is 10.
xxxxxxxxxx
%display latex
var('z')
expand((z^3+ z^4+z^5)*(z^2+ z^3+ z ^4 + z^5)^2)
Exercises 8.5.7 Exercises
1.
What sequences have the following generating functions?
- 1
Answer.
2.
What sequences have the following generating functions?
3.
Find closed form expressions for the generating functions of the following sequences:
where for with and- The Fibonacci sequence:
with
Answer.
4.
Find closed form expressions for the generating functions of the following sequences:
for and for where for with and where for with
5.
For each of the following expressions, find the partial fraction decomposition and identify the sequence having the expression as a generating function.
Answer.
6.
Find the partial fraction decompositions and identify the sequence having the following expressions:
7.
Answer.
8.
Given that what is the the generating function of each of the following sequences:
9.
A game is played by rolling a die five times. For the roll, one point is added to your score if you roll a number higher than Otherwise, your score is zero for that roll. For example, the sequence of rolls gives you a total score of three; while a sequence of 1,2,3,4,5 gives you a score of zero. Of the possible sequences of rolls, how many give you a score of zero?, of one? of five?
Answer.
Coefficients of through in
10.
Suppose that you roll a die five times in a row and record the square of each number that you roll. How many ways could the sum of the squares of your rolls equal 40? What is the most common outcome?
You have attempted 1 of 1 activities on this page.