Lecture Notes on Enumerative Combinatorics | MATH 180, Study notes of Mathematics

Material Type: Notes; Class: Combinatorics; Subject: Mathematics; University: University of California - Los Angeles; Term: Winter 2009;

Typology: Study notes

Pre 2010

Uploaded on 08/30/2009

koofers-user-kx3
koofers-user-kx3 🇺🇸

9 documents

1 / 58

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 1 March 30
We start our investigation into combinatorics by fo-
cusing on enumerative combinatorics. This topic deals
with the problem of answering “how many?” We will
start with a set S, which is a collection of objects called
elements, and then we will determine the number of
elements in our set denoted |S|. (More information
about the basics of set theory are found in the ap-
pendix of Applied Combinatorics.)
We start with a few basic rules for counting.
Addition Rule
If the set we are counting can be broken into disjoint
pieces, then the size of the set it the sum of the size
of the pieces.
S=
m
[
i=1
Si, SiSj=if i6=j |S|=
m
X
i=1 |Si|.
Example: A square with side length 4 is divided into
16 equal sqaures as shown below. What is the total
number of squares in the picture?
Solution: We break the squares up according to size.
There are sixteen 1×1 squares, nine 2×wsquares, four
3×3 squares and one 4 ×4 square. So by the addition
rule there is a total of 16 + 9 + 4 + 1 = 30 squares.
(Note: here we must be careful about what is meant by
disjoint. Geometrically as squares the squares are not
all disjoint one from another, but we are not concerned
with the geometry of the problem so when we talk
about disjoint we mean not the same square. So in
our case when we broke up the squares into these sets
by size theses sets are disjoint one from another.)
Multiplication Rule
Suppose we can describe the elements in our set us-
ing a procedure with msteps, where at the ith step
we have richoices available. (Where the number
of choices is independent of our previous choices.)
Then the size of the set is r1r2·· ·rm.
It is important to realize that what we are counting
using the multiplication rule is the number of choices
that can be made. In order to guarantee that we get
the right count it is important that (1) every element
in our set is realizable by at least one set of choices and
(2) no two sets of choices gives us the same element.
An example of what can go wrong will be given in a
later lecture.
Another important thing to note is that the number
of choices is independent on the previous choices but
not necessarily the choice that we have to make. This
is illustrated in the next example.
Example: How many standard California license
plates are possible? A standard license plate has the
form NLLLNNN where Nis a number and Lis a
letter. How many are possible if there is no repetition
of numbers or letters?
Solution: We can form the license plate one character
at a time. So we will use the multiplication rule where
the decision at the ith stage is what character goes in
the ith slot. Since there are 10 possible numbers and
26 possible letters we have that the number of license
plates is
10·26·26·26·10·10·10 = 175,760,000.
When we add the restriction that that there is no rep-
etition of characters we again use the same principle
as before. Now the difference is that when we fill in
the second number we only have nine options since
we have already used one number, when we fill in the
third we only have eight options and when we fill in
the fourth we only have seven. Note that here we do
not know which nine, eight or seven choices are avail-
able because that depends on previous choices, but the
number of choices does not! So the number when there
is no repetition of numbers is
10·26·25·24·9·8·7 = 78,624,000.
Bijection Rule
If the elements in Scan be paired in a one-to-one
(i.e., bijective) fashion, then |S|=|T|.
We have already used the bijection rule when we
did the multiplication rule, since what we are doing
is counting the number of choices which are paired
one-to-one with the elements. One interesting thing
is that it is possible to show that two sets have equal
size by giving a bijection between the sets without ever
knowing the size of the sets themselves.
Example: How many subsets of [n] = {1,2, . . . , n}are
there?
Solution: We can pair a subset of [n] with a binary
word of length n(a binary word is a word with the
individual letters coming from 0 and 1). The way this
is done is by taking a subset Aand letting the ith
letter of the binary word be 1 if iis in Aand 0 if iis
not in A. For example for {1,2,3}we have
000 {3}001
{1} 100 {1,3}101
{2} 010 {2,3}011
{1,2} 110 {1,2,3}111
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a

Partial preview of the text

Download Lecture Notes on Enumerative Combinatorics | MATH 180 and more Study notes Mathematics in PDF only on Docsity!

Lecture 1 – March 30

We start our investigation into combinatorics by fo- cusing on enumerative combinatorics. This topic deals with the problem of answering “how many?” We will start with a set S, which is a collection of objects called elements, and then we will determine the number of elements in our set denoted |S|. (More information about the basics of set theory are found in the ap- pendix of Applied Combinatorics.) We start with a few basic rules for counting.

Addition Rule If the set we are counting can be broken into disjoint pieces, then the size of the set it the sum of the size of the pieces.

S =

⋃^ m

i=

Si, Si ∩ Sj = ∅ if i 6 = j ⇒ |S| =

∑^ m

i=

|Si|.

Example: A square with side length 4 is divided into 16 equal sqaures as shown below. What is the total number of squares in the picture?

Solution: We break the squares up according to size. There are sixteen 1×1 squares, nine 2×w squares, four 3 × 3 squares and one 4 × 4 square. So by the addition rule there is a total of 16 + 9 + 4 + 1 = 30 squares. (Note: here we must be careful about what is meant by disjoint. Geometrically as squares the squares are not all disjoint one from another, but we are not concerned with the geometry of the problem so when we talk about disjoint we mean not the same square. So in our case when we broke up the squares into these sets by size theses sets are disjoint one from another.)

Multiplication Rule Suppose we can describe the elements in our set us- ing a procedure with m steps, where at the ith step we have ri choices available. (Where the number of choices is independent of our previous choices.) Then the size of the set is r 1 r 2 · · · rm.

It is important to realize that what we are counting using the multiplication rule is the number of choices that can be made. In order to guarantee that we get the right count it is important that (1) every element in our set is realizable by at least one set of choices and (2) no two sets of choices gives us the same element. An example of what can go wrong will be given in a later lecture.

Another important thing to note is that the number of choices is independent on the previous choices but not necessarily the choice that we have to make. This is illustrated in the next example.

Example: How many standard California license plates are possible? A standard license plate has the form N LLLN N N where N is a number and L is a letter. How many are possible if there is no repetition of numbers or letters?

Solution: We can form the license plate one character at a time. So we will use the multiplication rule where the decision at the ith stage is what character goes in the ith slot. Since there are 10 possible numbers and 26 possible letters we have that the number of license plates is

10 · 26 · 26 · 26 · 10 · 10 ·10 = 175, 760 , 000. When we add the restriction that that there is no rep- etition of characters we again use the same principle as before. Now the difference is that when we fill in the second number we only have nine options since we have already used one number, when we fill in the third we only have eight options and when we fill in the fourth we only have seven. Note that here we do not know which nine, eight or seven choices are avail- able because that depends on previous choices, but the number of choices does not! So the number when there is no repetition of numbers is 10 · 26 · 25 · 24 · 9 · 8 ·7 = 78, 624 , 000.

Bijection Rule If the elements in S can be paired in a one-to-one (i.e., bijective) fashion, then |S| = |T |.

We have already used the bijection rule when we did the multiplication rule, since what we are doing is counting the number of choices which are paired one-to-one with the elements. One interesting thing is that it is possible to show that two sets have equal size by giving a bijection between the sets without ever knowing the size of the sets themselves.

Example: How many subsets of [n] = { 1 , 2 ,... , n} are there?

Solution: We can pair a subset of [n] with a binary word of length n (a binary word is a word with the individual letters coming from 0 and 1). The way this is done is by taking a subset A and letting the ith letter of the binary word be 1 if i is in A and 0 if i is not in A. For example for { 1 , 2 , 3 } we have ∅ ↔ 000 { 3 } ↔ 001 { 1 } ↔ 100 { 1 , 3 } ↔ 101 { 2 } ↔ 010 { 2 , 3 } ↔ 011 { 1 , 2 } ↔ 110 { 1 , 2 , 3 } ↔ 111

Since there are 2n^ binary words it follows by the bi- jection rule that the number of subsets is also 2n.

Rule of Counting in Two Ways If we count S in two different ways the results must be equal.

This is the basic idea behind many combinatorial proofs. Namely we find an appropriate set and count it in two different ways. By then setting them equal we get some nontrivial relationships.

Example: Count the number of ∗’s in the diagram which has n rows and n + 1 columns (below we show the case n = 4) in two different ways.

∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗

Solution: For our first method we count along rows. Each row has (n + 1) of the ∗’s and there are n rows so in total we have n(n + 1) total ∗’s. For our second method we count using the diagonals. In particular we have that there are

1 + 2 + 3 + · · · + n + n + · · · + 3 + 2 + 1 = 2

∑^ n

i=

i.

Equating these two ways of counting we have

n(n + 1) = 2

∑^ n

i=

i or

∑^ n

i=

i = n(n + 1) 2

Probability is counting Probability is a measurement of how likely an outcome is to occur. If we are dealing with finitely many possible outcomes and each outcome is equally likely (very common assumptions!) then the probability that a certain outcome occurs is the ratio of the outcomes with the desired result divided by the number of all possible outcomes.

Lecture 2 – April 1

Example: A domino is a tile of size 1 × 2 divided into two squares. On each square are pips (or dots), the number of pips possible are0, 1 , 2 , 3 , 4 , 5 , 6. There are 28 possible domino pieces, i.e., 0 0 , 0 1 ,

0 2 ,.. ., 6 6. Two domino pieces fit if we can arrange them so the two adjacent squares have the same number of pips. So for example 1 3 3 6 fit

but 1 3 2 6 do not fit. What is the probability that two dominos chosen at random will fit?

Solution: First let us count the total number of ways to pick two dominos. We can think of choos- ing one domino and then a second one. This can be done in 28·27 = 756 ways. But we have overcounted, this is because the order that we pick domino pieces should not matter. So for example right now we dis- tinguish between the choice 1 3 5 6 and the choice 5 6 1 3. In essence we have counted ev- ery pair twice. To correct for this we divide by 2 so that the number of ways to pick two domino pieces is 756 /2 = 378. Next let us count the number of pairs for which the dominos fit. We again think of picking a domino and then seeing how many domino pieces fit with it. There are two cases, if we first pick a domino of the form x x (of which there are seven of this form) then dominos which fit with it are of the form x y with y 6 = x, so there are six matches. So in this case we got 6·7 = 42 pairs. In the second case we have a domino of the form x^ y^ where x 6 = y, there are 21 such dominos and there are twelve dominos that can fit with this type of domino, namely, x z for z 6 = x and y z for z 6 = y. So in this case we got 21 ·12 = 252 pairs. Combining we have 42 + 252 = 294 pairs that match, but as before we have counted every pair twice and so there are 147 pairs of dominos that fit. Combining we have that the probability that two dominos chosen at random will fit is 147/378 = 7/18.

Given a set with n objects, a permutation is an ordered arrangement of all n of the objects. An r- permutation is an ordered arrangement of r of the n objects. An r-combination is an unordered selection of r of the n objects. We now count how many of each type of the fol- lowing there are. First off for a permutation by the multiplication rule we choose which object will be first (we have n choices), then we choose which object will be second (we now have n − 1 choices), and continue so on to the end. So there are

n(n − 1)(n − 2) · · · 3 · 2 ·1 = n! permutations.

The notation n!, read “n factorial”, arises frequently in combinatorics and it is important to get a good handle on using it. For example, it is useful to be able to rewrite factorials, i.e., (2n+2)! = (2n+2)(2n+1)(2n)!. For convenience we will define 0! = 1 (this helps to simplify a lot of notation). Another useful fact for factorials is Stirling’s approx- imation which states that

n! ≈

2 πn

n e

)n .

This is useful when trying to get a handle on the size of an expression that involves factorial. For instance,

lead to the same outcome. This can sometimes be subtle to detect so great care should be taken!

Example: From among seven boys and four girls how many ways are there to choose a six member volleyball team with at least two girls?

Solution: One (seemingly) natural approach is to first pick two girls and then pick the remainder of the team. This way we guarantee that we meet the condition. The number of ways to pick the two girls is

2

, there are now nine people left and we have to choose 4 of then and this could be done in

4

ways, for a grand total of

2

4

= 756 different possible teams. But wait! Suppose the girls are A, B, C, D and the boys 1, 2 , 3 , 4 , 5 , 6 , 7 then we could have first chosen AB and then C246 to form the team ABC246, but we could also have first chosen BC and then A246 to form the team ABC246. So different choices gave us the same team. (We have committed the cardinal sin of overcounting.) To correct this we have two options, one is to figure out how much we have overcounted and then subtract off the overcount. The other is to go back and count in a different way, one such different method is to split up the count into smaller cases where we won’t overcount. For example in this problem let us break it up by the number of girls on the team. If there are two girls we pick two girls and four boys to form the team which can be done in

2

4

, if there are three girls we pick three girls and three boys to form the team which can be done in

3

3

, if there are four girls we pick four girls and two boys to form the team which can be done in

4

2

ways, so altogether there are ( 4 2

= 371 teams.

An arrangement of n distinct objects is n!. But what happens if the objects are not distinct? For example, suppose we are looking at anagrams, rearrangements of letters of a word. For instance “STEVE BUTLER” can be arranged to “RUE VEST BELT” but it could also be arranged to gibberish “VTSBEEERTLU”. So the number of ways there are to rearrange the letters of a given word (allowing for gibberish answers) is found by counting the arrangements of objects with repeti- tion.

Example: How many ways are there to rearrange the letters of the word “BANANA”?

Solution: We present two methods. The first method is to group the letters together by type. We have one B, three As and two Ns. We now start with six empty slots which we will fill in with our letters in order. First we put in the B, there are six slots and we must choose

one of them so this can be done in

1

ways. We now have five slots left for us to choose for the position of the three As which can be done in

3

ways. Finally we have two slots left for us to choose for the position of the two Ns which can be done in

2

ways. Giving us a total of ( 6 1

= 60 rearrangements.

For our second method we first make the letters dis- tinct. This is done by labeling, so we have the letters B, A 1 , A 2 , A 3 , N 1 , N 2. These letters can be arranged in 6! ways and finally we remove the labaling. The prob- lem is that we have now overcounted. For instance for the end result of ABAN N A this would show up twelve ways, as

A 1 BA 2 N 1 N 2 A 3 A 1 BA 3 N 1 N 2 A 2 A 2 BA 1 N 1 N 2 A 3 A 2 BA 3 N 1 N 2 A 1 A 3 BA 1 N 1 N 2 A 2 A 3 BA 2 N 1 N 2 A 1 A 1 BA 2 N 2 N 1 A 3 A 1 BA 3 N 2 N 1 A 2 A 2 BA 1 N 2 N 1 A 3 A 2 BA 3 N 2 N 1 A 1 A 3 BA 1 N 2 N 1 A 2 A 3 BA 2 N 2 N 1 A 1

Namely, we have 3! ways to label the As and 2! ways to label the Ns and 1! ways to label the B. This happens with each arrangement so in total we have

6! 1!3!2!

= 60 rearrangements.

These two approaches generalize. The first idea is to choose the slots for the first type of objects, then choose the slots for the second type of objects and so on. The second idea is to label the elements and permute and then divide out by the overcounting.

Given n 1 objects of type 1, n 2 objects of type 2,.. ., nk objects of type k and n = n 1 + n 2 + · · · + nk then the number of ways to arrange these objects is ( n n 1

n − n 1 n 2

n − n 1 − n 2 − · · · − nk− 1 nk

n! n 1 !n 2! · · · nk!

n n 1 , n 2 ,... , nk

The term

( (^) n n 1 ,n 2 ,...,nk

is also known as a multinomial coefficient, we will discuss these more in a later lecture.

Example: How many ways are there to rearrange the letters of “ROKOKO” so there in no “OOO”?

Solution: The number of ways to rearrange the letters of “ROKOKO” is the same as the number of ways to rearrange the letters of “BANANA”, so there are 60 in all. But of course some of these have “OOO” but we can use one of the most useful techniques in counting: Sometimes it is easier to count the complement.

So we now count the number of arrangements with “OOO”. This can be done by considering the arrange- ments of the letters R,K,K,OOO. This can be done in 4!/2! = 12 ways. So the total number of rearrange- ments without “OOO” is 60 − 12 = 48.

A related problem is to distribute n identical objects among k different boxes (or people, or days, or so on). One way to do this is to use ∗’s (stars) to denote the identical objects and lay them down in a row. We then draw in k − 1 dividing lines (bars) which divides the n objects into k groups, the first group goes in the first box, the second group goes in the second box and so on. For example suppose we are distributing n = 20 pennies among k = 6 children. Then using bars and stars we represent giving four pennies to the first child, two to the second, six to the third, none to the fourth, five to the fifth and three to the sixth by

∗ ∗ ∗ ∗ | ∗ ∗ | ∗ ∗ ∗ ∗ ∗ ∗ | | ∗ ∗ ∗ ∗ ∗ | ∗ ∗ ∗.

In this case we have a total of 25 bars and stars and once we know where the bars (or stars) go then we know where the stars (or bars) go. So the number of ways to do the distribution is the number of ways to pick the bars (or stars) which is

5

20

The number of ways to distribute n identical objects into k distinguished boxes is ( n + k − 1 k − 1

n + k − 1 n

Example: How many ways are there to distribute twenty pennies among six children? What if each child must get at least one penny?

Solution: We already have answered the first part, this can be done in

5

= 53, 130 ways. For the sec- ond part we distribute pennies in two rounds. In the first round we give one penny to each child, thus sat- isfying the condition that each child gets a penny. In the second round we distribute the remaining fourteen pennies among the six children arbitrarily which can be done in

5

= 11, 628 ways.

Lecture 4 – April 6

Example: How many ways are there to order six 0s, five 1s and four 2s so that the first 0 occurs before the first 1 which in turn occurs before the first 2?

Solution: We can build up the words one group of letters at a time. To simplify the process we first put down the 2s, then the 1s and finally the 0s. First putting down the 2s we have

Next we put down the 1s which can go before and after the 2s, i.e.,

2 2 2 2. To satisfy the constraint we must have one of the 1s go into the first slot, and the remaining n = 4 1s are distributed among the k = 5 slots which can be done in

4

ways. We now need to decide how to put in the 0s, these again can go before and after the letters already placed, i.e., 1 * * * * * * * *.

To satisfy the constraint we must have one of the 0s go into the first slot, and the remaining n = 5 0s are distributed among the k = 10 slots which can be done in

9

ways. Combining this gives us ( 8 4

= 140, 140 ways.

Many problems into combinatorics relate to the problem of placing n balls into k bins. The number of ways to do this is dependent on our assumptions.

  • Identical balls and distinct bins: This is what was discussed in the previous lecture, so it can be done in (^) ( n + (k − 1) k − 1

ways.

  • Distinct balls into distinct bins: Imagine we place the balls one at a time. The first ball can go into any of k bins, the second ball can go into any of k bins,.. ., the nth ball can go into any of k bins. So by the multiplication rule the number of ways that this can be done is

k︸ · k · · · · ·︷︷ k︸ n times

= kn.

  • Distinct balls into distinct bins, with number of balls in each bin specified: That is we want to place the balls so that n 1 balls go into the first bin, n 2 balls go into the second bin,.. ., nk balls go into the kth bin, where n = n 1 + · · · + nk. This can be done by choosing n 1 balls for the first bin, then choose n 2 of the remaining balls for the second bin, n 3 of the now remaining balls for the third bin, and so on. The number of ways to do this is ( n n 1

n − n 1 n 2

n − n 1 − n 2 − · · · − nk− 1 nk

which from the last lecture is the same as n! n 1 !n 2! · · · nk!

The idea behind the term

(n k

is that the way we mul- tiply out (x + y)n^ is to choose one term from each of the n copies of (x + y), to get xkyn−k^ we have to choose the x value for exactly k of the n possible places which can be done in

(n k

. Because of its connection to the binomial theorem the terms

(n k

are also known as binomial coefficients. There is a more general version of the binomial at- tributed to Isaac Newton. First we define for any num- ber r (even imaginary!) and integer k ≥ 1

( r k

r(r − 1) · · ·

r − (k − 1 )

k!

Further we let

(r 0

= 1. Then for |x| < 1

(1 + x)r^ =

∑^ ∞

k=

r k

xk.

In the case that r is an integer then the term

(r k

be- comes 0 for k sufficiently large so this gives us back the form of the binomial theorem given above.

Lecture 5 – April 8

As an application of the binomial theorem we have the following.

Let e = 2. 718281828... and 0 ≤ k ≤ n, then ( n k

)k ≤

n k

en k

)k .

Proof: For the first inequality we have ( n k

n k

(n − 1) (k − 1)

(n − 2) (k − 2)

n − (k − 1) k − (k − 1) ≥

n k

n k

n k

n k

=

n k

)k ,

where we used the fact that (n − a)/(k − a) ≥ n/k for 0 ≤ a ≤ k − 1. For the other inequality we first note that from calculus we have that ex^ ≥ 1 + x for all x, In particular for x ≥ 0 we have

enx^ ≥ (1 + x)n

=

∑^ n

i=

n i

xi

n k

xk.

Now choose x = k/n and simplify to get the result.

Today we will look at using the binomial theorem and more generally at the binomial coefficients. Our starting point will be looking at the coefficients in the binomial theorem, i.e.,

(n k

. These can be arranged in a triangle known as Pascal’s triangle as follows: ( 0 0

0

1

0

1

2

0

1

2

3

0

1

2

3

4

0

1

2

3

4

5

0

1

2

3

4

5

6

Inserting the values of these numbers we have

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

These numbers occur frequently in combinatorics so it is good to have the first few rows memorized and know some of the basic properties of numbers in this triangle. We will now start to describe some of the various properties of the numbers in this triangle. One thing which is apparent is that the rows are symmetric. In terms of the binomial coefficients this says the following.

( n k

n n − k

Algebraic proof: Using the definition of

(n k

from a previous lecture we have ( n k

n! k!(n − k)!

=

n! (n − k)!

n − (n − k)

n n − k

Combinatorial proof: By definition

(n k

is the number of ways to choose k elements from a set of n elements. This is the same as deciding which n − k numbers will not be chosen which can be done in

( (^) n n−k

ways.

We have now given two proofs. Certainly one proof is sufficient to show that it is true. Nevertheless it

is useful to have many different proofs of the same fact (for instance there are hundreds of proofs for the Pythagorean Theorem and new ones are constantly be- ing discvoered), since they can give us different ideas of how to use these tools in other problems. By “com- binatorial proof” we mean a proof wherein we count some object in two different ways (i.e., using the Rule of Counting in Two Ways from the first lecture).

Another pattern that seems to be happening is that the terms in the rows first increase until the halfway point and then they decrease. This behavior is called unimodal and we have the following.

For n fixed,

n k

is unimodal.

Proof: To show this we have to show that it first will increase and then decrease. This can be done by looking at the ratio of consecutive terms. In particular we have

(n k

( (^) n k− 1

≥ 1 then

(n k

( (^) n k− 1

≤ 1 then

(n k

( (^) n k− 1

Substituting in the definition for the binomial coeffi- cient we have (n k

( (^) n k− 1

n! k!(n−k)! n! (k−1)!(n−k+1)!

n − k + 1 k

Solving we see that

(n k

( (^) n k− 1

≥ 1 when k ≤ (n+1)/2. In particular we see that for the first half of a row on Pascal’s triangle that the binomial coefficients will increase and for the second half of the row they will decrease.

Actually more can be said about the size of the bi- nomial coefficients. Namely, it can be shown that they form the (infamous) bell shaped curve.

One very important pattern is how the coefficients of one row relate to the coefficients of the previous row. This gives us the most important identity for binomial coefficients.

( n k

n − 1 k − 1

n − 1 k

In other words this says to find the term

(n k

in Pas- cal’s triangle you look at the two numbers above and add them. Using this one can quickly generate the first few rows (so instead of memorizing the rows you can also memorize the first three or four and then memo- rize how to fill in the rest). This also can be used to give an inductive proof for the binomial theorem.

Algebraic proof: Plugging in the definitions for bino- mial coefficients we have ( n − 1 k − 1

n − 1 k

(n − 1)! (k − 1)!(n − k)!

(n − 1)! k!(n − k − 1)!

= (n − 1)! (k − 1)!(n − k − 1)!

n − k

k

(n − 1)! (k − 1)!(n − k − 1)!

n k(n − k)

n! k!(n − k)!

n k

Combinatorial proof: We have that

(n k

is the number of ways to select k elements from { 1 , 2 ,... , n}. Using the addition rule this is the number of ways to select k elements from { 1 , 2 ,... , n} with n being one of the chosen elements added to the number of ways to select k elements from { 1 , 2 ,... , n} with n not being one of the chosen elements. In the first case there are

(n− 1 k− 1

ways to choose the remaining k − 1 elements other than n and in the second case there are

(n− 1 k

ways to choose k elements other than n.

If we sum the values in the first few rows of Pascal’s triangle we see that we get 1, 2 , 4 , 8 , 16 , 32 , 64. This is a nice pattern and it holds in general.

∑^ n

k=

n k

n 0

n 1

n n

= 2n.

Algebraic proof: Putting x = y = 1 into the binomial theorem we have

2 n^ = (1 + 1)n^ =

∑^ n

k=

1 k 1 n−k

n k

∑^ n

k=

n k

Combinatorial proof: In a previous lecture we saw that the number of subsets of { 1 , 2 ,... , n} is 2n. On the other hand the number of subsets with k elements is

(n k

. Combining these two ideas we have that the number of subsets is the number of subsets of size 0 added to the number of subsets of size 1 added to the number of subsets of size 2... added to the number of subsets of size n.

We can also use the binomial theorem in more subtle ways.

∑^ n

k=

k

n k

n 1

n 2

n n

= n 2 n−^1.

We have already seen how to use committees to give identities about binomial coefficients. Another useful object is studying walks on a square lattice.

Example: On the square lattice shown below how many different walks are there from (0, 0) to (7, 4) which consists of steps to the right by one unit or up one unit?

Solution: Looking at the walks we see that we will need to take 7 steps to the right and 4 steps up, for a total of 11 steps. Moreover, every walk from (0, 0) to (7, 4) can be encoded as a series of right steps (R) and up steps (U ). For instance the path RRRU U RRU RRU corresponds to the following path.

So the number of walks is the same as the number of ways to arrange seven Rs and four U s which is

4

7

= 330 (i.e., choose when we take an up step or choose when we take a right step).

Example: On the square lattice shown below how many different walks are there from (0, 0) to (7, 4) which consists of steps to the right by one unit or up one unit?

Solution: This problem is nearly the exact same as the problem before except now we have to forbid some walks. In particular we have to throw out all walks that pass through the point (4, 2). So let us count how many walks there are that pass through (4, 2). Such a walk can be broken into two parts, namely a walk from (0, 0) to (4, 2) (of which there are

2

such walks)

and a walk from (4, 2) to (7, 4) (of which there are

2

such walks). Since we can combine these two halves of the walk arbitrarily then by the Rule of Multipli- cation the number of walks that pass through (4, 2) is

2

2

= 150. Therefore the number of walks not

passing through

2

is 330 − 150 = 180.

Lecture 6 – April 10

As another application of the binomial theorem we have the following.

For n ≥ 1 ∑n

k=

(−1)n

n k

In other words starting with the second row and going down if we sum along the rows alternating sign as we go the result is 0. Given the symmetry

(n k

( (^) n n−k

it trivially holds when k is odd, it is not trivial to show that it holds when k is even.

Algebraic proof: In the binomial theorem set x = − 1 and y = 1 to get

0 = (−1+1)n^ =

∑^ n

k=

(−1)k 1 n−k

n k

∑^ n

k=

1 k

n k

Combinatorial proof: First note that this is equivalent to showing the following: ( n 0

n 2

n 4

n 1

n 3

n 5

The left hand side counts the number of subsets of { 1 , 2 ,... , n} with an even number of elements while the right hand side counts the number of subsets with an odd number of elements. To show that we have an equal number of these two types we will use an involution argument. An involution on a set X is a mapping φ : X → X so that φ(φ(x)) = x. Given an involution φ the elements then naturally split into fixed points (elements with φ(x) = x) or pairs (two elements x 6 = y where φ(x) = y and φ(y) = x). In our case our involution will act on 2[n]^ (the set of all subsets of { 1 , 2 ,... , n}) and is defined for a subset A as follows:

φ(A) =

A \ { 1 } if 1 is in A, A ∪ { 1 } if 1 is not in A.

In other words we take a set and if 1 is in it we re- move it and if 1 is not in it we add it. We now make some observations. First, for any subset A we have φ(φ(A)) = A so that it is an involution. Further, there are no fixed points since 1 must either be in or not in a set. So we can now break the collection of subsets into pairs {A, φ(A)}. Finally, by the involution A and φ(A) will differ by exactly one element so one of them is even and one of them is odd. So we now have a way to pair every subset with an even number of elements

with a subset with an odd number of elements. So the number of such subsets must be equal.

We now give two identities which are useful for sim- plifying sums of binomial coefficients.

( n 0

n + 1 1

n + k k

n + k + 1 k

and ( k k

k + 1 k

n k

n + 1 k + 1

To prove the first one we will count the number of walks from (0, 0) to (n + 1, k) using right steps and up steps in two ways.

(n + 1, k)

We must make n + 1 steps to the right and k steps up. So the number of ways to walk from one corner to the other is the number of ways to choose when to make the up steps which is ( n + k + 1 k

We can also count the number of walks by grouping them according to which line segment is used in the last step to the right (in the picture above this cor- responds to grouping according to the line segment which intersects the dotted line). These line segments go from (n, i) to (n + 1, i) where i = 0,... , k. Once we have crossed the line segment there is only one way to finish the walk to the corner (straight up the side). On the other hand the number of ways to get to (n, i) is

(n+i i

. So by the rule of addition we have that the total number of walks is ( n + 0 0

n + 1 1

n + 2 2

n + k k

Combining these two different ways to count the paths gives the identity. A proof of the other result can be done similarly us- ing the following picture (we leave it to the interested reader to fill in the details).

(n − k, k + 1)

These identities can also be proved by using

(n k

n− 1 k− 1

(n− 1 k

. For example, we have the following. ( n + 1 k + 1

n k

n k + 1

n k

n − 1 k

n − 1 k + 1

n k

n− 1 k

k+ k

k+ k+

n k

n− 1 k

k+ k

k k

When I was taught these identities they were called the “hockey stick” identities. This name comes from the pattern that they form in Pascal’s triangle. For instance we have that

3

(shown below in blue) is the ( 2 2

2

(shown below in red). ( 0 0

0

1

0

1

2

0

1

2

3

0

1

2

3

4

0

1

2

3

4

5

0

1

2

3

4

5

6

The other identity corresponds to looking at the mirror image of Pascal’s triangle.

We now give an application of the hockey stick iden- tity.

∑^ n

i=

i^2 =

n(n + 1)(2n + 1) 6

In the first lecture we saw how to add up the sum of i by counting dots in two different ways. Here we want to sum up i^2 , the problem is that we don’t have an easy method to do that. We do have an easy method to add up the binomial coefficients, so if we can rewrite i^2 in terms of binomial coefficients then we can easily answer this question. So consider the following.

i^2 = 2

i(i − 1) 2

  • i = 2

i 2

i 1

(The ability to rewrite i^2 as a combination of binomial coefficients can also be used for any other polynomial expression of i. The trick is to find the coefficients involved. For the case of polynomials of the form i` we have that the coefficient of

(i k

is k!

{ `

k }^ where^ {^

` k }

Finally, reading off the coefficient for xk^ in h(x, y) gives us our desired function, namely

g(y) =

n

n k

yn^ = yk (1 − y)k+^

Lecture 7 – April 13

Today we look at one motivation for studying gen- erating functions, namely a connection between poly- nomials and distribution problems. Let us start with a simple example.

Example: Give an interpretation for the coefficient of x^1 1 for the polynomial

g(x) = (1 + x^2 + x^3 + x^5 )^3.

Solution: First note that we can write g(x) as

(1 + x^2 + x^3 + x^5 )(1 + x^2 + x^3 + x^5 )(1 + x^2 + x^3 + x^5 )

and that a typical term which we will get when we expand has the form xn^1 xn^2 xn^3 where the term xn^1 comes from picking a term from the first polynomial (so n 1 ∈ { 0 , 2 , 3 , 5 }), the term xn^2 comes from pick- ing a term from the second polynomial (so n 2 ∈ { 0 , 2 , 3 , 5 }), and the term xn^3 comes from picking a term from the third polynomial (so n 3 ∈ { 0 , 2 , 3 , 5 }). Since we are interested in the coefficient of x^11 then we need n 1 + n 2 + n 3 = 11. So this can be rephrased as a balls and bins problem where we are trying to distribute 11 balls among three bins where in each bin we can have either 0, 2, 3 or 5 balls.

Example: Give an interpretation for the coefficient of xr^ for the function

g(x) = (1 + x + x^2 )(1 + x + x^2 + · · · )(x + x^3 + x^5 + · · · ).

Solution: By the same reasoning as we have before a typical term in the expansion looks like xn^1 +n^2 +n^3 with n 1 being 0, 1 or 2; n 2 ≥ 0; and n 3 ≥ 0 and even. So this can be rephrased as a balls and bins problem where we are trying to distribute r balls among three bins where in the first bin we put 0, 1 or 2 balls; in the second bin we put any number of balls we want; in the third bin we put in an odd number of balls.

In general given a polynomial

g(x) = g 1 (x)g 2 (x) · · · gk(x)

with each gi a sum of some power of xs, i.e.,

gi(x) =

`

xq

i` .

Then the coefficient of xr^ in g(x) is the number of ways to place r balls into k bins so that in the ith bin the number of balls is qifor some. (The idea is that the term gi(x) tells you the restrictions about the kind of balls that can be placed into that bin. It is important that the coefficients of the gi(x) are all 1’s.) We can also start with a balls and bins problem and translate it into finding the coefficient of some appropriate polynomial.

Example: Translate the following problem into finding a coefficient of some function: “How many ways are there to put 12 balls into four bins so that the first two bins have between 2 and 5 balls, the third bin has at least 3 balls and the last bin has an odd number of balls?”

Solution: Since there will be 12 balls we will be look- ing for the coefficient of x^12. Now let us translate the condition on each bin. For the first two bins there are between 2 and 5 balls so

g 1 (x) = g 2 (x) = x^2 + x^3 + x^4 + x^5

(remember, the powers list the number of balls that can be put in the bin). For the third bin we have to have at least 3 balls so

g 3 (x) = x^3 + x^4 + · · ·.

We could also use the function

g′ 3 (x) = x^3 + x^4 + · · · + x^12 ,

the difference being that we stop and have a poly- nomial instead of an infinite series. The reason we can do this is that we are only interested in the co- efficient of x^12 , anything which will not contribute to that coefficient can be dropped without changing the answer. However by keeping the series we can use the same function to answer the question for any arbitrary number of balls and so the first option is more general. Finally for the last bin we have

g 4 (x) = x + x^3 + x^5 + · · ·.

Putting it altogether we are trying to find the coeffi- cient of x^12 for the function

(x^2 + x^3 + x^4 + x^5 )^2 (x^3 + x^4 + · · · )(x + x^3 + x^5 + · · · ).

Of course translating one problem to another is only good if we have a technique to solve the second prob- lem. So our next natural step is to find ways to deter- mine the coefficient of functions of this type. To help us do this we will make use of the following identities.

(1 + x)n^ =

∑^ n

k=

n k

xk

(1 − xm)n^ =

∑^ n

k=

(−1)k

n k

xmk

1 − xm+ 1 − x

= 1 + x + x^2 + · · · + xm

1 − x

= 1 + x + x^2 + · · · (for |x| < 1)

(1 − x)n^

k≥ 0

n − 1 + k k

xk

The first two are simple applications of the binomial theorem. The third is easily verifiable by multiplying both sides by (1 − x) and simplifying. The fourth one is a well known sum and can be considered the limiting case of the third one. (Note that as a function of x, i.e., analytically, this makes sense only when |x| < 1. Formally there is no restriction on x, this is because formally xk^ is acting as a placeholder.) To see why the last one holds we note that this is

1 (1 − x)n^

1 − x

1 − x

︸ ︷︷ 1 −^ x︸ n times = (1 + x + x^2 + · · · ) · · · (1 + x + x^2 + · · · ) ︸ ︷︷ ︸ n times

Translating this into a balls and bins problem, the co- efficient of xk^ would correspond to the number of so- lutions of e 1 + e 2 + · · · + en = k

where each ei ≥ 0. We have already solved this prob- lem using bars and stars, namely this can be done in( n−1+k k

ways, giving us the desired result.

We will need one more tool, and that is a way to multiply functions. We have the following which is a simple exercise in expanding and grouping coefficients.

Given

f (x) = a 0 + a 1 x + a 2 x^2 + · · · , g(x) = b 0 + b 1 x + b 2 x^2 + · · ·.

Then

f (x)g(x) = a 0 b 0 + (a 0 b 1 + a 1 b 0 )x + · · ·

  • (a 0 bk + a 1 bk− 1 + · · · + akb 0 )xk^ + · · ·.

The key is that the coefficient of xk^ is found by combining elements (aixi)(bk−ixk−^1 ) for i = 0,... , k.

We now show how to use these various rules to solve a combinatorial problem.

Example: How many ways are there to put 25 balls into 7 boxes so that each box has between 2 and 6 balls?

Solution: First we translate this into a polynomial problem. We are looking for 25 balls so we will be looking for a coefficient of x^25. The constraint on each box is the same, namely the between 2 and 6 balls so that the function we will be considering is

g(x) = (x^2 + x^3 + x^4 + x^5 + x^6 )^7 = x^14 (1 + x + x^2 + x^3 + x^4 )^7.

Here we pulled out an x^2 out of the inside which then becomes x^14 in front. Now since we are looking for the coefficient of x^25 and we have a factor of x^14 in front, our problem is equivalent to finding the coefficient of x^11 in g′(x) = (1 + x + x^2 + x^3 + x^4 )^7.

(Combinatorially, this is also what we would do. Namely distribute two balls into each bin, fourteen balls in total, and then decide how to deal with the remaining 11.) Using our identities we have

g′(x) = (1 + x + x^2 + x^3 + x^4 )^7

1 − x^5 1 − x

= (1 − x^5 )^7 ·

(1 − x)^7

x^5 +

x^10 +· · ·

k≥ 0

6+k k

xk

Finally, we use the rule for multiplying functions to- gether to find the coefficient of x^11. In particular note that in the first part of the product only three terms can be used, as all the rest will not contribute to the coefficient of x^11. So multiplying we have that the coefficient to x^11 is ( 7 0

This can also be done combinatorially. The first term counts the numbers without restriction. The second term then takes off the exceptional cases, but it takes off too much and so the third term is there to add it back in.

geniuses of the twentieth century was the Indian math- ematician Srinivasa Ramanujan. Originally a clerk in India he was able through personal study discover dozens of previously unknown relationships about par- titions. He sent these (along with other discoveries) to mathematicians in England and one of them, G. H. Hardy, was able to recognize the writings as some- thing new and exciting which caused him to bring Ra- manujan to England which resulted in one of the great mathematical collaborations of the twentieth century. Examples of facts that Ramanujan discovered include that p(5n + 4) is divisible by 5; p(7n + 5) is divisible by 7; and p(11n + 6) is divisible by 11. One natural question is to whether the exact value of p(n) is known. There is a “nice” formula for p(n), namely

p(n) =

π

∑^ ∞

k=

Ak(n)

k

[

d dx

sinh

( (^) π k

x − 241

x − 241

]

x=n

where Ak(n) is a specific sum of 24kth roots of unity. Proving this is beyond the scope of our class! We now turn to the (much) easier problem of finding the generating function for p(n), that is we want to find

n≥ 0

p(n)xn.

The first thing is to observe that a partition of size n corresponds to a solution of

e 1 + 2e 2 + 3e 3 + · · · + kek + · · · = n,

where each ei represents the number of parts of size i. Notice in particular the the contribution of ek will be a multiple of k. So turning this back into balls and bins we have n balls and infinitely many bins. So the number of solutions (using what we did last time) is

n≥ 0

p(n)xn^ = (1+x+x^2 +x^3 + · · · ) ︸ ︷︷ ︸ e 1 term × (1+x^2 +x^4 +x^6 + · · · ) ︸ ︷︷ ︸ e 2 term

× (1+x^3 +x^6 +x^9 + · · · ) ︸ ︷︷ ︸ e 3 term × · · · × (1+xk+x^2 k+x^3 k+ · · · ) ︸ ︷︷ ︸ ek term

× · · ·.

Since

1 + zk^ + z^2 k^ + z^3 k^ + · · · =

1 − zk^

we can rewrite the generating function as

n≥ 0

p(n)xn^ =

1 − x

1 − x^2

1 − x^3

1 − xk^

k≥ 1

1 − xk^

We can do variations on this. For instance we can look at partitions of n where no part is repeated. In other words we want to restrict our partitions so that ek = 0 or 1 for each k. If we denote these partitions by pd(n) then ∑

n≥ 0

pd(n)xn^ = (1 + x)(1 + x^2 ) · · · (1 + xk) · · ·

k≥ 1

(1 + xk)

Similarly we can count partitions with each part odd. In other words we want to restrict out parti- tions so that e 2 k = 0 for each k. If we denote these partitions by po(n) then it is easy to modify our con- struction for p(n) to get ∑

n≥ 0

po(n) =

k≥ 1

1 − x^2 k−^1

We can combine these two generating functions to derive a remarkable result.

For n ≥ 1 we have pd(n) = po(n).

Remarkably, we do not know in general what pd(n) or po(n) is, nevertheless we do know that they are equal! As an example of this we have that po(6) = 4 because of the partitions

1 + 1 + 1 + 1 + 1 + 1, 1 + 1 + 1 + 3, 1 + 5, 3 + 3,

while pd(6) = 4 because of the partitions

1 + 2 + 3, 1 + 5, 2 + 4, 6

It suffices for us to show that the two generating functions are identical. If the functions are the same then the coefficients must be the same giving us the desired result. So we have that ∑

n≥ 0

pd(n)xn^ =

k≥ 1

(1 + xk)

k≥ 1

1 − x^2 k 1 − xk

1 − x^2 1 − x

1 − x^4 1 − x^2

1 − x^6 1 − x^3

1 − x^8 1 − x^3

1 − x

1 − x^3

1 − x^5

k≥ 1

1 − x^2 k−^1

n≥ 0

po(n)xn.

We can also give a bijective proof. To do this we need to give a way to take a partition with odd parts and produce a (unique) partition with distinct parts, and vice versa. This can be done by repeatedly apply- ing the following rule until it cannot be done anymore:

  • With the current partition, if any two parts are equal combine them into a single part.

For example for the partition

1 + 1 + 1 + 1 + 1 + 1 → 2 + 1 + 1 + 1 + 1 → 2 + 2 + 1 + 1 → 4 + 1 + 1 → 4 + 2

This rule takes a partition with odd parts and produces a partition with distinct parts. To go in the opposite direction this cane be done by applying the following rule until it cannot be done anymore:

  • With the current partition, if any part is even then split it into two equal parts.

For example for the partition

3 + 4 + 6 → 2 + 2 + 3 + 6 → 1 + 1 + 2 + 3 + 6 → 1 + 1 + 1 + 1 + 3 + 6 → 1 + 1 + 1 + 1 + 3 + 3 + 3

These two rules give a bijective relationship between partitions with an odd number of parts and partitions with distinct parts.

Lecture 9 – April 17

We can visually represent a partition as a series of rows of dots (much like we did in the example in the previous lecture). This representation is known as a Ferrer’s diagram. The number of dots in each row is the size of the part and we arrange the rows in weakly decreasing order. The partition 4 + 3 + 1 + 1 would be represented by the following diagram.

We can use Ferrer’s diagrams to gain insight into properties of partitions. For instance one simple op- eration that we can do is to take the transpose (or the conjugate) of the partition. This is done by “flip- ping” across the line in the picture below, so that the columns become rows and rows become columns.

Since we do not change the number of dots by taking the transpose this takes a partition and makes a new

partition. So in this case we get the new partition 4 + 2 + 2 + 1. Note that if we take the transpose of the transpose that we get back the original diagram. There are some partitions such that the transpose of the partition gives back the partition, such partitions are called self con- jugate. For instance there are two self conjugate par- titions for n = 8, namely 4 + 2 + 1 + 1 and 3 + 3 + 2. A famous result says that the number of self conjugate partitions is equal to the number of partitions with distinct odd parts. So for example for n = 8 there are two partitions with distinct odd parts, namely 7 + 1 and 5 + 3. One proof of this relationship is based on using Ferrer’s diagrams. We will not fill in all of the details here but give the following “hint” for n = 8.

Also note that when we take the transposition that the number of rows becomes the size of the largest part in the transposition while the size of the largest part becomes the number of rows. So mapping a partition to its transpose establishes the following fact.

There is a one-to-one correspondence between the number of partitions of n into exactly m parts and the number of partitions of n into parts of size at most m with at least one part of size m.

It is easy to count partitions with parts of size at most m with at least one part of size m. In particular if we let

∣ n m

∣ (^) denote the number of partitions of n into exactly m parts then we have (using the techniques from the last lecture) ∑

n≥ 0

n m

∣ x

n (^) = x m (1 − x)(1 − x^2 ) · · · (1 − xm)

Another object associated with a Ferrer’s diagram is the Durfee square which is the largest square of dots that is in the upper left corner of the Ferrer’s diagram. For example for the partition 6 + 6 + 4 + 3 + 2 + 1 + 1 we have a 3×3 Durfee square as shown in the following picture.

It should be noted that every partition can be de- composed into three parts. Namely a Durfee square

We have

p(n) = p(n − 1) + p(n − 2) − p(n − 5) − p(n − 7) + · · ·

where the terms on the right hand side are those from the pentagonal theorem.

This follows by noting that

n≥ 0

1 − xn

n≥ 1

(1 − xn

n≥ 0

p(n)xn

−∞ Note that the approach is nearly identical for both problems, the only difference in the (initial) setup for the generating functions is the introduction of the fac- torial terms. So the same techniques and skills that we learned in setting up problems before still holds. The only real trick is to decide when to use an expo- nential generating function and when not to use it. In the end it boils down (for now) to whether or not we need to account for ordering in what we choose. If we don’t then go with an ordinary generating function, if we do go with an exponential generating function.

Lecture 10 – April 20

In the last lecture we saw how to set up an expo- nential generating function to solve an arrangement problem. As with ordinary generating functions, if we want to use exponential generating functions we need to be able to find coefficients of the functions that we set up. To do this we list some identities.

ex^ =

∑^ ∞

k=

xk k!

e`x^ =

∑^ ∞

k=

`k^

xk k!

ex^ + e−x 2

x^2 2!

x^4 4!

x^6 6!

ex^ − e−x 2

= x + x^3 3!

x^5 5!

x^7 7!

k≥n

xk k!

= ex^ − 1 − x − x^2 2!

x^3 3!

xn−^1 (n − 1)!

Example: Find the number of ternary sequences (se- quences formed using the digits 0, 1 and 2) of length n with at least one 0 and an odd number of 1s.

Solution: From last time we know that the exponen- tial generating function g(x) which counts the number of ternary sequences is

g(x) =

(e^3 x^ − e^2 x^ − ex^ − 1)

n≥ 0

3 n^

xn n!

n≥ 0

2 n^

xn n!

n≥ 0

xn n!

n≥ 1

3 n^ − 2 n^ − 1

) (^) xn n!

So reading off the coefficient of xn/n! we have that the number of such solutions is (3n^ − 2 n^ − 1)/2 for n ≥ 1 and 0 for n = 0.

Example: Find the exponential generating function where the nth coefficient counts the number of n letter words which can be formed using letters from the word “BOOKKEEPER”.

Solution: We will use an exponential generating func- tion since we are interested in counting the number of words and the arrangement of letters in words gives different words. Since order is important we will go with an exponential generating function. We group by letters. There are 3 Es, 2 Ks and Os and 1 B, P and R. So putting this together the desired exponential gen- erating function is

f (x) =

1 + x +

x^2 2!

x^3 3!

1 + x +

x^2 2!

1 + x

= 1 + 6x + 33

x^2 2!

x^3 3!

x^4 4!

x^5 5!

  • 11130

x^6 6!

x^7 7!

x^8 8!

  • 151200

x^9 9!

x^10 10!

(The last step is done by multiplying the polynomial out, letting the computer do all of the heavy lifting. So we can read off the coefficients and see, for example, that there are 34020 words of length 7 that can be formed using the letters from BOOKKEEPER.)

Example: How many ways are there to place n dis- tinct people into three different rooms with at least one person in each room?

Solution: This does not look like an arrangement problem, so we might not automatically think of using exponential generating functions. However, we previ- ously saw that the number of ways of arranging n 1 objects of type 1, n 2 objects of type 2,.. ., and nk objects of type k is the same as the number of ways to distribute n distinct objects into k bins so that bin 1 gets n 1 objects, bin 2 gets n 2 objects,.. ., and bin k gets nk objects. So this problem is perfect for exponential generating functions. In particular, since there are three room we can set this up as n 1 + n 2 + n 3 = n where ni are the number people in room i. Since each room must have at least one person we have that ni ≥ 1. So the exponential generating function is

h(x) =

x + x^2 2!

x^3 3!

x^4 4!

ex^ − 1

= e^3 x^ − 3 e^2 x^ + 3ex^ − 1

n≥ 0

3 n^

xn n!

n≥ 0

2 n^

xn n!

n≥ 0

xn n!

n≥ 1

3 n^ − 3 · 2 n^ + 3

xn.