0% found this document useful (0 votes)
57 views

Notes

The document is a textbook on combinatorics titled "Combinatorics I" by Stephen Suen. It covers various topics in basic counting principles including representations of sample spaces and events, the sum and product principles, permutations, factorials, Stirling's formula, combinations, binomial coefficients, and balls in boxes problems. It also outlines additional topics to be covered in subsequent chapters such as Stirling numbers, the principle of inclusion-exclusion, generating functions, integer partitions, recurrence relations, and permutations.

Uploaded by

vanaj123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Notes

The document is a textbook on combinatorics titled "Combinatorics I" by Stephen Suen. It covers various topics in basic counting principles including representations of sample spaces and events, the sum and product principles, permutations, factorials, Stirling's formula, combinations, binomial coefficients, and balls in boxes problems. It also outlines additional topics to be covered in subsequent chapters such as Stirling numbers, the principle of inclusion-exclusion, generating functions, integer partitions, recurrence relations, and permutations.

Uploaded by

vanaj123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 194

Combinatorics I

Stephen Suen
Department of Mathematics
University of South Florida
December 17, 2015

Contents
1 Basic Counting Principles
1.1 Representing the Situation .
1.2 Sum Principle . . . . . . . .
1.3 Product Principle . . . . . .
1.4 Factorials and Permutations
1.5 Stirlings formula . . . . . .
1.6 Combinations . . . . . . . .
1.7 Binomial Coefficients . . . .
1.8 Multinomial Coefficients . .
1.9 Small Cases . . . . . . . . .

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

2 Balls and Boxes


2.1 Distinct Balls and Distinct Boxes .
2.2 Distinct Balls and Identical Boxes .
2.3 Identical Balls and Distinct Boxes .
2.4 Identical Balls and Identical Boxes
2.5 Summary . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

1
1
2
2
3
3
4
6
7
8

.
.
.
.
.

12
12
13
16
18
20

3 Stirling Numbers
21
3.1 The Second Kind . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.2 The First Kind . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4 Principle of Inclusion-Exclusion
28
4.1 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.2 Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.3 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

ii

iii

CONTENTS

5 Generating Functions
36
5.1 A Quick Introduction . . . . . . . . . . . . . . . . . . . . . . . 36
5.2 Inverses of Generating Functions . . . . . . . . . . . . . . . . 38
5.3 Identical Balls and Distinct Boxes, Again! . . . . . . . . . . . 40
6 Integer Partitions Revisited
42
6.1 The Generating Function for pk . . . . . . . . . . . . . . . . . 43
6.2 The Generating Function for pk,n . . . . . . . . . . . . . . . . 45
6.3 One More Example . . . . . . . . . . . . . . . . . . . . . . . . 48
7 Recurrence Relations
7.1 Ordinary Generating Functions
7.2 Fibonacci Numbers . . . . . . .
7.3 Bell Numbers Revisited . . . . .
7.4 Catalan Numbers . . . . . . . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

49
49
51
53
54

8 Permutations
8.1 Notation . . . . . . . . . . . . . . . . .
8.2 Random Permutations . . . . . . . . .
8.3 Analysis of a Simple Algorithm . . . .
8.4 Number of Permutations with k Cycles

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

57
57
58
59
63

9 A Generating Function for Permutations


9.1 The Cycle Index of Sn . . . . . . . . . . .
9.2 The Exponential Generating Function . . .
9.3 Examples . . . . . . . . . . . . . . . . . .
9.4 Even Permutations and Transpositions . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

66
66
68
68
73

.
.
.
.

.
.
.
.

.
.
.
.

10 Permutation Runs and


75

Inversions
10.1 A Recurrence for nk . . . . . . . . . . . . . . . . . . . . . . . 75
10.2 The Average Length of the k-th Run . . . . . . . . . . . . . . 77
10.3 Inversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
11 Extension to Complex Numbers
11.1 The Gamma Function . . . . . . .
11.2 Convergence of the Infinite Product
11.3 Factorials in the Complex Plane . .
11.4 The Falling Factorial . . . . . . . .
11.5 The Binomial Coefficient . . . . . .

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

86
86
87
87
91
92

iv

CONTENTS

11.6 Four Basic Identities . . . . . . . . . . . . . . . . . . . . . . . 93


12 Binomial Identities
95
12.1 Basic Identities . . . . . . . . . . . . . . . . . . . . . . . . . . 95
12.2 Vandermondes Convolution . . . . . . . . . . . . . . . . . . . 99
13 More Binomial Identities
13.1 Negating the Upper Entry
13.2 Differences . . . . . . . . .
13.3 Higher Order Differences .
13.4 Inversion . . . . . . . . . .
13.5 Generating Functions . . .

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

107
. 107
. 107
. 109
. 112
. 114

14 A Generalized Urn Model


14.1 The Model . . . . . . . .
14.2 Realizations . . . . . . .
14.3 The Optimal Strategy .
14.4 The Value of G(m, p) . .
14.5 A Simplified G(m, p) . .
14.6 Asymptotics . . . . . . .

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

117
117
118
119
120
123
129

15 Hypergeometric Series
132
15.1 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
15.2 Reduction to Standard Hypergeometric Functions . . . . . . . 133
16 Gospers Algorithm
16.1 A Brief Description .
16.2 The Functions a, b, c
16.3 The Function x . . .
16.4 Examples . . . . . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

139
139
140
143
145

17 Zeilbergers Algorithm
152
17.1 Sister Celines Method . . . . . . . . . . . . . . . . . . . . . . 153
17.2 Zeilbergers Algorithm . . . . . . . . . . . . . . . . . . . . . . 156
18 Burnsides Lemma
159
18.1 Proof of Burnsides Lemma . . . . . . . . . . . . . . . . . . . 162
18.2 Two More Examples . . . . . . . . . . . . . . . . . . . . . . . 166

CONTENTS
19 Polyas Theory of Counting
19.1 Groups Acting on Functions . . .
19.2 Cycles and Burnsides Lemma . .
19.3 The Cycle Index of a Permutation
19.4 Counting Nonisomorphic Graphs

. . . .
. . . .
Group
. . . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

168
. 168
. 169
. 172
. 174

20 A Generating Function for Orbits


177
20.1 The Generating Function . . . . . . . . . . . . . . . . . . . . . 178
20.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
21 Symmetry in B
186
21.1 The Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
21.2 The Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

Chapter 1
Basic Counting Principles
1.1

Representing the Situation

Example 1.1. Consider the experiment of rolling a die 4 times, sequentially.


An outcome is a sequence of 4 integers between 1 and 6:
(x1 , x2 , x3 , x4 ),

xi = 1, 2, 3, 4, 5, 6,

i = 1, 2, 3, 4.

The sample space is the set of all outcomes:


= {(x1 , x2 , x3 , x4 ) : xi = 1, 2, 3, 4, 5, 6,

i = 1, 2, 3, 4}.

The event that the experiment results in a sum less than 6 is the set of all
outcomes (x1 , x2 , x3 , x4 ) such that
x1 + x2 + x3 + x4 5.
An event is said to occur if one (and exactly one) of the outcomes in the
event has happened. In the example, the event that the sum is at most 5 is
in fact
E = {(x1 , x2 , x3 , x4 ) : x1 + x2 + x3 + x4 5}
= {(1, 1, 1, 1), (2, 1, 1, 1), (1, 2, 1, 1), (1, 1, 2, 1), (1, 1, 1, 2)}.
There are therefore 5 ways for the event to happen.
1

CHAPTER 1. BASIC COUNTING PRINCIPLES

1.2

Sum Principle

Two events are disjoint if their intersection is empty. Note that two disjoint
events cannot happen at the same time. Note that for (mutually) disjoint
sets E1 , E2 , , En ,
|E1 E2 En | =

n
X
j=1

|Ei |.

Hence, for disjoint events E1 , E2 , , En , the number of ways for at least one
of them to happen can be obtained by adding the numbers of ways for each
individual event to happen.

1.3

Product Principle

Recall that
A B = {(a, b) : a A, b B},
and that
|A B| = |A| |B|.
Thus, if an event E can be divided in two stages where there are m outcomes
for the first stage and if for each of the outcomes in the first stage, there are
n outcomes for the second stage, then the number of ways for E to happen
is m n. This can be generalized to events that can be separated into more
than 2 stages.
Example 1.2. There are 7 men and 8 women in a club. Nominate a person
for the president and a person for the treasurer. A nomination is a pair (x, y)
where x (for president) and y (for treasurer) are club members.
(a) If a person can be the president and the treasurer at the same time,
then the number of possible different nominations is 15 15 = 225.
(b) If no person can hold both positions at the same time, then the number
of possible different nominations is 15 14 = 210.

CHAPTER 1. BASIC COUNTING PRINCIPLES

(c) If people with different gender are to hold the positions, then the number of possible different nominations is
(7)(8) + (8)(7) = 112.
Notice that the set of nominations in this case is the union of two
disjoint sets.

1.4

Factorials and Permutations

A k-permutation of n distinct elements is a list (or an ordered tuple) of


k distinct elements chosen from the n elements. Thus, it follows from the
product principle that the number of k-permutations of n (distinct) elements
equals
n (n 1) (n k + 1)
= (n)k
n!
.
=
(n k)!
Also, when k = n, the number of permutations of n different objects is n!.
Note that (n)k is read n-falling-k and that for integer n,

(n)(n 1) (3)(2)(1), n 1,
n! =
1,
n = 0.
Note that n! is not defined for n = 1, 2, . . .. Also, we can take 1/n! = 0
for those values of n.
Example 1.3. There are n! ways to arrange n different books on a shelf.
Also, there are n! ways to pair n boys and n girls for a dance.

1.5

Stirlings formula

Note that
n!

2n nn en .

CHAPTER 1. BASIC COUNTING PRINCIPLES

That is,

n!
1
2n nn en
Thus, n! is a huge number when n is big.

1.6

as n .

Combinations


Define nk as the number of k-subsets of an n-set. Since a k-subset of an
n-set represents
 a selection of k distinct elements from a set of n (distinct)
n
elements, k is also known as the number of ways to select (where order in
which objects are selected is immaterial) k (distinct) objects from n (distinct)
objects.
Theorem 1.1.
 
(n)k
n
n!
=
=
,
k
k!
(n k)! k!

n, k 0.

Proof. This proof serves as an example of a general technique in combinatorics which we call equivalence via a bipartite graph. Let A be the set of all
k-subsets of a given n-set X and let B be the set of all k-lists of elements in
X. The objects, k-sets and k-lists, in A and B are vertices in the bipartite
graph whose edges are defined as follows. For a set A A and a list B B,
we join A and B by an edge iff the list B can be obtained by ordering the
elements in A. Every k-list B in B is related (by an edge) to exactly one
k-subset of X. Thus, the number of edges is (n)k . On the other hand, each
k-subset
 of X can be ordered in k! ways, giving rise to k! k-lists. Thus, there
are nk k! edges. It therefore follows that
 
 
(n)k
n
n
=
k! = (n)k , or
k
k
k!
as required.
Example 1.4. Consider strings of 0s and 1s, length n.
(a) There are 2n different strings since there are two possible choices for
each element in the string.

CHAPTER 1. BASIC COUNTING PRINCIPLES


n
. The reason is
(b) The number of strings
with
k
0s
(and
n

k
1s)
is
k

n
that there are k ways to select k elements (out of n elements) of the
string to be filled with 0s.
(c) Let us find the number of strings with k 0s (and n k 1s) such that
no two 0s are adjacent. Observe that there are n k 1s in each
string of length n and that these 1s separate the string into n k + 1
substrings. Each substring either is empty or has exactly one 0 because
no two 0s are adjacent. Thus, each string in this case is specified by
the k nonempty
substrings out of n k + 1 substrings. The answer is

n
therefore k .

(d) Using (c), the number of strings with length n and no adjacent 0s is
X n k + 1 
k0

(n+1)/2 

X
k=0


nk+1
.
k

Example 1.5. Consider arranging m men and w women in a line.


(a) How many different arrangements are there if no men is followed by
another man?
(b) How many different arrangements are there if all men follow one another?
Solution. (a) Each arrangement can be separated into two stages. First
arrange the women and there are w! ways. For each arrangement of the
women,
 insert the men into the w + 1 substrings and there are (w + 1)m =
w+1
m! ways. Hence the answer is
m


w+1
w! m!.
m
(b) Here, we can arrange the men in m! ways, and treat the men as a group.
Then arrange the w women and the group of men (w + 1 objects) in (w + 1)!
ways. Hence the answer is
m! (w + 1)!.

CHAPTER 1. BASIC COUNTING PRINCIPLES

1.7

Binomial Coefficients


Recall that nr is the number of r-subsets of an n-set and is equal to the
number of ways to select, order not important, r objects from
 a group of n
distinct objects. We shall give one more interpretation of nr in this section.
Theorem 1.2 (Pascals Triangle). For integers n, r satisfying n, r 0,

   

n+1
n
n
=
+
.
r+1
r
r+1

Theorem 1.3 (Binomial


Theorem). The coefficient of xr in the expansion

of (1 + x)n is nr . That is,
n  
X
n r
n
(1 + x) =
x.
r
r=0
Proof. Consider the expansion of
(1 + x1 )(1 + x2 ) (1 + xn ).
Notice that each term in the expansion
is a product of 0 or more of the

n
variables xi s, and that there are r terms involving r xi s. Also, if we equate
all xi s to x, then the number of terms in the above expansion involving r
xi s equals the coefficient of xr in the expansion of (1 +
x)n . This shows that

n
the coefficient of xr in the expansion of (1 + x)n is r , and hence
n  
X
n r
n
(1 + x) =
x.
r
r=0
Example 1.6. By setting x = 2, 1, 1 respectively, one gets
n  
X
n r
2 = 3n ,
n 0,
r
r=0
n  
X
n
= 2n ,
n 0,
r
r=0
n  
X
n
(1)r = 0,
n 1.
r
r=0

CHAPTER 1. BASIC COUNTING PRINCIPLES


Using the last two equalities, we obtain
n  
X
n
= 2n1 ,
r
r=0
r even
n 
X
r=0
r odd

Also, since

1.8

n
r

n
nr

n
r

= 2n1 ,

n 1,
n 1.

, we have

n 
X
2n + 1
= 22n .
r
r=0

Multinomial Coefficients

Suppose that k1 , k2 , , km are nonnegative integers satisfying


k1 + k2 + + km = n.


n
be the number of ways to form subsets A1 , A2 , , Am of an
Let k1 ,k2 ,
,km
n-set such that Ai Aj = for all i 6= j and |Ai | = ki , i = 1, 2, , m.
Theorem 1.4.

n
k1 , k2 , , km

n!
.
k1 ! k2 ! km !

Proof. Using the product principle, we have



 

 

n k1 k2 km1
n k1
n
n

=
km
k2
k1
k1 , k2 , , km
n!
= =
.
k1 ! k2 ! km !

Theorem 1.5. Suppose that k1 , k2 , , km are nonnegative integers satisfying


k1 + k2 + + km = n.

Then the coefficient


of xk11 xk22 xkmm in the expansion of (x1 + x2 + + xm )n

n
is k1 ,k2 , ,km .

CHAPTER 1. BASIC COUNTING PRINCIPLES

Proof. Simply observe that by repeatedly applying the binomial theorem,

=
=
=
=
Corollary 1.1.

[xk11 xk22 xkmm ] (x1 + x2 + + xm )n


 
n
[xk22 xkmm ] (x2 + + xm )nk1
k1
 

 
n k1 k2 km1
n k1
n

km
k2
k1


n
.
k1 , k2 , , km


n
= mn ,
k1 , k2 , . . . , km
where the sum is taken over all k1 , k2 , . . . , km such that ki 0 and k1 + k2 +
+ km = n.
X

Proof. Use the previous theorem and set x1 = x2 = = xm = 1.

1.9

Small Cases

This section is related to enumeration by brute force. Brute force is only good
for small cases, but it often gives us insights into the general problems. In
addition, it is often good to be able to verify general formulas by considering
small examples.
We shall be using balls and boxes as examples here. The balls can be
distinct or identical and the same is true for the boxes. Thus we have 4
cases. For each case, one might put conditions on the number of balls in
each box.
Example 1.7. There are 5 balls and 3 boxes. Solve the following two problems under the 4 cases where the balls are either distinct or identical and
where the boxes are either distinct or identical.
(a) Find the number of ways to put the balls into the boxes (with no
additional condition).

CHAPTER 1. BASIC COUNTING PRINCIPLES

(b) Find the number of ways to put the balls into the boxes so that no box
is empty.
Solution. Case ONE: The 5 balls are distinct and the 3 boxes are distinct,
labeled X, Y, Z.
(a) Each ball has 3 choices, and hence there are 35 = 729 ways.
(b) Suppose that box X has i balls. Then the remaining 5 i balls are to
be put into boxes Y, Z so that Y and Z are nonempty. Obviously 5 i 2
because boxes Y and Z are nonempty. The number of ways to put balls into
Y and Z is 25i 2 because there are two ways for either box Y or box Z to
be empty. Thus, the answer is
 
3  
X
5
5
5i
(25i 2) = 70 + 60 + 20 = 150.
(2 2) =
i
i
i=1
i1,5i2
X

Case TWO: The 5 balls are distinct and the 3 boxes are identical.
(b) We shall consider first the condition where no box is empty. In this
case, the numbers of balls in the boxes can be 1, 2, 2 or 1, 1, 3. For the 1, 2, 2
situation, the number of ways is
 
5
number of ways to put balls a, b, c, d into 2 identical boxes,
1
which is equal to

   
5 4 2

1 2 2

1
2

= 15,

where the factor 12 comes from the fact that the boxes are identical. Similarly,
for the 1, 1, 3 case, we have
   
5 4 3
12 = 10.
1 1 3
Thus, the number of ways in this case is 15 + 10 = 25. Note that there is
a simple way to relate the answer here to the answer in (b) in the previous
case later.
(a) Here the numbers of balls in the boxes can be
(i) for two empty boxes: 0, 0, 5,
(ii) for one empty box: 0, 1, 4 or 0, 2, 3,

CHAPTER 1. BASIC COUNTING PRINCIPLES

10

(iii) for no empty box which is case (b) before.


Thus, the answer is
   
5
5
+ 25 = 41.
+
1+
2
1

Case THREE: The 5 balls are identical and the 3 boxes are distinct, labeled
X, Y, Z.
(a) Let x, y, z be the number of balls in boxes X, Y, Z respectively. Then the
number of ways is
5 X
5x
X

1=

x=0 y=0 z=5xy

5
X
x=0

(5 x + 1) =

5
X
x=0

(6 x) = 36 (6)(5)/2 = 21.

(b) For the condition where there is no empty box, since the balls are identical, we may as well put one ball into each box to satisfy the nonemptyness
condition first. Thus, the answer is
2 X
2x
X

x=0 y=0 z=2xy

1=

3
X
x=0

(3 x) = 9 (3)(2)/2 = 6.

Case FOUR: The 5 balls are identical and the 3 boxes are identical.
(a) The outcomes are multisets of three nonnegative integers that sum to 5:
{0, 0, 5}, {0, 1, 4}, {0, 2, 3}, {1, 1, 3}, {1, 2, 2}.
Thus, there are 5 ways.
(b) From (a) above, we see that if no box is empty, then there are 2 ways.
The following table summarizes the answers obtained in the previous
example.
5 balls

3 boxes

distinct
distinct
identical
identical

distinct
identical
distinct
identical

number of balls per box


0
1
729
150
41
25
21
6
5
2

CHAPTER 1. BASIC COUNTING PRINCIPLES

11

Example 1.8. In combinatorics, it is often the case that astray ideas can
lead us into the wrong the direction. Small examples can help sort this out
quickly. Consider the following way to enumerate the number of ways to put
5 distinct balls into 3 distinct boxes so that no box is empty: First put a
ball into box X 5 ways; put a ball into box Y 4 ways; put 1 ball into box
Z 3 ways; then put the remaining two balls into the boxes (3)(3) ways.
Hence the answer is
(5)(4)(3)(9) = 540.
Is the above correct? Give reasons.
Solution. The above is not correct. For example, consider the distribution
where balls a, b are in box X, balls c, d are in box Y and ball e is in box Z.
Now it is obvious that this distribution is counted more than once by the
above method, because the above method distinguishes between the order in
which the balls are put into the boxes.
Example 1.9. This example is equivalent to one of the previous examples.
Find the number of integer solutions to
x1 + x2 + x3 = 5,

x1 , x2 , x3 0.

Solution.
Observe that each solution corresponds to a distribution of 5
identical balls to 3 distinct boxes (as the values of the variables x1 , x2 , x3
specify the number of balls in each of the 3 distinct boxes). Thus, from a
previous example, the answer is 21.

Chapter 2
Balls and Boxes
We shall be considering the distributions of balls into boxes in some generality
as many enumeration problems can be formulated using balls and boxes.
Recall that the balls and boxes can be distinct or identical, and conditions
may be placed on the number of balls per box. We shall assume that there
are always k balls and n boxes.

2.1

Distinct Balls and Distinct Boxes

A distribution of k distinct balls to n distinct boxes is a function from a k-set


to an n-set because such a function specifies to which box each ball is placed.
Theorem 2.1.

(a) The number of functions is nk .

(b) The number of bijections is




n!, n = k,
0, n =
6 k.

(c) The number of surjections (onto functions) equals the number of distributions of k distinct balls to n distinct boxes with at least one ball per
box, and is

X
k
,
i1 , i2 , . . . , i n
12

CHAPTER 2. BALLS AND BOXES

13

where the sum is taken over all i1 , i2 , . . . , in such that i 1 and i1 +


i2 + + in = k.
(d) The number of injections (1-1 functions) is (n)(n 1) (n k + 1) =
(n)k . This corresponds to the situation where there is at most one ball
per box.

2.2

Distinct Balls and Identical Boxes

A partition of an n-set is a collection of nonempty subsets of such


that
(a) A implies that A 6= ,
(b) A, B and A 6= B imply that A B = , and
(c) A = .
Using [n] = {1, 2, 3, 4, 5} as an example,
= {{1}, {2, 4, 5}, {5}}
is a partition of [n] into 3 (nonempty) subsets (which are usually called blocks
in a partition).

Let nk denote the number of partitions of a k-set into n nonempty
subsets. This is the so-called Stirling number of the 2nd kind. The 1st kind
is related to the number of permutations with a fixed number of cycles and
will be studied later.


Example 2.1. Find 42 and 43 .

Solution. To partition [4] into 2 nonempty subsets, we see that there are 41
partitions containing a singleton set, and they are of the form {{1}, {2, 3, 4}}.
Also, there are 21 42 partitions containing two doubleton sets of the form
{{1, 2}, {3, 4}}. Furthermore, there are no other cases. Thus,
 
   
4
4
1 4
= 4 + 3 = 7.
=
+2
2
2
1

14

CHAPTER 2. BALLS AND BOXES


To partition [4] into three subsets, we observe that there are
obtain partitions of the form {{1}, {2}, {3, 4}}. Thus,
 
4
= 6.
3

4
2

= 6 ways to

We next define the Bell number Bk as the number of partitions of [k].


Thus, we easily have this result.
Theorem 2.2.

k  
X
k
Bk =
,
n
n=1

k 1.

Example 2.2. To find B4 , we observe that


 
 
4
4
= 1,
= 1.
1
4
Thus, using the previous example, we find that
B4 = 1 + 7 + 6 + 1 = 15.
The next theorem relates set partitions to balls and boxes.
Theorem 2.3. The number of distributions
of k distinct balls to n identical

boxes with no empty boxes equals nk .
Proof. Think of subsets in a partition as identical boxes. Each distribution
of k distinct balls to n identical boxes gives a partition of [k] into n nonempty
subsets, and vice versa. Hence the assertion in the theorem follows.

Theorem 2.4. The number of distributions of k distinct balls to n identical


boxes equals

min(k,n)  
X
Bk ,
k n,
k
= Pn k
j
j=1 j , k > n.
j=1

Proof. The statement in the Theorem is self-explanatory.

CHAPTER 2. BALLS AND BOXES

15

We next relate Stirling numbers of the 2nd kind to distributions of distinct


balls to distinct boxes.
Theorem 2.5. The number of distributions of k distinct balls to n distinct
boxes so that no box is empty equals
 
k
n!
.
n
Proof. We shall use the method of equivalence by bipartite graphs. Let
A be the set of distributions of k distinct balls to n distinct boxes with no
empty boxes. Also, let B be the set of distributions of k distinct balls to n
identical boxes with no empty boxes. A distribution A in A is related by an
edge to a distribution B in B iff B can be obtained from A by erasing the
labels of the distinct boxes in distribution A. Note that
(1) Each distribution in A is related to exactly one distribution in B.
(2) Each distribution in B is related to exactly n! distributions in A. To
see this, observe that the (nondistinct) boxes in a distribution B B
are identified by the balls in them. Thus, labeling the n boxes is like
permuting n distinct objects.
Thus,
|A| = n! |B|,
and the result in the theorem follows.
Note that the above argument does not carry over to the case when the
boxes are allowed to be empty. Why?
Theorem 2.6.

 


1 X
k
k
=
,
n
i1 , i2 , . . . , in
n!

where is the sum is taken over all i1 , i2 , . . . , in such that i 1 and i1 + i2 +


+ in = k.

16

CHAPTER 2. BALLS AND BOXES


Example 2.3. Prove

Solution.

 
k
= 2k1 1.
2

Using the previous theorem, we have


 
k1  
1X k
k
=
= 12 (2k 2) = 2k1 1.
2
2 i=1 i

Observe that we have obtained a general formula for a previous example on


k = 4.

2.3

Identical Balls and Distinct Boxes

This kind of distributions is related to two well known problems in combinatorics: counting multisets and integer solutions.
A multiset is a collection of objects (elements from a set) in which an
object can appear more than once. For example,
{1, 2, 2, 4, 5, 5}
is a multiset of elements in [5].
Theorem 2.7. (a) The number of multisets with k elements chosen from
[n] equals the number of integer solutions to
x1 + x2 + + xn = k,

xi 0,

i = 1, 2, . . . , n.

(b) The number of binary strings with k 0s and n1 1s equals the number
of integer solutions to
x1 + x2 + + xn = k,
(c) All three numbers equal

k+n1
k

xi 0,

i = 1, 2, . . . , n.

17

CHAPTER 2. BALLS AND BOXES

Proof. (a) Let xi be the number of occurrences of i in the multiset. Then it


is clear that each integer solution specifies a multiset and vice versa.
(b) View a binary string from left to right. As before, the n 1 1s separate
the binary string into n substrings of 0s. Let xi be the number of 0s in the
i-th substring of 0s. Thus, each binary string with k 0s and n 1 1s is
specified by an n-tuple
(x1 , x2 , . . . , xn ),

xi 0,

x1 + x + 2 + + xn = k.

Also, each integer solution gives a binary string with k 0s and n 1 1s.
(c) Simply observe
that the number of binary strings with k 0s and n 1

k+n1
.
1s is
k

Theorem 2.8. The


 number of distributions of k identical balls to n distinct
.
boxes equal k+n1
k
Proof. Let xi be the number of balls in the i-th box. Then
x1 + x2 + + xn = k,

xi 0,

i = 1, 2, . . . , n.

Since each distribution gives an integer solution to the above equation, and
each integer solution corresponds to a distribution, the theorem therefore
follows.
Theorem 2.9. The number of distributions
of k identical balls to n distinct

k1
.
boxes with no empty boxes equal kn
Proof. The number of distributions equals the number of integer solutions to
x1 + x2 + + xn = k,

xi 1,

i = 1, 2, . . . , n.

By replacing each xi with yi + 1, then we see that the number of integer


solutions to the above equation equals the number of integer solutions to
y1 + y2 + + yn = k n,

yi 0,

which, according to a previous theorem, equals



 

k1
kn+n1
.
=
kn
kn

i = 1, 2, . . . , n,

18

CHAPTER 2. BALLS AND BOXES

2.4

Identical Balls and Identical Boxes

This kind of distributions is related to the number of integer partitions. A


partition of an integer k is a multiset of positive integers that add to k. For
example, {1, 1, 3, 3, 4} is a partition of 12 into 5 (positive) parts.
Let p(k, n) denote the number of partitions of k into n parts, and let p(k)
be the number of partitions of k. Thus,
(a) p(k, n) = 0 if k < n.
(b) p(k, 1) = 1, p(k, k) = 1, for integer k 1.
(c)
p(k) =

k
X

p(k, n).

n=1

When putting k identical balls into n identical boxes so that no box is


empty, we are in fact partitioning k into n (positive) parts. Hence we have
the following theorem.
Theorem 2.10. The number of distributions of k identical balls to n identical
boxes with no empty boxes equals p(k, n). Also, the number of distributions
of k identical balls to n identical boxes equals
n
X

min(k,n)

p(k, i) =

p(k, i).

i=1

i=1

Theorem 2.11. For integers k > n 1,


p(k, n) =

n
X
i=1

p(k n, i).

Before we prove the theorem, let us consider first its consequence. Recall
that
p(k, k) = p(k, 1) = 1,

k 1,

and

p(k, n) = 0,

k < n.

19

CHAPTER 2. BALLS AND BOXES

Thus, we know the value of p(1, n) for all n 1. We claim that the formula
in the theorem, together with the above boundary conditions, completely
determine p(k, n) for 1 n k. This claim can be proved by induction
on k. Assume as induction hypothesis that for integer k0 2, the values of
p(k, n) are known for all n 1 and all k < k0 . Then the value of p(k0 , n),
where n < k0 , can be calculated by
p(k0 , n) =

n
X
i=1

p(k0 n, i),

since by the induction hypothesis, the values of p(k0 n, i) are known, for
all values of i 1. Note also that for n = k0 , we have p(k0 , k0 ) = 1. Thus,
the following table of values of p(k, n) can be calculated row by row using
the formula in the theorem.
k
1
2
3
4
5
6
7

p(k, 1)
1
1
1
1
1
1
1

p(k, 2)

p(k, 3)

p(k, 4)

p(k, 5)

p(k, 6)

p(k, 7)

1
1
2
2
3
3

1
1
2
3
4

1
1
2
3

1
1
2

1
1

For example, to calculate p(7, 3), one can go up 3 rows (where the value of k
is 7 3 = 4) and then sum the first 3 entries in that row to get 1 + 2 + 1 = 4.
Proof of Theorem. Recall that p(k, n) equals the number of distributions of
k identical balls to n identical boxes so that no box is empty. For each such
distribution, suppose that a ball is removed from each box and it results in
i n nonempty boxes, then we have a distribution of k n identical balls
to n identical boxes (with no condition on the number of balls per box).

CHAPTER 2. BALLS AND BOXES

20

Observe that the process can be reversed, and hence we have


p(k, n)
n
X
#distributions of k n identical balls
=
to i identical boxes with no empty boxes
i=1

n
X
i=1

p(k n, i).

The equation in the theorem is an example of recurrence relations, which


will be studied in more details in a later chapter.

2.5

Summary

The following tables summarize the different types of problems, and their
solutions, discussed in this chapter.
k 1 balls

n 1 boxes

distinct
distinct
identical
identical

distinct
identical
distinct
identical

number of balls per box


0
 1
k
k
n
n! n
Pn k
k
j=1 j
n 
k+n1
k1
n1
Pn k
p(k, n)
j=1 p(k, j)

The number of distributions of balls to boxes under different assumptions.


balls
distinct
distinct
identical
identical

boxes
distinct
identical
distinct
identical

related problems
functions
set partitions
multisets, integer solutions
integer partitions

Combinatorial problems related to balls and boxes.

Chapter 3
Stirling Numbers
3.1

The Second Kind

Recall that
sets.

k
n

equals the number of partitions of [k] into n nonempty sub-

When k = 0, the set to be partitioned is empty (since [0] = ) and we


use the convention that
 
   
0
k
0
=1
and
=
= 0, k 6= 0.
0
0
k
That is,

   
0
k
= k,0 ,
=
k
0

where is the Kroneckers delta function. Note also that


   
k
k
=
= 1,
k 1.
k
1
and that

 
k
= 0,
n

21

k < n.

22

CHAPTER 3. STIRLING NUMBERS


Recall also that
# distributions of k distinct balls to
n distinct boxes with no empty boxes
# distributions of k distinct balls to
n identical boxes with no empty boxes

 
k
= n!
,
n
 
k
=
n

and that



 
k
1 X
k
,
=
n!
i1 , i2 , . . . , in
n
where is the sum is taken over all i1 , i2 , . . . , in such that i 1 and i1 + i2 +
+ in = k.
However, the above formula is useless when both n and k n are large.
We shall develop recurrence relations for computing Stirling numbers of the
2nd kind.
Theorem 3.1. For integers k 1 and n 1,
  



k
k1
k1
=
+n
.
n
n1
n

Proof. Consider the distribution of k distinct balls to n distinct boxes with


no empty boxes. There are two cases:
Case ONE: The box containing the k-th ball has only one ball in it. Then
removing the k-th ball results in a distribution of k 1 distinct balls to n 1
distinct boxes. As the process can be reversed, we see that the number of
distributions in this case is


 
k1
n
.
(n 1)!
n1
1

Case TWO: The box containing the k-th ball has at least 2 balls in it. Then
removing the k-th ball gives a distributions of k 1 distinct balls to n distinct
boxes with no empty boxes. In reversing this process, we need to decide which
of the n boxes to put the k-th ball in, and there are n choices. Thus, the
number of distributions in this case equals n times the number of distributions
of k1 distinct balls to n distinct boxes with no empty boxes, and is therefore
equal to


k1
n n!
.
n

23

CHAPTER 3. STIRLING NUMBERS


Combining the two cases, we obtain




 
k1
k1
k
,
+ n n!
= n (n 1)!
n!
n
n1
n

which implies the formula in the theorem. You can see that the method
works (more directly) if we consider identical boxes instead.
Notice that the above formula together with the boundary conditions:
   

k
0
1, k = 0,
=
= k,0 =
0, k 6= 0,
0
k

completely determines nk for all integers k, n 0. Therefore, we obtain the

following table of values of nk .
k
0
1
2
3
4
5
6

k
0

1
0
0
0
0
0
0

k
1

1
1
1
1
1
1

k

k

k

k

k

1
3
7
15
31

1
6
25
90

1
10
65

1
15

Theorem 3.2. For integers k n 1,




  X
k1 
j
k1
k
.
=
n

1
j
n
j=0
Proof. Consider the distributions of k distinct balls to n identical boxes with
no empty boxes. Consider the box containing the k-th ball. If it contains i
balls then there are k i balls in the other n 1 boxes. As there are k1
i1
ways to choose the i balls in the box containing the k-th ball, we see that
the number of distributions of k distinct balls to n identical boxes with no

24

CHAPTER 3. STIRLING NUMBERS


empty boxes equals

 
k
# distributions of k distinct balls to n
X
k
identical boxes so that there is no empty box and that
=
n
i=1 there are i balls in the box containing the k-th ball

k1 
X
k1
# distributions of k i distinct balls to n 1

=
identical boxes so that there is no empty box
i

1
i=1


k1 
X
k1
ki
=
i1
n1
i=1


k1 
X
j
k1
,
=
n1
j
j=0
where the last equality is obtained from the previous one by replacing i with
k j throughout.
As an example, for integer k 2,

  X
  X
k1 
k1 
k1
j
k1
k
= 2k1 1.
=
=
j
1
j
2
j=1
j=0
Also, for integers k 3,
  X
  X

k1 
k1 
k
k1
j
k1
=
=
(2j1 + 1) = 21 (3k1 + 1) 2k1 .
3
j
2
j
j=0
j=2
Theorem 3.3.
X k 
x =
(x)n ,
n
n0
k

integer k 0.

Note that
(x)n = (x)(x 1) (x n + 1),
and that in particular,
(x)1 = x,

(x)0 = 1.

integer n 0.

25

CHAPTER 3. STIRLING NUMBERS


Proof of Theorem. We use induction on k. For k = 0, since
have
X 0
(x)n = (x)0 = 1 = x0 = xk .
n
n0

0
n

= n,0 , we

For the induction step, assume  1 and the formula in the theorem holds
for all values of k < . Then since 0 = 0, we have
X 
(x)n
n
n0


X  1 
1
=
+n
(x)n
n

1
n
n1
X  1
X  1
(x)n
(x)n+1 +
n
=
n
n
n1
n0
X  1 
X  1
(x)n
(x)n (x n) +
n
=
n
n
n1
n0
X  1 
X  1
X  1
(x)n
(x)n +
n
(x)n
n
= x
n
n
n
n1
n0
n0
= x (x1 ),
= x .

(using the induction hypothesis)

This completes the induction step and the proof of the theorem.

3.2

The First Kind

Recall that the falling factorial is


(x)k =

k1
Y
j=0

(x j) = (x)(x 1) (x k + 1),

integer k 0.

Note that since the empty product is 1, we have (x)0 = 1. Define Stirling
numbers of the first kind by
s(k, n) = [xn ](x)k ,

integers n, k 0.

26

CHAPTER 3. STIRLING NUMBERS

Since a term involving xn in the expansion of (x)k is obtained by multiplying


n xs and k n constants chosen from the k factors in (x)k , we see that
(provided that k n 0) the sign of s(k, n) is given by (1)kn . That is,
s(k, n) = (1)kn |s(k, n)|.
The unsigned Stirling numbers of the first kind are
 
k
= |s(k, n)| = (1)kn s(k, n).
n
 
There are other ways to define nk . One definition is related to the number
of cycles in a permutation as we shall see in a later chapter. Another is
given below. The rising factorial (also known as the Pochhammer symbol) is
defined by
x(k) = (x)k =

k1
Y
j=0

(x + j) = (x)(x + 1) (x + k 1),

and one can see easily that


 
k
= [xn ]x(k) ,
n

integer k 0,

integers n, k 0.

The following theorem is a counterpart to the last theorem in the previous


section.
Theorem 3.4. For integers k 1 and n 1,



  
k1
k1
k
.
+ (k 1)
=
n
n1
n
The boundary conditions are
   
k
0
=
= k,0 .
0
k
Proof. We first check the boundary conditions. For k = 0, we have
X 0
(0)
xn ,
1=x =
n
n0

27

CHAPTER 3. STIRLING NUMBERS


and equating coefficients gives
 
0
= 0,n .
n
For k 1, by considering the constant term on both sides of
X k 
(k)
xn ,
x =
n
n0

we get that

 
k
= 0, k 1.
0
This shows that the boundary conditions are satisfied. To prove the recurrence relation, let k 1 and consider
X k 
xn = x(k)
n
n0
= (x + k 1)x(k1)
= xx(k1) + (k 1)x(k1)


X  k 1
X
k1 n
n+1
=
x
+
(k 1)
x
n
n
n0
n0




X k 1
k1
k1
n
=
+ (k 1)
x + (k 1)
.
n1
n
0
n1

Comparing coefficients of xn , n 1, on both sides, we find that





  
k
k1
k1
=
+ (k 1)
.
n
n1
n
The above theorem gives a method for computing
k
0
1
2
3
4
5
6

k 
0

1
0
0
0
0
0
0

k 
1

1
1
2
6
24
120

k 

k 

k 

k 

1
3
11
50
274

1
6
35
225

1
10
85

1
15

k 
n

. We find that

k 
6

Chapter 4
Principle of Inclusion-Exclusion
4.1

Notation

Let U be a set of objects and P be an index set. For i P be Ai U . We


may regard P as a set of properties and Ai as the set of objects in U with
property i.
For K P , let
NK =

Ai ,

iK

N = |U |.

Here NK is the number of objects in U with at least those properties in K.


In addition, let
MK = # objects in U with exactly those properties in K but no others.
For integer k 0, let
Nk = # objects in U with at least k properties
Mk = # objects in U with exactly k properties
Example 4.1. Consider the distribution of 9 distinct balls to 3 distinct
boxes. Let
U = set of all distributions
Ai = set of distributions where box i is empty
28

CHAPTER 4. PRINCIPLE OF INCLUSION-EXCLUSION

29

Then
M0 = # distributions not in A1 , A2 , A3
= # distributions with no empty box.
Now the following formula (which is a special case of the principle of inclusionexclusion) is well known:
M0 = |A1 A2 A3 |
= |U | (|A1 | + |A2 | + |A3 |)
+(|A1 A2 | + |A1 A3 | + |A2 A3 |) |A1 A2 A3 |.
Here,
|U | = 39 ,
|A1 | = |A2 | = |A3 | = 29 ,
|A1 A2 | = |A1 A3 | = |A2 A3 | = 1,
|A1 A2 A3 | = 0.
Thus, the number of distribution of 9 distinct balls to 3 distinct boxes with
no empty box equals
M0 = 39 (3)(29 ) + (3)(1) 0 = 18150.
For 5 balls, we have
M0 = 35 (3)(25 ) + (3)(1) 0 = 150,

as before.

For the general case where there are k distinct balls and 3 distinct boxes, we
have
M0 = 3k (3)(2k ) + 3.

4.2

Formulas

We shall first give a general formula, and derive from it other useful formulas.
Theorem 4.1. For K P ,
MK =

J:KJP

(1)|J||K| NJ .

CHAPTER 4. PRINCIPLE OF INCLUSION-EXCLUSION

30

Proof. Recall that MK is the number of objects with exactly those properties
in K while NJ is the number of objects with at least those properties in J.
We shall prove the theorem by considering the contribution of an object q to
the sum on the RHS.
Case ONE: If q does not possess all properties in K, then q contributes
nothing to NJ for any J K. So q contributes nothing to the sum.
Case TWO: If q possesses exactly all properties in K and no others, then q
contributes 1 to NK but none to NJ for any J % K (and J 6= K). So q
contributes 1 to the sum.
Case THREE: If q possesses i, i 1, properties in addition to those in K,
then let X be the set of properties that q possesses. Thus q contributes 1 to
NJ if J satisfies K J X P , and q contributes 0 to NJ if otherwise.
Hence, qs contribution to the sum equals


|X|
X
X
|J||K|
j|K| |X K|
(1)
=
(1)
j |K|
J:KJX
j=|K|

i
X

 
i
=
(1)

=0

= 0.

Combining these three cases, we see that the sum equals # objects with
exactly those properties in K. That is, the sum equals MK as asserted in
the theorem.
For the other formulas, we need to define for integer j 0,
X
X
\
Sj =
NJ .
Ai =
J: |J|=j,JP

iJ

J: |J|=j,JP


n

Notice that if |P | = n, then there are j terms in Sj . Note that as usual, we


take empty product as 1, empty intersection as U , the universal set. Thus,
S0 = |U |. Also, when there is a symmetry in the sets Ai , i P , it is usually
the case that the NJ s are identical for all J with the same cardinality, which
means that Sj is easy to calculate.
Theorem 4.2. Assume |P | = n. For integer i 0,
 
n
X
ji j
Sj .
Mi =
(1)
i
j=i

CHAPTER 4. PRINCIPLE OF INCLUSION-EXCLUSION

31

Proof. Recall that Mi is the number of objects with exactly i properties.


Then
X
Mi =
MK
K:|K|=i,KP

(1)|J||K| NJ

K:|K|=i,KP J:KJP

=
=
=

(1)|J||K| NJ

J:|J|i,JP K:KJ,|K|=i
 
n
X
X

j=i J:|J|=j,JP
n  
X
j
ji
j=i

(1)

j
(1)ji NJ
i

Sj .

Theorem 4.3. Assume |P | = n. For integer i 0,


M0 = M =

n
X

(1)j Sj .

j=0

Proof. Use the last theorem and set i = 0.


Theorem 4.4. Assume |P | = n. For integer i 1,


n
X
ji j 1
Ni =
(1)
Sj .
i1
j=i
Also, N0 is the number of objects with at least 0 properties and hence N0 =
S0 = |U |.
Proof. Exercise.

CHAPTER 4. PRINCIPLE OF INCLUSION-EXCLUSION

4.3

32

Examples


Example 4.2. Prove the following formula for nk :
 
  X
n
k
j n
(n j)k .
=
(1)
n!
j
n
j=0
Solution.
Consider the # distributions of k distinct balls to n distinct
boxes but no empty boxes. Notice that this is equal to the LHS of the
above identity. Thus, it is sufficient to show that the number of distributions
equals the RHS. We shall use inclusion-exclusion. Here, the objects are
distributions, and property j is box j is empty:
Aj = {distributions in which box j is empty},

j P = [n].

Then, the number of distribution with no empty box is


M0 =

n
X

(1)j Sj .

j=0

Notice that by symmetry,


Sj =

J:JP,|J|=j

Thus,

 
 
n
n
(n j)k .
|A1 A2 Aj | =
NJ =
j
j
n
X

 
n
M0 =
(1)
(n j)k ,
j
j=0

as desired. This gives yet another formula for nk :
  X
n
n
k
(1)j (n j)k X (1)nj j k
=
=
.
n
j!(n j)!
(n j)! j!
j=0
j=1
j

For example, when n = 2, the formula gives


  X
2
(1)2j j k
k
=
= 1 + 2k1
2
(2

j)!
j!
j=1
as before.

CHAPTER 4. PRINCIPLE OF INCLUSION-EXCLUSION

33

Example 4.3. A bijection f on [n] is called a permutation. A derangement


is a permutation f such that
f (i) 6= i,

i [n].

Find the number of derangements on [n].


Solution. Using inclusion-exclusion, the objects are permutations on [n].
Permutation f has property j, j [n], iff f (j) = j. That is,
Aj = {permutations f on [n] with f (j) = j}.
The number of derangements is the number of permutations without any of
these properties. Thus,
n
X
M0 =
(1)j Sj ,
j=0

and by symmetry,
 
 
n!
n
n
Sj =
|A1 A2 . . . Aj | =
(n j)! = .
j
j
j!
Thus,
M0 = n!

n
X
(1)j
j=0

j!

Note that when n , the proportion of permutations on [n] that are


derangements is close to

X
(1)j
= e1 .
j!
j=0

Notice that

|M0 n!e1 | = n!

(1)j /j!

j>n

1
n+1
1
,
for all n 1.

2
<

It therefore follows that for n 1, M0 is in fact the integer nearest to


n!e1 .

CHAPTER 4. PRINCIPLE OF INCLUSION-EXCLUSION

34

Example 4.4. There 2n beads in n pairs. Each pair of beads have the same
color but different shapes. Beads from different pairs have different colors.
Arrange the beads in a circle so that no two beads from a pair are next to
each other. How many different arrangements?
Solution. When n = 1, there is only one pair, and the number of arrangements is 0. We shall therefore assume n 2. Also, note that the number of
ways to arrange m 1 different objects in a circle is (m 1)!. We shall use
inclusion-exclusion. Here the objects are circles with the 2n beads. A circle
has property j iff beads from pair j are next to each other in the circle. That
is,
Aj = {circles where beads in pair j stay together}.
We like to find the number of circles without any of these properties. Observe
that by symmetry,
 
n
|A1 A2 Aj |.
Sj =
j
To find |A1 A2 Aj |, we take the two beads in pair i, 1 i j, as a
group. Together with the other 2n 2j beads, there are 2n 2j + j objects
to be arranged in a circle, and there are (2n j 1)! such circles. For each
such circle, there are 2j ways to arrange the beads in each group. Hence,
|A1 A2 Aj | = 2j (2n j 1)!.
Thus, the number of circles in which no beads in the same pair are together
is
n
n  
X
X
n
j
M0 =
(1) Sj =
(1)j 2j (2n j 1)!.
j
j=0
j=0
Example 4.5. Suppose that k is a positive integer with P as its set of prime
divisors. Find the number
(k) = |{x : gcd(x, k) = 1, 1 x k}|.
Solution. The objects are integers 1, 2, . . . , k. An integer x has property p
iff x is divisible by the prime p P . That is,
Ap = {x : p|x, 1 x k},

p P.

35

CHAPTER 4. PRINCIPLE OF INCLUSION-EXCLUSION


Now
(x) = M0 =

(1)|I|

IP

For any subset I of prime divisors of k,


\

pP

Thus,

Ap .

pI

Ap = {x : p|x, p I, 1 x k} = Q

k
pI


Y
X Y  1
1
=k
1
.
M0 =
(1) Q
=k

p
p
pI p
pP
IP
IP pI
X

|I|

Chapter 5
Generating Functions
5.1

A Quick Introduction

Recall that to get a term in the expansion of a product of factors, for example,
(1 + x + x4 ) (1 + y 2 + y 5 ),
one can simply choose one term from each factor, and multiply them together
to form a term. This is not very much different from enumeration. Each
factor represents a stage (in the product principle) and the terms in each
factor represent the choices within the stage represented by the factor.
Example 5.1. Let us consider a very detailed example. Choose k items
from a basket of 2 apples, 1 orange and 5 pears. Fruits of the same type are
considered identical. Then we can use
xi , 0 i 2, denote choosing i apples,
y i , 0 i 1, denote choosing i orange,
z i , 0 i 5, denote choosing i pears.
Now consider the product
(x0 + x1 + x2 )(y 0 + y 1 )(z 0 + z 1 + z 2 + z 3 + z 4 + z 5 ).
Each term is of the form xa y b z c and it represents the selection of a apples,
b oranges and c pears. The number of ways to choose k fruits equals the
36

37

CHAPTER 5. GENERATING FUNCTIONS

number of terms whose exponents a, b, c are such that a + b + c = k. Thus,


by equating x, y, z, we have
(1 + x + x2 )(1 + x)(1 + x + x2 + x3 + x4 + x5 )
and the coefficient of xk equals the number of possible selections of k fruits.
Now
(1 + x + x2 )(1 + x)(1 + x + x2 + x3 + x4 + x5 )
= 1 + 3x + 5x2 + 6x3 + 6x4 + 6x5 + 5x6 + 3x7 + x8 .
This shows that for example, there are 5 ways to choose 2 fruits and 6 ways
to choose 5 fruits.
Example 5.2. Find the number of integer solutions to
x + y + z = 4,
Solution.

0 x 2,

0 y 1,

0 z 5.

This equals the coefficient of x4 in


(1 + x + x2 )(1 + x)(1 + x + x2 + x3 + x4 + x5 ),

and is hence 6.
Example 5.3. How about 5 different math books and 4 identical copies of
Arthur C. Clarke novels?
Solution. The enumerator for each math book is 1 + x, and the enumerator
for the Clarke novels is 1 + x + x2 + x3 + x4 . Thus, the generating function
for the numbers ar of ways to choose r books is
(1 + x)5 (1 + x + x2 + x3 + x4 ).
Example 5.4. Let ak be the number of combinations of pennies, nickels and
dimes to give k cents of change in a check-out counter. Then the enumerator
for pennies is
1
,
1 + x + x2 + =
1x
the enumerator for nickels is
1 + x5 + x10 + =

1
,
1 x5

38

CHAPTER 5. GENERATING FUNCTIONS


and the enumerator for dimes is
1 + x10 + x20 + =

1
.
1 x10

Hence the generating function for the sequence (ar )r0 is






1
1
1
.
1x
1 x5
1 x10

5.2

Inverses of Generating Functions

We shall consider formal power series. That is, we are only interested in the
algebraic properties (differential operator included) of power series. We shall
not be concerned with analytical properties (such as convergence).
If G, F are generating functions and GF = 1, then G is the inverse of F
and write
1
F 1 = G = .
F
For example,
(1 + x + x2 + )(1 x) = 1,
and hence
F = 1 + x + x2 + =
Similarly, we have by replacing x with 3x,

1
.
1x

1 3x + 9x2 27x3 + . . . =

1
.
1 + 3x

Also, we have
1 + 2x + 3x2 + 4x3 + =

(k + 1)xk =

k0

which can be proved by noting that


X
(k + 1)xk
[xn ](1 2x + x2 )
k0

1
,
(1 x)2

39

CHAPTER 5. GENERATING FUNCTIONS

equals 1 when n = 0, equals 0 when n = 1, and for n 2, the coefficient of


xn equals
(n + 1) + (2n) + (n 1) = 0.
Note that Taylors Theorem is a good source to find more examples.
Theorem 5.1. If

F =

ai x i ,

a0 6= 0,

i0

then F 1 exists.
Proof. Consider G =

FG =

i0 bi x

ai x i

i0

where
ci =

i
X
j=0

. Then
!

bi xi

i0

c i xi ,

i0

aj bij = a0 bi + a1 bi1 + + ai b0 ,

i 0.

Now if we know b0 , b1 , . . . , bi1 and ci , then we can solve for bi (since a0 6= 0).
Thus, if F G = 1, then we have
c0 = 1,

ci = 0,

i 1.

This shows that b0 , b1 , b2 , . . . exist and are all uniquely determined.


The previous theorem says that for example
X
F =
n!xn = 1 + x + 2x2 + 6x3 + 24x4 +
n0

has an inverse. However, notice that the power series does not converge for
x 6= 0 and that Taylors theorem does not apply here.

40

CHAPTER 5. GENERATING FUNCTIONS

5.3

Identical Balls and Distinct Boxes, Again!

Consider putting identical balls into individual (distinct) boxes. The enumerator for each box is
1 + x + x2 + =

1
,
1x

where the term xi indicates that there are i balls in the box. Hence, the
generating function for the numbers (fk )k0 of distributions of k identical
balls into n distinct boxes is
1
.
(1 x)n
Now we learned before that



k+n1
fk =
.
k
Hence, we have given a combinatorial proof of the formal power series:


X
k+n1 k
1
x .
=
k
(1 x)n
k=0
Or equivalently,
(1 + x)



X
k+n1
k=0

(1)k xk .

Let us generalize the definition of the binomial coefficient and the binomial theorem. Using Taylor Series, we have for any real number r,

X xk d k
X (r)k

r
r
(1 + x) =
=
(1
+
z)
xk .

k
k! dz
k!
z=0
k0
k0

Recall that the binomial coefficient was defined as


 
(n)k
n
=
,
integers n, k 0.
k
k!

41

CHAPTER 5. GENERATING FUNCTIONS

In view of the Taylor series for (1 + x)r , if we generalize our definition of the
binomial coefficient so that for all r R and all k Z,
   (r)
k
r
, k 0,
k!
=
0,
k < 0.
k
then the binomial theorem can be written as
 
 
X
r k X r k
r
x ,
x =
(1 + x) =
k
k
k
k=0

r R.

However, we showed before that




X
k+n1
n
(1)k xk .
(1 + x) =
k
k=0

Thus, we must have for all integer n 0 and all integer k that


 
k+n1
n
n
(1) =
.
k
k

We shall show that the above is in fact true for all r R. Suppose that
k 0. Then
 
(r)(r 1) (r k + 1)
r
=
k
k!
(k + r 1)k
= (1)k
k!


k k+r1
.
= (1)
k

Notice that the above equality also holds for k < 0 as both sides are 0. Thus,
we have


 
r
k k+r1
,
r R, k Z.
= (1)
k
k
As simple examples, we
1
1x
1
(1 x)2
1
(1 x)3

observe that
= 1 + x + x2 + x3 + ,
= 1 + 2x + 3x2 + 4x3 + ,
= 1 + 3x + 6x2 + 10x3 + .

Chapter 6
Integer Partitions Revisited
Recall that p(k, n) equals the number of distributions of k identical balls into
n identical boxes with no empty box, and is equal to the number of integer
partitions of k into n (positive) parts. Also, p(k) is the number of partitions
of k. For this section, we write
pk,n = p(k, n),

pk = p(k).

For example,
p4,2 = 2
because 1 + 3 = 2 + 2 = 4, and
p4 = 5.
because in addition to the previous 2 partitions of 4, we also have 3 other
partitions of 4: 1 + 1 + 1 + 1 = 1 + 1 + 2 = 4.
As in Stirling numbers, we define
p0,n = 0,n ,

pk,0 = k,0 .

42

CHAPTER 6. INTEGER PARTITIONS REVISITED

6.1

43

The Generating Function for pk

Example 6.1. Assume integer k 0. What is the generating function for


the number of integer solutions to
2x + 3y = k,

x, y 0?

The enumerator for the contribution of x to k is


1
1 + x2 + x4 + =
.
1 x2
Similarly, the enumerator related to y is
1
.
1 x6
Thus, the generating function for the number of integer solutions to the given
equation is
1
.
2
(1 x )(1 x3 )
Observe that each integer solution corresponds to a partition of k with part
sizes restricted to 2 and 3.
1 + x3 + x6 + =

Theorem 6.1. The generating function for the sequence (pk )k0 is
Y 1
.
1 xi
i1
Proof. We regard a partition of k as deciding, for each i 1, the number of
parts with size i it contains. Thus, the enumerator for (the contribution to
the partition by) parts of size i is
1 + xi + (xi )2 + =

1
,
1 xi

where (xi )j represents the situation that the partition contains j parts of size
i (thus making a contribution of ki to the partition of k). Then the number
of partitions of k equals the coefficient of xk in
Y 1
,
i
1

x
i1
which implies the theorem.

CHAPTER 6. INTEGER PARTITIONS REVISITED

44

Example 6.2. (a) The generating function for the numbers of integer partitions with all parts at most n is
n

Y 1
1
pn (x) =
=
.
(1 x)(1 x2 ) (1 xn ) i=1 1 xi
(b) The generating function for the numbers of integer partitions with all
odd parts only is
Odd(x) =

Y
1
1
=
.
3
5
(1 x)(1 x )(1 x ) i0 1 x2i+1

(c) The generating function for the numbers of integer partitions with all
even parts only is
Even(x) =

Y 1
1
=
.
(1 x2 )(1 x4 )(1 x6 ) i1 1 x2i

Theorem 6.2. Suppose k is a nonnegative integer. Then the number of


partitions of k into unequal parts equals the number of partitions of k into
odd parts only.
Proof. Consider the generating function for the number of integer partitions
with unequal parts. The enumerator for parts of size i is 1 + xi (since all
parts are unequal). Thus, the generating function is
Y
u(x) = (1 + x)(1 + x2 )(1 + x3 ) =
(1 + xi ).
i1

We next rewrite this generating function as follows:


Q
2i
Y (1 + xi )(1 xi )
Y
1
i1 (1 x )
Q
u(x) =
=
= Odd(x).
=
i
2i+1 )
i
1

x
(1

x
(1

x
)
i1
i1
i0

We see that u(x) = Odd(x) and hence the two corresponding sequences
represented by the generating functions are equal.

CHAPTER 6. INTEGER PARTITIONS REVISITED

6.2

45

The Generating Function for pk,n

Define
F (x, y) =

XX

pk,n xk y n .

k0 n0

Now x is for the sum of the parts and y is for the number of parts. Thus,
the enumerator for the parts of size i is
1 + xi y + (xi y)2 + (xi y)3 + =
Hence, we have
F (x, y) =

Y
i1

1
.
1 xi y

1
,
1 xi y

and we have proved the following theorem.


Theorem 6.3. The generating function for pk,n is
F (x, y) =

XX

pk,n xk y n =

k0 y0

Notice that
pk =

Y
i1

1
.
1 xi y

pk,n ,

n0

and that if we set y = 1, then

XX
X
1
k
=
F
(x,
1)
=
p
x
=
p k xk ,
k,n
i
1

x
k1
k0 n0
k0
Y

as expected.
Theorem 6.4.
(1 xy)F (x, y) = F (x, xy).

46

CHAPTER 6. INTEGER PARTITIONS REVISITED


Proof. Simply note that
F (x, y) =
=

1
1 xi y
i1
1 Y

1 xy

i2

1
1 xi y

1 Y
1
=
1 xy i1 1 xi (xy)
=

1
F (x, xy)
1 xy

Here are two consequences of the above theorem.


Example 6.3. Find the generating function for the number of integer partitions with n parts. That is, for fixed n, find the generating function for the
sequence (pk,n )k0 .
Solution. Define
X
gn (x) =
pk,n xk .
k0

Observe that

F (x, y) =

XX

pn,k xk y n =

k0 n0

gn (x)y n ,

n0

and hence from the theorem, we have


X
X
(1 xy)
gn (x)y n = (1 xy)F (x, y) = F (x, xy) =
gn (x)(xy)n .
n0

n0

Comparing the coefficient of y n , it follows that


gn (x) xgn1 (x) = xn gn (x),
That is,

n 1.

x
gn1 (x),
n 1.
1 xn
Also, it can be checked from the definition of gn (x) that
gn (x) =

g0 (x) = 1.

47

CHAPTER 6. INTEGER PARTITIONS REVISITED

Therefore, we have a recurrence relation for gn (x) with an initial condition.


Solving this recurrence gives that
gn (x) =

n
Y

x
xn
Q
g
(x)
=
.
n
i 0
i)
1

x
(1

x
i=1
j=1

Example 6.4. Recall that

(1 xy)F (x, y) = F (x, xy).


That is,
(1 xy)

XX

pk,n xk y n =

k0 n0

XX

pk,n xk (xy)n .

k0 n0

k n

Comparing the coefficient of x y on both sides, we obtain


pk,n pk1,n1 = pkn,n ,

k, n 1.

We have therefore obtained this recurrence for pk,n :


pk,n = pk1,n1 + pkn,n ,

k, n 1.

With the boundary conditions stated in the beginning of this chapter, we see
that this recurrence completely determines pk,n . Notice that this recurrence
is essentially the same as the one studied in a previous chapter:
pk,n =

n
X

k > n 1.

pkn,i ,

i=1

Let us try
gn (x) =

X
x
g
(x)
=
x1+jn gn1 (x),
n1
n
1x
j0

where
gn (x) =

n 1,

pk,n xk .

k0

If we compare the coefficient of xk in the recurrence, we get


X
pk,n =
pkjn1,n1 ,
n 1,
j0

which is a recurrence appeared in an assignment problem.

g0 (x) = 1,

CHAPTER 6. INTEGER PARTITIONS REVISITED

6.3

48

One More Example

Finally, let us consider the generating function for the number of integer
partitions with largest part size equal to n. For i = 1, 2, . . . , n 1, the
enumerator for the part with size i is 1/(1 xi ) as before. The enumerator
for the part of size n is
xn
x + x(x ) + (x ) + =
,
1 xn
n

n 2

n 3

since there is at least one part of size n. Thus, the generating function is
xn
,
i
i=1 (1 x )

Qn

which is the same as gn (x). Recall that gn (x) is the generating function
for the number of integer partitions with n parts and that the generating
function for the number of integer partitions with part sizes at most n is
1
.
i
i=1 (1 x )

Qn

We therefore have the following theorem.


Theorem 6.5. For integer n 1 and k 1, the number of integer partitions
of k with n parts equals the number of integer partitions of k with largest part
size equal to n. Also, both numbers equal the number of integer partitions of
k n with part sizes at most n.

Chapter 7
Recurrence Relations
We have seen how to solve simple recurrence relations. The purpose of this
chapter is to introduce a standard (and powerful) solution method by using
generating functions.

7.1

Ordinary Generating Functions

The general method is as follows. Use the recurrence to find the generating
function of the sequence. Then expand the generating function to obtain a
formula for the n-th term of the sequence.
Example 7.1. Solve the recurrence
with initial conditions

sn = 2sn1 sn2 ,
s0 = 0,

Solution.

Let
G(x) =

n 2,

s1 = 1.
X

s n xn .

n0

Then multiply both sides of of the recurrence by xn and sum over n 2 to


get
X
X
X
s n xn = 2
sn xn+1
sn xn+2 ,
n2

n1

n0

49

50

CHAPTER 7. RECURRENCE RELATIONS


or
G(x) s1 x s0 = 2x(G(x) s0 ) x2 G(x).

Making use of the initial conditions, we obtain


(1 2x + x2 )G(x) = x,

or

G(x) =

x
.
(1 x)2

Expanding the power series, we find that


X
X
X
G(x) = x
(n + 1)xn =
nxn =
nxn .
n0

n1

n0

Thus,

sn = n,

n 0.

The next example demonstrates that partial fractions may be used in


expanding the generating function.
Example 7.2. Solve
fn = 7fn1 10fn2 ,

n 2,

with
Solution.

f0 = 2,

Let

F (x) =

f1 = 1.
X

f n xn .

n0

Then as before, we have

F (x) f1 x f0 = 7x(F (x) f0 ) 10x2 F (x),


and using the initial conditions,
(1 7x + 10x2 )F (x) = 2 + 13x.
Thus,

1
3
2 + 13x
=
+
.
(1 5x)(1 2x)
1 5x 1 2x
Expanding F (x) to obtain
X
X
F (x) =
5n xn 3
2n xn .
F (x) =

n0

n0

Thus,

fn = 5n (3)(2n ),

n 0.

CHAPTER 7. RECURRENCE RELATIONS

7.2

51

Fibonacci Numbers

The Fibonacci numbers are


0, 1, 1, 2, 3, 5, 8, 13, 21, . . . .
They are defined by
an = an1 + an2 ,

n 2,

with
a0 = 0,

1 = a1 .

Example 7.3. Let fn be the number of strings with n bits containing no


adjacent 0s. Consider the last bit of such strings. There are two cases:
Case ONE: If the last bit is 1, then we have no restriction on the other n 1
bits. Thus, there are fn1 such strings.
Case TWO: If the last bit is 0, then the last but one bit is 1, and we have
fn2 such strings.
Hence, we have
fn = fn1 + fn2 ,
n 2.

Also, when n = 0, we have f0 = 1 (see Case TWO) and when n = 1, we have


fn = 2. Therefore, the initial conditions are
f0 = 1,

f1 = 2.

Compare with the Fibonacci numbers an , we see that


fn = an+2 ,

n 0.

From a previous example, we see that


fn =

(n+1)/2 

X
k=0


nk+1
.
k

Thus, we see that for n 1 (and one can check that the following is also
true for n = 0),

(n1)/2 
X
nk1
.
an =
k
k=0

CHAPTER 7. RECURRENCE RELATIONS

52

Let us consider what happens when we solve the recurrence for an . We


shall however consider generalized Fibonacci numbers: Let k be a given number.
gn = gn1 + k gn2 , n 2,
g0 = 0, g1 = 1.
Notice that g2 = 1 always (and is independent of k). Define
X
G(x) =
g n xn .
n0

Then

giving that

G(x) g1 x g0 = x(G(x) g0 ) + k x2 G(x),

x
.
1 x kx2
Consider 1 x kx2 = 0 = (1 x)(1 x), where and are zeros of
y 2 y k = 0. Thus,

1 + 1 + 4k
1 1 + 4k
=
,
=
,
2
2
with
+ = 1,
= k.
G(x) =

Using partial fractions,

G(x) =

B
A
+
,
1 x 1 x

and upon solving for A, B, we obtain from A(1 x) + B(1 x) = x that


1
1
1
1
A=
=
=
, B=
.

1 + 4k
1 + 4k
Therefore, gn equals

[xn ] G(x) = An + B n

n 
n !

1 1 + 4k
1
1 + 1 + 4k
.

=
2
2
1 + 4k
In particular, we have proved that for Fibonacci numbers, an equals
!n
!n !

(n1)/2 
X
1
nj1
1+ 5
1 5
=
.

j
2
2
5
j=0
We shall study more of this in a later chapter.

CHAPTER 7. RECURRENCE RELATIONS

7.3

53

Bell Numbers Revisited

Recall that the Bell numbers Bn is the number of partitions of an n-set. Also,
we obtained the recurrence:

n1 
X
n1
Bn =
Bj , n 1,
B0 = 1.
j
j=0
The purpose of this section is to introduce the exponential generating function
(which, in this case, is an ordinary generating function for the sequence
Bn /n!). The final solution requires solving a differential equation.
Define
F (x) =

Bn

n0

Then the recurrence relation gives

xn
.
n!


n1 
xn X X n 1
xn
Bn
Bj ,
=
n!
n!
j
n1
n1 j=0

X
giving that

G(x) B0 =

n1
XX
Bj
n1 j=0

xn
,
j! n(n 1 j)!

X X Bj
xn
=
j! n(n 1 j)!
j0 nj+1
Thus,
X X Bj
xn1
,
j!
(n

j)!
j0 nj+1
X Bj
=
x j ex ,
j!
j0

G (x) =

= ex G(x).

This shows that


x

G(x) = Aee ,

for some constant A.

CHAPTER 7. RECURRENCE RELATIONS

54

Since G(0) = B0 = 1, we see that A = e1 and hence


G(x) = exp(ex 1).
Next we expand G(x) to get
G(x) = e1

X ejx
j!

j0

= e1

X X (jx)n

j!n!
!
X j n xn
X
=
e1
.
j! n!
j0
n0
j0 n0

Thus,
Bn = e1

X jn
j0

7.4

j!

Catalan Numbers

Catalan numbers appear in many enumeration problems. Here is an example.


Let fn be the number of ways to parenthesize the expression
w1 + w2 + + wn
so that two numbers are added at one time. For example, when n = 3, we
have f3 = 2 because
(w1 + w2 ) + w3 = w1 + (w2 + w3 ).
Our task is to find fn .
Let us first obtain a recurrence for fn . Suppose that the last addition is
performed on 2 numbers N1 and N2 where N1 is the sum of the first i terms
and N2 is the sum of the other n i terms. Now N1 can be obtained in fi
ways and N2 can be obtained in fni ways. Thus
fn =

n1
X
i=1

fi fni ,

n 2.

55

CHAPTER 7. RECURRENCE RELATIONS


Notice that f1 = 1. Now if we define f0 = 0, we have
fn =

n
X

fi fni ,

i=0

n 2,

Define
G(x) =

f0 = 0, f1 = 1.

f n xn .

n0

Then
X

x fn =

G(x) xf1 f0 =

fi fni xn ,

n2 i=0

n2

or

n
XX

n
XX
n0 i=0

fi fni xn x

1
X
i=0

fi f1i f0 f0 .

Upon simplifying using the initial conditions, we have


G(x) x =
=

n
XX

fi fni xn ,

n0 i=0

XX

fi fni xn ,

i0 ni
2

= G(x) .
That is,

G(x)2 G(x) + x = 0.
To solve for G(x), we take the above equation as a quadratic in G(x) and
find that

1 1 4x
G(x) =
.
2
Now G(0) = f0 = 0 enables us to determine that

1 1 4x
G(x) =
.
2
We next use Taylors expansion to get that the n-th term of the power series
of (1 + y)1/2 is


y n (1/2)n
y n dn
1/2
(1
+
y)
=
.

n! dy n
n!
y=0

CHAPTER 7. RECURRENCE RELATIONS

56

Thus, the coefficient of xn , where n 1, in the series expansion of G(x) is




1 (4)n (1/2)n
2n1 (1)(1)(3) (2n 3)

=
2
n!
n!
(2n 2)!
=
(n 1)!n!


1 2n 2
.
=
n n1
We therefore find that
fn =

0,

1 2n2
n n1

n = 0,
, n 1.

Note: Catalan numbers, Cn , appear in many problems and they are usually
defined as Cn = fn+1 . That is,
 
1
2n
Cn =
, n 0.
n+1 n

Chapter 8
Permutations
A permutation on [n] is a bijection on [n]. We write i = (i). Permutations have rich properties in groups, combinatorics and analysis of sorting/searching algorithms.

8.1

Notation

As usual, assume is a permutation on [n] and write i = (i). The standard


notation for a permutation is


1 2 n
1 2 n
One can use the linear notation:
1 , 2 , . . . , n .
The digraph representation is a graph G = (V, E) with vertex set V = [n]
and edge set
E = {(i, i ) : i [n]}.

Notice that the outdegree and indegree of each vertex are both equal to
1. Thus, the digraph is simply a collection of (directed) cycles. The cycle
notation simply lists all cycles in the permutation.
57

58

CHAPTER 8. PERMUTATIONS
5

1
111111111
000000000
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
00
11
0
1
0
1
111111111
000000000
00
11
0
1
0
1
2

6
11
00
00
11

11
00
00
11
00
11
4

11
00
00
11
00
11
1

For example, the above permutation can be written as




1 2 3 4 5 6 7
,
6 7 2 4 3 1 5
or in the cycle notation as
(1 6), (2 7 5 3), (4),
or in linear notation as
6, 7, 2, 4, 3, 1, 5.

8.2

Random Permutations

A random permutation on [n] is a permutation chosen uniformly at random


from the set of all possible n! permutations. Hence the probability that a
particular permutation is chosen is 1/n!.
There are two ways to generate a random permutation on [n].
Method ONE: Choose an integer uniformly at random from [n], and call it
n . Then 1 , 2 , . . . , n1 is a random permutation on [n] {n }. Here is a
simple program in Maple:
> RandPerm := proc(n, seed)
>
local i, P, j, k, t;
>
global _seed;
>
_seed := seed;
>
P := array(1..n);
>
for i from 1 to n do P[i] := i; end do;
>
for j from n by -1 to 2 do
>
k := rand(1..j)();
>
t := P[k]; P[k] := P[j]; P[j] := t;

CHAPTER 8. PERMUTATIONS

59

>
end;
>
P;
> end:
> P := RandPerm(10,201):
> for i from 1 to 10 do printf("%a ",P[i]); end do;
Method TWO: Take a random permutation on [n1] and place 1 , 2 , . . . , n1
in a row, creating n slots between them:
|{z} 1 |{z} 2 |{z} |{z} n1 |{z} .

Choose one slot randomly and insert the integer n.

Here is a Maple program to list all permutations on [n].


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

AllPerm := proc(i,n,B)
local C, j, t;
if (i=0) then
for j from n by -1 to 1 do printf("%a ",B[j]); end do:
printf("\n");
else
for j from 1 to n do C[j] := B[j]; end do;
for j from i by -1 to 1 do
t := C[i]; C[i] := C[j]; C[j] := t;
AllPerm(i-1,n,C);
end do;
end if;
end:
n := 5:
for i from 1 to n do A[i] := i: end do:
AllPerm(n,n,A);

Recall that n! is a huge number; so do not try this when n is big.

8.3

Analysis of a Simple Algorithm

Consider this algorithm for finding the minimum of an array of integers:

60

CHAPTER 8. PERMUTATIONS
Algorithm FindMin
Input: n numbers B[i], i = 1, 2, . . . , n
Output: mini B[i]
Assume: the numbers B[i] 6= B[j] for all i 6= j.
> FindMin := proc(n,B)
>
local i;
>
for i from 2 to n do
>
if (B[1] > B[i]) then B[1] := B[i]; end if;
>
end do;
>
B[1];
> end:
> _seed := 2003: n := 10:
> for i from 1 to n do
>
P[i] := rand(1..1000)();
> end:
> FindMin(10,P);

Let An be the number of times that the assignment statement B[1] := B[i]
is performed. Assume without loss of generality that B is a permutation on
[n].
Best Case: An = 0. This occurs when B[1] = 1 is the minimum, and it
happens with probability
# permutations with B[1] = 1
(n 1)!
1
=
= .
n!
n!
n
Worst Case: An = n 1. This occurs when B[i] = n i + 1 for all i =
1, 2, . . . , n and it happens with probability
P r(An = 0) =

1
.
n!
Our question is about the average case. Suppose that each permutation on
[n] is equally likely to be the input, what can we say about An ? How about
its mean and variance:
X
E(An ) =
jP r(An = j),
P r(An = n 1) =

j0

var(An ) = E(A2n ) E(An )2 .

One of the first way to try to solve problems like this is by recurrence
relations. Recall that a random permutation on [n] can be constructed by

61

CHAPTER 8. PERMUTATIONS

taking a random permutation on [n 1] and randomly inserting the element


n.
Let us start by considering the cases where the number n is stored in B:
Case ONE: B[1] = n. The elements B[2], B[2], . . . , B[n] is a random permutation on [n 1], and since an assignment is performed before FindMin is
applied to B[2], B[2], . . . , B[n], we see that in this case
An = An1 + 1 in distribution.
Case TWO: B[1] 6= n and so B[i] = n for some i 6= 1. Here, B[1] < n and
the existence of B[i] does not affect An . That is,
An = An1

in distribution.

Therefore, if we define the indicator



1, B[1] = n,
(B[1]=n) =
0, B[i] =
6 n,
then for n 2,
An = An1 + (B[1]=n)

in distribution.

Notice that An1 and (B[1] = n) on the right above are independent.
To calculate the mean of An , observe that
E(An ) = E(An1 ) + E((B[1]=n) ) = E(An1 ) +

1
.
n

Thus, solving the recurrence gives


E(An ) = E(A1 ) +

1
1
1 1
+ + +
+ .
2 3
n1 n

Now E(A1 ) = 0, and so we have


E(An ) = Hn 1 = ln(n) + 1 + o(1),
where Hn is the harmonic series, = 0.5772156649 is the Euler constant and
o(1) represents a function that goes to 0 as n .

62

CHAPTER 8. PERMUTATIONS
To calculate the variance of An , we use independence to get
var(An ) = var(An1 ) + var((B[1] = n)).
Now
var((B[1]=n)) =

E(2(B[1]=n) )

1
E((B[1]=n) ) = (1)
n
2

 2
1
1
1
= 2.
n
n n

Thus,
1
1
2
n n

X 1
1
= var(A1 ) +

j j2
j2

var(An ) = var(An1 ) +

= Hn Hn(2) ,

where
Hn(s)

n
X
1
=
js
j=1

is the generalized harmonic series. Thus,

V ar(An ) = ln(n) +

2
+ o(1).
6

We can actually do better with a little more effort. Let


pn,k = P r(An = k),
where pn,k is unrelated to integer partitions. Then from
An = An1 + (B[1]=n)

in distribution,

we see that with probability 1/n, An = An1 + 1 and with probability (n


1)/n, An = An1 . Thus, we have
pn,k =

n1
1
pn1,k + pn1,k1 ,
n
n

n 2.

Also, we have
p1,k = k,0 ,

k,

and

pn,k = 0,

k < 0.

63

CHAPTER 8. PERMUTATIONS
Define the generating function
Pn (x) =

pn,k xk ,

and we have
Pn (x) =

n1
x
x+n1
Pn1 (x) + Pn1 (x) =
Pn1 (x),
n
n
n

n 2.

Thus, solving the recurrence, we obtain


Pn (x) =

(x + n 1)n1
P1 (x).
(n)n1

But P1 (x) = 1 and therefore, we have


(x)n
(x + n 1)n1
=
,
Pn (x) =
n!
xn!
where (x)n is the rising factorial:
(x)n = (x)(x + 1)(x + 2) (x + n 1).
Thus,
pn,k




(x)n
n
1
k+1 (x)n
= [x ]Pn (x) = [x ]
.
= [x ]
=
xn!
n!
n! k + 1
k

Thus, the number of


on [n] requiring k assignment operations

 npermutations
in FindMin equals k+1 .

8.4

Number of Permutations with k Cycles

Recall that a permutation can be represented by cycles. Now the cycle representation is not unique in the sense that a permutation can have two (or
more) cycle representations as described before. In order to have a unique
representations, we use the so-called canonical cycle representation:
Step ONE: always list the vertices in a cycle starting from the smallest label,

CHAPTER 8. PERMUTATIONS

64

and call this the label of the cycle;


Step TWO: Arrange the cycles so that the labels of the cycles are in decreasing order.
For example, the permutation
(4, 2, 1, 6), (3), (5, 7, 9), (8)
has the canonical cycle representation:
(8), (5, 7, 9), (3), (1, 6, 4, 2).
Now if we ignore the parentheses, we have a permutation in linear notation.
For example,
8, 5, 7, 9, 3, 1, 6, 4, 2.
Now clearly this is a 1-1 correspondence because the process can be reversed
by noting that each cycle starts with a label that is smaller than the label
of the previous cycle. If we apply FindMin to a permutation in linear order,
we can imagine that the linear order actually represents a permutation in
canonical cycle notation. And the number of assignment statements performed equals the number of cycles minus 1 because the first cycle does not
need assigning a new value to B[1], whereas B[1] is assigned the label of
every subsequent cycle. Thus,
# permutations on [n] with k cycles
= # permutations on [n] for which FindMin needs k 1
assignment operations
 
n
.
=
k
We have therefore proved the following theorem.
Theorem 8.1. The number of permutations on [n] with k cycles equals
 
n
= [xk ](x)n .
k
Also, if we let Cn be the number of cycles in a random permutation on
[n], and recall that An is the number of assignment operations needed by

65

CHAPTER 8. PERMUTATIONS

FindMin when applied to a random permutation. Then the above discussion


shows that
Cn = An + 1,
and hence
var(Cn ) = Hn Hn(2) .

E(Cn ) = Hn ,

As an example, let use the previous theorem to show that E(Cn ) = Hn .


Note that
 
1 n
P (Cn = k) =
,
n! k
and hence

Gn (x) =

n
X

P (Cn = k)xk =

k=0

Thus,
E(Cn ) =

n
X

(x)n
.
n!

kP (Cn = k) = Gn (1).

k=0

But

(1)n

= n! and

Gn (x)
giving that
E(Cn ) =

n1
X
1
1

,
= (x)n
n!
x+k
k=0

Gn (1)

n1
X
k=0

1
= Hn .
1+k

One can find the variance of Cn in a similar fashion.

Chapter 9
A Generating Function for
Permutations
The Cycle Index of Sn

9.1

Let Sn be the set of all permutations on [n]. A permutation Sn is said


to have cycle class (or of type) (t1 , t2 , . . .) if there are ti cycles of length i in
. Note that
X
iti = n,
i1

and that for Sn , we have

ti = 0,

i > n.

(n)

(n)

Let St1 ,t2 ,...,tn = St1 ,t2 ,... be the number of permutations in Sn with cycle class
(n)
(t1 , t2 , . . .). To find St1 ,t2 ,... , we follow these steps:
Step ONE: Fix the vertices in the cycles, and number of ways to do this is


n
Y
1
1
n
,
= n!
ti t !
n t1 ! t2 ! . . . , tn !
(i!)
1, . . . , 1, 2, . . . , 2, . . . , |{z}
i
i=1
| {z } | {z }
t1

where the factor


ordered.

t2

1
ti !

tn

comes from the fact that the cycles of lengths i are not

66

CHAPTER 9. A GENERATING FUNCTION FOR PERMUTATIONS 67


Step TWO: Arrange the vertices to form cycles: For each set of i vertices
designated for an i-cycle, there are (i 1)! ways to arrange the vertices, and
hence the number of ways in this step is
n
Y
i=1

((i 1)!)ti .

Thus,
(n)
St1 ,t2 ,...,tn

= n!

n
Y
i=1

it i

1
.
ti !

It should be noted that the above expression works if we allow ti = 0 for


i > n. Hence
Y 1
(n)
.
St1 ,t2 ,... = n!
ti t !
i
i
i1
The cycle index of Sn is defined as

Zn (x1 , x2 , . . .) =

1 X Y ti ()
x
n! S i1 i
n

and is therefore equal to


Zn (x1 , x2 , . . .) =

1
n!

St1 ,t2 ,...

Pt1 ,t2 ,...


i1 iti =n

xtii .

i1

Upon simplifying, we see that


Zn (x1 , x2 , . . .) =


n 
Y
1  xi ti
ti ! i
i=1

Y  1  xi ti 
.
ti ! i
i1

t1 ,t2 ,...0
P
i1 iti =n

t1 ,t2 ,...0
P
i1 iti =n

For n = 0, we see that ti = 0 for all i and hence we assume Z0 (x1 , x2 , . . .) = 1.

CHAPTER 9. A GENERATING FUNCTION FOR PERMUTATIONS 68

9.2

The Exponential Generating Function

The generating function for the cycle indices Zn of the symmetric groups Sn ,
n 0, is
X
G(z; x1 , x2 , . . .) =
Zn (x1 , x2 , . . .)z n .
n0

Simplifying to obtain

G(z; x1 , x2 , . . .) =

X
n0

t1 ,t2 ,...0
P
i1 iti =n

Y  1  xi ti 
zn
t
!
i
i
i1

n0

t1 ,t2 ,...0
P
i1 iti =n

X Y

t1 ,t2 ,...0 i1

i1

1
ti !

z i xi
i

t i !

t !
z i xi i
i
ti !

X 1  z i xi
=
t!
i
i1
ti 0 i
 i 
Y
z xi
=
exp
i
i1
!
X z i xi
= exp
.
i
i1
Y

1
ti !

Notice that this is also an exponential generating function for the number of
permutations on [n] with cycle classes (t1 , t2 , . . .). The term exponential
comes from the factor 1/n! hidden in Zn .

9.3

Examples

Example 9.1. If x1 = x2 = = x then


!
X xz i
= exp(x ln(1 z)) = (1 z)x .
G(z; x, x, . . .) = exp
i
i1

CHAPTER 9. A GENERATING FUNCTION FOR PERMUTATIONS 69


Upon expanding G, we have
G(z; x, x, . . .) =

X x
n0

(z)n .

Now the number of permutations on [n] with k cycles is n! times the coefficient
of xk z n in G and is therefore
n! [xk z n ]G(z; x, x, . . .) = [xk ](x)n (1)n
= [xk ](x)n
 
n
=
,
k
 
where nk is an unsigned Stirling number of the 1st kind. We have seen this
before.
Example 9.2. Find an expression for the # permutations on [n] with k
cycles of length . Cycles of other lengths are allowed.
Solution. The answer is
n! [xk z n ] G(z; 1, . . . , 1, x , 1, 1, . . .)
!
X z i x z z
= n! [xk z n ] exp
+

i1

= n! [xk z n ] exp( ln(1 z)) exp(xz /) exp(z /)


!
!
X (xz )j
X (z )j
1
= n! [xk z n ]
1 z j0 j j!
j j!
j0
!
!
X
z k X (z )j
j
n
z
= n! [z ]
k k! j0 j j!
j0
!
!
X
X (z )j
n!
zj
= k [z nk ]
k!
j j!
j0
j0
n/k
n! X (1)j
= k
.
k! j=0 j j!

Note that when k = 0 and = 1, the above formula gives the number
of derangements as discussed before. Also, as n , the proportion of

CHAPTER 9. A GENERATING FUNCTION FOR PERMUTATIONS 70


permutations on [n] with k cycles of length tends to
n/k
n! X (1)j
n!
= k e1/ .
k
j
k! j=0 j!
k!

Example 9.3. A cycle is even (resp. odd) if it have an even (resp. odd)
number of vertices. Find fn,k which is the number of permutations on [n]
with exactly k even cycles and no odd cycles.
Solution. Take G(z; x1 , x2 , . . .) and set x1 = x3 = = 0, x2 = x4 = = x
to get
!
X xz 2
G(z; 0, x, 0, x, . . .) = exp
2
1
!
x X (z 2 )
= exp
2 1
= (1 z 2 )x/2 .

Thus, fn,k equals n! times the coefficient of z n xk in G(z; 0, x, 0, x, . . .) and is


hence equal to
 k

(1)m , n = 2m,
[x ](2m)! x/2
n k
2 x/2
m
n! [z x ](1 z )
=
0,
n is odd
Thus, we have f2m+1,k = 0 and

(2m)! k
[x ](x/2)m (1)m
m!
(2m)! k
=
[x ](x/2)m
m!  
(2m)! m
.
=
2k m! k

f2m,k =

Can you find a combinatorial argument to get this formula? Also, one might
want to verify that the formula works at least for f4,1 = 6 and f4,2 = 3.
Example 9.4. Let us consider the number gn of permutations on [n] without
odd cycles. This number equals
!
X z 2
n
n
n! [z ]G(z; 0, 1, 0, 1, . . .) = n![z ] exp
2
1
= n![z n ](1 z 2 )1/2 .

CHAPTER 9. A GENERATING FUNCTION FOR PERMUTATIONS 71


Thus, g2m+1 = 0 and
g2m = (2m)![z 2m ](1 z 2 )1/2
(1/2)m
= (2m)!
(1)m
m!
(2m 1)!!
= (2m)!
2m m!
(2m)!
= (2m)! 2m
2 (m!)2
 
(2m)! 2m
.
=
m
4m
One may verify that the formula works when n = 4 = 2m, g4 = 9. Also,
notice that
m
X
g2m =
f2m,k .
k=0

Example 9.5. How about the number of permutations on [n] with k odd
cycles and no even cycles? The number equals n! times
!
X xz 21
n k
n k
.
[z x ]G(z; x, 0, x, 0, . . .) = [z x ] exp
2 1
1
But
exp

X xz 21
1

2 1

= exp

X xz
1

X xz 2
1

= (1 z)x (1 z 2 )x/2
x/2

1+z
.
=
1z

Note that
(1 z)x (1 z 2 )x/2 =

X (x)j
j0

j!

(z)j

X (x/2)
0

(z 2 ) .

CHAPTER 9. A GENERATING FUNCTION FOR PERMUTATIONS 72


Thus,
n/2

[z n ](1 z)x (1 z 2 )x/2 =

X (x/2) (x)n2
(1)n
!(n 2)!
=0

n/2

X (x/2) (x)n2
=
(1) .
!(n

2)!
=0
Also,
[x

](x/2) (x)n2



k 
X

n 2
(1/2)kj (1)k+j .
=
k

j
j
j=0

Thus, the number of permutations on [n] with k odd cycles and no even
cycles is



n/2
k
X X
n!(1)kj
n 2

.
kj !(n 2)!
2
j
k

j
=0 j=0

I do not know if this formula can be simplified. One can however put this
formula into Maple to verify it for small cases of n and k.

Example 9.6. How about the number permutations on [n] with no even
cycles. Well, one can take the formula in the previous example and sum over
k but this is too cumbersome. Instead, we observe that the answer equals n!
times
 
n/2
X
j 1/2
n
1
2 1/2
(1)
,
[z ](1 z) (1 z ) =
j
j=0
which after simplifying (see Theorem 12.4 later) equals
  

2m 1
m 1/2
=
(1)
,
where m = n/2.
m 4m
m
That is, the answer is
 
n! 2m
,
4m m

where m = n/2.

CHAPTER 9. A GENERATING FUNCTION FOR PERMUTATIONS 73

9.4

Even Permutations and Transpositions

A permutation is even (resp. odd) if it contains an even (resp. odd) number


of even cycles. For example, the identity permutation is an even permutation
because it does not contain any even cycles. Note that for a square matrix
M = (Mi,j ), the determinant of M is
det(M ) =

Sn

where
sgn() =

sgn()

n
Y

Mi,i ,

i=1

1,
is even,
1, is odd.

Given a permutation , a transposition of results in another permutation


, where for some i 6= j,

i = j ,

j = j ,

k = k , k 6= i, j.

That is, we may think of a transposition of as switching two elements of


. It may also be viewed as a permutation of two elements.
Theorem 9.1. Any transposition of a permutation turns from even to
odd or from odd to even. Therefore, since the identity is even, a permutation
is even iff it can be obtained from the identity using an even number of
transpositions.
Proof. What does a transposition do? It either combines two cycles into one
or separates a cycle into 2. By considering these cases, one finds that the
number of even cycles is changed by 1 with each transposition. This shows
the first part of the theorem. The second part is obvious.
How many even permutations are there? Let En and On respectively
be the number of even and odd permutations on [n]. One can show (using
recurrence) that En = On = n!/2 for n 2.
If we approach the problem using generating functions, we first observe
that

P
 

xt11 xt22 + xt11 (x2 )t2 xt33 (x4 )t4 = 1 + (1) i1 t2i xt11 xt22

CHAPTER 9. A GENERATING FUNCTION FOR PERMUTATIONS 74


P
is 0 if i1 t2i is odd. Thus, we see that the exponential generating function
for (the cycle indices of) even permutations on [n] is
1
2

(G(z; x1 , x2 , x3 , x4 , . . .) + G(z; x1 , x2 , x3 , x4 , . . .)) .

Thus, En equals n! times the coefficient of z n in


1
2

(G(z; 1, 1, 1, 1, . . .) + G(z; 1, 1, 1, 1, . . .))


!
!!
X
X
= 21 exp
z i /i + exp
(z)i /i

1
2

i1
1

(1 z)

i1

+ (1 + z) .

This gives that


En =

1
n!,
2

1,

n 2,
n = 0, 1.

Can you find the number of even permutations on [n] with k cycles?

Chapter 10
Permutation Runs and
Inversions
A permutation (in linear notation) can be divided into segments where each
segment is a maximal increasing sequence called runs. For example, the
permutation 2, 5, 9, 3, 8, 7, 1, 4, 6 contains 4 runs:
2, 5, 9; 3, 8; 7; 1, 4, 6.


Let nk be the number of permutations on [n] with k runs. These numbers are
called Eulerian numbers. This is not to be confused with the Euler constant
= .5772156649 or the Euler numbers.

10.1

A Recurrence for

n
k

Recall that to generate all permutations on [n], we need only take each
permutation on [n 1] and insert n into one of the n possible slots:
|{z} 1 |{z} 2 |{z} |{z} n1 |{z} .

Observe that (1) if n is inserted at the end of one of the runs in , then the
number of runs remains unchanged, and that (2) if n is inserted in any other
positions, then the number of runs is increased by 1.
75

CHAPTER 10. PERMUTATION RUNS AND INVERSIONS

76

Thus, to get all permutations on [n] with k runs:


(1) Take all permutations

on [n 1] with k runs and insert n at the end


k permutations on [n] with k runs;
of a run. This gives n1
k
(2) Take all permutations on [n 1] with k 1 runs, and insert n at
of the n (k 1) slots that are not the end of a run in . This gives

one
n1
(n k + 1) permutations on [n] with k runs.
k1
We therefore obtain the recurrence:
 




n
n1
n1
= (n k + 1)
+k
, n, k 1.
k
k1
k
We next need to consider boundary conditions. In order for the above to
work for n = 1 or k = 1, we need
 
 
n
0
= n,0 ,
= 0,k ,
n, k 0.
0
k
Let
G(t, z) =

X X n z k tn
n0 k0

n!

Then assignment exercises will show that


G(t, z) =
and that

1z
,
1 z exp(t(1 z))



  X
k
n
j n+1
(k j)n ,
=
(1)
j
k
j=0

where in the above formula 00 = 1.

n, k 0,

CHAPTER 10. PERMUTATION RUNS AND INVERSIONS

10.2

77

The Average Length of the k-th Run

Consider a random permutation on [n]. Let wk,p be the probability that the
first k runs have a total length at least p. Then
wk,p = P r(1 , 2 , . . . , p has at most k runs)
k
X
=
P r(1 , 2 , . . . , p has j runs)
j=1

 
k
X
1 p
=
,
p! j
j=1

1 p n,

1 k.

We shall take w0,p = 0,p . Thus, the above becomes, for k 0,


wk,p =

 Pk

1 p
j=0 p! j

0,

, 0 p n,
p > n.

Let i be the average length of the i-th run. If we use a standard result in
elementary probability theory, the expected total length of the first k runs
equals
1 + 2 + + k
X
=
P r(the first k runs have a total length at leaset p)
p1

wk,p .

p1

Or we can first observe that


P r(The first k runs have a total length equal to p) = wk,p wk,p+1 .

CHAPTER 10. PERMUTATION RUNS AND INVERSIONS

78

Then
1 + 2 + + k
X
=
p P r(The first k runs have a total length equal to p)
p1

X
p1

X
p1

p(wk,p wk,p+1 )
p wk,p

X
p2

(p 1)wk,p

wk,p .

p1

Therefore,
k =

X
p1

X
p1

But wk,p =
that

and hence

Pk

wk,p

wk1,p

p1

(wk,p wk1,p ).

1 p
j=1 p! j

if 0 p n and is 0 if p > n. It therefore follows


 1
p
, if 1 p n,
p! k
wk,p wk1,p =
0,
if p > n.

 
n
X
1 p
k =
(wk,p wk1,p ) =
,
p!
k
p=1
p1
X

k 1.

If we take 0 = 1, then we have


 
n
X
1 p
,
k =
p! k
p=0

k 0.


We obtain a formula for k from an earlier formula on kp . Or we can go
through the generating function as follows. Recall that
X X n z k tn
1z
G(t, z) =
=
.
k n!
1 z exp(t(1 z))
n0 k0

CHAPTER 10. PERMUTATION RUNS AND INVERSIONS

79

Thus, using an earlier result from a homework problem, we have


 !
n
X X X
1 p
1z
z k tn =
.
t(1z) )
k
p!
(1

t)(1

ze
p=0
n0 k0
Thus, the average length of the k-th run in a random permutation on [n]
equals
1z
(1 t)(1 zet(1z) )
1 z X j jt(1z)
= [z k tn ]
z e
1 t j0
[z k tn ]

= [z k tn ]

1 z X j X j i ti (1 z)i
z
1 t j0 i0
i!

= [z ](1 z)
=

k
X

[z kj ]

j=0

n
XX
z j (1 z)i

n
X
j i (1 z)i+1

i!

i=0

k X
n
X
(1)kj j i
j=0 i=0

i!

j0 i=0

i!

i+1
kj

Example 10.1. We can verify the above formula for n = 3. Using Maple,
> kthRun := proc(k,n)
>
add(add(j^i * binomial(i+1,k-j) * (-1)^(k-j) /i!,
>
i=0..n), j=0..k);
> end:
> n := 3:
> for k from 1 to 3 do
>
printf("For n=%a, average length of %a-th run is %a.\n",
>
n,k,kthRun(k,n));
> end;
For n=3, average length of 1-th run is 5/3.
For n=3, average length of 2-th run is 7/6.
For n=3, average length of 3-th run is 1/6.

CHAPTER 10. PERMUTATION RUNS AND INVERSIONS

80

For the 6 permutations on [3], we have

permutation
1, 2, 3
1, 3; 2
2, 3; 1
2; 1, 3
3; 1, 2
3; 2; 1

1st run
3
2
2
1
1
1

length of
2nd run 3rd run
0
0
1
0
1
0
2
0
2
0
1
1

Thus, we have from the table that the average length of the 1st run is 10/6, of
2nd run is 7/6 and of 3rd run is 1/6. These figures agree with those obtained
from the formula.
Let k be a fixed nonnegative integer and let Lk be the limit of k as
n . That is, Lk is the average length of the k-th run (when n )
and Lk equals

i+1
k X

X
(1)kj j i kj
i!

j=0 i=0

k
X

(1)

j=0

We observe first that for m 1,



X z i i+1
m
=
i!
i0
=
=

kj

X
ji
i=0

i+1
kj

i!

!

X z i (i + 1)m
i! m!
im1

d X z i+1 (i)m1
dz im1 m!
i!

z im+1 z m
d X
dz im1 (i m + 1)! m!

d zm z
e
dz m!
1
(m + z)z m1 ez .
=
m!
=

CHAPTER 10. PERMUTATION RUNS AND INVERSIONS

81

Also, it can be checked easily that the above formula works for m = 0, and
for all z. (When z = 0 and m = 0, take the limit z 0.) Thus, with z = j
and m = k j, we have

i+1
X j i kj
1
=
kj kj1 ej .
i!
(k j)!
i0
Therefore, the length of the first k-th run, as n , equals
k
X
(1)kj
j=0

(k j)!

kj kj1 ej .

Note that
L1 = e 1
L2 = e2 2e
L3 = e3 3e2 + 32 e

1.718,
1.952,
1.996.

Consult Knuth, The Art of Computer Programming, Vol 3, for more information.

10.3

Inversions

Let be a permutation on [n]. The pair (i , j ) is an inversion if i < j and


i > j . Let Xn () be the number of inversions in permutation . This is
related to a well-known sorting algorithm:
Algorithm Bubblesort
INPUT: A[1], A[2], . . . , A[n], and assume inputs are all different.
OUTPUT: A[1] < A[2] < < A[n].
ALGORITHM:
> for i from 1 to n do
>
for j from 2 to n-i+1 do
>
if (A[j] < A[j-1]) then swap(A[j],A[j-1]);
>
end do;
> end do;

82

CHAPTER 10. PERMUTATION RUNS AND INVERSIONS

We may assume without loss of generality that A[i] = i and is a permutation on [n]. Consider the number of swaps executed by BUBBLESORT.
Note that each swap corrects one inversion in and hence
Xn () = # swaps executed by BUBBLESORT.
Best Case: This happens when is the identity, and hence
Xn () = 0,

P r(Xn = 0) =

1
.
n!

Worst Case: This occurs when 1 > 2 > > n , that is, when i =
n i + 1. Hence
Xn () = 21 n(n + 1),

P r(Xn = n(n + 1)/2) =

1
.
n!

Our aim is to consider the average case.


Let
Mn,k = # permutations on [n] with k inversions.
Define
Gn (z) =

Mn,k z k ,

n 1.

We shall find a recurrence for Gn (z). Recall that a permutation on [n] can
be obtained from a permutation on [n 1] by inserting n into any of the
n possible positions:
|{z} 1 |{z} 2 |{z} n1 |{z},
n1

n2

where the number of inversions created by the insertion is given below the
corresponding underbraces. Every permutation on [n] appears once in this
construction if we take all permutations on [n 1] and insert n into every n
possible slots.
Thus, we have
Gn (z) = (z 0 + z 1 + + z n1 )Gn1 (z) =
Also, when n = 1, we have
M1,k = k,0 ,

1 zn
Gn1 (z),
1z

n 2.

83

CHAPTER 10. PERMUTATION RUNS AND INVERSIONS


giving that
G1 (z) = 1.
Let
Fn (z) =

z k P r(Xn = k) =

k0

Thus,

X
k0

Fn (z) =
and

zk

Mn,k
1
= Gn (z).
n!
n!

1 1 zn
Fn1 (z), n 2,
n 1z

F1 (z) = G1 (z) = 1.
Let
n = E(Xn ) = Fn (1).
Then
n

1
=
n

n1
X
j=0

jz j1 Fn1 (z) + (1 + z + + z n1 )Fn1


(z)

z=1


1 1
n(n

1)
+
n
=
n1
n 2
= 21 (n 1) + n1 ,
n 2.
Thus,
n =
since 1 = 0.

1
2

n
X

1
(i 1) + 1 = n(n 1),
4
i=2

Note that it is in fact very


j n, define the indicator Xij

1,
Xij =
0,

easy to work out n as follows. For 1 i <


by
if (i , j ) is an inversion,
otherwise.

Let Xn be the number of inversions in a random permutation on [n]. Then


we have
X
X
Xn =
Xij ,
where
is over all pairs (i, j) satisfying 1 i < j n.
i<j

i<j

CHAPTER 10. PERMUTATION RUNS AND INVERSIONS

84

It can be checked easily that P r(Xij = 1) = 12 , and so


 
1
1 n
= n(n 1).
n = E(Xn ) =
2 2
4
It will be quite tedious to work out the variance using the sum formula for
Xn .
Let us work out the variance n2 of Xn using the generating function. Note
that
var(Xn ) = E(Xn2 ) E(Xn )2
X
=
(k(k 1) + k)P r(Xn = k) E(Xn )2
k0
Fn (1)

Also,
Fn (z) =

+ Fn (1) Fn (1)2


1
2
n1
(1 + z + z + + z ) Fn1 (z).
n

We shall first show this general result (which is standard in probability theory). let
A(z) = B(z)C(z)
where B(1) = C(1) = 1. Then
A (1) = (B (z)C(z) + B(z)C (z))z=1 = B (1) + C (1),
and
A (1) = (B (z)C(z) + 2B (z)C (z) + B(z)C (z))z=1
= B (1) + 2B (1)C (1) + C (1).
Using the above equations, we find that
A (1) + A (1) A (1)2 = (B (1) + B (1) B (1)2 ) + (C (1) + C (1) C (1))2 .
Now, taking B(z) = n1 (1 + z + z 2 + + z n1 ) and C(z) = Fn1 (z), we see
that
2
n2 = (B (1) + B (1) B (1)2 ) + n1
.

CHAPTER 10. PERMUTATION RUNS AND INVERSIONS

85

Here,
n1

1 X j1
B (z) =
jz ,
n j=0

and

B (1) = 21 (n 1),

n1

1X
B (z) =
j(j 1)z j2 ,
n j=0

giving

n1

1
1X
j(j 1) = (n 1)(2n 1) 12 (n 1).
B (1) =
n j=1
6

Thus,
1
1
B (1) + B (1) B (1)2 = (n 1)(2n 1) (n 1)2 /4 = (n2 1).
6
12
Thus,

n2

X 1
1
2
(i2 1) + 12 .
=
= (n2 1) + n1
12
12
i=2

Now 1 = 0 and so


1 1
1
2
n =
(n)(n + 1)(2n + 1) n = n(n 1)(2n + 5).
12 6
72
Note: BUBBLESORT is not a very efficient sorting algorithm. MERGESORT and HEAPSORT, for example, are more efficient. The average case
analysis of HEAPSORT was not resolved until a few years ago.

Chapter 11
Extension to Complex
Numbers
11.1

The Gamma Function

We begin by generalizing the factorial to the complex plane. We define (due


to Weierstrass) of the Gamma function using an infinite product

Y
1
z
= ze
((1 + z/n) exp(z/n)) ,
(z)
n=1

z C,

where is the Eulers constant, and is defined as


!
n
X
1
ln(n) 0.5772.
= lim
n
i
i=1
Note that another definition of (z) is
Z
(z) =
tz1 et dt,
0

86

Re(z) > 0,

CHAPTER 11. EXTENSION TO COMPLEX NUMBERS

11.2

Convergence of the Infinite Product

Let an be the logarithm of the n-th factor. That is,



z z
an = ln 1 +
.
n
n
Then for |z| r, where r is any real number, and for z 6= n,


 2
z
z2
z
r
an =
.
2 + = O
n 2n
n
n2

This shows that for z 6= 1, 2, . . .,

X
n=1

and hence

|an | <

an is convergent.

n=1

Hence, for z 6= 1, 2, . . ., the infinite product

((1 + z/n) exp(z/n)) =

n=1

11.3

exp(an ) is convergent.

n=1

Factorials in the Complex Plane

Theorem 11.1.

1
(z)

= 0 iff z = 0, 1, 2, . . ..

Proof. Recall that

Thus,

1
(z)

Y
1
= zez
((1 + z/n) exp(z/n)) ,
(z)
n=1

= 0 iff
z = 0,

That is,

z C.

1
(z)

or

(1 + z/n) = 0 for some n = 1, 2, 3, . . ..

= 0 iff
z = 0,

or

z = 1, 2, . . . .

87

CHAPTER 11. EXTENSION TO COMPLEX NUMBERS


We next define
z! = (z + 1).
Note that

1
= 0 for z = 0, 1, 2, . . . .
(z)

Thus, our definition of z! should be


z 6= 1, 2, . . . .

z! = (z + 1),
That is,

n! is undefined for n = 1, 2, . . ..
Theorem 11.2.

(a)
lim

zn

1
= 0,
z!

n = 1, 2, . . . .

(b)
0! = 1

and

z! = z(z 1)!,

(c)
(z)!(z 1)! =

z 6= 0, 1, 2, . . . .

,
sin(z)

(d)
( 12 )! =

Proof. (a) For n = 1, 2, . . .,


1
1
= lim
= 0.
zn z!
zn (z + 1)
lim

z 6 Z.

88

89

CHAPTER 11. EXTENSION TO COMPLEX NUMBERS


(b) We first show 0! = 1. Observe that

Y
1

= e
((1 + 1/n) exp(1/n))
(1)
n=1

= e lim

m
Y

((1 + 1/n) exp(1/n))

i=1

= e lim (m + 1) exp
m

m
X

1/n

n=1

!
m
X
m
+
1
exp ln(m)
1/n
= e lim
m
m
n=1
!!


m
X
m
+
1
exp lim ln(m)
= e lim
1/n
m
m
m
n=1
= e e
= 1

Thus, 0! = (1) = 1. To show the recurrence on z!, we note that


1
(z + 1)
= (z + 1) exp((z + 1)) lim

= exp(z) exp()(1 + z) lim

m
Y

n=1
m 
Y

= exp(z) lim

lim

= exp(z)

n=1

1
.
=
z(z)

m+1
Y

((1 + (z + 1)/n) exp((z + 1)/n))

n=1

n+1
n

z
1+
n+1

z+1
exp
n

((1 + z/n) exp(z/n))

n=1

exp

z
m+1

m
X
1
exp
+ log(m + 1) +
n
n=1

((1 + z/n) exp(z/n))

!!



CHAPTER 11. EXTENSION TO COMPLEX NUMBERS

90

(c) Note that


(z)!(z 1)! = (1 z)(z)

and from the definition of (z), we have as in (b) that for z 6= 0, 1, 2, . . .,


(z)!(z 1)! =

m
Y
1
1
e lim
m
z(1 z)
(1 + z/n)(1 + (1 z)/n) exp(1/n)
n=1

m
Y
1
n2 exp(1/n)

=
e
lim
m
z(1 z)
(n + z)(n + 1 z)
n=1

!
m
Y
1
n2 exp(1/n)
m + 1 z n=1 (n + z)(n z)
!
! m
m
X
Y
1
1
.
exp
1/n
m
1 z 2 /n2
n=1
n=1

1
=
e
lim
m
z
=

1
e
lim
m
z

But

sin(z) = z

(1 z 2 /n2 ),

n=1

and
lim

Hence,

m
X
1
1/n
exp
m
n=1

!!

= e .

,
z 6= 0, 1, 2, . . . .
sin(z)

(d) ( 21 )! = follows from (c) by taking z = 21 .


(z)!(z 1)! =

The following is a graph of the function on the real line:


10
8
6

4
2
4

0
2
4
6
8

10

2
z

91

CHAPTER 11. EXTENSION TO COMPLEX NUMBERS

11.4

The Falling Factorial

We defined the falling factorial as


(r)n = (r)(r 1) (r n + 1),
We now define

n = 0, 1, 2, . . . ,

z!
,
zr (z n)!

r R.

r, n C.

(r)n = lim

Theorem 11.3. (a) If n = 0, 1, 2, . . ., then


r C.

(r)n = r(r 1) (r n + 1),


In particular, if r = 0, 1, 2, . . . , n 1, then (r)n = 0.
(b) If n = m where m = 1, 2, . . ., then
(r)n =

1
,
(r + 1)(r + 2) (r + m)

r C,

r 6= 1, 2, . . . , m.

Proof. (a) This part shows that our definition corresponds to our old definition. For n = 0, 1, . . .,
z!
= lim z(z 1) (z n + 1) = r(r 1) (r n + 1).
zr
zr (z n)!

(r)n = lim

(b) For n = m and m = 1, 2, . . .,


z!
zr (z + m)!

(r)n = lim

1
(z + m)(z + m 1) (z + 1)
1
=
.
(r + 1)(r + 2) (r + m)

= lim

zr

Example 11.1. For n = 0, 1, 2, . . . and r C,


(r)n =
=
=
=

(r)(r 1) (r n + 1)
(1)n (r)(r + 1) (r + n 1)
(1)n (r)n
(1)n (r + n 1)n .

CHAPTER 11. EXTENSION TO COMPLEX NUMBERS

11.5

92

The Binomial Coefficient

We defined before that


 
(r)n
r
=
,
n
n!
and we commented that
 
r
= 0,
n
We now define

n = 0, 1, 2, . . . ,

r R,

n = 1, 2, . . . .

 
r
(z)w
= lim lim
,
zr wn w!
n

r, n C.

Notice that the order of the limits is important. Also, we usually consider
only the case when n Z.
Theorem 11.4. For r C and n Z,
   (r)n
r
, n = 0, 1, 2, . . . ,
n!
=
0,
n = 1, 2, . . . .
n
Proof. This theorem shows that our new definition of the binomial coefficient
is consistent with our earlier one. Notice that
 
z!
r
= lim lim
.
zr wn (z w)!w!
n
Since y! is defined for all y 6= 1, 2, . . ., we see that there is a neighborhood
N (not including r since we are taking limits) of r such that
1
1
=
,
wn (z w)!
(z n)!
lim

z N.

Thus, for n = 0, 1, 2, . . ., we have


 
z!
r
(r)n
= lim
=
.
zr (z n)!n!
n
n!

CHAPTER 11. EXTENSION TO COMPLEX NUMBERS

93

Also, for n = 1, 2, . . ., we have


1
1
= lim
= 0,
lim
wn (w + 1)
wn w!
giving that

 
z!
r
= lim
0 = 0.
zr (z n)!
n

Recall that using Taylors Theorem (or a combinatorial argument by


treating the formula below as a formal power series),
 

X
(r)n n X r n
r
(1 + z) =
z ,
|z| < 1, r R.
z =
n
n!
n=0
n

Thus we have the following fact that we have seen before.


Theorem 11.5. For r R and n Z,
 
r
= [z n ](1 + z)r .
n

11.6

Four Basic Identities

Theorem 11.6. (a) For integers n 0 and k Z,


  
n!
, n k 0,
n
k!(nk)!
=
0,
otherwise.
k
(b) For integers n 0 and k Z,
  

n
n
=
.
k
nk

(c) For r C and k Z,



 
  
r1
r1
r
.
+
=
k1
k
k

(d) For r C and k Z,




r
k


r+k1
(1)k .
k

CHAPTER 11. EXTENSION TO COMPLEX NUMBERS

94

Proof.
(a) If k is a negative integer, we have from an earlier theorem that

n
= 0. So assume that k is a nonnegative integer. If k > n 0 then
k
 
(n)k
n
=
= 0.
k
k!

If n k 0 then

 


(n)k
n
n!
n
=
=
=
.
k
k!
(n k)!k!
nk

(b) Follows from (a) immediately. Notice that the formula does not hold
when n is a negative integer. For example, when n = 4 and k = 2, we have
 
(4)2
n
=
= (4)(5)/2 = 10,
k
2
but

 
  
n
4
n
.
= 0 6=
=
k
6
nk
(c) We know that the identity holds for integers
 r, k 1 because of a combinatorial argument using the definition that nk is the number of k-subsets of
[n]. Also, the identity works when k = 0 (since both sides equal 1). Hence
the identity works for all integer r 1 and all integer k 0. Now for each
integer k 0, both sides are polynomials of degree at most k in r and they
agree on more than k points (r = 1, 2, . . .). Thus, the identity is true for
all r C and all integer k 0. Finally, the identity holds for all negative
integer k and all r C because both sides are 0.
(d) For k = 0, 1, 2, . . .,
 
(r)k
r
=
k
k!
(r)(r 1) (r k + 1)
=
k!
(r)(r + 1) (r + k 1)
(1)k
=
k!
(r + k 1)k
=
(1)k
k!


r+k1
(1)k .
=
k


The identity is true for k = 1, 2, . . . because both sides are 0.

Chapter 12
Binomial Identities

We shall be interested in identities involving the binomial coefficient xk
where k is usually an integer, but x is a real number (or complex number,
using the extension by the polynomial argument). The identities are not to
memorize; they are here for reference and as examples.

12.1

Basic Identities

Theorem 12.1. For x C and k Z,


(a)

 

x x1
x
=
,
k
k k1
(b)

(c)

k 6= 0.

 


x
x1
k
=x
.
k
k1
 




x
x1
x
(x k)
=x
= (k + 1)
.
k
k
k+1

Proof. We shall show (a) only. The other two identities can be proved simi-

95

96

CHAPTER 12. BINOMIAL IDENTITIES


larly. Assume k 1 and x is an integer at least k. Then
 


x!
x
x
x x1
(x 1)!
=
.
=
=
k
(x k)!k!
k (x k)!(k 1)!
k k1

This shows that the identity holds for all integers x k 1. Now both sides
of the identity are polynomials in x of degree at most k and they agree on
more than k values of x. Thus, the identity holds for all x C and integer
k 1. Finally, when k = 1, 2, . . ., both sides are 0. Thus, the formula
works for all x C and all integers k 6= 0.
Theorem 12.2. For integers m, b, a with b a and x C,

 
 
b 
X
x+a
x+b+1
x+k
.

=
m+1
m+1
m
k=a
Proof. Recall that
  
 

r
r1
r1
=
+
,
k
k
k1

k Z,

r C.

Thus,

b 
X
x+k+1


b 
X
x+k
k=a

x+k

=
m+1
m+1
k=a

 

x+a+1
x+b+1
.

=
m+1
m+1



The above proof uses a standard method by taking differences. The


following are two special cases of the above identity.
Theorem 12.3. (a)


n  
X
k
n+1
=
,
m
m
+
1
k=0
(b)


n 
X
x+k
k=0

integers n 0 and m 6= 1.



x+n+1
,
n

n Z.

97

CHAPTER 12. BINOMIAL IDENTITIES

Proof. (a) Take the identity in the previous theorem and set x = a = 0,
b = n. Then it becomes

 

n  
X
k
n+1
0
=

.
m
m+1
m+1
k=0

0
= 0 and so (a) follows.
When m 6= 1, we have m+1
(b) Consider first the special case where x is a nonnegative integer m. Take
the identity in the previous theorem and set x = m, a = 0, b = n. Then it
becomes
 
 
 

n 
X
m+k
m+n+1
m
m+n+1
=

=
.
m
m
+
1
m
+
1
m
+
1
k=0
Now for integers m, k, n 0, we have

 


 

n+m+1
n+m+1
m+k
m+k
=
,
=
n
m+1
k
m
Thus, we have for integers n, m 0,

n 
X
m+k
k=0


m+n+1
.
n

Now both sides are polynomials in m with degrees at most n and they are
equal for more than n values of m. This shows that we can replace m with
x C, giving that for integer n 0 and x C,

n 
X
x+k
k=0


x+n+1
.
n

The identity now follows by observing that both sides are 0 when n is a
negative integer.
Theorem 12.4.
n
X

 


x
n x1
(1)
= (1)
,
k
n
k=0
k

n Z.

98

CHAPTER 12. BINOMIAL IDENTITIES

Proof. We give two proofs here. We can take the identity in (b) in the
previous theorem and replace x with x 1 throughout to get
 

n 
X
x 1 + k
x + n
=
,
n Z.
k
n
k=0
We next negate the upper entry:
 


x 1 + k
k x
,
= (1)
k
k
to get

n  
X
x
k=0

x + n
n


x1
,
n

= (1)


x1
,
n

n Z.

Another method is by generating function as follows. Suppose that r R.


Then
n
n  
X
X
r
(1)k =
[z k ](1 z)r
k
k=0
k=0
= [z n ](1 + z + z 2 + )(1 z)r
(1 z)r
= [z n ]
1z
n
= [z ](1 z)r1


n r1
.
= (1)
n

Then polynomial argument extends r R to r C.


How about

r
km k


? Following the above argument

X r 

km

m
X

[z k ](1 + z)r

k=0
m

= [z ](1 + z + z 2 + )(1 + z)r


(1 + z)r
,
= [z m ]
1z

which does not look promising! Note that sums often do not have closed
forms.

99

CHAPTER 12. BINOMIAL IDENTITIES


Theorem 12.5. For integer m,
X r
X m + r
k mk
(x)k (x + y)mk .
x y
=
k
k
km
km

Proof. If m < 0 then both sides are 0 because the binomial coefficients
are 0. So assume m 0. Suppose for now that r is an integer satisfying
m r 0. Then
LHS =

m+r
X
k=0


m + r k mk
x y
= (x + y)m+r y r ,
k

and
RHS =


r 
X
r
k=0

(x)k (x + y)mk

x
1
= (x + y)
x+y
m+r r
= (x + y)
y
= LHS.
m

r

Thus the formula holds for r Z satisfying 0 r m. Now both sides


are polynomials of r with degree at most m. But both sides agree on m + 1
values of r. Thus, the formula works for all values of r.

12.2

Vandermondes Convolution

Here is Vandermondes identity and its variations. All unspecified variables


are real numbers and can be extended to complex numbers by polynomial
argument.
Theorem 12.6.
(12.1)

(a) For integers m, n,


X  r  s   r + s 
=
.
m+k
nk
m+n
k

CHAPTER 12. BINOMIAL IDENTITIES


(b) For integer 0 and integers m, n,
X   s   + s 
=
.
(12.2)
m
+
k
n
+
k

m
+
n
k
(c) For integer 0 and integers m, n,


X  s + k 
k
+m s m
.
(1) = (1)
(12.3)
n
m+k
n
k
(d) For integer m 0 and integers , n,


X  k  s 
k
+m s m 1
.
(1) = (1)
(12.4)

n
k

n
m
k
(e) For integers , m 0 and integers n q 0,

 


X
+q+1
q+k
k
.
=
(12.5)
m
+
n
+
1
n
m
k=0
Proof. (a) For integers m, n,
X  r  s 
X
=
[z m+k ](1 + z)r [z nk ](1 + z)s
m
+
k
n

k
k
k
= [z m+n ](1 + z)r (1 + z)s


r+s
.
=
m+n

(b) For integer 0 and integers m, n,




X
X   s 

s
=
mk
n+k
m+k
n+k
k
k

+s
=
,
m+n
where the last equality follows from (a).
(c) Observe that for integer 0 and integer m,
X 

(1)m+k (1 z)m+k .
z = (1 (1 z)) =
m
+
k
k

100

101

CHAPTER 12. BINOMIAL IDENTITIES


Thus, for integer 0 and integer m,
X 

sm
(1)m+k (1 z)s+k ,
z (1 z)
=
m
+
k
k
giving that for integer 0 and integers m, n,


X 
m+k+n s + k
n
sm
(1)
.
[z ]z (1 z)
=
m
+
k
n
k
Therefore, for integer 0 and integers m, n,
X  s + k 
(1)k = [z n ](1)m+n z (1 z)sm
n
m+k
k

= [z n ](1)m+n (1 z)sm


m+n s m
.
= (1)
n

(d) Recall that



  
n
n
,
=
nk
k
and that

Now consider


k
m

r
k

integer n, k and n 0,


r+k1
,
k

k Z, r C.

where , k, m are integers and k 0. Then we have



 
 
m 1
k
k
(1)km .
=
=
km
km
m

Now if k is a summation index, we have changed the given binomial coefficient


to one involving k in the lower entry. Therefore, we have



X
X  k  s 
s
m 1
k
m
(1) =
(1)
km kn
k

n
m
k
k

CHAPTER 12. BINOMIAL IDENTITIES


Now since m 0, we see that

m1
km

102

= 0 if k > . Thus,




X
X  k  s 
m 1
s
k
m
(1) =
(1)
m
km kn
kn
k
k



X
m 1
s
m
=
(1)
km kn
k


m s m 1
,
= (1)
nm
which is the RHS of the given formula. Notice that induction can be used to
prove the formula, but it can be quite tedious. I shall include an induction
proof as an example. Let us prove the formula by induction on m.
Basis. When m = 0, using the formula


X r 
k
r1
,
integer ,
(1) = (1)

k
k
we have
LHS =
=
=
=

X s 
(1)k
kn
k
X s
(1)k+n
k
kn


n
n s 1
(1) (1)
n
RHS.

Induction Step. Let m Z and m 0. Assume as induction hypothesis


that for s C and integers , n, m satisfying m m 0,


X  k  s 
k
m s m 1
.
(1) = (1)
mn
kn
m
k

CHAPTER 12. BINOMIAL IDENTITIES


Consider the case when m = m + 1. Then since m + 1 6= 0,
X  k  s 
(1)k
LHS =
+1
k

n
m
k
X k  k 1 s 
=
(1)k

kn
m +1
m
k



X k k1
s
(1)k .
=
+1

n
m
m
k1
Now using the induction hypothesis, we have
X n  k 1 s 
(1)k

m +1
m
kn
k1


s m 1
1+m n
= (1)
.
m + 1 1 m n


and the induction hypothesis, we have
Also, using k xk = x x1
k1
X n k  k 1 s 
(1)k

kn
m +1
m
k1



X s
s1
k1
=
(1)k

+1
k

1
m
m
k1


s
s m 2
1+m
=
.
(1)
m n 2
m + 1

Thus, the left hand side equals (1)1+m times






s
s m 1
s m 2
n

m + 1 1 m n
m + 1 m n 2




n
ns
s m 2
s m 2
=
+
m + 1 1 m n
m + 1 m n 2




n
m n 1
s m 2
s m 2
=

m + 1 1 m n
m + 1
m n 1


s m 2
=
,
m n 1

103

104

CHAPTER 12. BINOMIAL IDENTITIES


where in the last but one step, we used the formula


 
x
x
,
integer k.
= (k + 1)
(x k)
k+1
k
Thus,
LHS = (1)

1+m


s m 2
,
m n 1

which is equal to the RHS of the formula when m = m + 1. This completes


the induction step.
(e) For integers , q, m, n, k satisfying k 0 and q + k 0, we have






k
k
m 1
km
=
= (1)
,
m
km
km






n 1
q+k
q+k
q+kn
.
= (1)
=
q+kn
q+kn
n
Thus, for integers , q, m, n satisfying , q 0, we have



X
q+k
k
k=0



n 1
m 1
=
(1)
km q+kn
k=0



X
n 1
m 1
m+qn
.
= (1)
km q+kn
k=0

Now, if m, 0 then


m 1
= 0,
km
and if n q 0 then


n 1
= 0,
q+kn

m+qn

whenever k Z and k > ,

whenever k Z and k < 0.

105

CHAPTER 12. BINOMIAL IDENTITIES


Thus,



X
k
q+k
k=0

= (1)

m+qn

= (1)m+qn




X
m 1
n 1
km q+kn
k=0

X m 1  n 1 
km q+kn

m n 2
m+qn


k

= (1)m+qn

+q+1
=
m+qn


+q+1
=
,
m+n+1

since + q + 1 Z+ .

This completes the proof of the identities.


Example 12.1. Consider this sum: For integer n 0,
X n + k 2k  (1)k
.
k
+
1
2k
k
k0
We shall try to simplify it by using one of the convolution identities. Observe
that

 
n+k
2k
1
(n + k)!
1
=
2k
k k+1
(n k)!k!k! k + 1


n!
n+k
=
n
(n k)!(k + 1)!



1
n+k
n+1
=
.
n+1
n
k+1
We have thus reduced the # occurrences of k in the summand to 2, and the

CHAPTER 12. BINOMIAL IDENTITIES

106

sum looks like a convolution sum:


X n + k 2k  (1)k
2k
k k+1
k0



1 X n+k
n+1
=
(1)k
n
k+1
n + 1 k0






1
n+1
1 X n+k
n1 n+1
k
(1)
=
(1)1
n
k+1
n+1 k
n+1
n
0





1
n+1
n1
1 X n+k
(1)k +
=
n
k+1
n+1 k
n+1
n



1 X n+k
n+1
=
(1)k + n,0 .
k+1
n
n+1 k
Recall that from (12.3) that for integer 0 and integers m, n,


X  s + k 
k
+m s m
(1) = (1)
,
m+k
n
n
k
where we shall take s = n, m = 1 and = n + 1 to get
X n + k 2k  (1)k
2k
k k+1
k0



n+1
1 X n+k
(1)k + n,0
=
n+1 k
n
k+1


(1)n+2 n 1
=
+ n,0
1
n+1
= n,0 .

Chapter 13
More Binomial Identities
We have seen several methods in proving identities (without using the computer). We shall try to give a brief description of some common techniques.

13.1

Negating the Upper Entry

Recall that


r
k


r+k1
(1)k ,
k

k Z, r C.

Notice that we have used this method in proving the identities (12.4) and
(12.5). We refer the reader to those proofs for examples.

13.2

Differences

Observe that if
then

g(x) = f (x) = f (x + 1) f (x),


b
X
x=a

g(x) = f (b + 1) f (a).
107

108

CHAPTER 13. MORE BINOMIAL IDENTITIES


Also, the binomial coefficient can be written as a difference:



 
  
x
x
x+1
x
,
=

=
m+1
m+1
m+1
m

and the above is useful when the index of the summation is in the upper
entry:

 

b  
X
a
b+1
x
.

=
m
+
1
m
+
1
m
x=a
We have in fact come across the above formula before.
Example 13.1. Get a closed form for


h
X

m
k
n ,
k

k=0

integers n m h 0.

Solution. First observe that some factors in the summand can be canceled:



m
m! (n k)!
nk
m!(n m)!
1
(n k)!
k
.
=
= n
n =
nm
n! (m k)!
n!
(n m)!(m k)!
k
m

Therefore, the sum becomes



h 
1 X nk

=
n
nm
m k=0

 

h 
1 X
nk+1
nk


n
nm+1
nm+1
m k=0

 

1
nh
n+1

.

n
nm+1
nm+1
m

If h = m, then we have
m
X
k=0

m
k
n
k

=
=

n+1

n
nm+1
m

n+1
.
nm+1

We shall come back to this when we talk about Gospers algorithm later.

109

CHAPTER 13. MORE BINOMIAL IDENTITIES

13.3

Higher Order Differences

Define the shift operator E by


E(f (x)) = f (x + 1).
Then
f (x) = f (x + 1) f (x) = (E 1)f (x),

where 1 is the identity operator on f . Then,

n f (x) = (E 1)n f (x)


n  
X
n
(1)nk E k (f (x))
=
k
k=0
n  
X
n
=
(1)nk f (x + k).
k
k=0
Here is a simple example.
Example 13.2. Since
  
   

x
x+1
x
x

=
,
k
k
k
k1

k Z.

Applying the difference operator repeatedly for n 0 times to get


  

x
n x
=
,
integer m and integer n 0.

m
mn
Thus, for integer m and integer n 0, we have
 


x
n x
=
m
mn
 

n
X n
x
nk k
(1) E
=
m
k
k=0




n
X
n
nk x + k
(13.1)
,
=
(1)
m
k
k=0
which is in fact equivalent to the convolution identity (12.3).

CHAPTER 13. MORE BINOMIAL IDENTITIES


Example 13.3. Observe that for integer m,
(r)m = (r + 1)m (r)m


(z + 1)!
z!
= lim

zr
(z + 1 m)! (z m)!


z!
= lim
((z + 1) (z + 1 m))
zr
(z + 1 m)!
= lim m(z)m1
zr

= m(r)m1 .
This shows that for m Z,
n (r)m = (m)(m 1) (m n + 1)(r)mn .
Now take r = x 1 and m = 1 and we have for integer n 0,
n (x 1)1 = (1)(2) (n)(x 1)1n = (1)n n!(x 1)n1 .
Recall that for integer k 1,
(r)k =

1
,
(r + 1)(r + 2) (r + k)

giving that
(x 1)1n =
and hence
n

(x 1)1
Thus,

1
,
(x)(x + 1)(x + 2) (x + n)

(1)n n!
.
=
(x)(x + 1)(x + 2) (x + n)

(1)n n!
= n (x 1)1
(x)(x + 1)(x + 2) (x + n)
n  
X
n
(1)nk E k ((x 1)1 )
=
k
k=0
n  
X
n
=
(1)nk (x 1 + k)1
k
k=0

n
X n
1
(1)nk
=
,
k
x
+
k
k=0

110

111

CHAPTER 13. MORE BINOMIAL IDENTITIES

1
which is essentially a partial fraction of (x)(x+1)(x+2)(x+n)
. Notice that it is
1
actually very easy to obtain a partial fraction of (x)(x+1)(x+2)(x+n) . Suppose
that
n
X
Ai
1
=
.
(x)(x + 1)(x + 2) (x + n)
n+i
i=0

To find Ai , we can multiply both sides by (x)(x + 1)(x + 2) (x + n) and


set x = i to get
n
Y
1 = Ai
(i + j),
j=0,j6=i

giving that

 
(1)i
(1)i n
.
Ai =
=
i
(n i)!i!
n!

Example 13.4. We have from Assignment 7, Q4, that


X nx + k 1
= xn .
n
k
k

, we get that
By applying the m-th difference to x+k1
n







X n
X n x+k1
m x+k1

=
k
n
k
nm
k
k






m
X n X
x+k1
m
mj j
(1)
E
=
n
j
k
j=0
k


m  
X  n X
m
mj x + k 1 + j
(1)
=
k
j
n
j=0
k
m  
X
m
(1)mj (x + j)n
=
j
j=0


m
X
m
=
(1)j (x + m j)n .
j
j=0
If x = 0 then
X n k 1 
k

nm

m  
X
m
j=0

 
n
.
(1) (m j) = m!
m
j
j

112

CHAPTER 13. MORE BINOMIAL IDENTITIES

13.4

Inversion

Two sequences an,m , bn,m is an inversion pair if


X
an,k bk,m = n,m .
k

Theorem 13.1. Suppose that an,m , bn,m is an inversion pair. Then


X
X
gn =
bn,k fk
=
fn =
an,k gk .
k

Proof.
X

an,k gk =

an,k

X X
j

bk,j fj

an,k bk,j

fj

n,j fj

= fn .


 
n n
n n
is an inversion
, (1)
From Assignment 3, Q3, we see that (1)
m
m




n n
n n
pair. Similarly, one can show that (1) m , (1) m is an inversion pair
also.
Also from (13.1), we have for integer n 0 that



 X
n  
n
x
nk x + k
(1)
.
=
k
m
mn
k=0

Setting x = 0 and m Z, we see that



  
n  
X
0
n
nk k
= n,m .
=
(1)
n

m
m
k
k=0

n
and itself is an inversion pair. That is,
Thus, we see that (1)n m


X  n
X n
n
n
gk .
fk
iff
fn = (1)
gn = (1)
k
k
k
k

113

CHAPTER 13. MORE BINOMIAL IDENTITIES


Here is a simple example.
Example 13.5 (Stirling numbers of the second kind again). Recall that
can be defined as
X m
m
x =
(x)j .
j
j

n
m

This gives that by setting x = n Z,

X mn
j!
(1) n = (1)
.
j
j
j
n m

Hence, by taking

 
m
,
fj = j!
j

n m

gn = (1) n ,
we have
gn = (1)

X  n
j

fj ,

and its inversion gives


 
X n
X n 
m
n
n
(1)k k m .
gk = (1)
= fn = (1)
n!
k
k
n
k
k
That is,

  X
n  
n
m
(1)nk k m .
n!
=
k
n
k=0

Notice that we have seen this formula when studied inclusion-exclusion.


Example 13.6 (Derangements again). Let Dk be the number of derangements on [k]. That is, Dk is the number of permutations on [k] such that
i 6= i for all i [k]. Let fj be the number of permutations on [n] such that
there are exactly j elements x [n] with x = x. Then obviously
 
n
X
n
Dnj .
n! =
fj ,
fj =
j
j=0
Thus, we have
n! =

n  
X
n
j=0

Dnj =

n  
X
n
j=0

Dj .

CHAPTER 13. MORE BINOMIAL IDENTITIES

114

The inversion of the above formula gives that


n  
n
X
X
n
(1)j
n
j
Dn = (1)
(1) j! = n!
.
j
j!
j=0
j=0
We obtained the same formula using inclusion-exclusion.

13.5

Generating Functions

We have seen how identities are proved using generating functions. Here are
two examples:
Example 13.7 (Generalized Fibonacci numbers again). Let m be an integer
and m 0. Consider

m 
X
mk k
Im =
x .
k
k=0

Then since


 
 

mk
m1k
m1k
=
+
,
k
k
k1
we have for m 1 that

m 
X
mk k
x
Im =
k
k=0
m1
X m k 
xk
=
k
k=0
m1
X m 1 k  m 1 k 
+
xk
=
k
k

1
k=0
m1
X m 2 (k 1)
= Im1 + x
xk1
k

1
k=1
= Im1 + xIm2 .

Notice that
I0 = 1,

and

 
 
1 0
0
I1 =
x +
x = 1.
0
1

115

CHAPTER 13. MORE BINOMIAL IDENTITIES

Thus Im , m 0, are generalized Fibonacci numbers studied before. We


found that


m+1 
m+1 !
1
1 + 1 + 4x
1 1 + 4x
Im =

.
2
2
1 + 4x
In particular, for x = 1, we have

1 + 3
= e 3 i,
2

= e 3 i .

Thus, for x = 1,
Im =


m 
X
mk
k=0

(1)k

k

 (m+1)
(m+1)
e 3 i e 3 i

1
=
3i
2
= sin((m + 1)/3)
3
m 0, 1 (mod 6)
1,
0,
m 2, 5 (mod 6)
=

1, m 3, 4 (mod 6).

Example 13.8. How about this one? For integers m, n 0,


X  n + k 2k  (1)k
.
Im,n =
k
+
1
m
+
2k
k
k
When m = 0, we found in an earlier example that it can be reduced to a
convolution identity, and
X n + k 2k  (1)k X n + k 2k  (1)k
I0,n =
=
= 0,n .
k
2k
k
2k
k
+
1
k
+
1
k
k0
In general, since


n+k
m + 2k


 

n+k1
n+k1
=
+
,
m + 2k
m + 2k 1

CHAPTER 13. MORE BINOMIAL IDENTITIES

116

we see that
Im,n = Im,n1 + Im1,n1 ,

integers m, n 1.

Also, in addition to I0,n = 0,n , we have


X  k 2k  (1)k
Im,0 =
= m,0 .
k k+1
m + 2k
k
Thus, Im,n is completely determined by the above recurrence and the boundary conditions I0,n = 0,n , Im,0 = m,0 . In fact,


n1
,
n, m 1.
Im,n =
m1

n
satisfies the same recurrence and it can be checked
This is so because m
easily that the boundary conditions are similar.

Chapter 14
A Generalized Urn Model
The purpose here is to introduce an example. The example consists of three
parts:
(1) Finding an optimal solution;
(2) Simplification of the solution;
(3) Asymptotics.
The example is a generalization of the model in a paper by Chen, Zame,
Odlyzko and Shepp, appeared in SIAM J. Discrete Math. 11, 185-195, 1998.

14.1

The Model

An urn contains two types of balls: p +t balls and m 1 balls, where t


is a positive integer. At each stage,
(1) decide whether to place a bet,
(2) pick a ball (without replacement) at random from the urn,
(3) if decision in (1) is to place a bet, then you lose $1 if you pick a 1
ball and you gain $t if you pick a +t ball,
(4) if decision in (1) is not to place bet, then nothing happens.
The process is repeated until the urn is empty.

117

CHAPTER 14. A GENERALIZED URN MODEL

14.2

118

Realizations

In order to study this urn model, we shall need some enumeration techniques.
We start with the following basic observation. Given that the urn has m 1
balls and p +t balls, we define a realization as a sequence of m + p balls
drawn without replacement from the urn.
Lemma 14.1. Each realization is equally likely, and the probability that a
1
particular realization happens is m+p
.
(m)
Proof. This is actually quite obvious. In order to be rigorous, we shall give a
proof based on induction on the number m + p of balls. If there is one ball in
the urn, then
 there is one realization and the probability of that happening
1
is 1 = 1/ 1 . Suppose next as induction hypothesis that the lemma holds for
less than m + p balls. Consider the situation when there are m + p balls with
m 1 balls and p +t balls, and let be a realization. If the realization
is such that the first ball drawn is a 1 ball, then using the induction
hypothesis,
m
1
1


P () =
m+p1 = m+p .
m + p m1
m

If on the other hand the realization is such that the first ball drawn is a +t
ball, then
p
1
1


P () =
m+p1 = m+p .
m+p
m
m
This completes the induction step and hence the lemma is proved.

CHAPTER 14. A GENERALIZED URN MODEL

14.3

119

The Optimal Strategy

An optimal strategy is one that maximizes the expected gain, given m, p, t.


Define
A(m, p) =

expected gain if bet on the first ball


and follow an optimal strategy subsequently,

B(m, p) =

expected gain if do not bet on the first ball


and follow an optimal strategy subsequently,

G(m, p) =

expected gain under the optimal strategy.

Then
G(m, p) = max(A(m, p), B(m, p))
p
m
A(m, p) =
(t + G(m, p 1)) +
(1 + G(m, p))
m+p
m+p
p
m
B(m, p) =
G(m, p 1) +
G(m, p)
m+p
m+p
The last two equations show that
A(m, p) =

pt m
+ B(m, p).
m+p

Thus, an optimal strategy is to place a bet on the next ball if pt > m and
do not bet on the next ball if otherwise.
Let Xn be the value of the urn at stage n (after having chosen n balls).
Then
X0 = pt m,
Xm+p = 0.
Our optimal strategy is to bet on the next (n + 1-st) ball iff Xn > 0. Observe
that pt m is the expected gain if the strategy is to bet on all balls. Note
also that if Xi = x is known then one can calculate the current numbers a, b
of +t balls and 1 balls respectively. This is because
a + b = m + p i,
from which a and b can be found.

and

at b = x,

CHAPTER 14. A GENERALIZED URN MODEL

14.4

120

The Value of G(m, p)

Suppose that Xn = 0 and n 6= m + p. Let


= n = min{h > n : Xh 0}.
Let Gn be the gain from stage n + 1 to stage , that is, according to our
optimal strategy,

Xn+1 X , if Xn+1 = +1,
Gn =
0,
otherwise.
We shall concentrate on the case that m pt. The other case seems to
be more difficult.
Lemma 14.2. Suppose that m pt. Then
X
E(Gn | Xn = 0) P (Xn = 0).
G(m, p) =
n6=m+p

Proof. Since X0 0, the player under our optimal strategy will not place
bets until after the first time, say time n, when the value of the urn is at least
0. The player will then gain Gn until the next time X 0. The process is
then repeated until the urn is empty. Thus, if

1, if Xn = 0,
n =
0, if Xn 6= 0,
then the gain of the player (under the optimal strategy) is
X
Gn n ,
n6=m+p

and hence the expected gain is


X
X
G(m, p) =
E(Gn n ) =
E(Gn | Xn = 0) P (Xn = 0).
n6=m+p

n6=m+p

The rest of the section is devoted to calculating E(Gn | Xn = 0) and


P (Xn = 0). To calculate E(Gn | Xn = 0), first observe the following table
on the possible outcomes of Gn given that Xn = 0:

121

CHAPTER 14. A GENERALIZED URN MODEL


Xn+1
t
+1
+1
+1
..
.

action
no bet
start betting
start betting
start betting
..
.

X
t
0
1
2
..
.

Gn
0
1
2
3
..
.

+1

start betting

(t 1)

Lemma 14.3.
P (Gn = | Xn = 0) =

1
,
t+1

= 0, 1, 2, . . . , t.

Proof. Observe that in order to have Xn = 0, we must have at time n that


for some k 1, there are k +t balls and kt 1 balls remaining in the
urn. This is so because Xm+p = 0. Thus
P (Gn = 0 | Xn = 0) = P (the next ball is a +t)
k
=
k + kt
1
.
=
t+1
Assume that is an integer and that 1 t. We shall complete our proof
by showing that each realization in which Xn = 0 and Gn = is in a 1-1
correspondence with a realization in which Xn = 0 and Gn = 0. This
proves the lemma because
P (Gn = | Xn = 0) = P (Gn = 0 | Xn = 0) =

1
.
t+1

Recall that each realization is a sequence of m + p balls drawn without


replacement from the urn and that Xn is the value of the urn at time n after
n balls have been drawn. For each realization in which Xn = 0, Xn+1 =
1, Gn = , we have X = + 1, we relocate the balls drawn in stages
n + 1, n + 2, . . . , 1 to the end of to obtain a realization . (Note
that for future reference, the total value of these balls is t 1 because
X 1 = t + 1 and Xn = 0.) Now since the ball drawn at stage in
is a +t ball, we see that is a realization in which Xn = 0, Xn+1 =

122

CHAPTER 14. A GENERALIZED URN MODEL

t, Gn = 0. This process can be reversed. For each realization in which


Xn = 0, Xn+1 = t, Gn = 0, let
h = h = max{j : Xj = t 1},

= 1, 2, . . . , t.

Now h exists because Xn+1 = t and that the Xs can only increase by 1.
Also, the ball drawn at stage h + 1 must be a 1 ball because if it were
a +t ball, then Xh+1 = 2t 1 and there would be a j > h such that
Xj = t 1. Now relocating the balls in stages j + 1, j + 2, . . . , m + p
to immediately after stage n gets back a realization with Xn = 0, Xn+1 =
1, Gn = .
Thus,
t

1 X t
= .
E(Gn | Xn = 0) =
t + 1 i=0
2

It therefore follows from Lemma 14.2 that for m pt,


X
G(m, p) =
E(Gn | Xn = 0) P (Xn = 0)
n6=m+p

t X
P (Xn = 0).
2 n6=m+p

Now for which values of n 6= m + p can Xn = 0? Since Xm+p = 0, we


must have, for some k > 1, that there are k +t balls and kt 1 balls
remaining in the urn at stage n. Since each realization is equally likely, we
have for stage n = m + p k kt for some k 1,


kt+k m+pkkt
P (Xn = 0) =

pk

m+p
p

kt+k
k

Thus, for m pt,


p

tX
G(m, p) =
2 k=1

We have thus proved the following lemma.

m+pkkt
pk

m+p
p

CHAPTER 14. A GENERALIZED URN MODEL

123

Lemma 14.4. For m pt,




p 
X
kt + k
m + p k kt

.
m+p
k
p

k
p
k=0

t
t
G(m, p) = +
2 2

Proof. The lemma follows from the observation that for k = 0,




kt+k m+pkkt
k

14.5

pk

m+p
p

= 1.

A Simplified G(m, p)

Theorem 14.1. For integer n 0 and any r, t,


  X


n
n 
X
r + (n k)t kt
k r + nt k
=
t
.
nk
k
nk
k=0
k=0
We shall prove the theorem later. For now, let us apply the theorem to
G(m, p). Recall that for m pt,


p 
m + p k kt
t
t 1 X kt + k
.
G(m, p) = + m+p
k
pk
2 2 p k=0

By taking r = m + p nt and then replacing t with t + 1 and n with p, the


formula in Theorem 14.1 gives that


 X

p
p 
X
m + p k(t + 1) k(t + 1)
k m+pk
.
(t + 1)
=
p

k
k
p

k
k=0
k=0
This shows that for m pt,
p
X


m+pk

(t + 1)
m+p
pk
p
k=0


p
t
t 1 X
nk m + k
.
= + m+p
(t + 1)
k
2 2 p k=0

t
t
G(m, p) = +
2 2

124

CHAPTER 14. A GENERALIZED URN MODEL


Next, we recall (see Theorem 12.5) that for integer m,
X m + r 
X r + k 1 
k mk
x y
=
xk (x + y)mk .
k
k
km
km
Thus, by taking x = 1, y = t, m = p and then r 1 = m, we have


p 
p 
X
p + m + 1 pk X m + k
(1 + t)pk .
t
=
k
k
k=0
k=0
The following lemma now follows.
Lemma 14.5. For m pt,
t
t
G(m, p) = +
2 2


p 
X
p + m + 1 pk

t .
m+p
k
p
k=0
1

The rest of this section is devoted to proving Theorem 14.1. We say


a sequence of integers +1s and ts is a (t, n) sequence if the sequence
a1 , a2 , . . . , an+nt contains nt +1s and n ts such that all partial sums
Xi =

i
X

ai ,

i = 0, 1, 2, . . . , n + nt,

X0 = 0,

j=1

are nonnegative. Let gn (t) be the number of (t, n) sequences. We define


g0 (t) = 1.
Lemma 14.6.
gn (t) =

n0 +n1 +nt =n1


ni 0

gn0 (t)gn1 (t) gnt (t),

n 1.

Proof. Let a1 , a2 , . . . , an+nt be a (t, n) sequence and Xi , 0 i nt + n, be


its partial sums. Define
kj = max{h : h < nt + t, Xn = j},

j = 0, 1, . . . , t.

Notice that necessarily, Xn+nt = 0, Xnt+n1 = t, ant+n = t and kt =


nt + n 1. Since the Xs can only be increased by +1 each time, we see

CHAPTER 14. A GENERALIZED URN MODEL

125

that the kj s are well-defined. Note also that by maximality in the definition
of kj , we must have akj +1 = +1 and that Xh Xkj +1 for all h satisfying
kj + 1 h < nt + n. Now it is clear that the sequences
(a1 , a2 , . . . , ak0 ),
(ak0 +2 , . . . , ak1 ),
..
.
(aki1 +2 , . . . , aki ),
..
.
(akt1 +2 , . . . , akt )
are all (t, ni ) sequences for some ni 0, i = 1, 2, . . . , t. The total lengths of
these sequence is nt + n t 1 because one t and t +1s are dropped
from the original sequence. Furthermore, since only one t is dropped,
we must have n0 + n1 + nt = n 1. The lemma now follows because the
above process can be reversed to obtain a (t, n) sequence.
We next write for t 2 and n 0,

G(t)
n = gn (t 1).

Then from the above lemma, we have


G(t)
= gn (t 1)
n
X
=

n0 +n1 +nt1 =n1


ni 0

n1 +n2 +nt =n1


ni 0

n1 +n2 +nt =n1


ni 0

gn0 (t 1)gn1 (t 1) gnt1 (t 1)

gn1 (t 1)gn2 (t 1) gnt (t 1)


(t)
(t)
G(t)
n 1 Gn 2 Gn t .

Also,
G0 (t) = g0 (t 1) = 1.

For t 2, let Bt (z) be the generating function


X (t)
Bt (z) =
Gk z k .
k0

126

CHAPTER 14. A GENERALIZED URN MODEL


(t)

Then it follows from the recurrence on Gn that


X
n
Bt (z) 1 =
G(t)
n z
n1

n1 n1 +n2 +nt =n1


ni 0

i=1,2,...,t
ni 0

= z

t
Y
i=1

(t)
(t) n
G(t)
n 1 Gn 2 Gn t z

(t)
(t) n
G(t)
n 1 Gn 2 Gn t z

ni
G(t)
ni z

ni 0
t

= zBt (z) .
Therefore, we have for t 2,

Bt (z) = 1 + zBt (z)t .


We shall need Lagranges inversion formula to expand Bt (z). Below is
Lagranges inversion formula in its simplest form. We shall not prove it.
Theorem 14.2 (Lagranges Inversion Formula). Suppose that (y) is analytic at y = y0 and (y0 ) 6= 0. If
y = y0 + z(y),
then an analytic function f (y) can be expanded as a power series in z by
f (y) = f (y0 ) +
Also,

X
z n dn1
(f (y)(y)n )
n1
n!
dy
n=1

.
y=y0

X z n dn
f (y)
=
(f (y)(y)n )
1 z (y) n=0 n! dy n
To apply LIF to
Bt (z) = 1 + zBt (z)t ,

.
y=y0

127

CHAPTER 14. A GENERALIZED URN MODEL


we set
y = Bt (z),
and get

(y) = y t ,

y0 = 1,

f (y) = y r ,

X

z n dn1
r1 nt
Bt (z) = f (1) +
ry
y
n! dy n1
n=1
r

Thus, for n 1,

r Z+ ,
.

y=1

r dn1 nt+r1
y
n! dy n1
y=1
r
(nt + r 1)n1
=
n!


r
nt + r
=
.
nt + r
n

[z n ]Bt (z)r =

Also, if we write
G

(t,r)

then

Bt (z)r
,
(z) =
1 ztBt (z)t1

Bt (z)r
1 ztBt (z)t1
f (y)r
=
1 z (y)

X
z n dn
=
(f (y)(y)n )
n
n!
dy
n=0

G(t,r) (z) =

n=0

y=1

z d nt+r
y
n! dy n

y=1

zn
(nt + r)n
n!
n=0


X
nt + r n
=
z .
n
n=0

Also,
G

(t,0)

 
X
ztBt (z)t1
1
nt n
=1+
=
z .
(z) =
t1
t
1 ztBt (z)
Bt (z) ztBt (z)
n
n=0

128

CHAPTER 14. A GENERALIZED URN MODEL


Writing
H (t,r) (z) = G(t,r) (z)G(t,0) (z) =
we have
H

(t,r)

Bt (z)r
(z) =
1 ztBt (z)t1

Bt (z)r
,
(1 ztBt (z)t1 )2

ztBt (z)t1
1+
Bt (z) ztBt (z)t

= G(t,r) (z) + ztH (t,r+t1) (z).

Repeatedly applying the above recurrence, we obtain for any integer n 0,


!
n1
X
(t,r)
i (t,r+i(t1))
H (z) =
(zt) G
(z) + (zt)n H (t,r+n(t1)) (z).
i=0

Using the above identity, we obtain that


n

[z ]H

(t,r)

(z) = t H

(t,r+n(t1))

(0) +

n1
X

[z ni ]ti G(t,r+i(t1)) (z).

i=0

Note that H (t,r+n(t1)) (0) = 1 from the definition of H (t,r) (z), and that since
G

(t,r)

(z) =



X
nt + r
n=0

zn,

we have
[z

ni

]G

(t,r+i(t1))

(z) =

r + i(t 1) + (n i)t
ni


r + nt i
.
ni

Hence
n

[z ]H

(t,r)

 X

n1 
n 
X
r + nt i i
i r + nt i
(z) = t +
=
t
t.
ni
ni
i=0
i=0
n

On the other hand,


H (t,r) (z) = G(t,r) (z)G(t,0) (z) =



X
nt + r n
z
n
n=0

 
X
nt
n=0

zn

129

CHAPTER 14. A GENERALIZED URN MODEL


and so
n

[z ]H

(t,r)

(z) =

 
n 
X
(n k)t + r kt
nk

k=0

We have thus shown that for integers n 0, r 1 and t 2,



  X
n 
n 
X
r + nt i i
(n k)t + r kt
t.
=
n

i
k
n

k
i=0
k=0
Now the polynomial argument extends r, t to any numbers, and hence Theorem 14.1 is proved.

14.6

Asymptotics

Recall that for m pt, we have


t
t
G(m, p) = +
2 2


p 
X
m + p + 1 pk

t .
m+p
k
p
k=0
1

We shall assume t is fixed and investigate the behavior of G(m, p) when


m, p . We shall consider only the case m/pt > 1. Need to refer to
old notes for other cases.
Theorem 14.3. For any fixed integer t 1, if
lim G(m, p) =

Proof. Let
tk =
Then
rk =

t+1
,
2( 1)

m
p

t as m , then

p .


m + p + 1 pk
t .
k

m+p+1k1
tk+1
.
=
tk
k+1
t

Since k p, we have
m+1
m
rk
=
t(p + 1)
pt

1+
1+

1
m
1
pt

130

CHAPTER 14. A GENERALIZED URN MODEL


Furthermore, for k p p1/2 , we have
m + p1/2
m
rk
=
1/2
(1 + p p )t
pt

p1/2
m
p1/2 1
p

1+
1

This shows that for k satisfying p p1/2 k p, there are functions f1 (p)
and f2 (p) which do not depend on k and which tend to 0 as p such
that
(1 + f1 (p)) rk (1 + f2 (p)).
For p p1/2 k p, we write

rk = (1 + o(1))
to denote the fact that rk can be bounded above and below by functions,
independent of k, that tend to 0 as p . Hence we have as p that
X m + p + 1
tpk
k
pp1/2 kp
X
= tp
((1 + o(1))k
0kp1/2

1/2

1 ((1 + o(1))p
1 ((1 + o(1))1
1
= tp
(1 + o(1))
1 1

(1 + o(1)).
= tp
1

tp

Also, observe that for k p,


rk

m+p+1p
> 1,
(p + 1)t

for all large enough p.

It follows that for k p p1/2 , we have


tk tpp1/2 ,
and

tpp1/2 = tp ((1 + o(1)))p

1/2

131

CHAPTER 14. A GENERALIZED URN MODEL

giving that as p ,
X m + p + 1 
1/2
tpk ptp ((1 + o(1)))p = tp o(1) = o(tp ).
k
1/2
0kpp

Thus,

p 
X
m+p+1
k=0

(1 + o(1))
1



m+p+1
(1 + o(1)).
=
1
p

tpk = tp

Finally, for fixed integer t 1 and


t
t
G(m, p) = +
2 2

m
pt

1
m+p
p

> 0 as p , we have

p 
X
m+p+1

tpk

k
k=0

t
t 1
m+p+1

= + m+p
(1 + o(1))
2 2 p
1
p
t
tm+p+1
(1 + o(1))
= +
2 2 m+1 1
t 1 t + 1
= +
(1 + o(1))
2 2 1
t+1
(1 + o(1)).
=
2( 1)

Chapter 15
Hypergeometric Series
15.1

Definition

P
Consider the series k0 tk where tk can depend on some other parameters
(and such parameters are regarded as constants). If
tk+1
= x,
tk
then

then

P
P

k0 tk

is a geometric series. If
P (k)
tk+1
,
=
tk
Q(k)

k0 tk

for some constant x,

for some polynomials P, Q,

is a hypergeometric series.

Example 15.1. Consider the series


X nn + an a
.
n

k
k
k
k
Then

Since

tk+1
tk

tk+1
nkn+ak nk
.
=
tk
k+1 k+1 k+1a

is a rational function in k, the sum is therefore hypergeometric.


132

133

CHAPTER 15. HYPERGEOMETRIC SERIES


Also, we shall need the formula
(z)!(z 1)! = (1 z)(z) =

(15.1)

,
sin(z)

giving that
(2z 1)! sin(2z)
(2z)!
(z)!
=
=
cos(z).
(2z)!
(z 1)! sin(z)
z!

Thus, if n is a positive integer, then


(15.2)

15.2

(z)!
(2n)!
=
(1)n .
zn (2z)!
n!
lim

Reduction to Standard Hypergeometric


Functions

P
Consider the hypergeometric series k0 tk . We shall assume that t0 = 1.
If not, then we can shift k so that t0 6= 0 and then divide every term by t0 .
Then rewrite the ratio of successive terms as
tk+1
P (k)
(k + a1 )(k + a2 ) (k + ap ) 1
=
=
x.
tk
Q(k)
(k + b1 )(k + b2 ) (k + bq ) k + 1
The series is now identified as the hypergeometric function


a1 , . . . , ap
;x
p Fq
b1 , . . . , bq
Note that if we write (a)m = (a)(a + 1) (a + m 1) as the rising factorial,
then

 X
(a1 )k (a2 )k (ap )k 1 k
a1 , . . . , ap
x .
;x =
p Fq
b1 , . . . , bq
(b1 ) (b2 ) (bq ) k!
k0

Notice that p Fq is a power series in x whose convergence depends on p, q and


x:
CASE 1: If some ai is a non-positive integer, then the series is finite (because
(ai )a1 +1 = 0).
CASE 2: If some bi is a non-positive integer, then the function is undefined

CHAPTER 15. HYPERGEOMETRIC SERIES

134

for all nonzero x (unless there is a negative ai of smaller absolute value in


which case we have CASE 1).
CASE 3: If p q, then the series converges for all x unless CASE 2 happens.
CASE 4: If p = q + 1 then the series converges for all |x| < 1 unless CASE
2 happens.
CASE 5: If p > q + 1 then the series diverges for all x 6= 0.
Example 15.2. Reduce
X n + a2 n a
k

nk

(1)k

to a standard hypergeometric function and look up existing hypergeometric


identities to get a closed form.

Solution. Notice that nk is 0 when k < 0. Hence the sum is over k 0,
where


na
.
t0 =
n

6= 0. It will turn out that this assumption
We shall assume also that na
n
is not important. Then we have
2 


tk+1
nk
n+ak
(1)
=
tk
k+1
ka+1
(k n)(k a n)(k a n) 1
=
.
(k a + 1)(k + 1)
k+1
Thus, the series is




na
n, a n, a n
;1 .
3 F2
1,
1a
n

We next look up known formulas (see for example A=B) for hypergeometric
functions, and find that


(a b)!(a c)!( a2 )!( a2 b c)!
a,
b,
c
.
F
;
1
=
3 2
1 + a b, 1 + a c
a!( a2 b)!( a2 c)!(a b c)!
Here, we replace the constants a, b, c in the formula with a n, a n, n
respectively and find that


(a)!( an
)!( a+3n
)!
n, a n, a n
2
2
.
;1 =
3 F2
na
a+n
1,
1a
(a n)!( 2 )!( 2 )!n!

135

CHAPTER 15. HYPERGEOMETRIC SERIES


Therefore, the sum is


X  n + a 2  n a 
)!( a+3n
)!
(a)!( an
na
k
2
2
(1) =
a+n
na
k
nk
n
(a n)!( 2 )!( 2 )!n!
k0
)!( a+3n
)!
(n a)!( an
2
2
.
=
na
a+n
(a n)!( 2 )!( 2 )!n!2

Notice that if the denominator and numerator are both zero, then we should
(7!)
take limits. For example, when n = 10, a = 4, we have (14)!
, and so we
consider the limit (and using (15.2))
(z)!
14!
= ,
z7 (2z)!
7!
lim

giving that for n = 10 and a = 4, as an example,



10  2 
X
X  n + a 2  n a 
6
14
k
(1)k
(1) =
10

k
k
n

k
k
k=4
k0
(6!)(14!)(1)(17!)
(7!)(7!)(3!)(10!)2
= 11124256.
=

Also, if we use Maple:


> t := (n,a,k)->binomial(n+a,k)^2*binomial(n-a,n-k)*(-1)^k:
> convert(sum(t(n,a,k),k=0..infinity),hypergeom);
Then we obtain the following answer:

na
(1 + 3n+a
)(a + 1)
n
2
2
n+a
n+a 2
(n + a) sin((1 + 2 ))( 2 ) (n + 1)(1 +

na
)(1
2

n a)

One can check that this is equivalent to our answer by using the identity
(15.1).
Example 15.3. Let us try this one:



X
n+k
k k+a
4k ,
(1)
a
2k
+
2a
k

n, a Z,

n 0.

136

CHAPTER 15. HYPERGEOMETRIC SERIES

The terms are 0 if k is a negative integer. Also, if 2a > n then each term is
0. So assume n 2a throughout. Here
 
n
.
t0 =
2a
Also,



tk+1
(n + k + 1)(n k 2a)
k+1+a
(4)
= (1)
tk
k+1
(2k + 2a + 2)(2k + 2a + 1)
(k + 1 + n)(k + 2a n)
.
=
(k + 12 + a)(k + 1)
The series is therefore


 



X
n
n+k
n + 1, 2a n
k
k k+a
4 =
(1)
;1
2 F1
1
+a
2a
2k
+
2a
a
2
k
We look up existing hypergeometric identities, and we find Gausss identity:
If b is a nonpositive integer or if c a b has positive real part, then


(c a b)(c)
a, b
.
;1 =
2 F1
c
(c a)(c b)
Here we take
a = 1 + n,

b = 2a n,

c=

1
2

+a

and we get
c a b = 12 a,

c a = a 21 n,

cb=

1
2

a + n,

giving that
( 21 a)( 12 + a)
(c a b)(c)
.
=
(c a)(c b)
(a 12 n)( 21 a + n)
We next want to simplify the above expression. Recall that from (15.1)
(1 z)(z) =

.
sin(z)

CHAPTER 15. HYPERGEOMETRIC SERIES


But (1 z) = (z)(z) and hence
(z)(z) =

137

.
z sin(z)

Taking z = a + 12 , we get
( 21 a)( 21 + a) =

( 12

.
+ a) sin(( 21 + a))

Taking z = a 12 n, we get

(a n) sin((a 21 n))

=
1
(a 2 n) sin((a + 21 )) cos((n + 1))

n+1
.
=
1
1 (1)
(a 2 n) sin((a + 2 ))

(n + 21 a)(a 12 n) =

1
2

It follows that


( 21 a)( 21 + a)
n + 1, 2a n
;
1
=
F
2 1
1
+a
(a 12 n)( 21 a + n)
2
a 21 n
(1)n+1
a + 12
n 2a + 1
=
(1)n .
2a + 1

Thus, for integers n, a with n 0,




 

X
n+k
n 2a + 1
k k+a
k
n n
.
(1)
4 = (1)
2a + 1
a
2k + 2a
2a
k
Example 15.4. Consider
 


2n
2x
2z
(1)
.
k
x

n
+
k
z

n
+
k
k0

Here
t0 =

2x
xn



2z
zn

138

CHAPTER 15. HYPERGEOMETRIC SERIES


and we assume that t0 6= 0. Also,




tk+1
x+nk
z+nk
2n k
(1)
=
tk
k+1
xn+k+1
zn+k+1
(k 2n)(k n x)(k n z)
=
.
(k + x n + 1)(k + z n + 1)(k + 1)
Hence the series is

t0 3 F2


2n,
x n, z n
;1 .
x n + 1, z n + 1

Look up existing identities and we find that




(a b)!(a c)!( a2 )!( a2 b c)!
a,
b,
c
.
;1 =
3 F2
1 + a b, 1 + a c
a!( a2 b)!( a2 c)!(a b c)!
We take
and so

a = 2n,

a b = x n,

b = x n,

a c = z n,
a
2

a = 2n,

b = x,

a
2
a
2

c = z n,

= n,

c = z,

a
2
a
a
2

b c = x + z + n,

b c = x + z.

It therefore follows that


 


X
2x
2z
k 2n
(1)
k
xn+k
zn+k
k0



2x
2z
(x n)!(z n)!(n)!(x + z + n)!
=
(2n)!x!z!(x + z)!
xn zn
(2x)!(2z)!(n)!(x + z + n)!
.
=
(x + n)!(z + n)!(2n)!x!z!(x + z)!

Notice that for example, if n is a positive integer, then (n)! and (2n)! are
both zero. In situations like this, we would consider the limit when z n.
Thus, using (15.2), we as z n, where n is a positive integer, that
 


X
2x
2z
k 2n
(1)
k
xn+k
zn+k
k0
=

(2x)!(2z)!(2n)!(x + z + n)!
(1)n .
(x + n)!(z + n)!n!x!z!(x + z)!

Chapter 16
Gospers Algorithm
P
The aim is to find a simple form for the sum S(m) = m
n=0 tn where r(n) =
tn+1 /tn is a rational function of n. That is, tn is a hypergeometric term in n
and does not depend on m.

16.1

A Brief Description

The idea is find a hypergeometric term zn such that


(16.1)

zn+1 zn = tn ,

and the sum is therefore


S(m) = zm+1 z0 .
To find zn , we write
y(n) =

zn
=
tn

1
,
1

zn+1
zn

where since zn is a hypergeometric term, we see that y is a rational function,


and the problem is turned into finding a rational function y(n) where from
(16.1),
(16.2)

y(n + 1)r(n) y(n) = 1.


139

140

CHAPTER 16. GOSPERS ALGORITHM

The main step is to find functions a(n), b(n) and c(n) (with some required
properties to be stated later) so that
(16.3)

r(n) =

tn+1
a(n) c(n + 1)
,
=
tn
b(n) c(n)

and (16.2) now becomes


c(n + 1)y(n + 1)a(n)
y(n)c(n) = c(n).
b(n)
Writing
x(n) =

c(n)y(n)
,
b(n 1)

or

y(n) =

b(n 1)x(n)
,
c(n)

the previous recurrence in y becomes a recurrence in a rational function x:


a(n)x(n + 1) b(n 1)x(n) = c(n)
Now the functions a, b, c in (16.3) are chosen so that x is a polynomial in n.
The first order recurrence in x is then solved (if possible), and hence
(16.4)

16.2

zn = y(n)tn =

b(n 1)x(n)
tn .
c(n)

The Functions a, b, c

Theorem 16.1. Let r be a rational function over a field K with characteristic


zero. Then there are polynomials a, b, c over K such that b, c are monic and
r(n) =

a(n) c(n + 1)
,
b(n) c(n)

where
(i) gcd(a(n), b(n + h)) = 1 for all integer h 0,
(ii) gcd(a(n), c(n)) = 1,
(iii) gcd(b(n), c(n + 1)) = 1

141

CHAPTER 16. GOSPERS ALGORITHM


Proof. Suppose that
r(n) =

f (n)
,
g(n)

where f, g are polynomials in n over K. We can assume that g is monic


and that gcd(f (n), g(n)) = 1. If there does not exist h > 0 such that
gcd(f (n), g(n + h)) = 1, then take a = f , b = g and c = 1 and we are done.
Otherwise let h be the smallest positive integer such that
u(n) = gcd(f (n), g(n + h)) is not a constant.
Now u(n), u(n h) respectively are divisors of f (n) and g(n), and we write
f (n) = u(n)f1 (n),

g(n) = u(nh)g1 (n),

c1 (n) =

h
Y

u(ni) =

i=1

h1
Y

u(nh+i),

i=0

giving that
r(n) =

f (n)
f1 (n) u(n)u(n 1) u(n h + 1)
f1 (n) c1 (n + 1)
=

=
.
g(n)
g1 (n) u(n 1)n(n 2) u(n h)
g1 (n) c1 (n)

By the minimality of h, we see that


gcd(f1 (n), c1 (n)) = 1,

gcd(g1 (n), c1 (n + 1)) = 1.

If gcd(f1 (n), g1 (n)) = 1 then we are done, else we can repeat the above
process for f1 (n) and g1 (n).
From our proof, we need to find h > 0 (if possible) and the correspond(n)
and gcd(f (n), g(n)) = 1.
ing function u. We can assume that r(n) = fg(n)
Furthermore, we assume that f and g are factored into products of monic
polynomials. Then if
u(n) = gcd(f (n), g(n + h)) 6= 1,

for some h 1,

then there are nontrivial factors df (n) and dg (n) of f (n) and g(n) such that
u(n) = df (n),

u(n) = dg (n + h).

This shows that the degrees of df (n) and dg (n) are equal, say d, and that if
df (n) = nd + And1 + . . . ,

dg (n) = nd + Bnd1 + ,

142

CHAPTER 16. GOSPERS ALGORITHM


then

nd + And1 + . . . = df (n) = dg (n + h) = (n + h)d + B(n + h)d1 + ,

giving that (by considering the coefficient of nd1 )


dh + B = A,

or

h=

AB
.
d

This observation restricts our search for h, and provides a criterion for deciding when such an integer h 1 is not available (whence the process stops).
Example 16.1. Consider
r(n) =

2(n2 + 4n + 5)(n + 3)
f (n)
= 2
.
g(n)
(n + 1)(n2 + 3)n(n + 21 )(n + 2)

We compare pairs of factors df (n), dg (n), with the same degree, of f (n), g(n).
(1) For the pair df (n) = n2 + 4n + 5 and dg (n) = n2 + 1 (where A = 4, B = 0)
and we have
h = (4 0)/2 = 2

and we check that df (n) = dg (n + 2).


(2) For the pair df (n) = n2 + 4n + 5 and dg (n) = n2 + 3 (where A = 4, B = 0)
and we have h = 2 similarly, but this time df (n) 6= dg (n + 2) and so this pair
is discarded.
(3) For the pair df (n) = n + 3 and dg (n) = n, we have
h = (3 0)/1 = 3,
and we check that df (n) = dg (n + 3).
(4) For the pair df (n) = n+3 and dg (n) = n+ 12 , we have h = (3 21 )/1 = 2.5
which is not an integer, and so this pair is discarded.
(5) For the pair df (n) = n + 3 and dg (n) = n + 2, we have h = (3 2)/1 = 1
and we check that df (n) = dg (n + 2).
We shall take the pairs in (1) and (5). The pair in (3) is discarded because
we want to use a minimal h and n + 3 cannot be used in two pairs at the
same time. Thus, we have
r(n) =

a(n) c(n + 1)
,
b(n) c(n)

where
a(n) = 2,

b(n) = (n2 + 3)n(n + 12 ),

c(n) = (n2 + 1)((n + 1)2 + 1)(n + 2) = (n2 + 1)(n2 + 2n + 2)(n + 2).

CHAPTER 16. GOSPERS ALGORITHM

143

The Function x

16.3

Theorem 16.2. Suppose that a(n) and b(n) are such that
gcd(a(n), b(n + h)) = 1,

for all integer h 0,

and that x is a rational function satisfying


a(n)x(n + 1) b(n 1)x(n) = c(n).
Then x is a polynomial.
Proof. Let
x(n) =

f (n)
,
g(n)

where gcd(f (n), g(n)) = 1.

Then we have
(16.5)

a(n)f (n + 1)g(n) b(n 1)f (n)g(n + 1) = c(n)g(n)g(n + 1).

Assume for the purpose of contradiction that g(n) is a nonconstant polynomial. Then let N be the largest integer N 0 such that
u(n) | g(n) and u(n) | g(n + N ),
where u(n) is irreducible and is not a constant. Since g(n) is nonconstant,
the existence of such N 0 is guaranteed (as 0 is a possible value of N ).
Also, N < because g has finitely many irreducible factors. Now
=
=

u(n) | g(n) and u(n) | g(n + N )


u(n + 1) | g(n + 1) and u(n N ) | g(n)
u(n + 1) | a(n)f (n + 1)g(n) and u(n N ) | b(n 1)f (n)g(n + 1),

where the last implication follows from (16.5). Now


u(n + 1) g(n),
for otherwise (using u(n) | g(n + N )),
u(n + 1) | g(n) and u(n + 1) | g(n + N + 1),

CHAPTER 16. GOSPERS ALGORITHM

144

contradicting the maximality of N . Similarly, we have


u(n N ) g(n + 1),
for otherwise we have
u(n) | g(n + N + 1) and u(n) | g(n),
which contradicts the maximality of N . Thus, since u is irreducible, we have
=
=

u(n) | g(n) and u(n) | g(n + N )


u(n + 1) | a(n)f (n + 1)g(n) and u(n N ) | b(n 1)f (n)g(n + 1)
u(n + 1) | a(n)f (n + 1) and u(n N ) | b(n 1)f (n).

Next, since u(n) | g(n), we have u(n + 1) | g(n + 1). But gcd(f (n + 1), g(n +
1)) = 1 and u is not a constant. This shows that u(n+1) f (n+1). Similarly,
since u(n) | g(n + N ), we have u(n N ) | g(n) and so u(n N ) f (n). It
therefore follows that
=
=
=

u(n) | g(n) and u(n) | g(n + N )


u(n + 1) | a(n)f (n + 1) and u(n N ) | b(n 1)f (n)
u(n + 1) | a(n) and u(n N ) | b(n 1)
u(n + 1) | a(n) and u(n + 1) | b(n + N ),

but this contradicts our assumption on a, b. Thus g is a constant, and hence


x is a polynomial.
The rest of this section is devoted to finding the polynomial x. Recall
that
(16.6)

a(n)x(n + 1) b(n 1)x(n) = c(n).

We shall use deg(P ) and lc(P) respectively for the degree and the leading
coefficient of a polynomial P . Assume that the degree of x is d and we write
x(n) =

d
X

Ai ni .

i=0

The general idea is by equating coefficients of ni in (16.6). Consider the


degree d of x. There are two cases:

145

CHAPTER 16. GOSPERS ALGORITHM

Case ONE: The leading coefficients of the terms on the LHS of (16.6) do not
cancel. That is, deg(a) 6= deg(b) or lc(a) 6= lc(b). Then we have
max(deg(a) + d, deg(b) + d) = deg(c),
giving that
d = deg(c) max(deg(a), deg(b)).
Case TWO: We have the complement of case ONE, that is, deg(a) = deg(b) =
and lc(a) = lc(b) = . Then either one of the following two subcases must
happen:
(i) The terms of the 2nd highest degree on the LHS of (16.6) do not cancel,
and this gives
deg(a) + d 1 = deg(c),

or

d = deg(c) deg(a) + 1.

(ii) The terms of the 2nd highest degree on the LHS of (16.6) cancel. Then
if
a(n)
b(n 1)
x(n)
x(n + 1)

=
=
=
=

n + An1 +
n + Bn1 +
Cd nd + Cd1 nd1 +
Cd nd + (dCd + Cd1 )nd1 + ,

where Cd 6= 0, then because the 2nd highest degree term on the RHS of
(16.6) cancel, we have
ACd + (dCd + Cd1 ) (BCd + Cd1 ) = 0,

or

d = (B A)/.

We therefore have at most 3 possibilities for d, and for each possible d, we


need only compare the coefficients of ni to find x(n).

16.4

Examples

Example 16.2. Consider


m 
X
2n
n=0

zn.

146

CHAPTER 16. GOSPERS ALGORITHM


Here

4(n + 12 )
tn+1
(2n + 2)(2n + 1)
r(n) =
z.
=
z=
tn
(n + 1)2
n+1

Obviously,
r(n) =

a(n) c(n + 1)
,
b(n) c(n)

where
a(n) = 4z(n + 12 ),
If z 6=

1
4

b(n) = n + 1,

c(n) = 1.

then lc(a) 6= lc(b), and


deg(x) = deg(c) deg(a) = 1,

which is not possible and the sum is not Gosper-summable.


If z = 41 , we have deg(a) = deg(b) and lc(a) = lc(b). Thus, we have two
subcases for deg(x). The first is
deg(x) = deg(c) deg(a) + 1 = 0.
That is x = K for some constant K, and the equation
a(n)x(n + 1) b(n 1)x(n) = c(n)
becomes
(n + 12 )K nK = 1,
Now

and the sum is


m 
X
n=0

K = 2.

 
b(n 1)x(n)
2n 1 n
( ) ,
zn =
tn = 2n
n 4
c(n)



2m + 2 1 m+1
2n 1 n
( )
( ) = zm+1 z0 = 2(m + 1)
.
m+1 4
n 4

We do not need to consider the other subcase.


Example 16.3. Assume z is not an integer. Consider
m
X
n=1

(n 1)!2
.
(n z)!(n + z)!

147

CHAPTER 16. GOSPERS ALGORITHM


To start, we obtain
r(n) =
Obviously
a(n) = n2 ,

n2
a(n) c(n + 1)
=
.
(n + 1 z)(n + 1 + z)
b(n) c(n)
b(n) = (n + 1 z)(n + 1 + z),

c(n) = 1.

We have deg(a) = deg(b) = 2 and lc(a) = lc(b) = 1, giving that


deg(x) = deg(c) deg(a) + 1 = 0,
or (since b(n 1) = n2 z 2 )

00
= 0.
1
Thus, deg(x) = 0 is the only possibility. Suppose that x(n) = K, and we
have
n2 K (n2 z 2 )K = 1,
=
K = 1/z 2 .
deg(x) =

Hence
zn =

b(n 1)x(n)
(n 1)!2
n2 z 2
(n 1)!2
tn =
=
.
c(n)
z 2 (n z)!(n + z)!
z 2 (n 1 z)!(n 1 + z)!

The sum is
m
X
n=1

(n 1)!2
= zm+1 z1
(n z)!(n + z)!
=

m!2
1
2
.
2
z (m z)!(m + z)! z (z)!z!

If we want, we can proceed further to get


m
X
n=1

(n 1)!2
m!2
1
= 2
2
(n z)!(n + z)!
z (m z)!(m + z)! z (z)!z!
!
m
2
Y
1
i
= 2
1
2
z (z)!z! i=1 i z 2
!
m
2
Y
i
sin(z)
1 ,
=
3
2
z
i z2
i=1

and we have turned a sum into a product!

148

CHAPTER 16. GOSPERS ALGORITHM


Example 16.4. Let us consider an earlier example:

X
k=0

Here
tk =
and

m
k
n .
k

m
k
n ,
k

km
.
kn
Assume first that n m 6= 0, 1, 2, . . .. Then we can take
r(k) =

a(k) = k m,

b(k) = k n,

c(k) = 1,

and gcd(a(k), b(k + h)) = 1, for all integer h 0. Solving for x in


a(k)x(k + 1) b(k 1)x(k) = 1,
we obtain
x(k) =
and hence

1
,
n+1m

b(k 1)x(k)
kn1
zk =
tk =
c(k)
n+1m

Thus,

X
k=0

m
k
n
k

n
= z+1 z0 =
n+1m

m
+1

n
+1

m
k
n .
k

n+1
.
n+1m

For the case n m = 0, 1, 2, . . ., one can take limits:





mm
m
X

nn
nn + 1
+1
k
+
lim lim
.
n = nnn
nn
mmm nn + 1 mm
nn + 1 mm
+1
k=0 k

If we insist on using Gospers algorithm for the case where nm = 0, 1, 2, . . .,


we can proceed as follows. Here tk and r(k) as as before, but a, b, c are
a(k) = 1,

b(k) = 1,

c(k) = (k m 1)nm .

149

CHAPTER 16. GOSPERS ALGORITHM


Thus, we want to find x(k) such that
x(k + 1) x(k) = (k m 1)nm .
Recall that for any r, n C, we have
(r)n = lim((z + 1)n (z)n ) = lim n(z)n1 = n(r)n1 ,
zr

zr

and so we can take


x(k) =

1
(k
nm+1

m 1)nm+1 .

Thus,
1
b(k 1)x(k)
(k m 1)nm+1
tk =
zk =
c(k)
n m + 1 (k m 1)nm
and the rest proceeds as before.
Example 16.5. Consider

kn1
=
nm+1

m
k
n ,
k

m
X
n4 4 n

2n .
n=0

The ratio r(n) is

m
k
n
k

4(n + 1)4
(n + 1)2
r(n) =
n4
(2n + 2)(2n + 1)
5
2(n + 1)
=
n4 (2n + 1)
4


n+1
n+1
.
=
n
n + 12
Obviously,
a(n) = n + 1,

b(n) = n + 12 ,

c(n) = n4 .

We have deg(a) = deg(b) = 1 and lc(a) = lc(b) = 1. Thus, the degree of x


can be
deg(x) = deg(c) deg(a) + 1 = 4 1 + 1 = 4,

150

CHAPTER 16. GOSPERS ALGORITHM


or

21 1
deg(x) =
6 Z.
1
Thus, we have deg(x) = 4, which is a pain!!!
Nevertheless, we write
x(n) =

4
X

Ai ni ,

i=0

and consider the equation a(n)x(n + 1) b(n 1)x(n) = c(n), that is


(n + 1)x(n + 1) (n 12 )x(n) = n4 ,
or equivalently
4
X
i=0

Ai (n + 1)

i+1

4
X

Ai n

i+1

1
2

4
X

Ai ni = 1.

i=0

i=0

Comparing the coefficients of n4 , we get


 
 
5
4
A4 +
A3 A3 + 12 A4 = 1,
4
4
giving that
A4 =

2
.
11

Comparing the coefficients of n3 , we get


 
 
 
3
4
5
A2 A2 + 12 A3 = 0,
A3 +
A4 +
3
3
3
giving
A3 = 92 (10)(A4 ) = 40
.
99
Comparing the coefficients of n2 to get
 
 
 
5
4
3
A4 +
A3 +
A2 + 12 A2 = 0,
2
2
2
giving that
A2 = 27 (10A4 + 6A3 ) =

40
.
231

151

CHAPTER 16. GOSPERS ALGORITHM


Comparing the coefficients of n to get
 
 
 
 
2
3
4
5
A1 + 12 A1 = 0,
A2 +
A3 +
A4 +
1
1
1
1
giving that
A1 = 52 (5A4 + 4A3 + 3A2 ) =

52
.
693

Finally, comparing the coefficients of n0 , we get

A4 + A3 + A2 + A1 + A0 + 12 A0 = 0,
or
4
A0 = 32 (A4 + A3 + A2 + A1 ) = 231
.

Thus,
x(n) =

2 4
n
11

or
x(n) =

1
693

and

40 3
n
99

40 2
n
231

52
n
693

4
,
231


63n4 140n3 + 60n2 + 26n 6 ,
b(n 1)x(n)
tn
c(n)
(n 12 ) n4 4n

=
2n x(n)
n4
n

zn =

4n (2n 1)
 x(n).
=
2 2n
n

The sum is therefore

m
X
n4 4 n
 = zm+1 z0
2n
n=0

4(m+1) (2m + 1)

x(m + 1) + 12 A0
2m+2
2 m+1

4(m+1) (2m + 1)

x(m + 1)
2 2m+2
m+1

2
.
231

Chapter 17
Zeilbergers Algorithm
The aim is to find a closed form for
f (n) =

F (n, k).

We shall assume throughout that F (n, k) is a proper hypergeometric term in


n, k. That is,
Quu
i=1 (ai n + bi k + ci )! k
F (n, k) = P (n, k) Qvv
x ,
i=1 (ui n + vi k + wi )!

where P is a polynomial, x is in a field and uu 0, vv 0, ai , bi , ui , vi are


absolute constants (containing no other parameters).
For example, the summand in the sum

 
X
2n 2k
k n
(1)
n+a
k
k
is a proper hypergeometric term:
F (n, k) =

n!(2n 2k)!
(1)k ,
k!(n k)!(n + a)!(n 2k a)!

where P (n, k) = 1, uu = 2 and vv = 4.


152

CHAPTER 17. ZEILBERGERS ALGORITHM

17.1

153

Sister Celines Method

P
The method aims to turn a sum f (n) = k F (n, k) into a recurrence relation
in f (n). Solving the recurrence will then give f (n).
The method searches for a (non-trivial) recurrence of the form
I X
J
X
i=0 j=0

aij F (n j, k i) = 0,

where aij does not depend on k (but may depend on n). It uses trial and error
for different values of I and J, starting with (I, J) = (1, 1) and increasing I
and/or J if necessary.
 k
P
2 . We need to find a recurrence of
Example 17.1. Try the sum k n+k
k
the form
I X
J
X
aij F (n j, k i) = 0.
i=0 j=0

Starting with (I, J) = 1, and dividing both sides by F (n, k) to get


a00 + a01

F (n 1, k)
F (n, k 1)
F (n 1, k 1)
+ a10
+ a11
= 0.
F (n, k)
F (n, k)
F (n, k)

This gives that


a00 + a01

n
2k
2nk
+ a10
+ a11
= 0,
n+k
n+k
(n + k)(n + k 1)

or
a00 (n + k 1)(n + k) + a01 n(n + k 1) + a10 (2k)(n + k 1) + 2a11 kn = 0.
We can compare the coefficients of k 0 , k, k 2 to find the aij s. Or we can
proceed as follows:
(1) for k = (n 1), we get a11 = 0,
(2) for k = 0, we get a00 + a10 = 0,
(3) for k = n, we get a01 + 2a10 = 0. We therefore see that
a11 = 0,

a10 = 12 a01 ,

a01 = a00 .

CHAPTER 17. ZEILBERGERS ALGORITHM

154

We have therefore found that


(a00 , a01 , a10 , a11 ) = (2, 2, 1, 0)
is a (non-trivial) solution for the as. It follows that
2F (n, k) 2F (n 1, k) F (n, k 1) = 0.
Note that the recurrence is usually more complex in the sense that we may
need to try higher values of I, J. Nevertheless, we are lucky for our problem
and we can proceed to sum the above equation over k to get
2f (n) 2f (n 1) f (n) = 0,
giving that
f (n) = 2f (n 1),
or
f (n) = 2n f (0).
Now
f (0) =

X k 
k

giving that

2k =

2k = 2,

k0

X n + k 
2k = 2n+1 .
f (n) =
k
k
How about the sum
f (n) =


n 
X
n+k
k=0

2k ?

If we proceed as before, we have the same recurrence:


2F (n, k) 2F (n 1, k) F (n, k 1) = 0.
Summing over k from 1 to n 1 to get
2(f (n) F (n, n) F (n, 0)) 2(f (n 1) F (n 1, 0))
(f (n) F (n, n 1) F (n, n)) = 0.

CHAPTER 17. ZEILBERGERS ALGORITHM

155

Since



2n n
F (n, n) =
2 ,
F (n, 0) = F (n 1, 0) = 1,
n

 

2n n
2n 1 n+1
2 = F (n, n),
2
=
F (n, n 1) =
n
n1
we find that (by coincidence)
f (n) = 2f (n 1) = 2n f (0).
This time

and so

0  
X
k k
f (0) =
2 = 1,
k
k=0


n 
X
n + k k
2 = 2n .
f (n) =
k
k=0
The next theorem shows the correctness of Sister Celines method.
Theorem 17.1. If F (n, k) is a proper hypergeometric term, then there exist
I, J 1 and polynomials aij = aij (n), not all 0, such that
I X
J
X
i=0 j=0

aij F (n j, k i) = 0.

Proof. We shall only say a few words about the proof. Notice that the recurrence in the theorem, after multiplying both sides by the common denominator and canceling all common factors, is a polynomial in k, with degree of
the form I + J + , where , , are constants depending on a, b, u, vs.
Equating coefficients of k i gives I + J + + 1 equations. However, there
are (I + 1)(J + 1) unknown in aij s. Now by choosing sufficiently large I and
J, we see that we have
# unknown > # equations.
This implies that non-trivial solutions to aij s exist.

CHAPTER 17. ZEILBERGERS ALGORITHM

17.2

156

Zeilbergers Algorithm

Zeilbergers algorithm is similar to Sister Celines method, but it is faster by


making use of Gospers algorithm. The idea is to use Gospers algorithm to
find G(n, k) and polynomials aj in n so that
(17.1)

J
X
j=0

aj F (n + j, k) = G(n, k + 1) G(n, k),

The LHS is a polynomial L of the shift operator (on n) together with the
function G is called a Zeilberger pair. If a Zeilberger
pair is found, then
P
summing over k results in a recurrence in f (n) = k F (n, k):
J
X

(17.2)

aj f (n + j) = 0.

j=0

Solving the recurrence (if possible) gives the answer.


Theorem 17.2. Let F (n, k) be a proper hypergeometric term. Then F satisfies a nontrivial recurrence of the form (17.1) in which
G(n, k)
is a rational function of n, k.
F (n, k)
Proof. The proof follows from Theorem 17.1. Recall that there are I, J 1
and polynomials aij = aij (n), not all 0, such that
I X
J
X
i=0 j=0

aij F (n j, k i) = 0.

Now the above becomes


P (n, N, K)F (n, k) = 0
where P is a polynomial and N, K are the shift operators in n, k respectively.
Taking P as a polynomial in K, we can write
P (n, N, K) = P (n, N, 1) + (1 K)Q(n, N, K).

157

CHAPTER 17. ZEILBERGERS ALGORITHM


Now we take
J
X

aj F (n + j, k) = P (n, N, 1)F (n, k),

G(n, k) = Q(n, N, K)F (n, k).

j=0

For the details, please refer to the text.


Now equation (17.1) is similar to (16.1) in Gospers Algorithm with
tk =

J
X

aj F (n + j, k),

zk = G(n, k).

j=0

Our aim is to use Gospers Algorithm to find the aj s and perhaps G if


needed.
Example 17.2. Try
X
f (n) =
(1)k
k

n
k
,
z+k
k

integer n 0.

Try J = 0 (and please bear in mind that this is a simple example) and so
tk = a0 F (n, k),
and hence
r(k) =

tk+1
nk
kn
F (n, k + 1)
=
=
.
=
tk
F (n, k)
z+k+1
k+z+1

Thus, we take
a(k) = k n,

b(k) = k + z + 1,

p(k) = 1.

Forming Gospers Algorithm, we next want to find x(k) such that


a(k)x(k + 1) b(k 1)x(k) = p(k).
Here, deg(a) = deg(b) = 1 and lc(a) = lc(b) = 1. Thus, we have case 2, and
with subcase (i), we have
deg(x) = deg(p) deg(a) + 1 = 0.

158

CHAPTER 17. ZEILBERGERS ALGORITHM


Thus, we take
x(k) = X,
and we get
(k n)X (k + z)X = 1,
giving that
X=

1
.
n+z

We can take a0 = 1 so that


L = 1,

G(n, k) =

b(k 1)x(k)
k+z
tk =
F (n, k).
p(k)
n+z

That is,
F (n, k) = G(n, k + 1) G(n, k).
Summing over k from 0 to n gives
f (n) = G(n, n + 1) G(n, 0) =

z
.
n+z

It should be noted that most problems are more complicated than this example.

Chapter 18
Burnsides Lemma
A group G acts on a set X if for each g G, there is a permutation (bijection)
g on X such that
g h = gh ,
g, h G,
where the product of two permutations is their composition (that is, g h =
g h ).
Example 18.1. Let be the rotation by 90 clockwise. Then
G = {0 , 1 , 2 , 3 }
is a cyclic group of order 4. Let X = R2 . Then G induces permutations
i = i on X,

i = 0, 1, 2, 3,

so that for all (x, y) R2 ,


1 ((x, y)) = (y, x),
3 ((x, y)) = (y, x).

0 ((x, y)) = (x, y),


2 ((x, y)) = (x, y),

We often identify g with g (for g G). Thus, we have for (x, y) R2 that
0 ((x, y)) = (x, y),
2 ((x, y)) = (x, y),

1 ((x, y)) = (y, x),


3 ((x, y)) = (y, x).
159

160

CHAPTER 18. BURNSIDES LEMMA

Example 18.2 (Coloring the edges of a square, Part I). Color the edges of
a square with exactly two colors: 0, 1. That is, each edge is colored by 0 or
1, and both colors are used. Our aim is to answer this question: How many
different colorings are there, assuming equivalence by rotations? This is our
first example and we shall be more detailed than necessary.
Name the four sides of the square as a, b, c, d in clockwise order and let
E = {a, b, c, d}. Each coloring is a mapping : E {0, 1}. The set of
colorings that we are interested in is
X = set of all surjections : E {0, 1}
{0, 1}E ,
which is the set of all mappings from E to {0, 1}.
The rotations are i , i = 0, 1, 2, 3 and the group is G = {i : i = 0, 1, 2, 3} as
before. Now G acts on X as follows. For g G, define a function g on X
as follows:
(g ())() = (g 1 ()),
X, E.

Notice that for g G and X, g () is the coloring obtained by


(1) first coloring the edges of the square using and then
(2) rotating the square by g.
The reason behind the above equation is that for edge of the square, the
color of under the coloring g () is precisely the color of the edge g 1 ()
(before the rotation) under the coloring . With this understanding, it is
obvious that for each g G, g is a bijection (or permutation) on the set X
of colorings and that for g, h G,
g h = gh .
This shows that G acts on X.
Here in this example, we say that two colorings 1 , 2 X are equivalent
iff there is i = 0, 1, 2, 3 such that
1 () = 2 (i ()),

E,

or equivalently, there is a rotation g G such that g (1 ) = 2 .


We continue to develop a general solution method to problems of the type
in the previous example. Suppose that G is a group that acts on X. For
g G, some authors write g for g to minimize notation.

CHAPTER 18. BURNSIDES LEMMA

is,

161

For g G, let (g) denote the number of elements in X fixed by g. That


(g) = #{x X : g (x) = x}.

For x X, the orbit containing x is


Ox = {g (x) : g G}.
Example 18.3 (Coloring the edges of a square, Part II). Recall that X is
the set of surjections from E to {0, 1} and that G = {i : i = 0, 1, 2, 3} where
is the rotation (clockwise) by 90 . Also,
|X| = 24 2.
Furthermore, for g G, (g) is the number of colorings fixed by g. Hence,
(0 ) =
=
=
1
( ) =
=
=
(2 ) =
=
3
( ) =
=

# colorings fixed by the identity rotation


total # surjections
24 2,
# colorings fixed by
# colorings in which adjacent edges have the same color
0,
# colorings in which opposite edges have the same color
2,
# colorings in which adjacent edges have the same color
0.

Next, for X, the orbit O containing is the set of colorings g (), g G.


Thus, if we identify a coloring by ((a), (b), (c), (d)), then
O0001
O0011
O0101
O0111

=
=
=
=

{0001, 0010, 0100, 1000} = O1000 , etc.,


{0011, 0110, 1100, 1001},
{0101, 1010},
{0111, 1110, 1101, 1011}.

Thus, there are 4 different orbits, and therefore there are 4 nonequivalent
colorings.

162

CHAPTER 18. BURNSIDES LEMMA

The Burnside Lemma relates the number of orbits (which is the answer
we seek in the previous example) to (g)s.
Theorem 18.1 (Cauchy-Frobenius-Burnside). If a group G acts on X, then
# orbits of G (acting on X) is

1 X
(g).
|G| gG

Example 18.4 (Coloring the edges of a square, Part III). Recall that
(0 ) = 14,

(1 ) = (3 ) = 0,

(2 ) = 2,

and that
|G| = 4.
Thus, by the Theorem 18.1, we have
# nonequivalent colorings = # orbits
= 41 (14 + 0 + 2 + 0)
= 4.

18.1

Proof of Burnsides Lemma

Here is a series of lemmas for proving Burnsides Lemma. Recall that G is a


group acting on a finite set X and with permutations g , g G, on X such
that
g h = gh ,
g, h G.
Lemma 18.1. {g : g G} is a group under composition.
Proof. (i) Closure.
g, h G = g h = gh {g : g G}.
(ii) Identity. Let e be the identity in G. Then

e e = ee = e
e = (e )(e )1 = 1X ,

CHAPTER 18. BURNSIDES LEMMA

163

where 1X is the identity permutation on X. This shows that 1X is in {g :


g G}.
(iii) Associativity. Function composition is associative.
(iv) Inverses. For any g G, we have
g g1 = e = 1X .
This shows that the inverse of g is g1 {g : g G}. (Note that the
mapping g g is a homomorphism.)
Lemma 18.2. The set of orbits form a partition on X.
Proof. Recall that the orbit containing x X is
Ox = {g (x) : g G}.
(i) For all x X, since e (x) = 1X (x) = x, we see that x Ox .
(ii) From the above, we see that
[
Ox = X.
xX

(iii) It remains to show that for any x, y X, if Ox Oy 6= then Ox = Oy .


Suppose therefore that z Ox Oy . Then there are g, h G such that
g (x) = z = h (y).
This gives that
x = (g )1 h (y) = g1 h (y).
Thus, for any w Ox , we have for some k G that
w = k (x) = k (g1 h (y)) = kg1 h (y) Oy .
This proves that Ox Oy . Similarly, we have Oy Ox and hence Ox = Oy
as required. (This proves that the orbits are disjoint.)
Lemma 18.3. Let x X and Gx = {g G : g (x) = x}. Then
(a) Gx is a subgroup of G, and
|G|
(b) |Ox | = |G
.
x|

164

CHAPTER 18. BURNSIDES LEMMA


Proof. (a)
(i) Gx is nonempty because e Gx :
e (x) = 1X (x) = x.
(ii) For g, h Gx , we have
=
=
=
=

g (x) = x = h (x)
g (x) = h (x)
(g )1 h (x) = x
g1 h (x) = x
g 1 h Gx .

Thus Gx is a subgroup of G.
(b) Observe that for g, h G,
iff
iff
iff
iff

g (x) = h (x)
g1 h (x) = x
g 1 h Gx
h gGx
g, h are in the same left coset of Gx .

Thus,
|G|
,
|Gx |
since all left cosets have the same cardinality and they form a partition of
G.
|Ox | = # left cosets of Gx =

Lemma 18.4. Suppose that s, t X. If t Os then |Gs | = |Gt |.


Proof. Assume t Os . Then there is g G such that
g (s) = t,

or

g1 (t) = s.

Recall that
Gs = {g G : g (s) = s},

Gt = {g G : g (t) = t}.

CHAPTER 18. BURNSIDES LEMMA

165

Thus for h Gs , we have


=
=
=
=

h Gs
h (s) = s
h (g1 (t)) = g1 (t)
ghg1 (t) = t
ghg 1 Gt

But gh1 g 1 = gh2 g 1 = h1 = h2 . Thus, the map from Gs to Gt given by


h ghg 1 is 1-1. This shows that |Gs | |Gt |. Similarly, we have |Gt | |Gs |
and so we have |Gs | = |Gt |.
Proof of Burnsides Lemma. Let N be the number of pairs (g, x) satisfying
g (x) = x. We shall count N in two ways:
FIRST. For each g G, the number of x such that g (x) = x is by definition
(g). Thus we have
X
N=
(g).
gG

SECOND. For each x X, the number of g G such that g (x) = x is |Gx |.


This shows that
X
N =
|Gx |
xX

X X

orbit O xO

orbit O

orbit O

|Gx |,

since the set of orbits is a partition of G

|Ox ||Gx |,

|G|,

since s, t Ox = |Gs | = Gt |

by a previous lemma

= |G| # orbits.
We therefore have
# orbits =

1 X
(g),
|G| gG

166

CHAPTER 18. BURNSIDES LEMMA

18.2

Two More Examples

Example 18.5. Consider an n-sided regular polygon. Each side is colored


with 1 of m available colors. How many colorings are there, assuming equivalence under rotation?
Solution. Here X is the set of colorings and let is the rotation (clockwise) by 2
. Then the group {i : 0 i n 1} of rotations acts on X.
n
For i = 0, 1, . . . , n 1, consider the rotation i and we like to calculate the
number of colorings fixed by i . Let d = gcd(i, n). Now a coloring is fixed by
g = i iff it is fixed by g h = ih for all h 0 (since f = gf = g h f ). But the
least positive residue of ih modulo n is precisely d where d = gcd(i, n). Thus,
a coloring is fixed by i iff it is fixed by d where d = gcd(i, n). Also, for
d | n, a coloring is fixed by d iff when the n sides of the n-gon is partitioned
into n/d consecutive segments with d sides in each segment, each of the n/d
segments have the same coloring. That is, there are md colorings fixed by i .
Hence
# nonequivalent colorings
1 X
=
(g)
|G| gG
n

1 X gcd(i,n)
=
m
n i=1
1X
=
#{i : gcd(i, n) = d, i = 1, 2, . . . , n}md
n
d|n

1X
=
#{j : gcd(j, n/d) = 1, j = 1, 2, . . . , n/d}md
n
d|n

1X
=
(n/d)md ,
n
d|n

where is the Euler function. For example, when n = 10, we have


(10) = 4,

(5) = 4,

(2) = 1,

(1) = 1,

and hence the number of nonequivalent colorings (when n = 10) is



1
4m + 4m2 + m5 + m10 .
10

167

CHAPTER 18. BURNSIDES LEMMA

Example 18.6. Consider an n-sided regular polygon. Each side is colored


with 1 of m available colors and at least 2 colors are used. How many
colorings are there, assuming equivalence under rotation?
Solution. We have the same setting as before. This time
(ri ) = md m,

gcd(i, n) = d,

where the term m is due to the fact that there are m monochromatic colorings. Thus,
# nonequivalent colorings
1 X
=
(g)
|G| gG
n

1 X gcd(i,n)
=
(m
m)
n i=1
1X
=
#{i : gcd(i, n) = d, i = 1, 2, . . . , n}md m
n
d|n

1X
#{j : gcd(j, n/d) = 1, j = 1, 2, . . . , n/d}md m
=
n
d|n

1X
(n/d)md m,
=
n
d|n

when n = 4, we have
(4) = 2,

(2) = 1,

(1) = 1,

and hence the number of nonequivalent colorings (when n = 4) is




1
1
2m + m2 + m4 m =
m2 + m4 2m .
4
4

In particular, when m = 2 and n = 4, we have 41 (22 + 24 4) = 4 different


colorings as before.

Chapter 19
Polyas Theory of Counting
This is a powerful technique for enumeration with equivalence under symmetry imposed by a group. We shall start by formalizing some concepts
understood in the previous chapter.

19.1

Groups Acting on Functions

Lemma 19.1. Let A and B be finite sets and consider the set B A of functions
from A to B. Let G be a permutation group on A. Then G acts on B A with
g (f ) = f g 1 ,

g G,

f BA.

Proof. We first show that g is 1-1 for all g G. Suppose that g G. Then
for any f1 , f2 B A ,
g (f1 ) = g (f2 )

f1 g 1 = f2 g 1

f1 = f2 .

Thus for any g G, g is 1-1 and since B A is finite, we see that g is a


bijection.

168

CHAPTER 19. POLYAS THEORY OF COUNTING

169

Also, for all g, h G and any f B A ,


(g h )(f ) =
=
=
=
=
=

g (h (f ))
g (f h1 )
(f h1 )g 1
f (h1 g 1 )
f (gh)1
gh (f ).

We have therefore completed proving the lemma.


Example 19.1 (Coloring the edges of a square, Part IV). Here A is the set
of edges, and B is the set of colors, and B A is therefore the set of colorings.
The group of rotations is {i : i = 0, 1, 2, 3} where denotes the rotation
by 2 clockwise. This group induces a permutation group on A by regarding
i as a permutation that maps A to itself. Notice that we use i for two
objects here: One is an element of the group of rotations and the other is a
permutation on A. It is easy to check that this set G = {i : i = 0, 1, 2, 3}
of permutations is a group. The lemma says that G acts on B A , the set of
colorings of the edges of the square.

19.2

Cycles and Burnsides Lemma

Example 19.2 (Coloring the edges of a square, Part V). Suppose that the
edges of the square are labeled a, b, c, d clockwise. Then A = {a, b, c, d} and
the permutation group is {i : i = 0, 1, 2, 3}, where
(a) = b,

(b) = c,

(c) = d,

(d) = a,

and i denotes composition of with itself for i times. There are 4 cycles
(each with length 1) in 0 which is the identity mapping; 1 cycle of length 4
in 1 and 3 , and 2 cycles of lengths 2 in 2 .
Theorem 19.1. Let A and B be finite sets, and G be a permutation group
on A. Denote by ck (G) the number of permutations g in G that have exactly
k cycles. Then the number of orbits of G acting on B A is
1 X
ck (G)|B|k .
|G| k1

CHAPTER 19. POLYAS THEORY OF COUNTING

170

Proof. By Burnsides Lemma,


# orbits =

1 X
(g),
|G| gG

where (g) is the number of functions f B A fixed by g, that is,


g (f ) = f,

f g 1 = f.

or

This implies that if f is fixed by g, then


f g = f,

and

f g k = f,

k Z.

Now if a A is in a cycle of length in g, then


f (a) = f (f (a)) = f (f 2 (a)) = = f (g (a)) = f (a).
That is, if f B A is fixed by g G, then f is constant on each cycle of g.
Therefore,
# orbits =
=

1 X
(g)
|G| gG
X
1 X
|G|

k1

gG
g has k cycles

|B|k

1 X
ck (G)|B|k .
|G| k1

Example 19.3. Consider a regular n-gon. Each side is colored by one of m


available colors, and the colorings are equivalent under rotations. Find the
number of nonequivalent colorings.
Solution. Let A = {0, 1, . . . , n 1} be the set of edges of the n-gon. The
rotations form a permutation group G on A. There are n rotations: i ,
i = 1, 2, . . . , n, where is rotation by 2
. Observe that if k = gcd(i, n), then
n
for each j = 0, 1, 2, . . . , k 1, the edges
j + hi,

h = 0, 1, 2, . . . , nk 1,

where addition is performed under modulo n, form a cycle of length n/k.


That is, the rotation i has k = gcd(i, n) cycles. Now the number of rotations

CHAPTER 19. POLYAS THEORY OF COUNTING

171

with k cycles is
ck (G) = #{i : gcd(i, n) = k, 1 i n}
= #{i : gcd(i, n/k) = 1, 1 i n/k}
= (n/k).
Hence, by the previous theorem, we have
1X
ck mk
n k1
1X
=
(n/k)mk ,
n

# nonequivalent colorings =

k|n

which is the same as before.


Example 19.4. Consider a regular n-gon. Each side is colored by one of m
available colors so that every color is used and the colorings are equivalent
under rotations. Find the number of nonequivalent colorings.
Solution. Note that we cannot use the previous theorem because the group
acts on a proper subset X of B A . Here let X be the set of colorings of the set
A of edges with the colors in B (where |B| = m) so that all colors are used.
Then as before, for k | n, there are (n/k) rotations with k cycles. Now the
k
number of colorings fixed by such rotations is no longer |B|
 k , but equals the
number of surjections from [k] to [m], and is therefore m! m . Thus,
 
k
1X
ck m!
# nonequivalent colorings =
n k1
m
 
m! X
k
(n/k)
=
.
n
m
k|n

For the case where n = 4 and m = 2, we have


 

 
4
2
1
= 21 (1 + 7) = 4,
+ (1)
(2)
# nonequivalent colorings =
2
2
2
as before.
Example 19.5. There are m types of beads. Form a necklace with n beads.
How many different necklaces can be formed if equivalence is under rotation

CHAPTER 19. POLYAS THEORY OF COUNTING

172

and reflection?
Solution. The beads in a necklace are the vertices of an n-gon and the types
are the colors of the vertices. The permutation group on the set A of vertices
contains these elements:
(A) n rotations, and as before, the number of rotations with k cycles, where
k | n, is (n/k). The contribution of the rotations to the sum is
X
(n/k)mk .
k|n

(B) n reflections, but there are two cases here. (i) if n is odd, then each
reflection is about an axis through a vertex and the mid point of the opposite
edge. There is 1 cycle of length 1 (consisting of the vertex at the axis of
reflection) and (n 1)/2 cycles of lengths 2. Thus there are (n + 1)/2 cycles
in each reflection and so contribution of the reflections to the sum is
nm(n+1)/2 .
(ii) if n is even, then there are two kinds of reflections: There are n/2 reflections about the axes through opposite vertices, and each reflection contains
2 + (n 2)/2 cycles because there are 2 cycles of lengths 1 and (n 2)/2 cycles of lengths 2. Also, there are n/2 reflections about axes through the mid
points of opposite edges, and each reflection contains n/2 cycles of lengths
2. Thus, the contribution of the reflections to the sum is
n
n
+1
n
2
2
m
+
m
.
2

Hence, noting that |G| = 2n, we find that



1 nm(n+1)/2 + P (n/k)mk ,
if n is odd,
k|n
2n


# orbits =
P
k
1 n mn/2 (m + 1) +
, if n is even.
k|n (n/k)m
2n
2

19.3

The Cycle Index of a Permutation Group

Let G be a permutation group on A with |A| = n. For g G, let ti (g) be


the number of cycles of g with length i. Note that for each g G,
n
X
i=1

ti (g)i = n.

CHAPTER 19. POLYAS THEORY OF COUNTING

173

We now use
1t1 (g) 2t2 (g) ntn (g)

for the cycle class of g. The cycle index ZG of G is


n

1 X Y ti (g)
ZG (X1 , X2 , . . . , Xn ) =
.
X
|G| gG i=1 i
Recall that ck (G) is the number of permutations in G with k cycles, and
1 X
ck (G)mk .
# orbits =
|G| k1
P
Now i1 ti (g) is the number of cycles in g, and so
1 X Pi1 ti (g)
m
|G| gG
1 X # cycles in g
m
=
|G| gG
1 X
=
ck (G)mk
|G| k1

ZG (m, m, . . . , m) =

= # orbits.

We have therefore proved the following theorem.


Theorem 19.2. The number of orbits of G on B A where |B| = m is
ZG (m, m, . . . , m), where ZG is the cycle index of G.
Example 19.6. Let us consider the necklace problem in the previous section
with n beads, equivalent under rotation and reflection. The corresponding
cycle index is
n

1 X Y ti (g)
X
ZG (X1 , X2 , . . . , Xn ) =
|G| gG i=1 i



1 P (n/k)X k + n X2(n2)/2 X12 + n X2n/2 , if n is even,
n/k
2n
2
Pk|n
 2
=
(n1)/2
k
1
X1 ,
if n is odd.
k|n (n/k)Xn/k + nX2
2n

By setting Xi = m for all i, we get the number necklace with n beads from
m types.

CHAPTER 19. POLYAS THEORY OF COUNTING

19.4

174

Counting Nonisomorphic Graphs

Computing the exact number of nonisomorphic graphs is a very hard problem. No known efficient computer algorithm has been found, and most people (in the research area) do not expect that there is one. We shall work on
graphs with 5 vertices.

as the set of all unordered
Let V = [5] be the vertex set. Define E = [5]
2
pairs of vertices. A graph is a function f : E {0, 1}. Let G be the
permutation group on [5]. For G, define (2) on E by
(2) ({x, y}) = {(x), (y)}.
Thus, is a relabeling of the vertices and two graphs f1 , f2 are isomorphic
iff they are equivalent under a vertex labeling G. That is, f1 , f2 are
isomorphic iff there is G such that
f1 (e) = f2 ( (2) (e)),

e E.

We shall show below that (2) is a permutation and so f1 , f2 are isomorphic


iff there is G such that
1
.
f2 = f1 (2)

Lemma 19.2. Let G(2) = { (2) : G}. Then G(2) is a permutation group
on E.
Proof. We first show that (2) is 1-1. Thus, for e1 = {x1 , y1 }, e2 = {x2 , y2 }
E, we have
=
=
=

(2) (e1 ) = (2) (e2 )


{(x1 ), (y1 )} = {(x2 ), (y2 )},
{x1 , y1 } = {y2 , y2 },
since is a permutation on V
e1 = e2 .

Thus (2) is 1-1, and since E is finite, (2) is a bijection (permutation) on E.


We next show that G(2) is closed under composition. It is easy to show
that for any , G, we have for any e E that

(2) (2) (e) = ()(2) (e),

CHAPTER 19. POLYAS THEORY OF COUNTING

175

which implies that


(2) (2) = ()(2) G(2) ,

and hence G(2) is closed under composition.

We next show that G(2) is closed under inverse. It is easy to check that
for any G, we have
(2) ( 1 )(2) = ( 1 )(2) = (1G )(2) ,
where 1G is the identity in G and (1G )(2) is the identity in G(2) . Thus, G(2)
is closed under inverse.
Thus G(2) is a subgroup of the symmetric group on E. That is, G(2) is a
permutation group on E.
Since G(2) acts on {0, 1}E , the number of orbits is the number nonequivalent functions in {0, 1}E under the vertex relabelling G. Thus,
the number of nonisomorphic graphs equals the number of orbits of G(2)
acting on {0, 1}E . We restate this as a lemma below.

Lemma 19.3. Let V be a vertex set, and E = V2 be the set of unordered
pairs of vertices. Then the number of nonisomorphic graphs with vertex set
V equals the number of orbits of G(2) acting on {0, 1}E .
We shall now proceed to find the cycle index of G(2) .
cycle classes of
15

cycle classes of (2)


110

13 21

14 23

12 31

11 33

11 41

42 21

11 22

12 24

21 31

11 31 61

51

52

number of permutations
1

5
= 10
2

5
(2) = 20
3

5
(3!) = 30
4


5 3 1
= 15
2 1 2

5
(2!) = 20
3
4! = 24

CHAPTER 19. POLYAS THEORY OF COUNTING

176

P
Notice that a cycle class (t1 , t2 , . . .) must satisfy i1 iti = 10 because there
are 10 edges in E. Also, there are 5! = 120 permutations G and hence
120 permutations (2) in G(2) . Also, let us say a few words how the cycle
classes of (2) are decided. For example, if the cycle class of is 13 21 , then
edges with end
points in 2 of the 3 1-cycles in form a 1-cycle in (2) and

there are 32 = 3 such 1-cycles; an edge with one end point in a 1-cycle of
andother end point in a 2-cycle of is part of a 2-cycle in (2) and there
are 31 = 3 such 2-cycles; an edge with both end points in the 2-cycle of
gives a 1-cycle in (2) and there are 1 such 1-cycle. Hence the corresponding
cycle class of (2) is 14 23 .
From the table, we see that the cycle index of G(2) is
ZG(2) =

1
X110 + 10X14 X23 + 20X1 X33
5!
+30X2 X42 + 15X12 X24 + 20X1 X3 X6 + 24X52 ) .

Thus, the number of nonisomorphic graphs on [5] equals the number of orbits
[5]
of G(2) acting on {0, 1}( 2 ) , and is equal to

1 10
2 + 10(27 ) + 20(24 ) + 30(23 ) + 15(26 ) + 20(23 ) + 24(22 ) = 34.
5!

Chapter 20
A Generating Function for the
Number of Orbits
Suppose that A, B are finite sets. Let R be the set of polynomials with real
coefficients, and let w : B R be a weight function. Define W : B A R
by
Y
W (f ) =
w(f (a)).
aA

Suppose that G is a permutation group on A and hence G acts on B A . If f1


and f2 are in the same orbit of G then there is a permutation g G on A
such that
f1 = f2 g 1 ,
or
f1 g = f2 .

This implies that


W (f2 ) = W (f1 g) =

W (f1 (g(a)) =

aA

W (f1 (a)) = W (f1 ),

aA

where the last but one equality follows from the fact that g is a permutation
on A. This shows that if f1 and f2 are in the same orbit, then W (f1 ) = W (f2 ).
Therefore, the functions in the an orbit have the same weight. Let D be a
system of distinct representatives for the collection of orbits. That is, D
contains exactly one function from each orbit. Then we have the following
theorem.
177

CHAPTER 20. A GENERATING FUNCTION FOR ORBITS

20.1

178

The Generating Function

Theorem 20.1. Suppose that |A| = n.


X
W (f ) = ZG (X1 , X2 , . . . , Xn ),
f D

where
Xi =

w(b)i ,

i = 1, 2, . . . , n.

bB

Proof. Let

N=

W (f ).

gG,f B A
f g=f

We shall count N in two ways. First, recall that


Gf = {g G : f g = f }
is a subgroup of G and that
|Gf | |Of | = |G|.
Now
N =

f B A

f B A

f D

W (f )

gG,f g=f

W (f )|Gf |

W (f ) |Of | |Gf |

= |G|

W (f ),

f D

where the last but one equality follows from the fact that functions f1 Of
satisfies W (f1 ) = W (f ). Next, recall that the cycle index of G is
n

1 X Y ti (g)
ZG (X1 , X2 , . . . , Xn ) =
.
X
|G| gG i=1 i

CHAPTER 20. A GENERATING FUNCTION FOR ORBITS

179

It therefore remains to show that


N=

n
XY

t (g)

Xi i ,

gG i=1

where
Xi =

w(b)i ,

i = 1, 2, . . . , n.

bB

Note that

N=

X
gG

W (f ),

f B A ,f g=f

and that it is sufficient to show that for g G,


n
X
Y
t (g)
W (f ) =
Xi i .
i=1

f B A ,f g=f

Recall that if f g = f , then f is fixed by g and f is constant on cycles of g.


So suppose that C1 , C2 , . . . , Ck are cycles of g. Then if f is fixed by g, we
have for ai Ci , i = 1, 2, . . . , k,
!
k
k
Y
Y
Y
Y
W (f ) =
f (a) =
w(f (a)) =
w(f (ai ))|Ci | ,
i=1

aA

i=1

aCi

where the last inequality is due to the fact that f is constant on each Ci .
Consider the sum
X
X
W (f ) =
w(f (a1 ))|C1 | w(f (a2 ))|C2 | w(f (ak ))|Ck | .
f B A ,f g=f

f B A ,f g=f

The choices for f are f (ai ) for each i = 1, 2, . . . , k. Thus,


X
X X
X

w(b1 )|C1 | w(b2 )|C2 | w(bk )|Ck |
W (f ) =

b1 B b2 B

f B A ,f g=f

k
Y
i=1

w(bi )

|Ci |

bi B

k
X
Y
i=1

bB

n
Y

=1

bk B

bB

w(b)|Ci |
w(b)

!t (g)

CHAPTER 20. A GENERATING FUNCTION FOR ORBITS

180

where denotes the length of a cycle, and t (g) is the number of cycles of
length in g. Thus,
X

W (f ) =

n
Y

t (g)

X ,

where X =

=1

f B A ,f g=f

w(b) .

bB

It therefore follows that


N=

n
X Y
gG

t (g)

=1

as required.
Theorem 20.2. Let
A be a finite set with |A| = n,
G be a permutation group on A,
B be a finite set of m colors.
So B A is the set of colorings of A with m colors. Let
F (x1 , x2 , . . . , xm ) = ZG (X1 , X2 , . . . , Xn ),
where
X =

m
X

xj .

j=1

Then the number of (nonequivalent) colorings with kj elements of A colored


with color j, j = 1, 2, . . . , m, is
[xk11 xk22 xkmm ]F (x1 , x2 , . . . , xm ).
Proof. Note that xj is the weight of color j and that the weight of a coloring
f is
m
Y
elements in A with color j in the coloring f
W (f ) =
x#
.
j
j=1

CHAPTER 20. A GENERATING FUNCTION FOR ORBITS


Now
F (x1 , x2 , . . . , xm ) =

181

W (f ).

f D

It follows that

[xk11 xk22 xkmm ]F (x1 , x2 , . . . , xm )


is the number of (nonequivalent) colorings f D with kj elements of A
colored with color j, j = 1, 2, . . . , m.
Notice that the intuitive idea behind the previous theorem is that in the
cycle index, each X represents a cycle with length of a permutation g G
on A. The elements in the cycle have the same color. Thus, replacing X
with xi shows that the elements of A in the cycle represented by X are
colored with color ci . Since there are m colors, we should replace X with
P
m

i=1 xi .

20.2

Examples

Example 20.1. Recall that the cycle index of G(2) in nonisomorphic graphs
on 5 vertices is
ZG(2) =

1
X110 + 10X14 X23 + 20X1 X33
5!
+30X2 X42 + 15X12 X24 + 20X1 X3 X6 + 24X52 ) .

Now take B = {0, 1} and w(0) = x0 = 1, w(1) = x. Then X = 1 + x and


F (x) = ZG(2) (X1 , X2 , . . . , Xn )
1
(1 + x)10 + 10(1 + x)4 (1 + x2 )3 + 20(1 + x)(1 + x3 )3
=
5!
+30(1 + x2 )(1 + x4 )2 + 15(1 + x)2 (1 + x2 )4
+20(1 + x)(1 + x3 )(1 + x6 ) + 24(1 + x5 )2 ) .

CHAPTER 20. A GENERATING FUNCTION FOR ORBITS

182

The number of nonisomorphic graphs on 5 vertices with 2 edges is therefore


 
   
1
10
4
3
2
[x ]F (x) =
+ 10
+
+ 20(0)
5!
2
2
1

+30(1) + 15((1)(4) + (1)(1)) + 20(0) + 24(0)
=

1
(45 + 90 + 30 + 75) = 2.
120

Also, the number of nonisomorphic graphs with 5 vertices and 5 edges is


     
 
4 3
4 3
10
1
5
+ 20(0)
+
+ 10
[x ]F (x) =
3 1
1 2
5
5!

  
2 4
+ 20(0) + 24(2)
+30(0) + 15
1 2
1
= 120
(252 + 240 + 180 + 48)
= 6.
Using Maple, after inputting F , one finds that
> seq(coeff(F(x),x,i),i=0..10);
> 1, 1, 2, 4, 6, 6, 6, 4, 2, 1, 1
Notice that the sequence is symmetric because of graph complements.
Example 20.2. Color the vertices of an n-gon with m colors. Assume equivalence under rotations. Find the generating function for the number of colorings.
Solution. The group is the cyclic group of order n. Recall that for d | n, the
number of rotations with nd cycles of length d each is (d). Also, the cycle
index of a group G is
n
1 X Y ti (g)
,
X
n gG i=1 i
where ti (g) is the number of cycles with length i in g. Therefore the cycle
index of the cyclic group with order n is
1X
n/d
(d)Xd .
n
d|n

CHAPTER 20. A GENERATING FUNCTION FOR ORBITS

183

The generating function is therefore


m
X
1X
F (x1 , x2 , . . . , xm ) =
xdj
(d)
n
j=1
d|n

!n/d

For example, the generating function for the # colorings of the vertices of
an 8-gon using 3 colors c1 , c2 , c3 is

1
(x1 + x2 + x3 )8 + (x21 + x22 + x23 )4
F (x1 , x2 , x3 ) =
8

4
4
4 2
8
8
8
+2(x1 + x2 + x3 ) + 4(x1 + x2 + x3 ) .
In particular, the number of colorings of the vertices of a 8-gon such that 3
vertices are red, 2 are blue and 3 are green equals


8
1
3 2 3
= 70.
[x1 x2 x3 ]F (x1 , x2 , x3 ) =
8 3, 2, 3
Example 20.3. Consider the necklace problem with n beads of m types,
with equivalence under rotations and reflections. The cycle index is (from
before)
ZG (X1 , X2 , . . . , Xn )

P

n n/2
n (n2)/2 2
k
1
X
X
+
X
, if n is even,
(n/k)X
+
1
n/k
2n
2 2
Pk|n
 2 2
=
(n1)/2
k
1
X1 ,
if n is odd.
k|n (n/k)Xn/k + nX2
2n

If each type i bead costs i1 dollars, i = 1, 2, . . . , m. Then we should replace


xi with xi1 and then
X =

m
X
i=1

xi =

m1
X
i=0

xi =

xm 1
.
x 1

If n is odd, then the number of necklaces with n beads that cost k dollars
equals the coefficient of xk in







k
(n1)/2
m
2m
mn/k
x 1
x 1
x
1
1 X
.
+
n
(n/k)
2n
xn/k 1
x2 1
x1
k|n

184

CHAPTER 20. A GENERATING FUNCTION FOR ORBITS

For example, if n = 9 and m = 4, then the number of necklaces that cost k


dollars equals the coefficient of xk in
1
18

36

x 1
x9 1

+2

12

x 1
x3 1

3

x 1
x1

9

+9

x 1
x2 1

4 

x 1
x1

= 1 + x + 5x2 + 12x3 + 34x4 + 74x5 + 160x6 + 290x7 + 495x8 + 752x9


+1055x10 + 1347x11 + 1592x12 + 1724x13 + 1724x14 + 1592x15
+1347x16 + 1055x17 + 752x18 + 495x19 + 290x20 + 160x21 + 74x22
+34x23 + 12x24 + 5x25 + x26 + x27 .
Note. I have not checked everything in details.

Example 20.4 (Rotations of the cube). There are three kinds of axes of
rotation:
a

b
c
y

(A) There are three axes like xy, and each has rotations by 0, 2 , .
(B) There are six axes like ab, and each has rotations by 0, .
(C) There are four axes like cd, and each has rotations by 0, 2
.
3
Note that only the identity rotation appears more than once in the above,
and hence there are (3)(4 1) + 6(2 1) + 4(3 1) + 1 = 24 rotations.
Example 20.5 (Coloring the Vertices Of a Cube). Let A be the set of the 8
vertices of a cube. The 24 rotations of the cube induce 24 permutations on
A. We next calculate the cycle index of the group of these 24 permutations:

!

CHAPTER 20. A GENERATING FUNCTION FOR ORBITS


permutations
identity
2 about xy
about xy
about ab
about cd
2
3

185

# such permutations contribution to the ZG


1
X18
6
6X42
3
3X24
6
6X24
8
8X12 X32

The cycle index is therefore


ZG =


1
X18 + 6X42 + 9X24 + 8X12 X32 .
24

Thus, the number of colorings of the vertices of the cube using m colors,
equivalent under rotation, is


1
1
m8 + 6m2 + 9m4 + 8m4 =
m8 + 6m2 + 17m4 .
24
24

Also, for example, the number of colorings of the vertices of the cube so that
3 are red, 3 are blue and 2 are green equals
[x3 y 3 z 2 ]F (x, y, z),
where
F (x, y, z) =

Thus,

1
(x + y + z)8 + 6(x4 + y 4 + z 4 )2
24

+9(x2 + y 2 + z 2 )4 + 8(x2 + y 2 + z 2 )(x3 + y 3 + z 3 )2 .

[x3 y 3 z 2 ]F (x, y, z)





8
2
2
1
+0+0+8
=
24
3, 3, 2
0, 0, 2 1, 1, 0
1
=
(560 + 16)
24
= 24.

Chapter 21
Symmetry in B
We shall only touch on this topic. Our aim is to solve this problem. What is
the number of distributions of 2 red, 2 yellow and 4 green balls into 1 round
box and 3 square boxes? We shall develop a general solution method. Here
A is the set of balls and B is the set of boxes. Unfortunately some boxes are
identical as well as some balls.
Notice that since we can permute the balls with the same color, the
symmetry on A is given by S2 S2 S4 , where Sn is the symmetric group
with n elements. Similarly, the symmetry in B is given by S1 S3 .

Lemma 21.1. Suppose that A, B are finite sets and G, H are permutation
groups on A and B respectively. Then G H is a group acting on B A by
(g,h) (f ) = hf g 1 ,

g G,

h H,

f BA.

Proof. We shall omit proving that G H is a group. We shall only prove


that G H acts on B A .
FIRST. For each (g, h) G H, and for f1 , f2 B A ,
=
=

(g,h) (f1 ) = (g,h) (f2 )


hf1 g 1 = hf2 g 1
f1 = f2 .

This shows that (g,h) is 1-1 and is hence a permutation on B A (since B A is


finite).
186

CHAPTER 21. SYMMETRY IN B

187

SECOND. For (g, h), (g , h ) G H, we have for any f B A that


((g,h) (g ,h ) )(f ) =
=
=
=

(g,h) (h f g 1 )
hh f g 1 g 1
hh f (gg )1
(gg ,hh ) (f ).

This shows that G H acts on B A .

21.1

The Theorem

Theorem 21.1. Suppose that A and B are finite sets. Let |A| = n and let
G, H be permutation groups on A, B respectively. Then the number of orbits
of G H on B A is
1 X
ZG (m1 (h), m2 (h), . . . , mn (h)),
|H| hH
where

mi (h) =

tj (h),

i = 1, 2, . . . n,

j|i

tj (h) = # cycles in h with length j.


Proof. By Burnsides Lemma, the number of orbits of G H on B A equals
X
1
(g, h),
|G H|
(g,h)GH

where (g, h) is the number of functions f B A fixed by (g, h). Note that
a function f is fixed by (g, h) iff
f = hf g 1 ,

or equivalently

hf = f g.

Therefore
# orbits of G H on B A
!
1 X
1 X
# f B A such that hf = f g .
=
|H| hH |G| gG

CHAPTER 21. SYMMETRY IN B

188

It therefore remains to show that for each h H,


1 X
ZG (m1 (h), m2 (h), . . . , mn (h)) =
# f B A such that hf = f g.
|G| gG
Therefore, assume h H for the rest of the proof. Take any g G and
a A and b = f (a). Let C be the cycle in g containing a, and write c = |C|,
the length of cycle C. Then for any f B A fixed by (g, h), we have hf = f g
and so hc f = f g c . Now since c is the length of the cycle C in g, we have
hc (b) = hc (f (a)) = f (g c (a)) = f (c) = b.
It therefore shows that the cycle in h containing b must be a divisor of c,
the length of the cycle C in g. Conversely, if T is a cycle in h with length d
and d | c, then there are d possible ways to map a C to an element in T
and each determines the restriction fC,T of f so that fC,T : C T . Now the
number of functions fC : C B is therefore
X
dtd (h) = mc (h),
d|c

where (as before) td (h) is the number of cycles in h with length d. Thus, the
number of functions f : A B fixed by (g, h) equals
k
Y

mcj (h),

j=1

where k is the number of cycles in g and cj s are the lengths of those cycles.
But
k
n
Y
Y
mci (h) =
mi (h)ti (g) .
i=1

It therefore follows that


1 X
|G| gG

i=1

# f B A such that hf = f g

n
1 X Y
=
mi (h)ti (g)
|G| gG i=1

= ZG (X1 , X2 , . . . , Xn ),

!
where Xi = mi (h).

CHAPTER 21. SYMMETRY IN B

21.2

189

The Example

Recall that we are interested in finding the number of distributions of 2


red, 2 yellow and 4 green balls into 1 round box and 3 square boxes? Here
G = S2 S2 S4 and H = S1 S3 . Note that the cycle indices of the
symmetric groups are
ZS1
ZS2
ZS3
ZS4

= X1 ,

= 12 X12 + X2 ,

= 61 X13 + 3X1 X2 + 2X3 ,

1
X14 + 8X1 X3 + 6X12 X2 + 3X22 + 6X4 .
= 12

Note that the cycle index of a product of groups equals the product of the
cycle indices of the groups. Hence
ZG =

2

1
X12 + X2
X14 + 8X1 X3 + 6X12 X2 + 3X22 + 6X4 .
(2)(2)(24)

We next need to calculate mi (h) for h H = S1 S3 . Recall that


X
mi (h) =
jtj (h),
tj (h) = # cycles in h with length j.
j|i

# such h
1
3
2

cycle class of hs
14
12 21
11 31

m1 (h)
4
2
1

m2 (h)
4
4
1

m3 (h)
4
2
4

m4 (h)
4
4
1

Hence, the number of nonequivalent distributions is



1
(42 + 4)2 (44 + (8)(4)(4) + (6)(42 )(4) + (3)(42 ) + (6)(4))
(6)(96)

+3(22 + 4)2 (24 + (8)(2)(2) + (6)(22 )(4) + (3)(42 ) + (6)(4))


2

+2(1 + 1) (1 + (8)(1)(4) + (6)(1 )(1) + (3)(1 ) + (6)(1))


1
(336000 + 41472 + 384)
= 576
= 656.

You might also like