Generating Functions
Generating Functions
Ankur 2/19/2020
Singh Ankur Singh 1
• Generating functions are used to represent sequences efficiently by coding the
terms of a sequence as coefficients of powers of a variable 𝑥 in a formal power
series.
• Generating functions can be used to solve many types of counting problems, such
as the number of ways to select or distribute objects of different kinds, subject to
a variety of constraints, and the number of ways to make change for a dollar
using coins of different denominations.
• Generating functions can be used to solve recurrence relations by translating a
recurrence relation for the terms of a sequence into an equation involving a
generating function. This equation can then be solved to find a closed form for the
generating function. From this closed form, the coefficients of the power series for
the generating function can be found, solving the original recurrence relation.
• Generating functions can also be used to prove combinatorial identities by taking
advantage of relatively simple relationships between functions that can be
translated into identities involving the terms of sequences.
2/19/2020 Ankur Singh 2
akxk.
DEFINITION 1
• The generating function for the sequence 𝑎0 , 𝑎1 , . . . , 𝑎𝑘 , . . . of real numbers is the
infinite series
𝐺 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3 + ⋯ + 𝑎𝑘 𝑥 𝑘 + ⋯ = 𝑎𝑘 𝑥 𝑘
𝑘=0
2 2 3 3 𝑘 𝑘 ∞
𝐺 𝑥 = 1 + 3 ∗ 𝑥 + 3 ∗ 𝑥 + 3 ∗ 𝑥 + ⋯+ 3 ∗ 𝑥 +. . = 𝑘=0 3𝑘 𝑥 𝑘
Similarly, we can get the other generating functions.
2/19/2020 Ankur Singh 4
• We can define generating functions for finite sequences of real numbers
by extending a finite sequence 𝑎0 , 𝑎1 , . . . , 𝑎𝑛 into an infinite sequence by
setting 𝑎𝑛+1 = 0, 𝑎𝑛+2 = 0, and so on.
• Thegenerating function 𝐺(𝑥) of this infinite sequence {𝑎𝑛 } is a
polynomial of degree 𝑛 because no terms of the form 𝑎𝑗 𝑥 𝑗 with 𝑗 > 𝑛
occur, that is,
𝐺 𝑥 = 𝑎0 + 𝑎1 𝑥 + · · · + 𝑎𝑛 𝑥 𝑛 .
Solution:
The generating function for this sequence is
𝐺 𝑥 = 𝐶 𝑚, 0 + 𝐶 𝑚, 1 𝑥 + 𝐶 𝑚, 2 𝑥 2 + · · · + 𝐶 𝑚, 𝑚 𝑥 𝑚 .
EXAMPLE 4
1
The function 𝑓 𝑥 = is the generating function of the sequence
1−𝑥
1, 1, 1, 1, . . . , because
1
= 1 + 𝑥 + 𝑥2 + · · · for |𝑥| < 1.
1−𝑥
1, 𝑎, 𝑎2 , 𝑎3 , . . . ,
1
Because = 1 + 𝑎 𝑥 + 𝑎2 𝑥 2 + ⋯ when |𝑎𝑥| < 1,
1 − 𝑎𝑥
or
1
equivalently, when 𝑥 < for 𝑎 ≠ 0.
𝑎
∞
𝑓 𝑥 +𝑔 𝑥 = 𝑘=0 𝑎𝑘 + 𝑏𝑘 𝑥 𝑘 and
∞
𝑘
𝑓 𝑥 𝑔 𝑥 = 𝑎𝑗ሶ 𝑏𝑘−𝑗 𝑥 𝑘 .
𝑗=0
𝑘=0
• Remark: Theorem 1 is valid only for power series that converge in an interval, as
all series considered in this section do. However, the theory of generating
functions is not limited to such series. In the case of series that do not converge,
the statements in Theorem 1 can be taken as definitions of addition and
multiplication of generating functions.
2/19/2020 Ankur Singh 11
EXAMPLE 6
1
Let 𝑓 𝑥 = . Use Example 4 to find the coefficients 𝑎0 , 𝑎1 , 𝑎2 , . . . in the
1−𝑥 2
∞
expansion 𝑓 (𝑥) = 𝑘=0 𝑎𝑘 𝑥 𝑘
Solution:
∞
1 ∞
= σ𝑘𝑗=0 1 𝑘
𝑥 = 𝑘=0 𝑘 + 1 𝑥𝑘.
1−𝑥 2 𝑘=0
2/19/2020 Ankur Singh 12
DEFINITION 2
Let 𝑢 be a real number and 𝑘 a nonnegative integer. Then the extended binomial
𝑢
coefficient is defined by
𝑘
Note: Here, we are finding the binomial coefficients for the real number 𝑢
(need not be a positive integer always). If 𝑢 is a positive integer then, our
earlier binomial coefficients can be obtained as in earlier Section.
(𝑥 2 + 𝑥 3 + 𝑥 4 + 𝑥 5 )(𝑥 3 + 𝑥 4 + 𝑥 5 + 𝑥 6 )(𝑥 4 + 𝑥 5 + 𝑥 6 + 𝑥 7 ).
This follows because we obtain a term equal to 𝑥 17 in the product by
picking a term in the first sum 𝑥 𝑒1 , a term in the second sum 𝑥 𝑒2 , and a
term in the third sum 𝑥 𝑒3 , where the exponents 𝑒1 , 𝑒2 , and 𝑒3 satisfy the
equation 𝑒1 + 𝑒2 + 𝑒3 = 17 and the given constraints. (Cont…)
2/19/2020 Ankur Singh 24
It is not hard to see that the coefficient of 𝑥 17 in this product is 3.
Hence, there are three solutions.
𝑥2
(𝑥2 + 𝑥3 + 𝑥4 + ⋯ = 𝑥2(1 + 𝑥 + 𝑥2 + ⋯ ) =
1−𝑥
𝑥8
𝑓(𝑥) = (𝑥2/(1 − 𝑥))4 = 1 − 𝑥 4
𝑋 𝑒1 𝑋 𝑒2 𝑋 𝑒3
e1 + e2 + e3 = R
EXAMPLE 11
In how many different ways can eight identical cookies be distributed among three distinct
children if each child receives at least two cookies and no more than four cookies?
Solution: Because each child receives at least two but no more than four
cookies, for each child there is a factor equal to
(𝑥 2 + 𝑥 3 + 𝑥 4 )
in the generating function for the sequence {𝑐𝑛 }, where 𝑐𝑛 is the number of
ways to distribute 𝑛 cookies. Because there are three children, this generating
function is
𝑥2 + 𝑥3 + 𝑥4 3.
onstraints is the coefficient of 𝑥 17 in the expansion of
1 ∞
Using the identity = 𝑘=0 𝑎𝑘 𝑥 𝑘 , from Table 1, we have
1−𝑎𝑥
∞
∞
𝐺(𝑥) = 2 ා 3𝑘 𝑥 𝑘 = 2 ∗ 3𝑘 𝑥 𝑘 .
𝑘=0
𝑘=0
Consequently, 𝑎𝑘 = 2 ∗ 3𝑘
2/19/2020 Ankur Singh 32
Example with another method/approach
The sequence of numbers 1,1,2,3,5,8,13, .... is known as the Fibonacci
sequence. We can describe the sequence in terms of a recurrence relation
as : 𝑎0 = 1, 𝑎1 = 1 and
𝑎𝑛 = 𝑎𝑛−1 + 𝑎𝑛−2 for 𝑛 ≥ 2.
How do we find a formula for 𝑎𝑛 ?
Let 𝐺(𝑥) = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 +· · · +𝑎𝑛 𝑥 𝑛 +· · · be the generating
function for the sequence.
∞
=1+𝑥+ 𝑛=2(𝑎𝑛−1 + 𝑎𝑛−2 )𝑥 𝑛
= 1 + 𝑥 + 𝑎1 𝑥 2 + 𝑎2 𝑥 3 + ⋯ + (𝑎0 𝑥 2 + 𝑎1 𝑥 3 + 𝑎2 𝑥 4 + ⋯ )
= 1 + 𝑥 + 𝑥 ∗ 𝑎1 𝑥 + 𝑎2 𝑥 2 + ⋯ . + 𝑥 2 (𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + ⋯ . )
= 1 + 𝑥 + 𝑥 𝐺 𝑥 − 1 + 𝑥 2 𝐺(𝑥)
Therefore, 𝐺 𝑥 = 1 + 𝑥 + 𝑥 𝐺 𝑥 − 1 + 𝑥 2 𝐺(𝑥).
1 1
From this, we obtain 𝐺 𝑥 = = − 2
1−𝑥−𝑥 2 𝑥 +𝑥−1
We sum both sides of the last equation starting with 𝑛 = 1, to find that
∞ ∞
𝐺 𝑥 − 1 = 𝑎𝑛 𝑥 𝑛 = 8𝑎𝑛−1 𝑥 𝑛 + 10𝑛−1 𝑥 𝑛
𝑛=1 𝑛=1
∞ ∞
= 8 𝑎𝑛−1 𝑥 𝑛 + 10𝑛−1 𝑥 𝑛
𝑛=1 𝑛=1
∞ ∞
= 8𝑥 𝑛=1 𝑎𝑛−1 𝑥 𝑛−1 + 𝑥 𝑛=1 10𝑛−1 𝑥 𝑛−1 (Cont…)
2/19/2020 Ankur Singh 41
∞ ∞
Expanding the right-hand side of this equation into partial fractions (as is done in
the integration of rational functions studied in calculus) gives
1 1 1
𝐺 𝑥 = + . (Cont…)
2 1−8 𝑥 1−10 𝑥
2/19/2020 42
Ankur Singh
Using Example 5 twice (once with 𝑎 = 8 and once with 𝑎 = 10) gives
∞
∞ ∞
1 1 𝑛
𝐺 𝑥 = 8 𝑥 + 10 𝑥 = 8 + 10𝑛 𝑥 𝑛
𝑛 𝑛 𝑛 𝑛
2 2
𝑛=0 𝑛=0
𝑛=0
Consequently, we have shown that
1 𝑛
𝑎𝑛 = 8 + 10𝑛 .
2
1+𝑥 2𝑥 = 1+𝑥 𝑛 2
= 𝐶 𝑛, 0 + 𝐶 𝑛, 1 𝑥 + 𝐶 𝑛, 2 𝑥 2 + ⋯ + 𝐶 𝑛, 𝑛 − 1 𝑥 𝑛−1 + 𝐶 𝑛, 𝑛 𝑥 𝑛 2.
𝐶 𝑛, 0 𝐶 𝑛, 𝑛 + 𝐶 𝑛, 1 𝐶 𝑛, 𝑛 − 1 + 𝐶 𝑛, 2 𝐶 𝑛, 𝑛 − 2 + · · ·
+ 𝐶 𝑛, 𝑛 𝐶 𝑛, 0 .
𝑛
This equals 𝑘=0 𝐶 𝑛, 𝑘 2 , since 𝐶 𝑛, 𝑛 − 1 = 𝐶 𝑛, 𝑘 .
𝑛 2
Because bothe 𝐶(2𝑛, 𝑛) and 𝑘=0 𝐶 𝑛, 𝑘 arepresent the coefficeint of 𝑥 𝑛
2𝑛
in 1 + 𝑥 , they must be equal.