Beruflich Dokumente
Kultur Dokumente
R. Simon
MT3170, 2790170
2011
Undergraduate study in
Economics, Management,
Finance and the Social Sciences
This is an extract from a subject guide for an undergraduate course offered as part of the
University of London International Programmes in Economics, Management, Finance and
the Social Sciences. Materials for these programmes are developed by academics at the
London School of Economics and Political Science (LSE).
For more information, see: www.londoninternational.ac.uk
This guide was prepared for the University of London International Programmes by:
Dr R.Simon, Lecturer, Department of Mathematics, London School of Economics and
Political Science.
This is one of a series of subject guides published by the University. We regret that due
to pressure of work the author is unable to enter into any correspondence relating to, or
arising from, the guide. If you have any comments on this subject guide, favourable or
unfavourable, please use the form at the back of this guide.
Contents
Contents
1 Introduction
1.1
This course . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1.1
1.1.2
Aims . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1.3
Learning outcomes . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1.4
Topics covered . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Recommended books . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2.1
Essential reading . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2.2
Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3.1
The VLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3.2
1.4
Examination advice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.5
Basic notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2
1.3
2 Elementary counting
Essential reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2
Selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.1
Number of functions . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.2
. . . . . . .
2.2.3
Pascals triangle . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12
14
Inclusion-exclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
2.3.1
The theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15
2.3.2
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17
2.3.3
Surjective functions . . . . . . . . . . . . . . . . . . . . . . . . . .
18
22
23
2.3
2.4
Contents
2.4.1
Partitions of an integer . . . . . . . . . . . . . . . . . . . . . . . .
23
2.4.2
23
2.4.3
Number of partitions . . . . . . . . . . . . . . . . . . . . . . . . .
24
2.4.4
Permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
26
2.4.5
Ferrers diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . .
29
30
31
2.5.1
31
2.5.2
32
2.5.3
Number of permutations . . . . . . . . . . . . . . . . . . . . . . .
34
37
Learning outcomes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
38
Solutions to exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
38
38
39
42
43
2.5
3 Generating functions
Essential reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
47
Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
47
3.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
47
3.2
47
3.2.1
47
3.2.2
Making change . . . . . . . . . . . . . . . . . . . . . . . . . . . .
48
3.2.3
49
3.2.4
51
3.2.5
Algebraic manipulations . . . . . . . . . . . . . . . . . . . . . . .
52
3.2.6
Calculus manipulations . . . . . . . . . . . . . . . . . . . . . . . .
53
3.2.7
56
59
Recurrence relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
59
3.3.1
59
3.3.2
Equivalences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
60
3.3.3
62
3.3.4
65
3.3
ii
47
Contents
3.3.5
Initial conditions . . . . . . . . . . . . . . . . . . . . . . . . . . .
66
70
71
3.4.1
72
3.4.2
Partitions of an integer . . . . . . . . . . . . . . . . . . . . . . . .
73
3.4.3
A theorem of Euler . . . . . . . . . . . . . . . . . . . . . . . . . .
74
76
Learning outcomes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
77
Solutions to exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
77
77
79
84
3.4
4 Graph theory
87
Essential reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
87
Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
87
4.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
87
4.1.1
87
4.1.2
91
4.1.3
Degree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
91
4.1.4
Minors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
92
4.1.5
Directed graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . .
93
93
95
4.2.1
Eulerian walks
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
95
4.2.2
Hamiltonian cycles . . . . . . . . . . . . . . . . . . . . . . . . . .
96
98
98
4.3.1
99
4.3.2
Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
100
4.3.3
102
4.3.4
Greedy algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . .
103
104
Vertex colouring
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
104
4.4.1
104
4.4.2
A-cyclic orientations . . . . . . . . . . . . . . . . . . . . . . . . .
106
4.2
4.3
4.4
iii
Contents
108
Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
109
4.5.1
Halls theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
109
4.5.2
Vertex covering . . . . . . . . . . . . . . . . . . . . . . . . . . . .
111
4.5.3
Permutation matrices . . . . . . . . . . . . . . . . . . . . . . . . .
111
112
113
4.6.1
Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
113
4.6.2
Tournaments . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
113
4.6.3
Network flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
117
119
Learning outcomes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
120
Solutions to exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
120
120
122
123
124
126
127
4.5
4.6
5 Group theory
Essential reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
129
Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
129
5.1
Permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
129
5.1.1
Basic properties . . . . . . . . . . . . . . . . . . . . . . . . . . . .
129
5.1.2
Transpositions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
130
5.1.3
Even or odd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
133
135
Group axioms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
136
5.2.1
Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
136
5.2.2
Cancellation law . . . . . . . . . . . . . . . . . . . . . . . . . . .
136
5.2.3
Examples of groups . . . . . . . . . . . . . . . . . . . . . . . . . .
137
5.2.4
Subgroups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
138
5.2.5
Examples of subgroups . . . . . . . . . . . . . . . . . . . . . . . .
139
140
Cosets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
141
5.2
5.3
iv
129
Contents
5.3.1
Equivalence relation . . . . . . . . . . . . . . . . . . . . . . . . .
141
5.3.2
Homomorphisms . . . . . . . . . . . . . . . . . . . . . . . . . . .
142
5.3.3
Normal subgroups
. . . . . . . . . . . . . . . . . . . . . . . . . .
142
144
Group action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
145
5.4.1
Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
145
5.4.2
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
145
5.4.3
147
5.4.4
More on homomorphisms . . . . . . . . . . . . . . . . . . . . . . .
149
5.4.5
Commuting permutations . . . . . . . . . . . . . . . . . . . . . .
150
153
Counting orbits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
154
5.5.1
Burnsides lemma . . . . . . . . . . . . . . . . . . . . . . . . . . .
154
5.5.2
155
5.5.3
156
157
Learning outcomes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
158
Solutions to exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
158
158
159
161
162
165
5.4
5.5
169
Essential reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
169
Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
169
6.1
Introduction to rings . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
169
6.1.1
Axioms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
169
6.1.2
Elementary results . . . . . . . . . . . . . . . . . . . . . . . . . .
170
6.1.3
Examples of rings . . . . . . . . . . . . . . . . . . . . . . . . . . .
170
6.1.4
Ideals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
171
172
Commutative rings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
173
6.2.1
173
6.2.2
Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
174
6.2
Contents
6.2.3
Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
174
6.2.4
Factoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
177
178
179
6.3.1
Basic structure . . . . . . . . . . . . . . . . . . . . . . . . . . . .
179
6.3.2
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
180
6.3.3
Factoring by an irreducible . . . . . . . . . . . . . . . . . . . . . .
181
6.3.4
Field extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . .
182
184
Learning outcomes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
185
Solutions to exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
185
185
186
187
6.3
7 Finite geometry
Essential reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
189
Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
189
7.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
189
7.2
Finite fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
189
7.2.1
Basic construction . . . . . . . . . . . . . . . . . . . . . . . . . .
189
7.2.2
Characteristic . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
190
7.2.3
Cyclic groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
190
7.2.4
Existence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
192
195
195
7.3.1
196
7.3.2
Determinant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
197
7.3.3
Linear transformations . . . . . . . . . . . . . . . . . . . . . . . .
198
7.3.4
Inner product . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
198
7.3.5
Diagonalisation . . . . . . . . . . . . . . . . . . . . . . . . . . . .
199
201
Designs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
201
7.4.1
Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
202
7.4.2
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
202
7.4.3
Existence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
203
7.3
7.4
vi
189
Contents
7.4.4
t-designs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
204
7.4.5
Difference sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
205
207
Planes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
207
7.5.1
Affine planes . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
207
7.5.2
Projective planes . . . . . . . . . . . . . . . . . . . . . . . . . . .
208
7.5.3
Matrix action . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
211
214
Learning outcomes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
214
Solutions to exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
215
215
216
218
220
7.5
8 Coding theory
223
Essential reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
223
Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
223
8.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
223
8.1.1
The problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
223
8.1.2
Binary spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
224
8.1.3
Distance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
224
8.1.4
Error correcting . . . . . . . . . . . . . . . . . . . . . . . . . . . .
226
227
Linear codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
227
8.2.1
Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
227
8.2.2
Generator matrices . . . . . . . . . . . . . . . . . . . . . . . . . .
228
8.2.3
228
8.2.4
Minimal distance . . . . . . . . . . . . . . . . . . . . . . . . . . .
229
8.2.5
230
231
Special codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
232
8.3.1
Hamming codes . . . . . . . . . . . . . . . . . . . . . . . . . . . .
232
8.3.2
Cyclic codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
233
8.3.3
234
8.3.4
Irreducible polynomials . . . . . . . . . . . . . . . . . . . . . . . .
235
8.2
8.3
vii
Contents
236
Learning outcomes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
237
Solutions to exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
237
237
238
239
241
viii
List of Figures
List of Figures
2.1
2.2
|Y ||X| = |Y | |Y ||X | . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10
2.3
Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10
2.4
15
2.5
17
2.6
19
2.7
Surjective selections: (a) permuting the range, (b) permuting the domain.
21
2.8
26
2.9
Matching cycles.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28
29
33
35
3.1
50
3.2
73
4.1
The graph C8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
88
4.2
The graph K5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
88
4.3
89
4.4
A bipartite graph. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
89
4.5
90
4.6
Isomorphic graphs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
90
4.7
A subgraph. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
90
4.8
Complementary graphs. . . . . . . . . . . . . . . . . . . . . . . . . . . .
91
4.9
91
92
92
93
94
94
96
ix
List of Figures
97
99
100
101
102
106
106
107
110
4.26 A network. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
117
5.1
A transposition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
131
5.2
Combining transpositions. . . . . . . . . . . . . . . . . . . . . . . . . . .
132
5.3
133
5.4
134
5.5
The order of g is l. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
137
5.6
Cyclic groups. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
138
5.7
The kernel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
142
5.8
and generate D4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
146
5.9
Orbits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
148
151
7.1
191
7.2
An affine plane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
208
7.3
209
7.4
210
7.5
211
7.6
A translation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
213
112
Chapter 1
Introduction
In this very brief introduction, I aim to give you an idea of the nature of this course and
to advise on how best to approach it. I also give general information about the contents
and use of this subject guide, on recommended reading, and on how to use the
textbooks.
1.1
1.1.1
This course
Relationship to previous mathematics courses
If you are taking this course as part of a BSc degree, you will already have taken the
prerequisite mathematics course 116 Abstract mathematics. In 116 Abstract
mathematics you will have learned about the fundamentals of mathematical
reasoning, in addition to some background in discrete mathematics and algebra.
After studying this course, you should be equipped with a knowledge of concepts which
are central not only to advanced mathematics courses, but to applications of
mathematics in many areas. You may also discover that some concepts appear in many
different contexts, so that the course material will at times appear to be interwoven.
More generally, a course of this nature, with the emphasis on abstract reasoning and
proof, will help you to think in an analytical way and formulate mathematical
arguments in a precise, logical manner.
1.1.2
Aims
1.1.3
Learning outcomes
At the end of the course, and having completed the Essential reading and activities you
should be able to:
demonstrate knowledge of the definitions, concepts, and methods in the topics
covered, and how to apply these
find and formulate simple proofs
model situations in a mathematical way and derive useful results.
1. Introduction
1.1.4
Topics covered
1.2
1.2.1
Recommended books
Essential reading
This is just a course guide and not a textbook. Almost all of the theoretical material
covered in this guide can be found in the two books by Peter Cameron, Introduction to
Algebra and Combinatorics, and the book Discrete Mathematics by Norman Biggs. The
connections to these books will be mentioned throughout the guide. Additionally, you
should look at Part I (Foundations) of Discrete Mathematics as a summary of the
prerequisite mathematical knowledge for this course.
Unfortunately, there is no single book that covers all the material of this course.
Furthermore, some of the material of these books is too advanced for this course. You
would do well to read the chapters of these books that are mentioned as reading at the
start of each chapter of this guide. Almost all of the theoretical material of this guide is
to be found in these three books. However, some of the theoretical material of this guide
are variations on themes presented in these three books. When the material cannot be
found explicitly in any of these three books, the connections to the appropriate sections
in these books will, nevertheless, be mentioned. It may prove useful also to work
through examples and exercises presented in these books as well as the exercises and
examples of this guide. The proofs in this guide are my proofs. Sometimes they are
essentially the same as those presented in these three books and sometimes they are
quite different. Also, sometimes the proofs by Biggs and Cameron of the same result
will differ significantly. It is usually an advantage to understand how the same result
can be proven in different ways, and it is recommended that you read both the proofs in
this guide and the proofs in the three textbooks.
R
R
R
When cited in this guide, I will refer to them as Discrete Mathematics, Algebra and
Combinatorics respectively.
Detailed reading references in this subject guide refer to the editions of the set
textbooks listed above. New editions of one or more of these textbooks may have been
published by the time you study this course. You can use a more recent edition of any
of these books; use the detailed chapter and section headings and the index to identify
relevant readings. Also check the virtual learning environment (VLE) regularly for
updated guidance on readings.
1.2.2
Further reading
Please note that as long as you read the Essential reading you are then free to read
around the subject area in any text, paper or online resource. You will need to support
your learning by reading as widely as possible. To help you read extensively, you have
free access to the VLE and University of London Online Library (see below).
There are many additional books that might be useful for this course. Some are listed
below:
R
R
R
R
R
R
R
1.3
In addition to the subject guide and the Essential reading, it is crucial that you take
advantage of the study resources that are available online for this course, including the
VLE and the Online Library.
You can access the VLE, the Online Library and your University of London email
account via the Student Portal at:
http://my.londoninternational.ac.uk
You should have received your login details for the Student Portal with your official
offer, which was emailed to the address that you gave on your application form. You
1. Introduction
have probably already logged in to the Student Portal in order to register! As soon as
you registered, you will automatically have been granted access to the VLE, Online
Library and your fully functional University of London email account. If you forget your
login details at any point, please email uolia.support@london.ac.uk quoting your
student number.
1.3.1
The VLE
The VLE, which complements this subject guide, has been designed to enhance your
learning experience, providing additional support and a sense of community. It forms an
important part of your study experience with the University of London and you should
access it regularly.
The VLE provides a range of resources for EMFSS courses:
Self-testing activities: Doing these allows you to test your own understanding of
subject material.
Electronic study materials: The printed materials that you receive from the
University of London are available to download, including updated reading lists
and references.
Past examination papers and Examiners commentaries: These provide advice on
how each examination question might best be answered.
A student discussion forum: This is an open space for you to discuss interests and
experiences, seek support from your peers, work collaboratively to solve problems
and discuss subject material.
Videos: There are recorded academic introductions to the subject, interviews and
debates and, for some courses, audio-visual tutorials and conclusions.
Recorded lectures: For some courses, where appropriate, the sessions from previous
years Study Weekends have been recorded and made available.
Study skills: Expert advice on preparing for examinations and developing your
digital literacy skills.
Feedback forms.
Some of these resources are available for certain courses only, but we are expanding our
provision all the time and you should check the VLE regularly for updates.
1.3.2
The Online Library contains a huge array of journal articles and other resources to help
you read widely and extensively.
To access the majority of resources via the Online Library you will either need to use
your University of London Student Portal login details, or you will be required to
register and use an Athens login:
http://tinyurl.com/ollathens
The easiest way to locate relevant content and journal articles in the Online Library is
to use the Summon search engine.
If you are having trouble finding an article listed in a reading list, try removing any
punctuation from the title, such as single quotation marks, question marks and colons.
1.4
Examination advice
Important: the information and advice given here are based on the examination
structure used at the time this guide was written. Please note that subject guides may
be used for several years. Because of this we strongly advise you to always check both
the current Regulations for relevant information about the examination, and the VLE
where you should be advised of any forthcoming changes. You should also carefully
check the rubric/instructions on the paper you actually sit and follow those instructions.
A Sample examination paper is given at the end of this guide. There are no optional
topics in this course: you should study them all. The examination paper will provide
some element of choice as to which questions you attempt: see the Sample examination
paper at the end of the guide for an indication of the structure of the examination
paper.
Please do not assume that the questions in a real examination will necessarily be very
similar to these sample questions. An examination is designed (by definition) to test
you. You will get examination questions unlike questions in this guide and each year
there will be examination questions different from those in previous years. The whole
point of examining is to see whether you can apply knowledge in familiar and unfamiliar
settings. For this reason, it is important that you try as many examples as possible,
from the guide and from the textbooks. This is not so that you can cover every possible
type of question the Examiners can think of! It is so that you get used to confronting
unfamiliar questions, grappling with them, and finally coming up with the solution.
Do not panic if you cannot completely solve an examination question. There are many
marks to be awarded for using the correct approach or method.
The examination covers the material in this guide. The three textbooks used in this
course do contain material that is too advanced for this course, and therefore I would
not expect you to have mastered all the material covered in these books. However, if
you do, it would not hurt your performance in the examination! It would be very helpful
to study the Sample examination paper at the end of this guide to understand the level
of difficulty, the format and the types of topics covered. As a general rule, you will not
be expected to reproduce long or complicated proofs that are contained in this guide.
However, knowledge of shorter and simpler proofs may be requested and certainly it is
desirable that you know something of the significance and application of all the
theorems covered in this guide.
You will not be permitted to use calculators of any type in the examination. This is not
something that you should panic about: the Examiners are interested in assessing that
you understand the key concepts, ideas, methods and techniques, and will therefore set
questions which do not require the use of a calculator.
1. Introduction
1.5
Basic notation
We often use the symbol to denote the end of a proof, where we have finished
explaining why a particular result is true. This is just to make it clear where the proof
ends and the following text begins.
Chapter 2
Elementary counting
RR
Essential reading
Further reading
2.1
Introduction
In this chapter, we look at elementary counting, the ways to determine the size of a
finite set. In later chapters, we introduce ways to count that involve more sophisticated
algebraic methods.
2.2
Selections
The relevant reading here will be Sections 10.l to 10.4 of Discrete Mathematics and
Section 3 of Combinatorics.
The following definition is in Section 6.2 of Discrete Mathematics.
Definition 2.1 The cardinality of a non-empty finite set A is its number of elements,
equivalently the positive integer n such that there is a one-to-one matching of every
element of A with every element of {1, 2, . . . , n}. The cardinality of the empty set is
zero.
If X is a finite set, |X| stands for the cardinality of X.
2.2.1
Number of functions
2. Elementary counting
Proof
The proof is by induction on the size of X. If |X| = 1, then there are exactly |Y |
functions. Given X = X 0 {x} with x 6 X 0 , by induction assume that there are
0
|Y ||X | = |Y ||X|1 functions from X 0 to Y . See Figure 2.1. For every function from X 0 to
Y we have Y choices of where to send x, for a total of |Y ||X|1 |Y | = |Y ||X| .
X0
Y
x
0
The following lemma is also proven in Section 3.1 of Combinatorics and given as an
example following Theorem 10.4 of Discrete Mathematics.
Lemma 2.2 The number of subsets of a finite set X (including the empty set and
the full set X) is 2|X| .
Proof
Let Y = {0, 1}. For every function f : X Y = {0, 1} from X to the set {0, 1} of size
two define a subset Af of X by Af = {x | f (x) = 1}, the subset that gets mapped to 1
by f . Notice that every subset is Af for some function f : X Y = {0, 1} and f = g if
and only if Af = Ag . Therefore the number of subsets of X is 2|X| by Lemma 2.1.
2.2.2
The four most common selections determined by restrictions and equivalence relations
are discussed in Section 3.7 of Combinatorics and Section 10.5 of Discrete Mathematics.
The number of all functions from some set X to some set Y may not be interesting, for
two reasons:
(1) what may be interesting is only some subset of all functions: we call this
Restriction to a subset of the functions
(2) some pairs of functions may be essentially the same: we call this
Equivalence relation on the functions
2.2. Selections
Equivalence relations are also defined in Section 3.8 of Combinatorics and Section 7.2 of
Discrete Mathematics and you will have studied them in 116 Abstract mathematics.
To illustrate how an equivalence relation may be relevant, we may not care in which
order or to which position the players are chosen, only that five players are chosen. This
is a combination of a restriction to a subset and an equivalence relation. The number
1, 860, 480 must be divided by 120 = 5 4 3 2 1, the number of ways to order the five
players, for the answer 19 17 16 3 = 15, 504.
Also possible, though strange to the game of basketball, is concern for the equivalence
relation without the restriction that five players should be chosen. We do not care in
which order the players are chosen, but a player could be chosen twice (or more often).
Determining the number of equivalence classes of this equivalence relation may be
tricky, due to the different possibilities for functions to choose the same player more
than once. We return to this problem later when we show that there is a simple
mathematical solution.
Another example of when the number of equivalence classes of functions are more
interesting than the number of functions concerns the number of ways to create a
necklace of beads with different colours. Suppose we wanted to create necklaces with
twelve beads using the three colours red, blue, and yellow. The number of ways to
assign the three colours to six positions would be 36 . However, rotating or flipping the
2. Elementary counting
necklace results in the same necklace. For example, the necklace defined by the sequence
y, y, b, r, b, r is the same necklace as that defined by the sequences r, b, r, b, y, y
(flipping between beads) and is the same as that defined by the sequence y, r, b, r, b, y
(rotating by one). All three of these functions define the same necklace. See Figure 2.2.
Counting the number of necklaces is a problem of counting the number of equivalence
classes, where two functions are equivalent if they define the same necklace. An effective
method for determining this number will be presented in a later chapter.
r
In general, given a subset A of all the functions and an equivalence relation defined by
we will want to know the number k such that there is a partition {A1 , A2 , . . . , Ak } of
A such that for all a, b A it holds that a b if and only if a, b Ai for some i.
The following definitions are given in Section 5.2 of Discrete Mathematics and in 116
Abstract mathematics.
A function f : X Y is injective if f (x) = f (y) implies that x = y.
The image of a function f : X Y (im (f )) is the subset of all points in Y that are
f (x) for some x in X.
A function f : X Y is surjective if the image of f is the whole set Y .
A bijective function from a set X to itself is called a permutation of X. See Figure 2.3.
Injective
Surjective
Bijective
There are many types of subset restrictions and equivalence relations. But there are two
pairs that are most commonly used. They are the same as those presented in Chapter
10
2.2. Selections
1. Subsets of functions:
With repetitions: all functions from X to Y are relevant.
Without repetitions: only injective functions from X to Y are relevant.
2. Equivalence relations:
Ordered: no two distinct functions from X to Y are considered to be equivalent.
Unordered: permutations on X yield equivalent functions.
Permutations on Y yielding equivalent functions define a different equivalence relation.
We deal with this later.
Four most common selections
Ordered with repetitions: this is the most inclusive. These are all the functions from
a k-set to an n-set.
The best example is the number of different keys that can be made to open a lock. At
every depth of the key there are finitely many positions. The width of the key has to
match that of the lock for every position, otherwise the key will not work.
Ordered without repetitions: This is the subset of injective functions.
Suppose there is a cricket team of 20 players. The manager must choose not only 11
players from the 20 on the team to bat, but also determine the batting order. For the
first on the batting order, one of 20 can be chosen. For the second, one of 19 can be
chosen, and so on. The number of such functions is 20 19 10.
11
2. Elementary counting
2.2.3
Pascals triangle
n
Now we look in more detail at
and its properties. This can also be found in
k
Section 11.1 of Discrete Mathematics and Section 3.3 of Combinatorics.
The following lemma is Theorem 11.1.1 of Discrete Mathematics.
Lemma 2.3 For n k > 0
n
n1
n1
=
+
.
k
k
k1
Proof
Choose any number i from 1 to n. The k subsets of {1, 2, . . . , n}can be
made including
n1
the number i or excluding the number i. By including we have
ways and by
k1
n1
excluding we have
ways.
k
12
2.2. Selections
n
Lemma 2.3 gives one way to calculate
known as Pascals Triangle.
k
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
The following is proven in Section 3.3 of Combinatorics and Section 11.3 of Discrete
Mathematics. It is known as the Binomial Theorem.
n
X
n k nk
n
Lemma 2.4 (a + b) =
a b .
k
k=0
Proof (1)
0
When n = 0 then
= 1 and we get 1 on both sides of the equation. By induction,
0
we can assume that
n1
X
n 1 k nk1
n1
(a + b)
=
a b
.
k
k=0
It follows that
(a + b)(a + b)
n1
n1
n1
X
n 1 k nk X n 1 k+1 nk1
=
a b
+
a b
.
k
k
k=0
k=0
n
X
n 1 k nk
a b .
k
1
k=1
n1
which is 1
0
Proof (2)
The number of unordered ways
and without repetition to select k times the letter a and
n
n k times the letter b is
. This is exactly the coefficient for ak bnk in the
k
expression (a + b)(a + b) (a + b) repeated n times, which counts the number of k
choices for a with n k choices for b.
13
2. Elementary counting
Proof (3)
Let D be the differential operator on the polynomials, meaning that Df of the
df
polynomial f (x) is the function
. From elementary calculus there is Taylors formula,
dx
which states that for all polynomials f
f (x + y) = f (x) + [Df ](x)y +
n
[Dk f ](x)y k
+ .
k!
nk
n
(n)k
and
=
.
k
k!
2.3
Inclusion-exclusion
If in a room there are 17 adult men and 22 adult women then there are 39 adults. Why?
14
2.3. Inclusion-exclusion
First, all adults are either men or women, and second, nobody is both a man and a
woman.
The North London football teams Arsenal and Tottenham are playing and people are
watching the game on TV in a pub. If 13 fans of Arsenal are watching and 8 fans of
Tottenham are watching, how many people are watching? See Figure 2.4.
Tottenham
fans
Arsenal fans
TV
Figure 2.4: How many people are watching?
The equation 13 + 8 = 21 might be the wrong answer. First, there may be some people
watching who are not fans of either team. Second, some people may be fans of both
teams. If everyone is indeed a fan of one of the two teams and two of them are fans of
both teams, then we know that 19 people are watching. We can calculate this in two
ways. We can break things down into three categories: exclusive fans of Arsenal,
exclusive fans of Tottenham, and fans of both, with 13 2 = 11 of the first, 8 2 = 6 of
the second, and 2 of the third, and then add up for 11 + 6 + 2 = 19. Another way is to
add the 13 and 8 together, and then subtract the 2, the people who were counted twice.
The second way is of greater mathematical sophistication.
2.3.1
The theorem
Proofs of the following theorem are in Sections 11.4 and 11.5 of Discrete Mathematics
and Section 5.1 of Combinatorics.
Theorem 2.5 (Inclusion-Exclusion) Let A1 , A2 , . . . , An be finite sets.
n
[
\
X
(1)|K|+1
Ai .
Ai =
i=1
6=K{1,2,...,n}
iK
15
2. Elementary counting
Proof
The proof is by induction on n. If n = 1 then there is only one non-empty subset of {1}
and on the right side 1 is put to the power of 2 for (1)2 |A1 | = |A1 |. If n = 2 then on
the right side we have |A1 | + |A2 | |A1 A2 |.
n1
[
Ai .
i=1
n
[
Ai = |A | + |An | |A An |.
i=1
1. By induction
|A | =
2. With A An =
\
Ai .
(1)|K|+1
n1
[
i=1
iK
6=K{1,2,...,n1}
(Ai An ) by induction
|A An | =
\
|K|+1
Ai An .
(1)
Rewrite
|An | |A An | = |An |
= |An |
=
iK
6=K{1,2,...,n1}
(1)|K|+1
iK
6=K{1,2,...,n1}
\
Ai
(1)|K|
nK,K6={n}
(1)|K|+1
\
A
A
i
n
iK
\
Ai .
iK
nK{1,2,...,n}
n
n
[
X
j+1 n
(1)
bj .
Ai =
j
i=1
16
j=1
2.3. Inclusion-exclusion
2.3.2
Applications
Application to co-primes
For any positive integer n the number (n) is defined to be the number of positive
integers k less than n such that the greatest common divisor of k and n is 1, meaning
that the only positive integer that divides both k and n is the number 1. The following
application is presented in Section 11.5 of Discrete Mathematics.
n
iA
pi
the same as the number of positive integers less than or equal to n divided by
pi .
iA
1
=n 1
p1
iA
pi
1
1
1
1
.
p2
pq
Application to derangement
A company has the idea of its employees giving random Christmas presents to each
other. Each person brings a present for somebody else, and a number is attached to it.
The numbers are written on folded pieces of paper which are placed in a box. The
employees take turns removing a number from the box. An employee receives the
present corresponding to the number on the selected piece of paper. See Figure 2.5.
Employees
Induced bijection
Box
Employees
Figure 2.5: The Christmas lottery.
17
2. Elementary counting
The only problem with this idea is the possibility that somebody gives their present to
themselves. If there are only two employees, this probability is one-half. If there are
three employees then this probability is 32 (4 out of the six permutations).
What is the probability of somebody getting their own present if n is large? Will this
probability converge, and if so to 0, 1, or something in between as n goes to infinity?
This problem is treated in Section 11.4 of Discrete Mathematics.
Let N be the set of employees, and n = |N | its size. For every A N the number of
permutations of N such that all in A get their own presents is exactly the number of
permutations
of N \A, namely (n |A|)!. For every k the number of subsets of N of size
n
k is
.
k
By the inclusion-exclusion formula the number of permutations of N such that at least
one element is mapped to itself is
n
n
X
X
(1)k+1
k+1 n
.
(n k)! = n!
(1)
k!
k
k=1
k=1
After dividing by n!, the total number of permutations, the probability that nobody
gets their own present is
n
n
X
(1)k+1 X (1)k
1
=
.
k!
k!
k=1
k=0
n
X
X
xk
(1)k
x
The Taylor formula for e is
. It follows that lim
is e1 . Therefore the
n
k!
k!
k=0
k=0
1
probability that nobody gets their own present is e in the limit, or about 0.368. If the
company is big then the probability that somebody gets their own present is over 60 per
cent. Interestingly this probability is not monotone in the variable n. Even numbers of
elements give a slightly greater tendency for avoiding the situation where somebody
gives a present to themselves.
2.3.3
Surjective functions
How many surjective functions are there from a k-set to an n-set? We can use the
inclusion-exclusion method to get an answer.
We calculate the number of surjective functions from a k-set to an n-set by calculating
first the number of non-surjective functions. A function that is not surjective avoids
some subset of the n-set. The number of functions that avoids a subset of size j is
(n j)k , the total number of functions from a k-set to the other elements excluding the
chosen set of size j. By inclusion-exclusion the number of non-surjective functions is
n
X
j+1 n
(1)
(n j)k .
j
j=1
Therefore, the number of surjective functions is
n
n
X
X
k
j+1 n
k
j n
n
(1)
(n j) =
(1)
(n j)k .
j
j
j=1
j=0
18
2.3. Inclusion-exclusion
Surjective selections
1
f
1
2
3
1
f
1
2
2
3
f
1
2
2
3
Figure 2.6: How permutations change functions.
With regard to surjective functions from a k-set to an n-set there are at least two ways
to define equivalence relations. One can permute the domain, the k-set. This is what we
have done so far. Also one can permute the range, the n-set. We count the number of
surjective selections using both approaches. We discover that the solutions are not that
different from the solutions when one does not require surjectivity.
What do we mean by the equivalence relationships defined by permuting the domain
and permuting the range? Take the function f : {1, 2, 3} {1, 2} defined by f (1) = 2,
19
2. Elementary counting
f (2) = 2, f (3) = 1. Let be the permutation of the domain {1, 2, 3} represented by the
cycle (1 2 3) and the permutation of the range represented by the cycle (1 2). If
permutations in the domain defined equivalent functions then f would be equivalent to
the function f which takes 1 to 2, 2 to 1, and 3 to 2. If permutations in the range
defined equivalent functions then f would be equivalent to the function f which
takes 1 to 1, 2 to 1, and 3 to 2. See Figure 2.6.
Permuting the k-set
How many ways are there to map k non-distinct (equivalent) objects surjectively to n
distinct positions?
The method is virtually the same as when surjectivity is not required. We reserve in
each of the n positions at least one object. Only the distribution of the rest of the
objects matters. The answer is the same for the distributing
ofk n objects into n
k1
positions without the surjectivity requirement, namely
.
n1
Permuting the n-set
How many ways are there to map k distinct objects surjectively to n non-distinct
(equivalent) positions?
Divide the number of surjective functions by the number of permutations of n, namely
n
1 X
j n
n!. Define S(k, n) to be the number
(1)
(n j)k . This is also the number of
n! j=0
j
ways to partition k distinct objects into n different parts. The numbers S(k, n) are
called the Stirling Numbers of the Second Kind. We look at them in more detail later,
also in relation to the Stirling Numbers of the First Kind.
Why are the answers to the above two questions so different? When the equivalence
relation is defined by permuting the set X (of size k) why do we not divide the number
of surjective functions by k!, as we do by n! when the equivalence relation is defined by
permuting the set of size n?
Fix any two objects, a and b, in the set X. Some of the functions will take both a and b
to the same position and some will not, which explains the difference and why one does
not divide by k!. If k = 3 and n = 2 there will be 6 different surjective functions (23 = 8
functions in all but two that are not surjective). There are 2 rather than 1 = 3!6
equivalence classes when permuting the k-set, as can be easily checked. See Figure 2.7.
With regard to permuting the n-set we notice that the surjective solution gives us the
answer for when we do not require surjectivity. Simply, we add up all the possibilities
for different sizes of sets that can be hit for the answer S(k, 1) + S(k, 2) + + S(k, n).
Permuting both the k-set and the n-set
How many ways are there to map k non-distinct (equivalent) objects into n non-distinct
(equivalent) positions? This topic concerns the partitions of an integer, something that
we consider in more depth later.
20
2.3. Inclusion-exclusion
(a)
1
2
(b)
Figure 2.7: Surjective selections: (a) permuting the range, (b) permuting the domain.
39
26
13
0
4
6
+4
.
5
5
5
5
52
Subtracting from
gives the answer
5
52
39
26
13
4
+6
4
= 685, 464.
5
5
5
5
52
With the total number of hands being
= 2, 598, 960, we see that only about 26
5
per cent of all hands have all four suits.
There is another way to count this number. One of the suits must be represented by
two cards, the rest by one. We choose one
of four
suits to be represented twice, and
13
then two representatives can be chosen in
= 78 ways. For each of the other
2
three suits we have a choice of one of 13 representatives. The answer is
4 78 133 = 685, 464. It is valuable to look at both of these methods.
21
2. Elementary counting
22
Exercise 2.11
How many ways are there to distribute 6 black balls (indistinguishable objects) and 6
coloured balls (distinguishable objects with 6 distinct colours) to five distinguishable
people so that three people get 2 objects and two people get 3 objects?
2.4
Relevant to this section are Sections 3.5, 13.1 and 13.2 of Combinatorics and Sections
12.1 to 12.5 of Discrete Mathematics.
2.4.1
Partitions of an integer
3+2
2+2+1
2+1+1+1
1+1+1+1+1
The above listing of the partitions of 5 are grouped according to the size of the
partition. 3 + 1 + 1 and 2 + 2 + 1 are the partitions of 5 into three parts. For every
positive integer n there will be only one partition into one part, namely n itself, and
only one partition into n parts, namely 1 + 1 + + 1.
The partitions of an integer k are the equivalence classes of the functions from a k-set
to a k-set when permutations of both the domain and the range of the function result in
equivalent functions.
2.4.2
l
X
i=1
ri mi and r1 > r2 > > rl and dropping the exponent means that it
A partition [r1m1 r2m2 rlml ] of an integer k is also called a type. To every such type and
every set A of size k there belong partitions and permutations of the set A. We present
the relationship to partitions first.
23
2. Elementary counting
2.4.3
Number of partitions
l
X
is rj , k =
ri mi and r1 > r2 > > rl .
i=1
i
h
This structure uniquely defines a type, namely r1m1 r2m2 rlml . For example, the
i
h
partition {{1, 3, 4}, {2, 5, 9}, {6, 7}, {8}, {10}} belongs to the type 32 2 12 .
Lemma 2.7 The number of partitions of a set of cardinality k belonging to the type
[r1m1 r2m2 rlml ] is
k!
.
(r1 !)m1 (rl !)ml m1 ! ml !
Proof
We proceed by induction on l. Assume that l = 1 (and therefore k = r1 m1 ). Let us
k
choose the partition members. For the first partition member we have a choice of
r1
k r1
objects. For the second partition member we have a choice of
objects. The
r1
total number of possibilities is
k
k r1
r1
k! (k r1 )! r1 !
=
r1
r1
r1
(k r1 )! (k 2r1 )! 0! (r1 !)m1
=
k!
.
(r1 !)m1
But any permutation on the m1 sets of size r1 yields the same partition, and therefore
the number of partitions is
k!
.
(r1 !)m1 m1 !
Now assume that the lemma holds for the quantity l 1. Every partition of k
corresponding to the type [r1m1 r2m2 rlml ] defines a partition of a set of size r1 m1
according to the type [r1m1 ] and a partition of a set of size k r1 m1 belonging to the
type [r2m2 rlml ]. Vice-versa, due to r1 6= ri for all i > 1, distinct choices for a set of size
r1 m1 (determining a complementary choice of a set of size k r1 m1 ) followed by
distinct choices for the partitions of the r1 m1 -set and partitions of the (k r1 m1 )-set
corresponding to the types [r1 m1 ] and [r2m2 rlml ] respectively generate distinct
partitions of the k-set. Therefore the number of partitions of the k-set is
k
r1 m1 !
k r1 m1 !
k!
=
.
m
m
m
m
1
2
1
l
r1 m1
(r1 !) m1 ! (r2 !) (rl !) m2 ! ml !
(r1 !) (rl !)ml m1 ! ml !
24
We have a formula for the number of surjective functions from a k-set to an n-set and
therefore also a formula for the number of partitions of a k-set into n parts. For every
type of a k-set partitioned into n parts we know from Lemma 2.7 the number of
partitions belonging to it. These numbers should match up.
Example 2.3 Consider the surjective functions from a 5-set to a 3-set.
By the formula the number of surjective functions is
3
3
5
5
3
(3 1) +
(3 2)5 = 243 96 + 3 = 150.
1
2
150
150
=
= 25.
3!
6
Now consider the same task using the formula from Lemma 2.7 . A 5-set can be
partitioned into three parts in two ways, as the type [3 12 ] or as the type [22 1]. For
5!
the first our formula gives
= 10 partitions and for the second our formula
3! 2!
5!
gives
= 15 partitions.
(2!)2 2!
The number of partitions of a 5-set into 3 parts is therefore
The same classification scheme can be applied to the set of all functions of a k-set to an
n-set.
We can break down these functions:
1. according to the sizes m = 1, 2, . . . , n of the image
2. then according to a set for that image
3. then according to the types, and finally
4. to the corresponding partitions for each type.
Example 2.4 Consider the set of all functions from a 5-set to a 3-set.
We have already considered the types with 3 parts. Next, consider the types with 2
parts. These are [4 1] and [3 2]. According to Lemma 2.7:
the number of partitions corresponding to type [4 1] should be
5!
= 5, and
4! 1!
5!
= 10.
3! 2!
The total number of partitions should be 15, meaning that the corresponding
number of functions should be 30 (multiplying by 2!). According to the formula the
number of surjective functions from a 5-set to a 2-set should be 25 2 = 30.
the number of partitions corresponding to type [3 2] should be
Now consider the only type [5] of length 1. The number of partitions corresponding
to this type is one. The number of surjective functions (from a 5-set to a 1-set) is
likewise 1.
25
2. Elementary counting
Now add up all the results. The number of functions from a 5-set to a 3-set should be
3
3
3
150 +
30 +
1 = 150 + 90 + 3 = 243 = 35 .
3
2
1
2.4.4
Permutations
Permutations are bijective functions from a finite set to itself. There are k!
permutations of a k-set.
We could express a permutation as a function, with (i) = ai and then list the results
in the proper order:
1 a1 , 2 a2 , , k ak .
But there is a much more efficient way of expressing a permutation. Look at where the
first element 1 goes, namely (1). Then look at where this goes, ( )(1) = 2 (1). We
could continue until some number i = j (1) = j+l (1) is repeated for the first time, and
from then on cyclic repetition would rule:
1,
(1),
2 (1),
...,
j (1) = i,
...,
j+l (1) = i.
But because the permutation is a bijection, we could move backwards with its inverse
1 and show that j+l1 (1) = j1 (1) and so on backwards to 1 = l (1). So starting
from any element we get a cycle of elements returning to this first element. This allows
us to write down any permutation of a k-set as a partition of the k-set plus a cyclic
orientation of each partition. See Figure 2.8.
26
Because any permutation of the k-set is based on a partition of the k-set, the
permutations are also classified according to their types.
27
2. Elementary counting
i2
i1
i3
2
im
i4
j2
j1
j3
jm
j4
2
Figure 2.9: Matching cycles.
28
5!
5
5!
4
5!
32
5!
3 2!
= 24
= 30
= 20
= 20
5!
= 15
2!
5!
= 10
2 3!
5!
=1
5!
[22 1]
22
[2 13 ]
[15 ]
a1
ar
a2
(a1 a2 a3 . . . ar1
ar )
(a2 a3 a4 . . .
..
.
a1 )
ar
2.4.5
Ferrers diagrams
Ferrers diagrams are presented in Section 13.1 of Combinatorics and Sections 26.1 and
26.2 of Discrete Mathematics. There is a convenient way to express a particular partition
of k (a type), called a Ferrers diagram. We express [1 22 4 6], a partition of 15.
29
2. Elementary counting
The Ferrers diagram obtained by interchanging the rows and the columns is called the
conjugate diagram. The conjugate of the conjugate is the original diagram, a concept
called conjugate duality.
Ferrers diagrams provide intriguing equalities, such as the following:
Lemma 2.10 The number of partitions of k into j parts is equal to the number of
partitions of k such that the largest part has size j.
Proof
Partitions of the former are defined by having j rows and partitions of the latter are
defined by having j columns. There is a bijection between these two types of partitions,
by applying conjugate duality.
Lemma 2.11 The number of partitions of k such that no two parts have the same size
is equal to the number of partitions of k such that no size is skipped from 1 to some
maximal size j.
Proof
A partition with no two parts of the same size has a Ferrers diagram where each row is
of a different size. A partition with no size skipped (starting from size one) has a Ferrers
diagram where each column is of a different size. A bijection between the two types of
partitions follows from conjugate duality.
30
Exercise 2.13
Show that the number of partition of an integer n into distinct and odd parts is equal
to the number of partitions of the integer n that are self-conjugate (meaning that the
Ferrers diagram and its conjugate are the same).
Exercise 2.14
Let n and r be positive integers. Show that the number of partitions of n in which the
number of parts is r or less is equal to the number of partitions of n + r with exactly r
parts.
2.5
2.5.1
s(1, 0) = 0.
(x)2 = x(x 1) = x2 x, so
s(2, 2) = 1,
s(2, 1) = 1,
s(2, 0) = 0.
s(3, 2) = 3,
s(3, 1) = 2,
s(3, 0) = 0.
31
2. Elementary counting
s(4, 4) = 1,
2.5.2
s(4, 1) = 6,
s(4, 2) = 11,
s(4, 0) = 0.
S(k, n) is defined to be the number of partitions of a k-set into n parts, and these
numbers are called the Stirling numbers of the second kind. We show how they relate to
the Stirling numbers of the first kind, something also presented in Section 5.3 of
Combinatorics..
Because (x)k , (x)k1 , . . . , (x)0 = 1 form a basis of the vector space of all polynomials
with real coefficients of degree k or less (just as the xk , xk1 , . . . , 1 do the same), we
can write
k
X
k
x =
R(k, j)(x)j
j=0
k
X
j=0
x =
k
X
R(k, j)
j=0
j
X
s(j, m)xm .
m=0
With R(k, j) = s(k, j) = 0 if j > k the matrices defined by the R(k, j) and the s(k 0 , j 0 )
are inverses of each other, meaning that
k
1, k = m,
X
R(k, j)s(j, m) =
0, k 6= m.
j=0
R(k, k) = 1,
R(k, j) = R(k, 0) = 0
R(k, j)(x)j =
j=0
k1
X
j=0
x R(k 1, j)(x)j .
32
R(k, j)(x)j =
j=0
k1
X
R(k 1, j)(x)j+1 + j
k1
X
k
X
R(k 1, j 1)(x)j + j
k1
X
j=0
j=1
j=0
j=0
R(k 1, j)(x)j
R(k 1, j)(x)j .
Since the (x)j form a basis of the polynomial vector space, if we fix any value for j the
coefficients should be equal.
Choosing j = k, we get R(k, k) = R(k 1, k 1), and by induction we have R(k, k) = 1
for all k.
Choosing j = 0, we get R(k, 0) = jR(k 1, 0), and again by induction we have
R(k, 0) = 0 for all k.
Choosing 0 < j < k we get R(k, j) = R(k 1, j 1) + j R(k 1, j).
The following lemma is Theorem 12.1 of Discrete Mathematics.
Lemma 2.13 The Stirling numbers of the second kind, S(k, n), satisfy
S(0, 0) = 1,
S(k, k) = 1,
S(k, n) = S(k, 0) = 0
2
k
n
Figure 2.11: k is not alone.
Corollary 2.14 The R(k, n) are the same as the S(k, n).
33
2. Elementary counting
Proof
The two collections of numbers obey the same initial conditions and the same
recurrence relations.
2.5.3
Number of permutations
Now we show how the Stirling numbers of the first kind relate to the number of
permutations. This is worked out in Section 5.3 of Combinatorics, in particular in
Proposition 5.3.3. Recall the definition of n rising k, n(k) = n (n + 1) (n + k 1).
Lemma 2.15 The s(k, n) satisfy s(k, 0) = 0, s(k, k) = 1 and
s(k + 1, n) = s(k, n 1) ks(k, n)
for all k 1.
Proof
The first identities are trivial. For the last equation by definition (x)k+1 = (x)k (x k)
holds, yielding
s(k + 1, k + 1)xk+1 + + s(k + 1, n)xn + + s(k + 1, 0)
= (x k) s(k, k)xk + s(k, n)xn + s(k, n 1)xn1 + + s(k, 0) .
For any permutation of {1, 2, . . . , k 1} with n cycles we want to consider how many
permutations of {1, 2, . . . , k} with n cycles will generate . k could be inserted in any
of the cycles of . For each cycle putting k back in the front of the cycle or at the back
34
of the cycle results in the same cycle. Otherwise different cycles are obtained from
inserting k into different positions, and therefore the number of different cycles created
from a given cycle is equal to the number of elements in that cycle. Therefore, there are
k 1 such different permutations from the k 1 different positions to insert k that
would generate the given permutation .
But there are also permutations of {1, 2, . . . , k} into n cycles where k is alone, and they
generate the permutations of {1, 2, . . . , k 1} into n 1 cycles. See Figure 2.12. Putting
together the two possibilities gives the result.
n parts
Figure 2.12: k is not alone.
k
Proof
X
(k)
Define b(k, n) by x =
b(k, n)xn .
n=0
As x(0) = 1 and x divides x(k) for all k 1 it follows that b(0, 0) = 1, b(k, 0) = 0 for all
k 1.
x(k) = (x + k 1)x(k1) means
(x + k 1) + b(k 1, n)xn + b(k 1, n 1)xn1 + = + b(k, n)xn +
35
2. Elementary counting
n=0
= (1)
k
X
s(k, n)xn .
n=0
S(5, 2) = 15,
S(5, 3) = 25.
one type
24
n=2
two types
50
n=3
two types
35
n=4
one type
10
n=5
one type
1.
This means
s(5, 1) = 24,
s(5, 2) = 50,
s(5, 3) = 35,
s(5, 4) = 10,
s(5, 5) = 1.
Now find the Stirling number s(5, n) and S(5, n) using (x)k :
(x)4 = (x 3)(x3 3x2 + 2x) = x4 6x3 + 11x2 6x
(x)5 = (x 4)(x4 6x3 + 11x2 6x) = x5 10x4 + 35x3 50x2 + 24x.
36
With the Stirling numbers of the first kind put into a matrix, we need only find the
inverse of this matrix to discover the Stirling numbers of the second kind:
1 0 0 0 0 0
1 0 0 0 0 0
1 0
0
0
0 0
0
0
0 0 0 1 0 0 0 0 0 1 0 0 0 0
0 1
0 1 1
0 1 1 0 0 0 0 0 1 0 0 0
0
0
0
0 2 3 1
0 0
0 1 3 1 0 0 0 0 0 1 0 0
0 6 11 6 1 0 0 1 7 6 1 0 0 0 0 0 1 0
0 1 15 25 10 1
0 0 0 0 0 1
0 24 50 35 10 1
But we could have found the Stirling numbers of the second kind also by using the
above recursive formula S(k, n) = nS(k 1, n) + S(k 1, n 1) for all 1 n k.
n
.
Show that |s(n, 1)| = (n 1)! and |s(n, n 1)| =
2
Exercise 2.18
For each type of a partition of a 7-set into 4 or fewer parts determine how many
functions from a 7-set to a 4-set correspond to this type. Let two functions from a 7-set
to a 4-set be equivalent if they differ by a permutation of the 7-set. For each type
determine how many equivalence classes (of functions from the 7-set to the 4-set)
correspond to this type. Because equivalence is determined by a permutation of the
domain rather than the range, the answers will be very different from those obtained in
the previous exercise.
37
2. Elementary counting
Learning outcomes
At the end of this chapter and the relevant reading, you should be able to:
count the functions from a k-set to an n-set according to various restrictions and
equivalence relations
apply the inclusion-exclusion formula in various ways
count partitions and permutations according to their types
interpret a Ferrers diagram
calculate explicitly the Stirling numbers of the first and second kinds for small k
and n in various ways.
Solutions to exercises
Solutions to section 2.2 exercises
Solution to exercise 2.1
The throw of six identical dice yields six unordered choices of six different values. Six
objects
are divided by five dividers (for the six possible values), for a total of
11
= 462 results.
5
Solution to exercise 2.2
Concerning the rolling of two dice:
To roll a sum of 2, there is only 1 + 1.
To roll a sum of 4, there are 1 + 3 and 2 + 2.
To roll a sum of 6, there are 1 + 5, 2 + 4 and 3 + 3.
To roll a sum of 8, there are 2 + 6, 3 + 5 and 4 + 4.
To roll a sum of 10, there are 4 + 6 and 5 + 5.
To roll a sum of 12, there is only 6 + 6.
In total, there are 12 ways. But there are 21 ways to roll the dice, and yet the
probability of getting an even number is the same as getting an odd number. The
reason for this mismatch is simple: for each i {1, 2, 3, 4, 5, 6} the probability to roll
1
1
i + i is 36
while the probability to roll i + j for j 6= i is 18
.
To roll a sum of 3, there is only 1 + 2.
To roll a sum of 6, there are 1 + 5, 2 + 4 and 3 + 3.
To roll a sum of 9, there are 3 + 6, and 4 + 5.
38
n =
k
X
k
j=0
j kj
(n 1) 1
k
X
k
=
(n 1)j .
j
j=0
Now prove that nk is the number of functions from a k-set to an n-set using induction
on n rather than on k. If |n| = 1 then there is exactly one function and the formula is
true. Let x be any fixed element of the n-set and for every such function
f let
x(f ) be
k
the number of elements of the k-set that reach x. With j fixed there are
(n 1)j
j
different functions
f such that x(f ) = k j, the (n 1)j by the induction hypothesis
k
and the
being the number of choices for k j elements to be mapped to x.
j
k
X
k
Therefore by induction hypothesis there are
(n 1)j different functions from a
j
j=0
k-set to an n-set, and we have shown that this is equal to nk .
Solution to exercise 2.5
Order the possibilities of choosing a subset of size n from a set of size s + n in the
following way.
0: The first object is not chosen
1: The first object is chosen, but not the second
2: The first and second objects are chosen, but not the third, etc.
n: The first n objects are chosen.
This exhausts all the possibilities for choosing
an n-set
from an (s + n)-set. To any
s+ni1
possibilities.
category i above there will be exactly
ni
39
2. Elementary counting
S(6, 1) = 1
for a total of 187.
Solution to exercise 2.9
Try
the functions from a 9 set to a 4 set. The number of equivalence
relations is
12
8
= 220 but the number of those that are surjective is
= 56. The total number
9
5
of functions is 49 = 262, 144 and the number of surjective functions is
49 4 39 + 6 29 4 = 186, 480. Considering the functions from an n3 -set to an n2 -set
one can show that the proportion of surjective functions approaches 1 as n tends to
infinity while the proportion of surjective equivalence classes tends to 0.
Solution to exercise 2.10
52
(a) The answer is
.
4
(b) First
choose one of 4 suits, and then choose the numbers in the suit for a total of
13
4
.
4
13
(c) First choose which numbers are received twice. This is a total of
. For each
2
2
4
13 4
number there are
choices for which cards. The total number is
.
2
2
2
(d) The answer is independent of the hand of the first player. There are 48(12) ways to
distribute the remaining 12 cards one at a time, the first four to the next player,
the next four to the next player, and the last four to the third player. And then for
each player divide by 4! for the different orders that these four cards were received.
48(12)
48!
The answer is
. Equivalently we could write the multinomial
.
3
(4!)
(4!)3 36!
40
(e) Because Player One has one card from each suit, the 48 cards left have 12 cards in
each suit. There are three possibilities for the suits represented, one suit for which
all three players gets cards of this suit, two suits such that two players get cards
from one of the two and one player from the other, three different suits given to the
three other players. For the first case there are exactly four possibilities, as the
three players must exhaust all 12 cards of this suit. For the second case there are
4 3 3 possibilities, the first choice being the suit corresponding to two players and
the second choice being the suit given to only one player and the third choice being
which player does not share a suit with any other. For the third case there are
12!
4 3 2 possibilities. For the first case there will be
ways for the numbers of
(4!)3
this suit to be distributed to the three players. For the second case there will be
12!
ways to determine the numbers to the two players with the same suit and
(4!)3
3
12
12
ways for the third player. For the third case there will be
ways to
4
4
determine the numbers given to the three players. The final answer is
3
12!
12
12! 12
4
+433
+432
.
3
3
4
(4!)
(4!) 4
(f) The number of ways for some particular subset of i other players to have four cards
(48 4i)!
of the same number is [12]i
. So by inclusion-exclusion the answer is
(4!)3i 36!
3 12
44!
40!
3 12 11
+ 12 11 10.
2
(4!) 36!
4!36!
6
X
41
2. Elementary counting
42
Without reference to the types, there are at least three ways to calculate the Stirling
numbers of the second kind, through the formula for the number of surjective functions,
by the recursive formula S(k, n) = S(k 1, n 1) + nS(k 1, n), or by finding the
inverse of the matrix defined by the Stirling numbers of the first kind. Let us do the
third method first (and not do the first method).
(x)2 = (x 1)x
= x2 x,
(x)3 = (x 2)(x2 x)
= x3 3x2 + 2x,
(x)4 = (x 3)(x3 3x2 + 2x)
= x4 6x3 + 11x2 6x,
(x)5 = (x 4)(x4 6x3 + 11x2 6x)
= x5 10x4 + 35x3 50x2 + 24x,
(x)6 = (x 5)(x5 10x4 + 35x3 50x2 + 24x)
= x6 15x5 + 85x4 225x3 + 274x2 120x,
(x)7 = (x 6)(x6 15x5 + 85x4 225x3 + 274x2 120x)
= x7 21x6 + 175x5 735x4 + 1624x3 1764x2 + 720x,
and we have
s(7, 0) = 0,
s(7, 1) = 720,
s(7, 4) = 735,
s(7, 2) = 1764,
s(7, 5) = 175,
s(7, 6) = 21,
s(7, 3) = 1624,
s(7, 7) = 1.
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0 1
1
0
0
0
0
2
3
1
0
0
0
0
0 6
11
6
1
0
0
0 24
50
35
10
1
0
1
0
1 0 0
0
0
0
0
0 1 0
0
0
0
0
0
0 1 1
0
0
0
0
0
0
1
0
0
0
0 1 3
=
0 1 7
0
6
1
0
0
0
1
0
0 1 15 25 10
0 1 31 90 65 15 1
0
1
0 1 63 301 350 140 21
43
0
.
0
0
1
2. Elementary counting
Therefore
S(7, 0) = 0,
S(7, 1) = 1,
S(7, 4) = 350,
S(7, 2) = 63,
S(7, 5) = 140,
S(7, 3) = 301,
S(7, 6) = 21,
S(7, 7) = 1.
[5 2]
[3 22 ]
[4 2 1]
[4 13 ]
[4 3]
[3 2 12 ]
[3 14 ]
[32 1]
[23 1]
[22 13 ]
[2 15 ]
[17 ].
Counting the possible number of partitions and permutations for each type, we see that:
[7] has only 1 partition and 6! = 720 permutations.
[6 1] has 7 partitions and 7 5! = 840 permutations.
7
[5 2] has
= 21 partitions and 21 4! = 504 permutations.
2
7
[4 3] has
= 35 partitions and 35 3! 2 = 420 permutations.
3
7
[5 12 ] has
= 21 partitions and 21 4! = 504 permutations.
5
44
7!
= 105 partitions and 105 3! = 630 permutations.
4! 2
[4 2 1] has
[3 22 ] has
[32 1] has
7!
= 70 partitions and 70 22 = 280 permutations.
2 (3!)2
[4 13 ] has
7!
= 35 partitions and 35 3! = 210 permutations.
4! 3!
[3 2 12 ] has
[23 1] has
[3 14 ] has
[22 13 ] has
[2 15 ] has
7!
= 105 partitions and 105 2 = 210 permutations.
3! 23
7!
= 210 partitions and 210 2 = 420 permutations.
3! 2! 2!
7!
= 105 partitions and 105 permutations.
3! 23
7!
= 35 partitions and 35 2 = 70 permutations.
3! 4!
7!
= 105 partitions and 105 permutations.
3!
23
7!
= 21 partitions and 21 permutations.
2 5!
45
2. Elementary counting
If {1, . . . , n} is partitioned into n 1 parts, then one part is of size two and all the
others are
of
size one. The number of ways of doing this is the number of subsets of size
n
two, or
.
2
Solution to exercise 2.17
The number of permutations of {1, . . . n} with only one cycle is the number of ways to
write down 1 first followed by any permutation of the {2, . . . , n}, or (n 1)!.
The numberof
functions adds up to 47 = 16, 384 and the number of equivalence classes
10
adds up to
= 120.
3
46
Chapter 3
Generating functions
3
RR
Essential reading
Further reading
3.1
Introduction
In this chapter we look at a new way to count, using generating functions. Some, but
not all, problems of counting are easier to understand using generating functions. When
they are useful, generating functions connect the problems of counting to algebraic and
calculus methods. In later chapters we expand on the algebraic approach to counting.
Generating functions are introduced at the start of the fourth chapter of Combinatorics
and in their algebraic context at the start of Chapter 25 of Discrete Mathematics.
3.2
3.2.1
47
3. Generating functions
ai x i
i=0
The expression 1 + 2x + 3x2 + is called the generating function for the series
ai = i + 1 for all i 0.
Definition 3.1 If am , am+1 , . . . is an infinite sequence with m some integer (positive,
X
zero, or negative) then the expression
ai xi is the generating function for the
i=m
sequence am , am+1 , . . . .
3.2.2
Making change
For every n 0 let an be the number of ways to have one and two pence coins that add
up to n pence (where all the one pence coins are identical and all the two pence coins
are identical).
First, for every n there is only one way to add up to n pence with only one pence coins,
namely by giving n coins. This is represented by the power series 1 + x + x2 + x3 + .
For every positive k the coefficient ak is 1.
Next we do the same with two pence coins. For every n either n is odd and there is no
way or n is even and there is exactly one way to get n with two pence coins. This is
represented by the power series 1 + x2 + x4 + x6 + .
So far this has not been interesting. Now we want to use both one pence and two pence
coins. This is represented by the power series
(1 + x + x2 + )(1 + x2 + x4 + ).
Why? Look at the coefficient for xn . It represents all the ways to combine k two pence
coins with n 2k pennies, taking 2k exponents from the left side and n 2k exponents
from the right side.
Now add the five pence coins for the expression
(1 + x + x2 + )(1 + x2 + x4 + )(1 + x5 + x10 + ).
Power series can be manipulated. One can view them as functions on x, but one can
also view them as formal objects. This is discussed in Section 4.2 of Combinatorics and
Section 25.1 of Discrete Mathematics. For example, the power series 1 + x + x2 +
1
. For some real values of x this identity holds, namely for
can be represented as
1x
1 < x < 1 (and can be proven using the formula for the geometric series). Though for
other values it clearly does not hold (because the series would not be convergent), for
48
our purposes the equality always holds. The reason is that the multiplication of the two
power series (1 x) and (1 + x + x2 + ) results in cancellation to zero in every
coordinate except for the first one, meaning that (1 x)(1 + x + x2 + ) = 1.
A solution to the coin problem: Let f1 be the power series
1
= 1 + x + x2 + .
1x
f1
Let f2 be the power series f1 (1 + x + x + ). We can express this also as f2 =
1 x2
2
and again as f1 = (1 x )f2 . If b0 , b1 , . . . are the coefficients of f2 , we get
2
f1 =
x =
i=0
X
i=0
bi (x x
i+2
)=
X
i=0
bi x
bj2 xj
j=2
which gives the recursive formula 1 = bi bi2 , or bi = 1 + bi2 . Knowing the initial
values for f1 , we can write down a table of the values for bi . By definition of f2 , b0 must
be 1. This makes sense, since the first value for bi to be greater than one must take
place at b2 = 2, and this fits the recurrence relation bi = 1 + bi2 .
Next we add the possibility of using five pence coins. Let f5 be the power series
f2 (1 + x5 + x10 + ), with f5 = c0 + c1 x1 + . As before,
1
= 1 + x5 + x10 + ,
1 x5
X
X
i
5
and f2 = f5 (1 x ) (with c0 = 1). This gives
bi x =
ci (xi xi+5 ).
f2
1 x5
i=0
i=0
Fix any j and look at the jth power of x. If j < 5 we get cj = bj . If j 5 we get
cj cj5 = bj , or cj = bj + cj5 . With this relation we can complete the table.
f5 =
ai
bi
ci
Continuing in this way we can determine the answers for all types of coins and all
quantities of money.
3.2.3
49
3. Generating functions
1
. The roots of 1 x x2
2
1
51
2
a
2x
1
51
can be re-written as
a+
b
2x
1+
1+ 5
5+5
a=
,
10
5 51
2
With 1+2
namely
2b
51
= 0 we get
2a 5 = 1 + 5,
5 5
b=
.
10
ak =
1
1 x x2
2ax
2xb
+b
= 1.
1+ 5
51
for
5+5
10
!k
1+ 5
5
k 5
+ (1)
2
10
51
2
!k
Notice that | 51
| is less than one, so that taking it to higher powers will result in a
2
number increasingly close to zero. We obtain the curious fact that the first part
50
5+5
10
k
1+ 5
2
gets closer and closer to integers, indeed the integers of the Fibonacci
series. This is an interesting topic in its own right, but we will not cover it in this course.
3.2.4
The following method is one way to determine the generating function. It is also
presented in Sections 25.4 and 25.5 of Discrete Mathematics. Suppose that the relation
calls for
an = bk ank + + b1 an1
for all n greater than or equal to some k. Line up the polynomials in the following way:
f (x)
= a0
b1 xf (x)
=
..
.
bk xk f (x)
a1 x
b 1 a0 x
ak x k
b1 ak1 xk
b k a0 x k
Notice that the rule implies that the columns for xk add up to zero, and the same holds
for the xj columns for all j greater than or equal to k. This means that after summing
up all the rows we are left with
(1 b1 x bk xk )f (x)
= a0 + a1 x + + ak1 xk1 b1 a0 x b1 ak2 xk1 bk1 a0 xk1 .
We can now solve for f (x) by dividing by 1 b1 x bk xk .
For example, to do this with the Fibonacci sequence, let f (x) = a0 + a1 x + be its
generating function. We line up the appropriate polynomials:
f (x)
= a0
+ a1 x
xf (x)
x2 f (x)
+ a2 x 2
+ a3 x 3
a0 x
a1 x 2
a2 x 3
a0 x 2
a1 x3
51
3. Generating functions
3.2.5
Algebraic manipulations
52
f (x)
where the degree of f (x) is strictly less than the degree of g(x) and
g(x)
f (x)
g(x) can be factored into g1n1 (x) glnl (x) we can re-write
as a sum of terms of the
g(x)
r
form k
where r is a number and k is no greater than nj . The same method is used
gj (x)
to help integrate such functions. For example, suppose we have the generating function
expression
x2 2x 1
.
1 x x2 + x3
First notice that 1 x x2 + x3 is equal to (1 x)2 (1 + x). So we can re-write:
c
x2 2x 1
a
b
+
.
=
+
2
3
2
1xx +x
(1 x)
1x 1+x
Multiplying through by 1 x x2 + x3 we get
x2 2x 1 = a(1 + x) + b(1 + x)(1 x) + c(1 x)2 .
We could collect like powers of x and solve for three linear equations in three unknowns.
But the easier way is through the cover-up rule. Choose three distinct values for x that
make the calculations easy. Two of these choices are obvious, x = 1 and x = 1. From
x = 1 we get 1 2 1 = 2a, or a = 1. From x = 1 we get 1 + 2 1 = 4c, or c = 12 .
For a third choice x = 0 is possible, and with a and c already solved we get
1 = 1 + b + 21 or b = 21 . Therefore
1
1
1
x2 2x 1
=
+
.
2
3
2
1xx +x
(1 x)
2(1 x) 2(1 + x)
Why does the cover-up rule work? With the above example, we have to solve for
x2 2x 1 = a(1 + x) + b(1 + x)(1 x) + c(1 x)2 ,
or in other words we had two polynomials of degree 2 which had to be equal. To
uniquely determine a polynomial f (x) of degree n or less it suffices to know its values
for n + 1 distinct values of x. Let us assume that there is a second polynomial g of
degree n or less that agrees with f on these n + 1 distinct values of x. That would mean
that f g, a polynomial of degree n or less, has n + 1 distinct roots. This is possible
only if f g = 0, meaning f = g. The formal argument for why a polynomial of degree
n cannot have more than n distinct roots is presented in a later chapter.
3.2.6
Calculus manipulations
Taking derivatives of generating functions and its applications are presented in Section
4.2 of Combinatorics and in Exercise 25.7 of Discrete Mathematics.
One can take the derivative of any Laurent series, using the rule that the derivative of
xn is nxn1 , also when n is negative. Many of the other rules of calculus apply. We
1
demonstrate by taking the derivative of
= 1 + x + x2 + .
1x
53
3. Generating functions
1
and on the right side it is
(1 x)2
1 + 2x + 3x2 + 4x3 + .
1
3
4 2
5 3
=1+
x+
x +
x + .
3
(1 x)
2
2
2
2
we get
(1 x)3
6
= 3 2 + 4 3 2x + 5 4 3x2 +
(1 x)4
which we can rewrite as
1
4
5 2
=1+
x+
x + .
4
3
3
(1 x)
x)
k+n1
are equal to
.
k
Proof (1)
We proceed by induction. If n = 1 then all these coefficients
should be 1, since
k+11
1
. And indeed
is equal to 1.
1 + x + x2 + =
1x
k
Assume the formula is true for n 1 for any given n 2. Write
(1 x)n+1
and
1
= a0 + a1 x + a2 x 2 +
(1 x)n1
1
= b0 + b1 x + b2 x 2 + .
(1 x)n
54
n+i1
.
i
Proof (2)
Notice that the coefficient for xk of the power series (1 + x + x2 + )n is the number of
ways to select with repetition
n positions for k unordered objects, which we knew
n1+k
already to be
.
k
1
Return to generating functions a0 + a1 x + of the form
, which have a
n
(1
x)
n1+k
n1+k
solution of ak =
. For any fixed n 1 re-write
as
k
k
1
(k + 1)(n1) , a polynomial in k of degree n 1. Let us look at the polynomials
(n 1)!
1
(x + 1)(n1) .
(n 1)!
n=1:
n=2:
1
(x + 1)(0) = 1
0!
1
(x + 1)(1) = x + 1
1!
n=3:
1
1
x2 + 3x + 2
(x + 1)(2) = (x + 2)(x + 1) =
2!
2
2
n=4:
1
x3 + 6x2 + 11x + 6
1
(x + 1)(3) = (x + 3)(x + 2)(x + 1) =
.
3!
6
6
55
3. Generating functions
3.2.7
Putting together what we have learned so far, we discover a method for going from a
generating function to the explicit formula for its coefficients. There is, however, a
problem with this method, discussed later, which may make it impractical in many
situations.
f (x)
such that the degree of f (x) is less than the
First, put it in the form of h(x) +
g(x)
degree of g(x) and g(0) is equal to 1.
Second, express g(x) as a product of irreducible Q
factors. Using complex numbers, any
polynomial can be factored down completely toP k (x ri )mk where the rk are the roots
of the polynomial (with multiplicities mk ) and k mk is the degree of the polynomial.
For example, x2 + 1 is irreducible over the real numbers, but with complex numbers
x2 + 1 = (x + i)(x i), where i is the square root of 1. This is the hardest part of the
technique, since finding exact expressions for these roots may be impossible. However, if
approximate valuesare sufficient,
mk then this method works. Given that g(0) = 1 we can
Y
x
, where rk are the roots.
express g(x) as
1
r
k
k
mk
Q
x
Third, with g(x) factored and expressed as k 1
, one applies the methods of
rk
partial fractions and solves for the unique (complex) numbers bk,j which satisfy
m
k
f (x) X X
bk,j
=
j .
g(x)
x
k j=1
1
rk
Fourth, one uses Lemma 3.1 to express the pth power coefficient of f (x)/g(x) as
p
mk
XX
1
p+j1
bk,j
.
rk
p
k j=1
Fifth, combine with the polynomial h(x) (determining the initial values of the sequence)
for the complete answer.
A second approach to giving change
First, let us stick to giving change in only one and two pence coins, since otherwise the
explicit approach could be difficult. We want to know the coefficients of the power series
1
. Since 1 x2 = (1 x)(1 + x) this should be expressed as
(1 x)(1 x2 )
1
. Using partial fractions write this as
(1 x)2 (1 + x)
a
b
c
1
+
+
=
.
2
1 x (1 x)
1+x
(1 x)2 (1 + x)
Re-write it as
(1 x)(1 + x)a + (1 + x)b + (1 x)2 c = 1
56
and again as
(c a)x2 + (b 2c)x + a + b + c = 1.
We use the cover-up rule with x = 0, 1, 1:
2b = 1
4c = 1
a + b + c = 1.
1
1
and
are not difficult. We are already familiar with
1x
1+x
1
= 1 + x + x2 + ,
1x
while
1
= 1 x + x2 x3 + x 4 .
1+x
1
1
Therefore the sum of
and
is easy to express. At even positions we get
4(1 x)
4(1 + x)
1
1
and at odd positions we get 0. The
is more difficult to understand.
2
2(1 x)2
1
1
is
. Therefore we get
The derivative of the function
1x
(1 x)2
1
= 1 + 2x + 3x2 + 4x3 +
2
(1 x)
Now we can say explicitly how many ways one can give n pence in change using only
one or two pence coins. For any n we add half of n + 1 to the previous result (adding
the two easier power series) to get
if n is odd, in
n+1
ways
2
n+2
ways.
2
This corresponds exactly to our previous table. Needless to say, making the same
explicit calculation for coins in one, two, and five pence would be significantly more
difficult using this method. For all k 2 some of the roots of the polynomials
1 + x + + xk are non-real complex numbers (the roots of unity). Using tables is an
easier method when there are coins of higher value. However we extend this approach to
coins to the value of one and four (though a four pence coin does not exist).
if n is even, in
57
3. Generating functions
1
1
.
1 x 1 x4
The roots of x4 1 are 1, 1, i, and i (with i and i the complex numbers such that
i2 = 1). The generating function can be re-written as
1
1
1
1
.
2
(1 x) 1 + x 1 ix 1 + ix
Breaking down into partial fractions with variables a, b, c, d, e to solve we get the
generating function equal to
b
c
d
e
a
+
+
+
+
.
1 + ix 1 ix 1 + x 1 x (1 x)2
The equation can be re-written again as
1 = (1 x)2 (1 ix)(1 + x)a + (1 x)2 (1 + ix)(1 + x)b
+ (1 + x2 )(1 x)2 c + (1 + x2 )(1 x)(1 + x)d + (1 + x2 )(1 + x)e.
Using the cover-up rule with x = i, i, 1, 1, 0:
x=1:
x = 1 :
x=i:
x = i :
x=0:
4e = 1
8c = 1
4(1 i)a = 1
4(i + 1)b = 1
a+b+c+d+e=1
1 1
+ i,
8 8
b=
1 1
i,
8 8
1
c= ,
8
3
d= ,
8
1
e= .
4
The formula for the kth coordinate of the generating function is therefore
1 1
1 1
1
3 1
k
i i +
+ i (i)k + (1)k + + (k + 1).
8 8
8 8
8
8 4
Let us check a few values.
1 1
1 3 1
1 1
+ i+ i+ + + =1
8 8
8 8
8 8 4
1
1 1
1 1 3 1
= i+ i+ + + =1
8
8 8
8 8 8 2
1 1
1 1
1 3 3
= i + i+ + + =1
8 8
8 8
8 8 4
1
1 1
1 1 3
= i i + +1=1
8
8 8
8 8 8
1 1 3 5
= + + + =2
4 8 8 4
a0 =
a1
a2
a3
a4
58
1
using
1 + x + x2
Exercise 3.4
What is the generating function for the number of ways to distribute k pence to three
people (distinguishable) in one, two, and five pence coins so that the first person never
gets a one-pence (penny) coin, the second person never gets a two-pence coin, and the
third person never gets a five-pence coin?
3.3
3.3.1
Recurrence relations
What is a recurrence relation?
Recurrence relations are introduced with generating functions at the start of Chapter 4
of Combinatorics in the following way: A recurrence relation expresses the value of a
function f at the natural number n in terms of its values at smaller natural numbers.
Let N = {0, 1, 2, . . . }, the natural numbers, be the non-negative integers and Z be all
integers. Sometimes a definition of a recurrence relation is given as follows.
A recurrence relation of degree k is defined by a function p : N Zk Z and an initial
sequence of integers a0 , a1 , a2 , . . . , ak1 such that for all n k the number an is equal to
p(n, an1 , . . . , ank ).
The problem with this definition is that it describes any function on the natural number
if there is no restriction on the properties of the function p. But usually some form of
restriction on p is implicit in this definition.
A linear recurrence of degree k is defined by a function p such that for all n k
p(n, x1 , . . . , xk ) = q(n) + b1 xn1 + + bk xnk
for some function q and constants b1 , b2 , . . . , bk .
It is homogeneous if the function q is the zero function.
59
3. Generating functions
The homogeneous linear recurrence relations have a special structure that we will study
in some depth. And their definition as stated above is not ambiguous.
Just as recurrence relations define generating functions, so one can move in the opposite
direction.
1 + 7x
1 + x 6x2
and now determine the recursive relation for which f (x) is the generating function.
Then determine the explicit formula for ai as well as the initial values a0 and a1 .
f (x) =
Due to the polynomial in the denominator and our previous analysis of how to go
from the recurrence relation to the generating function, we have for n 2
an = an1 + 6an2 . The initial conditions are a0 = 1 and a1 = 6 (seen from the
initial process of long division). With 1 + x 6x2 = (1 2x)(1 + 3x) we can write
b
a
1 + 7x
+
=
1 + x 6x2
1 2x 1 + 3x
or (1 + 3x)a + (1 2x)b = 1 + 7x. With the cover-up rule, letting x =
and with x = 1
we get b = 4
. This solves to an = 95 2n 45 (3)n .
3
5
1
2
we get a =
9
5
3.3.2
Equivalences
60
ci+1
ck
aj1 ajk+i .
ci
ci
For the second part, let g(x) = q(k)xk + q(k + 1)xk+1 + be the generating function
for the function q. Look at the function
h(x) := f (x)(1 b1 x b2 x2 bk xk ) g(x),
where the b1 , b2 , . . . , bk define the recurrence relation. For all j k the xj coefficient is
aj b1 aj1 bk ajk q(j), which is zero by assumption. Therefore h(x) is a
polynomial of degree at most k 1. We can re-write f (x) as
h(x) + g(x)
.
1 b1 x b2 x 2 bk x k
Theorem 3.3 The following are equivalent about an infinite sequence a0 , a1 , . . . :
(i) The sequence is determined by a homogeneous linear recurrence relation.
2
(ii) The
expression a0 + a1 x + a2 x + is arational generating function
f
for some polynomials f, g with g 6= 0 .
g
mp
n X
X
p=1 j=0
bp,j (
1 k j
) k
rp
for some fixed n, m1 , . . . mn , complex numbers b1,1 , . . . , b1,m1 , b2,1 , . . . , bn,mn and
complex numbers r1 , . . . , rn .
If so then the r1 , . . . , rn are the roots of g(x) such that the generating function reduces
f (x)
for polynomials f (x), g(x).
to
g(x)
Proof
The equivalency of (i) and (ii) is Lemma 3.2 . (ii) implies (iii) is the result of our
explicit solution for the
series. (iii)
implies (ii) results from the fact that
1
n
1
+
k
[k + 1]n1 =
, the explicit solutions an for the generating function
(n 1)!
k
P
1
n
, for n = 1, 2, . . . form a basis of the polynomials in k, as
n=0 an y =
(1 y)k
described above.
Notice that y = rx can be substituted to incorporate the powers of 1r and that shifts of
index can be rewritten without the shift, such as an = (n 1)2 re-written as
an = n2 2n + 1 or an = cn+1 as an = c cn . (i) implies (iii) of the above is also
Theorem 25.5.2 of Discrete Mathematics.
61
3. Generating functions
3.3.3
Theoretically we know how to write down closed-form formulae for the recurrence
relations defined by all rational generating functions. But in reality finding the complex
roots of the appropriate polynomial may be too difficult, if not impossible. Given that
only partial factorisation of the polynomial in the denominator is possible, sometimes a
table of solutions is all that one can hope for.
As with the tables created for giving change in different types of coins, we can construct
sequences of solutions in tables, where the last sequence is the recurrence relation
desired. The general approach is the following. Start with a rational generating function
h(x) +
f (x)
g1 (x)g2 (x) gm (x)
where for all i gi (0) = 1 and the gi cannot be factored further and the degree of f is less
than the sums of the degrees of the gi .
f (x)
For every i = 1, 2, . . . m define the generating function ji to be
, so that
g1 (x) gi (x)
g1 (x)j1 (x) = f (x) and gi (x)ji (x) = ji1 (x).
Let
gi (x) = 1 + bi,1 x + bi,2 x2 + bi,pi xpi ,
f (x) = f0 + f1 x + + fl xl ,
jr (x) = ar,0 + ar,1 x + ar,2 x2 + .
For the first line of the table write down the finite sequence
f0
f1
...
fl
For any given k look at the coefficient for xk in the expression g1 (x)j1 (x) = f (x)
(1 + b1,1 x + b1,2 x2 + b1,p1 xp1 )(a1,0 + a1,1 x + a1,2 x2 + ) = f0 + f1 x + + fl xl .
We get a1,0 = f0 and
a1,k = fk b1,1 a1,k1 b1,k a1,0 ,
with fk = 0 if k > l.
The sequence for j1 can be written down according to this rule, below the sequence
f0 , . . . , f l .
f0 f1 . . . fl
a1,0 a1,1 . . . a1,l . . .
Assuming that this has been done for j1 , j2 , . . . , jr1 , we create the sequence
ar,0 , ar,1 , . . . corresponding to the generating function jr . With gr (x)jr (x) = jr1 (x) we
do the same trick:
(1 + br,1 x + br,2 x2 + br,pr xpr )(ar,0 + ar,1 x + ar,2 x2 + ) = ar1,0 + ar1,1 x +
62
implying
ar,k = ar1,k br,1 ar,k1 brk ar,0 ,
and these quantities are written down below ar1,0 , ar1,1 , . . . :
f0
f1
...
fl
a1,0
..
.
a1,1
..
.
...
a1,l
..
.
...
ar,1
...
ar,l
...
The process continues until the sequence for am,0 , am,1 , . . . is written down.
At the end bring back the polynomial h(x). It changes only some initial conditions.
Example 3.2 Assume that in a country, prior to the year 2000, there were coins of
one, two, five, and ten cents. In the year 2000 two new two cent coins were
introduced that looked different from the old two cent coin. We calculate the number
of ways to give change to the value of k = 1, 2, . . . , 15 where the number of two cent
coins of each of the three types matters, meaning that there are three ways of giving
7 cents using only a five cent coin and a two cent coin.
First we determine the generating function a0 + + ak xk + for giving change to
the value of k. It is
1
1
1
1
.
2
3
5
1 x (1 x ) (1 x ) (1 x10 )
The problem with determining an explicit formula for the numbers ai is that we
have as roots of this polynomial the complex
numbers
are the tenth roots of
that
2n
2n
unity, namely the complex numbers cos
+ sin
i for n = 0, 1, . . . , 9,
10
10
some of which have multiplicity more than one in this polynomial. Calculating the
coefficients for the partial fraction solution would involve a lot of algebraic work,
much more than our above solution for giving change in one and four cent coins.
Therefore we choose instead to find these numbers through the use of tables.
Let:
i be the coefficients for
1
1x
1
(1 x)(1 x2 )3
1
(1 x)(1 x2 )3 (1 x5 )
1
(1 x)(1
x2 )3 (1
x5 )(1 x10 )
63
3. Generating functions
and then continue with the rule i = i + 3i2 3i4 + i6 to get the influence of
the two cent coins:
1
10
10
20
20
35
35
56
56
84
84
120
120
And then i = i + i5 :
1
10
11
21
24
39
45
67
77
108
123
165
187
24
39
45
68
78
112
127
175
198
10
11
21
We conclude that there are 198 different ways to give change with values adding up
to 15.
Another method of going from a generating function to its corresponding sequence of
numbers is the old method known as long division. Long division on polynomials is
demonstrated in Section 25.1 of Discrete Mathematics. Given a generating function in
the form of f (x)/g(x), one can simply divide f (x) by g(x) using some simple rules. The
advantage to long division is that it does not require any factorisation of the polynomial
and in general can be performed without any additional preparation. Its drawback is
that one could quickly get bogged down in the complexity of the remainders that result
from long division.
1
, one divides 1 by
With the Fibonacci numbers, whose generating function is
1 x x2
1 x x2 .
The first step would give 1 with the remainder
1 (1 x x2 ) = x + x2 .
In the second step one adds x for 1 + x with the remainder
x + x2 (x x2 x3 ) = 2x2 + x3 .
1xx
64
1
1
1
x
x
x
x2
x2
x2
2x2
x3
+ x3
In the third step one adds 2x2 for 1 + x + 2x2 and the remainder
2x2 + x3 (2x2 2x3 2x4 ) = 3x3 + 2x4 .
In the fourth step one adds 3x3 for 1 + x + 2x2 + 3x3 with the remainder
3x3 + 2x4 (3x3 3x4 3x5 ) = 5x4 + 3x5 .
The next step yields a 5x . One recognises the pattern of the Fibonacci sequence in the
process of this long division.
3.3.4
The relationship between many homogeneous linear recurrence relations and their
generating functions can be well disguised. For example, for every n we may define l
different types of objects such that the number an of objects we want to know is the
sum of the numbers of the different types. The relations could be expressed entirely in
terms of these different types, so that the relation between the an and the previous
an1 , an2 , . . . is obscured. How could we discover the formula that makes it a
homogeneous linear recurrence relation? Formally we have for all n k
bjn
n X
l
X
pji bjni
i=1 j=1
pji
Often cleverness suffices to discover the general pattern without the complexity of a
composite formulation. For example, if an stands for the number of ways to climb n
stairs with strides of length 1, 2, or 3 one should recognise that an = an1 + an2 + an3
(from the last step being of size one, two, or three) without defining an additional three
sequences bn , cn , and dn , representing the ways to end in strides of length 1, 2, and 3
respectively.
It is good to know, however, that failing some clever solution to the problem that there
is a general method of linear algebra that will work.
Example 3.3 To demonstrate this method, we define a0 = 1, b0 = 0, c0 = 0, and
for all i 1 by
ai = ci1 + bi1 + ai1 ,
bi = ai1 ci1 ,
ci = ai1 bi1 ,
and we want to know ai for all i 0.
65
3. Generating functions
We can treat f , g, and h as variables, place these relations in a matrix, and solve
using the techniques of linear algebra:
x1 x x
f
1
x 1 x g = 0
x x 1
h
0
which reduces to
x 2 + x 1 0 x x2
f
x
1
x g = 0
0
x+1
1
0
x
and
and solves to
x
f
1 3x2
0 1
1
g =
x+1
1 0
0
x
0 0
f=
1+x
,
1 3x2
g=h=
x
.
1 3x2
3x
1+
3x
1+x
1 3x2
thus
(1 +
3x)u + (1 3x)v = 1 + x.
3
3
,
3
3
we get u =
3+3
6
and v =
3 3
6
for
3+3 k 3 3 k
( 3) +
( 3)
ak =
6
6
This corresponds to the answers obtained directly: a0 = 1, b0 = c0 = 0,
a1 = b1 = c1 = 1, a2 = 3, b2 = c2 = 0, a3 = 3.
3.3.5
Initial conditions
Two recurrence relations, both ruled by the same formula an = b1 an1 + + bk ank for
all n k, can act very differently. To illustrate this, we look at simple recurrence
relations defined by integers such that the initial conditions can determine whether the
66
0 = 1,
for all n 2, with 1 a variable.
Try first 1 = 1:
0 = 1,
1 = 1,
2 = 3 2 2 = 1,
3 = 3 2 3 = 8,
and so on downward.
Next try 1 = 3:
0 = 1,
1 = 3,
2 = 9 2 2 = 5,
3 = 15 6 3 = 6,
4 = 18 10 4 = 4,
5 = 12 12 5 = 5.
Next try 1 = 4:
0 = 1,
1 = 4,
2 = 12 2 2 = 8,
3 = 24 8 3 = 13.
Will this continue going up, or fall back like the others?
Let f (x) be the generating function for 0 , 1 , . . . .
1
x
2
With
equal
to
1
+
2x
+
3x
+
it
follows
that
is the generating
(1 x)2
(1 x)2
function for the recurrence relation n = n. We assume that 1 = 4
f (x)
3xf (x)
+2x2 f (x) =
x
+
=
(1 x)2
+ 2 x2
3 x3
3x
12x2
32 x3
2x2
8x3
2x2
3x3
+ .
4x
67
3. Generating functions
x
= 1 + 4x 3x + x = 1 + 2x.
(1 x)2
Re-write 1 + 2x
x
as
(1 x)2
1 x 3x2 + 2x3
(1 + 2x)(1 2x + x2 ) x
=
.
(1 x)2
(1 x)2
d
1 3 2
=1 + =0
8
2 4 8
or
d = 0,
x=1:
a = 1 1 3 + 2 = 1
or
a = 1,
or
b + c = 0,
or
6b + 12c = 6.
x=
x=0:
x = 1 :
a+b+c+d=1
3a + 6b + 12c + 8d = 1 + 1 3 2 = 3
68
(n + 1)(n + 2)
(n + 1)(n + 2)
+n+11=
+ n.
2
2
x
= 1 + 1 x 3x + x.
(1 x)2
(n + 1)(n + 2)
+ n + 1 2n ,
2
(n + 1)(n + 2)
+ n 1 + 2n .
2
3xf (x)
+2x2 f (x)
x
+5
(1 x)2
=
=
1 x
3x
5x
Sum up for
(1 3x + 2x2 )f (x) +
and
2 x2
31 x2
3 x3
32 x3
2x2
21 x3
10x2
15x3
5x
= 1 + 1 x + 2x
(1 x)2
1 + 1 x 5x 3x2 21 x2 + 2x3 + 1 x3
.
(1 x)3 (1 2x)
Putting into partial fractions:
f (x) =
b
c
d
1 + 1 x 5x 3x2 21 x2 + 2x3 + 1 x3
a
+
+
+
=
(1 x)3 (1 x)2 1 x 1 2x
(1 x)3 (1 2x)
69
3. Generating functions
and
(1 2x)a + (1 2x)(1 x)b + (1 2x)(1 x)2 c + (1 x)3 d
= 1 + 1 x 5x 3x2 21 x2 + 2x3 + 1 x3 .
8
2
4
2
4
8
2
which solves to d = 1 16. We conclude that if 1 > 16 then the limit of the
sequence will be positive infinity and if 1 < 16 then the limit of the sequence will
be negative infinity. It remains to see what happens when 1 = 16 (and d = 0).
Cover-up further with x = 1, x = 0, and x = 1:
x=1:
x=0:
x = 1 :
a = 1 + 16 5 3 32 + 2 + 16
a+b+c+d=1
3a + 6b + 12c + 8d = 1 16 + 5 3 32 2 16
or
a = 5,
or
b + c = 4,
or
6b + 12c = 78.
The explicit formula, which will have positive infinity as its limit, becomes
an =
5(n + 1)(n + 2)
+ 5(n + 1) 9.
2
This can be checked. On the left side is the quantity from the formula, on the right
side that from the recurrence relation starting with 0 = 1 and 1 = 16:
2 = 30 + 15 9 = 48 2 10 = 36,
3 = 50 + 20 9 = 108 32 15 = 61,
4 = 75 + 25 9 = 183 72 20 = 91.
1
1
.
1 x 1 x3
For all i 1, ai will be the number of ways of giving change in one and three pence
coins. Using long division, determine the values ai from i = 0 to i = 10.
70
Exercise 3.6
Let qn be the number of ways to write an n sequence of the letters a and b such that a
is never repeated three times consecutively (meaning that baabbabbbbabaab . . . is
allowed). Find the generating function for qn . (Hint: break down the possibilities to
three cases: those that end in b, those that end in one a, and those that end in two as.)
Exercise 3.7
The language of ALEBEMA has words consisting of the letters A, B, E, L , and M.
Every word must start with the letter A and alternate between the consonants and the
vowel letters A or E. The sequences A, AB, ALA, ABE and ABEL are words but BA,
ABLEB, EBA and AAL are not words. Let an denote the number of words of length n.
(a) Show that a1 = 1, a2 = 3, and an = 6an2 for all n 3.
(b) Write down the generating function for an , and the closed formula for the number
an as a function of n.
Next year the government of ALEBEMA will reform the language, permitting all
existing words but allowing for some new words. All words must still begin with the
letter A. Two consonants in succession are still not permitted and AA, EA, or EE in a
word is still not permitted; however AE in a word is permitted. AELEBAEMA and
ABAE are now words but ABEAL, AMAA and ALEE are still not words.
(c) Show that the recursive relation for the number bn of words of length n is b1 = 1,
b2 = 4, b3 = 9, and bn = 6bn2 + 3bn3 for all n 4.
Exercise 3.8
Consider the linear recurrences defined by a0 = 1 and an = 3an1 2an2 n2 . Find the
first positive integer for the initial value a1 such that the limit of the sequence is
positive infinity.
Exercise 3.9
The following problem is a little difficult. Let there be k planes in Euclidean space R3
such that any three distinct planes intersect at a point and any four distinct planes have
an empty intersection. Three planes will cut R3 into eight regions. Find the rational
generating function for how many regions (of both finite and infinite area) of R3 are
created by the cuts of k such planes and write down the explicit formula. Hint: Calculate
these numbers first for R1 and R2 with respect to points and lines, respectively.
3.4
Recurrence relations that do not conform to Theorem 3.3 do not have rational
generating functions and are not homogeneous linear. For non-linear recurrence relations
there is no cook book to solve them. Solving them is an art. We look at one example
that demonstrates the power of taking the derivative. This example is also worked out
in Section 4.5 of Combinatorics. See also Sections 26.3 to 26.7 of Discrete Mathematics.
71
3. Generating functions
3.4.1
a0 = 0, a1 = 1, for n 2
an = a1 an1 + a2 an2 + + an1 a1 .
Let f (x) = a0 + a1 x + a2 x2 + and look at the generating function f (x)2 . For any
k 2 its kth power coefficient is
ak a0 + an1 a1 + ak2 a2 + + a1 ak1 + a0 ak
and by a0 = 0 this is equal to ak . It holds that
(f (x))2 f (x) = a20 + 2a1 a0 x a0 a1 x = x.
Add
1
4
2
1
1
f (x)
= x.
2
4
1
f (x) =
2
1 4x
2
1 k
[D f ](0) +
k!
and [Dk f ](0) is equal to k! ak . So we need only find the derivatives of the function f (x).
1
2k1
(2k 3)!
(1 4x) 2
(k 2)!
(2k 3)!
(k 2)!
ak = 2
(2k 3)!
k!(k 2)!
72
the two possibilities (x1 + x2 ) + x3 and x1 + (x2 + x3 ). If there are k variables the first
cut can be made in k 1 places. If it is made in the jth place (meaning j variables to
the left, k j to the right) then the number of ways is aj akj , given that we let both a1
and a2 be 1. See Figure 3.2.
n j objects
j objects
(
n objects
Figure 3.2: A cut of n objects into j objects and n j objects.
The corresponding recurrence relation goes by the name of the Catalan numbers.
3.4.2
Partitions of an integer
Consider the number of ways that positive integers can add up to the number n (the
number of types corresponding to n). What is the generating function for this number?
This is presented as Theorem 13.1.1 of Combinatorics and also Sections 26.3 and 26.4 of
Discrete Mathematics.
First, a certain number of blocks of size 1 is used. This is represented by
1 + x + x2 .
Second, a certain number of blocks of size 2 is used. This is represented by
1 + x2 + x4 + .
Third, a certain number of blocks of size 3 is used. This is represented by
1 + x3 + x6 + .
If we are interested only in the number of types using blocks of size one, two, and three
the generating function would be
1
1
1
(1 + x + )(1 + x2 + )(1 + x3 + ) =
2
1 x 1 x 1 x3
as the coefficient for xn would be the number of ways of choosing quantities of blocks of
size one, two, and three to add up to n.
Since there is no limit on the size of the blocks used, the generating function would be
1
1
1
.
2
1 x 1 x 1 x3
This generating function is an infinite product; is it well defined? We need to know that
for every choice for k the coefficient for xk is well defined. Assuming that n is greater
than k, the generating function takes the form
(1 + x + )(1 + x2 + ) (1 + xk + ) (1 + xn + ) .
73
3. Generating functions
Being an infinite product, this generating function is not rational. However, given any
1
fixed n we can choose to ignore the terms
for k > n. Therefore fixing any large n
1 xk
we have a rational generating function for the number of ways to partition the integer k
into parts of size less than or equal to n.
However, with this large n fixed, finding an explicit formula through partial fractions
would be very difficult, due to the fact that the generating function up to n can be
rewritten as
1
1
1
1
.
2
n
1+x 1+x+x
1 + x + + x (1 x)n
The roots of the polynomial 1 + x + x2 + + xm are the complex numbers other than
1 whose (m + 1)th power is the number one.
On the other hand, we can calculate these numbers through the use of tables. One can
do so in exactly the same way one calculates the number of ways to give change, with
the idea that there are coins of all values. And one can do the same when there is no
limit to the size of the parts. There are efficient ways to create a table to reveal these
numbers. For a presentation of an efficient method using tables see Sections 26.5 and
26.6 of Discrete Mathematics.
What sequence of numbers is represented by the generating function
1
1
1
?
3
2
3
(1 x) (1 x ) (1 x3 )3
Assume that any positive integer can be coloured red, blue, or yellow. This is the
generating function for the number of ways to add up to k when the colours of the
numbers also matter.
Which sequence is represented by
1
1
1
?
(1 x)n (1 x2 )n (1 x5 )n
This represents the number of ways to give k pence to n distinguishable people in coins
of one, two, and five pence. The two questions are equivalent in the following way. If we
colour the coins with n different colours each colour could correspond to a different
person and the colouring of a coin is a determination of which person receives it.
3.4.3
A theorem of Euler
74
1
1
1
.
3
1 x 1 x 1 x5
(1 x2 )(1 x4 )
(1 x)(1 x2 )(1 x3 ) .
= (1 + x)(1 + x2 )(1 + x3 )
= f (x).
Previously we showed using Ferrers diagrams that the number of partitions of n into
distinct sizes is equal to the number of partitions of n where no size is skipped from 1 to
the maximal size. Now we have equality between three collections of partitions which
seem to have no apparent relation to each other. Let us check this with partitions of 8.
We mark partitions of distinct size with , partitions with only odd sizes with , and
partitions without skipped sizes with .
[8]
[7 1]
[6 2]
[5 3]
[6 12 ]
[5 2 1]
[5 13 ]
[42 ]
[4 3 1]
[4 22 ]
[4 2 12 ]
[4 14 ]
[32 2]
[32 12 ]
[3 22 1]
75
3. Generating functions
[3 2 13 ]
[3 15 ]
[24 ]
[23 12 ]
[2 16 ]
[22 14 ]
[18 ]
76
1
is the generating function for the sequence ai = 1 for
1x
Learning outcomes
At the end of this chapter and the relevant reading, you should be able to:
write down the generating function for the number of ways to make change and
calculate these values
obtain the generating function from a homogeneous linear recurrence relation
know how to multiply, divide and differentiate Laurent series
break down complicated expressions into partial fractions
find the explicit formula for a generating function, given that the appropriate
polynomial is easy to factor
identify homogeneous linear recurrence relations
solve explicitly for homogeneous linear recurrence relations using tables
perform long division on polynomials
convert composite linear recurrence relations into a single recurrence relation
determine the initial conditions that make a sequence go to positive or negative
infinity.
Solutions to exercises
Solutions to section 3.2 exercises
Solution to exercise 3.1
2x(2x + 1)
.
The answer is
(1 2x)3
1
corresponds to the polynomial
(1 y)2
function ai = i + 1. Therefore ai = i corresponds to the generating function
Consider first ai = i: The generating function
1
1
y
=
.
2
(1 y)
1y
(1 y)2
1
Then solve for ai = i2 . The generating function
corresponds to the polynomial
(1 y)3
(i + 2)(i + 1)
1
function ai =
. Multiply by 2 for 2
corresponding to i2 + 3i + 2.
2
(1 y)3
With the above results for i and 1 we get i2 corresponding to
2
3
1
+
.
(1 y)3 (1 y)2 1 y
1
y(1 + y)
for
. Now substitute y = 2x.
Put everything on top of
(1 y)3
(1 y)3
y
There is another way: take the derivative of
= y + 2y 2 + 3y 3 on both sides and
(1 y)2
then multiply the result by y. Lastly substitute y = 2x.
77
3. Generating functions
a1 is equal to 1 and a2 = 2 (in two strides or in one double stride). For n 3 either the
professor reaches the n 1th stair or he does not. In the former case he takes the last
stair in a single stride and in the latter case he takes the last two stairs in a double
stride. Therefore an = an1 + an2 for n 3 and with a0 = 1 we have the Fibonnaci
sequence.
Solution to exercise 3.3
First factor the polynomial 1 + x + x2 (or finds its roots). Then complete the square:
x2
3x2
x 2 3x2
1+x+
=
1+
=
4
4
2
4
3i
3i
x
x or
1+ =
2
2
2
!
!
1
+
3
i
1
3
i
1 + x + x2 = 1 +
x
1+
x .
2
2
1+
1+ 3 i
x
2
Thus
a+
3i
1+
1 3 i
x
2
ax + b +
1+
1
.
1 + x + x2
3i
bx = 1.
2
!n
3 3 i 1+ 3 i
3
+
3
i
3
i
1
an =
(1)n +
.
6
2
6
2
We can check by following the rule an = an1 an2 or doing long division on
1
. Notice that there are only finitely many numbers for an . Because the roots
1 + x + x2
of 1 + x + + xk are distinct roots of unity, this will hold for all rules of the form
an = an1 ank for all n k.
Solution to exercise 3.4
The number of ways to distribute k pence in coins of value v to n people has the
generating function
1
.
(1 xv )n
But here we have restrictions. The first coin gets distributed to only two people, so with
1
only the first coin the answer is
. Adding the second and third coins, and also
(1 x)2
78
considering that each of these coins can be distributed to only two people, we get
1
1
1
.
2
2
2
(1 x) (1 x ) (1 x5 )2
Not surprisingly, we get the first coefficient other than 1 at the third power, exactly the
level where there is more than one way to give change. 1 + x + x2 + 2x3 is on the top
with the remainder 2x4 + 2x5 + 3x6 + x7 + .
Next comes
1 + x + x2 + 2x3 + 2x4
on the top with the remainder 2x5 + 3x6 + 3x7 + x8 + .
Not surprisingly, with 6 we get more possibilities for giving change than just two. On
the top is
1 + x + x2 + 2x3 + 2x4 + 2x5 + 3x6
79
3. Generating functions
g = xf,
h = x + xf + xg + xh.
1
0
x
x
x 1
0 0
x x 1 x
x
0
0
1 0
x
x
0 1
x2 x2
0 x 1 x x2
x2 + x
0
x
x
1
x2
x2
2
3
3
2
0 1xx x
x +x +x
1 x x2 x3
1 0 0
x2
0 1 0
1 x x2 x3
0 0 1 x3 + x2 + x
1 x x2 x3
x
x2
x3 + x2 + x
+
+
1 x x2 x 3 1 x x2 x3 1 x x2 x3
x3 + 2x2 + 2x
=
.
1 x x2 x 3
80
f (x) =
f (x) =
Thus
(1 +
1+x
.
1 6x2
1+x
a
b
+
.
=
2
1 6x
1 6x 1 + 6x
6x)a + (1
6x)b = 1 + x
6 .
an =
2
12
2
12
6
.
6
(c) Let f be the generating function for the number of words ending in A, g the
generating function for the number of words ending in E, and h the generating
function for the number of words ending in a consonant. Being careful about the
initial conditions we could write the relations as f = xh 1, g = xf + xh + 1, and
h = 3xf + 3xg + 1. With f, g, h corresponding to the three columns, we need to
solve the following linear equations in Laurent series (in x):
1 0
x
1
x 1 x 1
3x 3x 1
1
and by reductions we get
1 0
x
1
0 1 x2 + x x 1
0 3x 3x2 1
3x 1
1 0
x
1
0 1
x 1 .
x2 + x
0
0 3x3 + 6x2 1
3x2 1
81
3. Generating functions
With 1 6x2 3x3 in the denominator of all the generating functions this is
enough to see the basic relation an = 6an2 + 3an3 for sufficiently large n and, of
course, the initial values are easy to calculate. One could also continue the process
of solving the linear equations to get
h=
1 3x2
,
1 6x2 3x3
g=
1 5x2
,
1 6x2 3x3
f=
1 + x + 6x2
1 6x2 3x3
3xf (x)
+2x2 f (x)
x(1 + x)
(1 x)3
a2 x 2
3x
3a1 x2
2x2
4x2
a1 x
We therefore get
(1 3x + 2x2 )f (x) +
x(1 + x)
= 1 + a1 x 2x.
(1 x)3
b
c
d
e
g
+
+
+
+
2
3
1 2x 1 x (1 x)
(1 x)
(1 x)4
and
1 6x + a1 x + 8x2 3a1 x2 7x3 + 3a1 x3 + 2x4 a1 x4
= (1 x)4 b + (1 x)3 (1 2x)c + (1 x)2 (1 2x)d + (1 2x)(1 x)e + (1 2x)g.
82
Now solve for b = 0 with the cover up rule using x = 21 for the answer a1 = 12 (obtained
by multiplying everything by 16 and simplifying). In the event that b = 0 and a1 = 12,
it is the value of g that matters. Plug in x = 1 and a1 = 12 for g = 2. Hence if a1 is 12
or more then the sequence goes to positive infinity and if a1 is less than 12 then to
negative infinity.
Solution to exercise 3.9
1
.
(1 x)2
1 x + x2
x
=
(1 x)2
(1 x)2
g=
1 x + x2
.
(1 x)3
1 2x + 2x2
1 x + x2
+
1
=
(1 x)3
(1 x)3
h=
1 2x + 2x2
.
(1 x)4
83
3. Generating functions
b a c = 4,
which solves to a = 0, b = 2, c = 2, and d = 1. This gives the formula
k+3
k+2
k+1
ck =
2
+2
.
3
2
1
We get
c0 = 1 2 + 2 = 1,
c1 = 4 6 + 4 = 2,
c3 = 20 20 + 8 = 8,
c4 = 35 30 + 10 = 15,
c5 = 56 42 + 12 = 26.
1
(1 x) (1 x3 )
(b) (1 + x)(1 + x2 )
(c)
1
(1 x) (1 x2 ) (1 xm )
(d) x
(e)
1
(1 x2 ) (1 x3 )
(1
x3 )
(1
x5 )
1
.
(1 x6 ) (1 x7 ) (1 x9 )
84
function then also by Theorem 3.3 there would be a positive real number r and a
positive integer m such that |ak | rk for
all
k m, something also impossible.
i
However, for a fixed m the expression
as a function of i is a polynomial in i,
m
hence by Theorem 3.3 it has a rational generating function.
Solution to exercise 3.12
The first values are a0 = 0, a1 = 1, a2 = 2, a3 = 5, a4 = 15, a5 = 51, and a6 = 188. Let f
be the generating function. According to the recurrence relation, for every n 2 the
1
nth coefficient of f 2 plus one is equal to the nth coefficient of f . Recalling that is
x
1
2
2
equal to 1 + x + x + , this allows us to write f f + equal to a polynomial of
x
1
degree no more than 1. Since f starts out with 0 + x we know that f 2 f + must be
x
5
1
1
2
. This
equal to x + 1 + x = 1. Completing the square gives f f + =
4
4 1x
r
r
1
5
1
1
5
1
solves to f (x) = +
or f (x) =
2
4 1x
must be the generating function. The first derivative is
1
2(1 x)2
1
5
4 1x
12
+ (1 x)
.
(1 x)3 4 1 x
4
4 1x
The first derivative evaluated at 0 is 1 and the second derivative evaluated at 0 is 4.
The first must be divided by 1! = 1 to get a1 = 1 and the second must be divided by 2!
to get a2 = 2.
85
3. Generating functions
86