You are on page 1of 74

Compositions, set partitions, and recurrences

Sergi Elizalde

Dartmouth College

Enumerative and algebraic combinatorics - Lecture 2

Sergi Elizalde Compositions, set partitions, and recurrences


Compositions

Denition

A composition of n is an ordered list of positive integers


(a1 , a2 , . . . , ak ) such that a1 + a2 + · · · + ak = n.

Sergi Elizalde Compositions, set partitions, and recurrences


Compositions

Denition

A composition of n is an ordered list of positive integers


(a1 , a2 , . . . , ak ) such that a1 + a2 + · · · + ak = n.

Example

There are 4 compositions of 3:

3, 2 + 1, 1 + 2, 1 + 1 + 1.

Sergi Elizalde Compositions, set partitions, and recurrences


Compositions

Denition

A composition of n is an ordered list of positive integers


(a1 , a2 , . . . , ak ) such that a1 + a2 + · · · + ak = n.

Example

There are 4 compositions of 3:

3, 2 + 1, 1 + 2, 1 + 1 + 1.

Proposition
n−1
The number of compositions of n with k parts is .

k−1
The total number of compositions of n is 2n−1 .

Sergi Elizalde Compositions, set partitions, and recurrences


Compositions

Proposition
n−1
The number of compositions of n with k parts is .

k−1
The total number of compositions of n is 2n−1 .

Proof.

Think of a composition as a placement of n balls into k boxes, by


inserting k −1 vertical separations | into a row of n balls •.

Sergi Elizalde Compositions, set partitions, and recurrences


Compositions

Proposition
n−1
The number of compositions of n with k parts is .

k−1
The total number of compositions of n is 2n−1 .

Proof.

Think of a composition as a placement of n balls into k boxes, by


inserting k −1 vertical separations | into a row of n balls •.
For example,
•| • • • | • | • •
represents the composition 1 + 3 + 1 + 2 = 7.

Sergi Elizalde Compositions, set partitions, and recurrences


Compositions

Proposition
n−1
The number of compositions of n with k parts is .

k−1
The total number of compositions of n is 2n−1 .

Proof.

Think of a composition as a placement of n balls into k boxes, by


inserting k −1 vertical separations | into a row of n balls •.
For example,
•| • • • | • | • •
represents the composition 1 + 3 + 1 + 2 = 7.
A composition with k parts is obtained by choosing k − 1 locations
for | among the n − 1 available gaps. This is equivalent to choosing
a (k − 1)-element subset of [n − 1].

Sergi Elizalde Compositions, set partitions, and recurrences


Compositions

Proposition
n−1
The number of compositions of n with k parts is .

k−1
The total number of compositions of n is 2n−1 .

Proof.

Think of a composition as a placement of n balls into k boxes, by


inserting k −1 vertical separations | into a row of n balls •.
For example,
•| • • • | • | • •
represents the composition 1 + 3 + 1 + 2 = 7.
A composition with k parts is obtained by choosing k − 1 locations
for | among the n − 1 available gaps. This is equivalent to choosing
a (k − 1)-element subset of [n − 1].
Finally, the total number of compositions of n is the total number
of subsets of [n − 1], which is 2
n−1 .

Sergi Elizalde Compositions, set partitions, and recurrences


Set partitions

Denition

A partition of a set X is a decomposition of X as a union of


disjoint non-empty sets.

Sergi Elizalde Compositions, set partitions, and recurrences


Set partitions

Denition

A partition of a set X is a decomposition of X as a union of


disjoint non-empty sets.
Specically, we write X = A1 ∪ A2 ∪ · · · ∪ Ak where Ai 6= ∅ for all i ,
and Ai ∩ Aj = ∅ for alli 6= j . The order of the sets Ai is irrelevant.

Sergi Elizalde Compositions, set partitions, and recurrences


Set partitions

Denition

A partition of a set X is a decomposition of X as a union of


disjoint non-empty sets.
Specically, we write X = A1 ∪ A2 ∪ · · · ∪ Ak where Ai 6= ∅ for all i ,
and Ai ∩ Aj = ∅ for alli 6= j . The order of the sets Ai is irrelevant.

Example

There are 5 partitions of [3]:

{1, 2, 3} {1}∪{2, 3} {1, 2}∪{3} {1, 3}∪{2} {1}∪{2}∪{3}.

Sergi Elizalde Compositions, set partitions, and recurrences


Set partitions

Denition

A partition of a set X is a decomposition of X as a union of


disjoint non-empty sets.
Specically, we write X = A1 ∪ A2 ∪ · · · ∪ Ak where Ai 6= ∅ for all i ,
and Ai ∩ Aj = ∅ for alli 6= j . The order of the sets Ai is irrelevant.

Example

There are 5 partitions of [3]:

{1, 2, 3} {1}∪{2, 3} {1, 2}∪{3} {1, 3}∪{2} {1}∪{2}∪{3}.

Note that {2} ∪ {1, 3} would be the same partition as {1, 3} ∪ {2},
since the order of the sets is irrelevant.

Sergi Elizalde Compositions, set partitions, and recurrences


Set partitions

Denition

Let B(n) denote the number of set partitions of [n]. These are
called the Bell numbers.

Sergi Elizalde Compositions, set partitions, and recurrences


Set partitions

Denition

Let B(n) denote the number of set partitions of [n]. These are
called the Bell numbers.
Let S(n, k) denote the number of set partitions of [n] into k blocks.
These are called the Stirling numbers of the second kind.

Sergi Elizalde Compositions, set partitions, and recurrences


Set partitions

Denition

Let B(n) denote the number of set partitions of [n]. These are
called the Bell numbers.
Let S(n, k) denote the number of set partitions of [n] into k blocks.
These are called the Stirling numbers of the second kind.
Pn
Note that B(n) = k=1 S(n, k).

Sergi Elizalde Compositions, set partitions, and recurrences


Set partitions

Denition

Let B(n) denote the number of set partitions of [n]. These are
called the Bell numbers.
Let S(n, k) denote the number of set partitions of [n] into k blocks.
These are called the Stirling numbers of the second kind.
Pn
Note that B(n) = k=1 S(n, k).

Example

S(3, 2) = 3, B(3) = 5.

Sergi Elizalde Compositions, set partitions, and recurrences


Set partitions

Denition

Let B(n) denote the number of set partitions of [n]. These are
called the Bell numbers.
Let S(n, k) denote the number of set partitions of [n] into k blocks.
These are called the Stirling numbers of the second kind.
Pn
Note that B(n) = k=1 S(n, k).

Example

S(3, 2) = 3, B(3) = 5.
S(n, 0) = 0, S(n, 1) =

Sergi Elizalde Compositions, set partitions, and recurrences


Set partitions

Denition

Let B(n) denote the number of set partitions of [n]. These are
called the Bell numbers.
Let S(n, k) denote the number of set partitions of [n] into k blocks.
These are called the Stirling numbers of the second kind.
Pn
Note that B(n) = k=1 S(n, k).

Example

S(3, 2) = 3, B(3) = 5.
S(n, 0) = 0, S(n, 1) = 1, S(n, n) =

Sergi Elizalde Compositions, set partitions, and recurrences


Set partitions

Denition

Let B(n) denote the number of set partitions of [n]. These are
called the Bell numbers.
Let S(n, k) denote the number of set partitions of [n] into k blocks.
These are called the Stirling numbers of the second kind.
Pn
Note that B(n) = k=1 S(n, k).

Example

S(3, 2) = 3, B(3) = 5.
S(n, 0) = 0, S(n, 1) = 1, S(n, n) = 1.

Sergi Elizalde Compositions, set partitions, and recurrences


Stirling numbers of the second kind

Here is a table of S(n, k) for small n and k:

n\k 1 2 3 4 5 6 B(n)
1 1 1
2 1 1 2
3 1 3 1 5
4 1 7 6 1 15
5 1 15 25 10 1 52
6 1 31 90 65 15 1 203

Sergi Elizalde Compositions, set partitions, and recurrences


Stirling numbers of the second kind

Here is a table of S(n, k) for small n and k:

n\k 1 2 3 4 5 6 B(n)
1 1 1
2 1 1 2
3 1 3 1 5
4 1 7 6 1 15
5 1 15 25 10 1 52
6 1 31 90 65 15 1 203

S(n, n − 1) =

Sergi Elizalde Compositions, set partitions, and recurrences


Stirling numbers of the second kind

Here is a table of S(n, k) for small n and k:

n\k 1 2 3 4 5 6 B(n)
1 1 1
2 1 1 2
3 1 3 1 5
4 1 7 6 1 15
5 1 15 25 10 1 52
6 1 31 90 65 15 1 203

n

S(n, n − 1) = 2 .
Proof: choose which two elements are in the same block.

S(n, 2) =

Sergi Elizalde Compositions, set partitions, and recurrences


Stirling numbers of the second kind

Here is a table of S(n, k) for small n and k:

n\k 1 2 3 4 5 6 B(n)
1 1 1
2 1 1 2
3 1 3 1 5
4 1 7 6 1 15
5 1 15 25 10 1 52
6 1 31 90 65 15 1 203

n

S(n, n − 1) = 2 .
Proof: choose which two elements are in the same block.

S(n, 2) = 2n−1 − 1.
Proof: To partition[n] = A1 ∪ A2 , choose A1 to be any subset
except A1 = ∅ and A1 = [n]; then take A2 to be its complement.
n
There are 2 − 2 choices of A1 . Finally, divide by 2 because the
n
order of A1 and A2 is irrelevant, giving (2 − 2)/2 = 2
n−1 − 1.

Sergi Elizalde Compositions, set partitions, and recurrences


Stirling numbers of the second kind

Proposition

For 0 < k < n,

S(n, k) = S(n − 1, k − 1) + k S(n − 1, k).

Sergi Elizalde Compositions, set partitions, and recurrences


Stirling numbers of the second kind

Proposition

For 0 < k < n,

S(n, k) = S(n − 1, k − 1) + k S(n − 1, k).

Proof.

Count partitions of [n] according to whether n is in a block by itself


or not.

Sergi Elizalde Compositions, set partitions, and recurrences


Stirling numbers of the second kind

Proposition

For 0 < k < n,

S(n, k) = S(n − 1, k − 1) + k S(n − 1, k).

Proof.

Count partitions of [n] according to whether n is in a block by itself


or not.

If n is in a block by itself, the remaining entries form a


partition of[n − 1] into k − 1 blocks, so there are
S(n − 1, k − 1) such partitions.

Sergi Elizalde Compositions, set partitions, and recurrences


Stirling numbers of the second kind

Proposition

For 0 < k < n,

S(n, k) = S(n − 1, k − 1) + k S(n − 1, k).

Proof.

Count partitions of [n] according to whether n is in a block by itself


or not.

If n is in a block by itself, the remaining entries form a


partition of[n − 1] into k − 1 blocks, so there are
S(n − 1, k − 1) such partitions.
If n is a block that contains other elements, such partitions
can be obtained as follows. Partition [n − 1] into k blocks
(S(n − 1, k) choices), then decide in which of these k blocks n
goes (k choices). There are k S(n − 1, k) such partitions.

Sergi Elizalde Compositions, set partitions, and recurrences


Bell numbers

Proposition
n  
X n
B(n + 1) = B(k).
k
k=0

Sergi Elizalde Compositions, set partitions, and recurrences


Bell numbers

Proposition
n  
X n
B(n + 1) = B(k).
k
k=0

Proof.

Count partitions of [n + 1] according to the number of elements


that are not in the same block as n + 1. Let k be this number, and
note that 0 ≤ k ≤ n.

Sergi Elizalde Compositions, set partitions, and recurrences


Bell numbers

Proposition
n  
X n
B(n + 1) = B(k).
k
k=0

Proof.

Count partitions of [n + 1] according to the number of elements


that are not in the same block as n + 1. Let k be this number, and
note that 0 ≤ k ≤ n.
n

We have
k choices for these k elements, since they form a subset
of [n]. Then we have B(k) choices for how to partition these
elements into blocks.

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

Suppose we want to solve a problem about counting the number of


certain objects of size n, such as compositions of n, set partitions
of [n], permutations of length n, tilings of a 2 ×n board with
dominoes, etc.

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

Suppose we want to solve a problem about counting the number of


certain objects of size n, such as compositions of n, set partitions
of [n], permutations of length n, tilings of a 2 ×n board with
dominoes, etc.

More abstractly, we are given an innite list of sets A1 , A2 , A3 , . . . ,


and we want to nd an = |An |.

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

Suppose we want to solve a problem about counting the number of


certain objects of size n, such as compositions of n, set partitions
of [n], permutations of length n, tilings of a 2 ×n board with
dominoes, etc.

More abstractly, we are given an innite list of sets A1 , A2 , A3 , . . . ,


and we want to nd an = |An |.
What does it mean to nd an ?

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

Suppose we want to solve a problem about counting the number of


certain objects of size n, such as compositions of n, set partitions
of [n], permutations of length n, tilings of a 2 ×n board with
dominoes, etc.

More abstractly, we are given an innite list of sets A1 , A2 , A3 , . . . ,


and we want to nd an = |An |.
What does it mean to nd an ?
Let us look at some possible ways to express the answer an .

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

1. Explicit closed formula

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

1. Explicit closed formula

Example

Let an be the number of subsets of [n] = {1, 2, . . . , n}. Then


an = 2n .

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

1. Explicit closed formula

Example

Let an be the number of subsets of [n] = {1, 2, . . . , n}. Then


an = 2n .

Example

Let an be the number of permutations of [n]. Then an = n!.

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

1. Explicit closed formula

Example

Let an be the number of subsets of [n] = {1, 2, . . . , n}. Then


an = 2n .

Example

Let an be the number of permutations of [n]. Then an = n!.

Example

Let an be the number of compositions of n. Then an = 2n−1 .

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

Example

Let an be the number of derangements of [n], that is, permutations


without xed points.

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

Example

Let an be the number of derangements of [n], that is, permutations


without xed points. For example, a3 = 2 because 231 and 312 are
the two derangements of {1, 2, 3}. Then

an =

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

Example

Let an be the number of derangements of [n], that is, permutations


without xed points. For example, a3 = 2 because 231 and 312 are
the two derangements of {1, 2, 3}. Then

n
X (−1)i
an = n! .
i!
i=0

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

Example

Let an be the number of derangements of [n], that is, permutations


without xed points. For example, a3 = 2 because 231 and 312 are
the two derangements of {1, 2, 3}. Then

n
X (−1)i
an = n! .
i!
i=0

Not as elegant as the previous formulas because of the summation


and the alternating signs, but still a good formula because we don't
have a simpler one.

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

2. Recurrence

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

2. Recurrence

Example

Let B(n) be the number of set partitions [n]. Then

n  
X n
B(n + 1) = B(k).
k
k=0

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

2. Recurrence

Example

Let B(n) be the number of set partitions [n]. Then

n  
X n
B(n + 1) = B(k).
k
k=0

Let's look at another important recurrence...

Sergi Elizalde Compositions, set partitions, and recurrences


A recurrence to count tilings

In how many ways can we tile an 2 ×2 board with dominoes?

Sergi Elizalde Compositions, set partitions, and recurrences


A recurrence to count tilings

In how many ways can we tile an 2 ×2 board with dominoes?

Answer: 2.

Sergi Elizalde Compositions, set partitions, and recurrences


A recurrence to count tilings

In how many ways can we tile an 2 ×n board with dominoes?

Sergi Elizalde Compositions, set partitions, and recurrences


A recurrence to count tilings

In how many ways can we tile an 2 ×n board with dominoes?

Let's call this number an , and look at the rst few values:

n 1 2 3 4 5 6
an 1 2

Sergi Elizalde Compositions, set partitions, and recurrences


A recurrence to count tilings

In how many ways can we tile an 2 ×n board with dominoes?

Let's call this number an , and look at the rst few values:

n 1 2 3 4 5 6
an 1 2 3

Sergi Elizalde Compositions, set partitions, and recurrences


A recurrence to count tilings

In how many ways can we tile an 2 ×n board with dominoes?

Let's call this number an , and look at the rst few values:

n 1 2 3 4 5 6
an 1 2 3 5

Sergi Elizalde Compositions, set partitions, and recurrences


A recurrence to count tilings

In how many ways can we tile an 2 ×n board with dominoes?

Let's call this number an , and look at the rst few values:

n 1 2 3 4 5 6
an 1 2 3 5 8

Sergi Elizalde Compositions, set partitions, and recurrences


A recurrence to count tilings

In how many ways can we tile an 2 ×n board with dominoes?

Let's call this number an , and look at the rst few values:

n 1 2 3 4 5 6
an 1 2 3 5 8 13

Do you see a pattern?

Sergi Elizalde Compositions, set partitions, and recurrences


A recurrence to count tilings

In how many ways can we tile an 2 ×n board with dominoes?

Let's call this number an , and look at the rst few values:

n 1 2 3 4 5 6
an 1 2 3 5 8 13

Do you see a pattern?

an = an−1 + an−2

This kind of relation is called a recurrence.

The numbers an satisfying this recurrence are called the Fibonacci


numbers. They originated in a problem about rabbit breeding.
Sergi Elizalde Compositions, set partitions, and recurrences
A recurrence to count tilings

an = an−1 + an−2

To prove this recurrence, look at the possible ways to put the


rightmost tile(s):

n−1 n−2

Sergi Elizalde Compositions, set partitions, and recurrences


A recurrence to count tilings

an = an−1 + an−2

To prove this recurrence, look at the possible ways to put the


rightmost tile(s):

n−1 n−2

If the rightmost tile is vertical, If the rightmost tiles are


the rest of the board can be horizontal, the rest of the board
tiled in an−1 ways. can be tiled in an−2 ways.

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

1. Explicit closed formula

2. Recurrence

Example

Let an be the number of number of tilings of a 2 ×n board with


dominoes. Then an = an−1 + an−2 , with initial conditions
a0 = a1 = 1.

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

1. Explicit closed formula

2. Recurrence

Example

Let an be the number of number of tilings of a 2 ×n board with


dominoes. Then an = an−1 + an−2 , with initial conditions
a0 = a1 = 1.

3. Algorithm

How good this method is depends on the elegance and the


performance of the algorithm. In particular, the time needed to
compute an should be much less than the value an itself.

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

4. Asymptotic estimate

Example

Let an be the number of labeled planar graphs with n vertices.


Then
an ∼ δn−7/2 γ n n!,
for some explicit constants δ, γ .

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

4. Asymptotic estimate

Example

Let an be the number of labeled planar graphs with n vertices.


Then
an ∼ δn−7/2 γ n n!,
for some explicit constants δ, γ .
Here an ∼ bn means that

lim an /bn = 1.
n→∞

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

4. Asymptotic estimate

Example

Let an be the number of labeled planar graphs with n vertices.


Then
an ∼ δn−7/2 γ n n!,
for some explicit constants δ, γ .
Here an ∼ bn means that

lim an /bn = 1.
n→∞

An asymptotic estimate can be very useful when we don't have a


formula, or when we are interested in the approximate behavior for
large n.

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

5. Generating function

Next we will learn about this powerful tool.

Sergi Elizalde Compositions, set partitions, and recurrences


Possible answers to counting questions

5. Generating function

Next we will learn about this powerful tool.

References about generating functions:

A. de Mier, Lecture notes for Enumerative Combinatorics:


https://mat-web.upc.edu/people/anna.de.mier/ec/
lectec.pdf
P. Flajolet, R. Sedgewick, Analytic Combinatorics. An online
http:
version is available at
//algo.inria.fr/flajolet/Publications/book.pdf
H. Wilf, Generatingfunctionology, available at
http://www.math.upenn.edu/~wilf/DownldGF.html

Sergi Elizalde Compositions, set partitions, and recurrences


Generating functions

Suppose we have a sequence of numbers a0 , a1 , a2 , . . . , where an is


counting the number of certain objects of size n; for example
compositions of n, partitions of [n], tilings of a 2 × n board, etc.

Sergi Elizalde Compositions, set partitions, and recurrences


Generating functions

Suppose we have a sequence of numbers a0 , a1 , a2 , . . . , where an is


counting the number of certain objects of size n; for example
compositions of n, partitions of [n], tilings of a 2 × n board, etc.

Denition

The generating function of a sequence a0 , a1 , a2 , . . . is the formal


power series

A(z) = a0 + a1 z + a2 z 2 + a3 z 3 + · · · =
X
an z n .
n≥0

Sergi Elizalde Compositions, set partitions, and recurrences


Generating functions

Suppose we have a sequence of numbers a0 , a1 , a2 , . . . , where an is


counting the number of certain objects of size n; for example
compositions of n, partitions of [n], tilings of a 2 × n board, etc.

Denition

The generating function of a sequence a0 , a1 , a2 , . . . is the formal


power series

A(z) = a0 + a1 z + a2 z 2 + a3 z 3 + · · · =
X
an z n .
n≥0

Here z is a variable that is used so that the coecients record the


sequence an . We usually do not think of z as taking any particular
values.

Sergi Elizalde Compositions, set partitions, and recurrences


Example 1: geometric series

Consider the sequence 1, r , r


2 , r 3 , . . . , that is an = r n for all n.

Sergi Elizalde Compositions, set partitions, and recurrences


Example 1: geometric series

Consider the sequence 1, r , r


2 , r 3 , . . . , that is an = r n for all n.
Its generating function is

A(z) = 1 + rz + r 2 z 2 + r 3 z 3 + . . .

Sergi Elizalde Compositions, set partitions, and recurrences


Example 1: geometric series

Consider the sequence 1, r , r


2 , r 3 , . . . , that is an = r n for all n.
Its generating function is

A(z) = 1 + rz + r 2 z 2 + r 3 z 3 + . . .

Note that

r z A(z) = rz + r 2 z 2 + r 3 z 3 + r 4 z 4 + . . . ,

and so A(z) − r z A(z) = 1.

Sergi Elizalde Compositions, set partitions, and recurrences


Example 1: geometric series

Consider the sequence 1, r , r


2 , r 3 , . . . , that is an = r n for all n.
Its generating function is

A(z) = 1 + rz + r 2 z 2 + r 3 z 3 + . . .

Note that

r z A(z) = rz + r 2 z 2 + r 3 z 3 + r 4 z 4 + . . . ,

and so A(z) − r z A(z) = 1. Solving for A(z), we get

1
A(z) = ,
1 − rz
which gives a compact way to write A(z).

Sergi Elizalde Compositions, set partitions, and recurrences


Example 1: geometric series

Consider the sequence 1, r , r


2 , r 3 , . . . , that is an = r n for all n.
Its generating function is

A(z) = 1 + rz + r 2 z 2 + r 3 z 3 + . . .

Note that

r z A(z) = rz + r 2 z 2 + r 3 z 3 + r 4 z 4 + . . . ,

and so A(z) − r z A(z) = 1. Solving for A(z), we get

1
A(z) = ,
1 − rz
which gives a compact way to write A(z).
We do not care about the value of z or about convergence of the
series.
Sergi Elizalde Compositions, set partitions, and recurrences
Example 2: compositions

The number of compositions of n is

(
1 if n = 0,
cn = n−1
2 if n ≥ 1.

Sergi Elizalde Compositions, set partitions, and recurrences


Example 2: compositions

The number of compositions of n is

(
1 if n = 0,
cn = n−1
2 if n ≥ 1.

So, the generating function is

n−1 n
X X X
cn z n = c0 + cn z n = 1 + 2 z
n≥0 n≥1 n≥1
X
n n+1
X
n n z 1−z
=1+ 2 z =1+z 2 z =1+ = .
1 − 2z 1 − 2z
n≥0 n≥0

Sergi Elizalde Compositions, set partitions, and recurrences


Example 2: compositions

The number of compositions of n is

(
1 if n = 0,
cn = n−1
2 if n ≥ 1.

So, the generating function is

n−1 n
X X X
cn z n = c0 + cn z n = 1 + 2 z
n≥0 n≥1 n≥1
X
n n+1
X
n n z 1−z
=1+ 2 z =1+z 2 z =1+ = .
1 − 2z 1 − 2z
n≥0 n≥0

In some cases we can nd a generating function even if we don't


know a formula for the coecients.

Sergi Elizalde Compositions, set partitions, and recurrences

You might also like