Aaron
Aaron
1
Definitions
Generating functions are a way to use our tools for dealing with functions to
tackle combinatorics problems. Here is a definition:
Definition: The generating function for the infinite sequence ⟨g0 , g1 , g2 , g3 . . . ⟩
is the power series:
g(x) = g0 + g1 x + g2 x2 + g3 x3 + . . .
2
Theorem 2: If A(x) represents choice from a set X, and B(x) repre-
sents choice from a set Y , and X ∩ Y = ∅ then A(x)B(x) represents
choice from X ∪ Y .
Proof: To count the number of ways to choose n elements from
X ∪ Y , we can break up the problem into n + 1 categories like this:
Now we can easily tackle the original problem: for a set of size k, we can think
of it as a union of k sets of size 1. Then the generating function represent-
ing choice from k elements can be constructed by multiplying k copies of the
generating function representing choice from a 1 element set. The generating
function representing choice from a 1-element set is 1 + x because there is 1 way
to choose 0 elements, and there is 1 way to choose 1. Therefore, choice from a
set of size k is represented by the generating function (1 + x)k .
Note: if you know the binomial theorem, you know that when you expand
out (1 + x)k the coefficients are exactly nk . So everything checks out.
3
1
from a k element set is represented by .
(1 − x)k
Unlike the previous example, it is not easy to see what sequence this gener-
ating function represents; we cannot simply expand terms. Instead, we can
make use of taylor’s theorem:
Partitions
In this section, we are going to use generating functions to count quantities
related to partitions.
Here are four quantities we will be able to count using generating functions:
1. p(n) : number of partitions of n
2. p(n, k) : number of partitions of n with k parts
Counting p(n)
We will do this using a similar technique to how we did the binomial counting:
4
Claim: we can use the trick of multiplying single element sets to
count partitions.
Proof sketch:
Suppose we have a generating function A(x) representing the num-
ber of partitions that can be formed using only a subset X of the
integers. For example, if X was {1,2} then the sequence would be
⟨1, 1, 2, 2, 3, . . . ⟩ because there is one partition of 0, one partition of
1 (the partition (1)), two partitions of 2 ((1,1) and (2)), 2 partitions
of 3 ((2, 1) and (1,1,1)), and 3 partitions of 4 ((14 ), (2,1,1), and
(2,2)). And suppose B(x) represents the sequence of the number
of partitions that can be formed from a subset Y , which is disjoint
from X. Then any partition using elements of X ∪ Y can be put into
one of n sets: the sets where the elements from X contribute i and
the elements from Y contribute n − i. Then just like before we find
that A(x)B(x) represents the sequence of the number of partitions
that are formed from X ∪ Y .
Essentially, we can use the same technique of breaking the set up into single
elements! Now let’s use it to count p(n):
Given a single element set {i}, the sequence representing the number of parti-
tions that can be formed from that set is 1 + xi + x2i + x3i + . . . because there
is one way to make a partition of 0, one way to make a partition of i, one way
1
to make a partition of 2i, and so on. We can write this in closed form as i .
x
Then we multiply all one-element sets to get the total number of partitions to
Q∞ 1
see that p(n) is represented by i=1 . Written in more rigorous notation,
1 − xi
we say:
∞
X
n
Y 1
p(n)x =
i=1
1 − xi
Counting p(n, k)
to calculate this quantity we will take a bit of a circuitous route. First, we
will count partitions of n where the size of each part is no more than k. This
is easy: we can simply multiply the generating functions for only the first k
natural numbers:
k
Y 1
i=1
1 − xi
Next, note that there is a bijection between the set of partitions of n where
the parts are all at most k, and the set of partitions of n where the number of
parts is at most k. This is illustrated in this diagram:
5
Where the map comes from flipping across the diagonal. Then our generating
function that we just made actually counts this quantity too!
Next, note that flipping across the diagonal also gives us a bijection between
partitions with exactly k parts (i.e p(n, k)), and partitions where the largest
part is k:
Now, note that the number of partitions of n where the largest part is k is the
same as the number of partitions of n − k where all parts are at most k. This
is because we can take any partition of n − k where all parts are less than or
equal to k, and then place a k part on top of it, and we will get a partition
of n with largest part k. This is great, because we already know how to count
Qk 1
partitions where all parts are less than or equal to k: it’s i=1 . To form
1 − xi
a generating function for p(n, k), we just have to shift this generating function
over by multiplying by xk , so that the (n − k)th term of that function gets put
in the nth place of this new one. So we have:
k
X Y 1
p(n, k)xn = xk
i=1
1 − xi
Let’s do the same single-element trick again: given the set {i}, the correspond-
ing generating function is 1x0 y 0 + 1xi y 1 + 1x2i y 2 . . . because there is one way
6
to make a partition of 0 with 0 parts, 1 way to mke a partition of i with one
part, and 1 way to make a partition of 2i with two parts, etc. In closed form we
1
have . Then taking the union we have:
1 − yxi
∞
X Y 1
p(n, k)xn y k =
i=1
1 − yxi
Now we can relate our two expressions that we know expand out to the same
sequence: we can use our one dimensional function to create a two dimensional
function by using the whole sum as a coefficient for y k :
∞ k
X X Y 1
p(n, k)xn y k = y k xk
i=1
1 − xi
k=1
Distinct parts
We can repeat what we just did except counting only partitions with distinct
parts. We will end up getting another valid algebraic identity. Let’s start by
counting q(n, k) directly. We will need two lemmas:
Proof:
The smallest part must be 1 or larger, and then every part after that
must be larger than the previous by at least one. Therefore, the nth
part is necessarily n or greater, meaning the staircase (which has
length n − 1 for the nth part) is contained within.
7
Lemma 2: any distinct partition minus the staircase gives you a valid
(not necessarily distinct) partition with the same number of parts:
Proof:
We need to show that in the diagram resulting from deleting the
staircase, the parts weakly increase from the bottom to top. This
must be true since going up one level in the original distinct parti-
tion adds one to the size of the staircase and adds at least one to the
length of the part. Therefore, the number of excess boxes outside
of the staircase on each part can never decrease as we go up the
partition. Hence, the resulting diagram is a valid partition.
Proof:
Where there was an increase in part size (between adjacent parts)
in the original partition, there is now a larger increase since the top
has been boosted 1 more. Where there was previously two adjacent
parts of the same size, there is now a gap of 1 between them. These
are the only two cases, so we conclude that there is a difference be-
tween every adjacent part of the boosted partition therefore, it is
distinct.
We can then use our generating function for p(n, k) and shift it by the size of
the staircase to get:
k
k 1
q(n, k)xn = xk+(2)
X Y
i=1
1 − xi
8
Now let’s get the two dimensional version directly. {i} corresponds to 1 + xi y 1 .
Then we have:
X ∞
Y
n k
q(n, k)x y = 1 + yxi
i=1
A surprising theorem
We just used combinatorics to prove an algebraic statement. Now we will use
algebra to prove a combinatorics fact:
Theorem 3: for all n, o(n), the number of partitions with all odd
parts, is equal to q(n), the number of partitions with distinct parts
Proof:
Let’s start by getting a generating function for q(n). {i} corresponds
to 1 + xi because we can only use i once. Then:
X ∞
Y
q(n)xn = (1 + xi )
i=1
This is exactly the same as our expression for q(n), the number of
odd partitions. Therefore, q(n) = o(n) for all n !!!