Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of...

87
Discrete Mathematics Silvia Marcaida Bengoechea

Transcript of Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of...

Page 1: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

Discrete Mathematics

Silvia Marcaida Bengoechea

Page 2: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

2

Page 3: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

Contents

1 Basic combinatorics 7

1.1 Combinatorics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.2 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

1.3 Floor and ceiling functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.4 Tree diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.4.1 Rule of product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.4.2 Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

1.4.3 Combinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

1.4.4 Permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

1.4.5 Combinations with repetitions . . . . . . . . . . . . . . . . . . . . . . 19

1.5 Factorial powers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

1.6 Classifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

1.7 The principle of inclusion and exclusion . . . . . . . . . . . . . . . . . . . . . 25

1.7.1 Euler’s totient or phi (φ) function . . . . . . . . . . . . . . . . . . . . 28

1.8 Translations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

1.9 The Dirichlet pigeonhole principle and the salutes lemma . . . . . . . . . . . 31

2 Combinatorial identities 33

3

Page 4: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

4 CONTENTS

2.1 Combinatorial identities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

2.1.1 Combinatorial identities and proofs . . . . . . . . . . . . . . . . . . . 33

2.1.2 Basic identities of combinatorial numbers . . . . . . . . . . . . . . . . 35

2.1.3 Pascal’s triangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

2.1.4 Vandermonde’s formula and other identities . . . . . . . . . . . . . . 36

2.2 Binomial formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

2.3 Multinomial coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

2.3.1 Multinomial coefficients . . . . . . . . . . . . . . . . . . . . . . . . . 42

2.3.2 Combinatorial meaning . . . . . . . . . . . . . . . . . . . . . . . . . . 43

2.3.3 Multinomial formula . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

2.3.4 Some applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

2.4 Generalized binomial formula . . . . . . . . . . . . . . . . . . . . . . . . . . 45

3 Generating functions and recurrence relations 49

3.1 Generating functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

3.1.1 Power series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

3.1.2 Generating function of a sequence of numbers . . . . . . . . . . . . . 51

3.1.3 Examples (direct problems) . . . . . . . . . . . . . . . . . . . . . . . 51

3.1.4 Examples (inverse problems) . . . . . . . . . . . . . . . . . . . . . . . 53

3.1.5 Operations with generating functions . . . . . . . . . . . . . . . . . . 53

3.2 Generating functions and combinatorial problems . . . . . . . . . . . . . . . 54

3.2.1 Number of solutions of an equation . . . . . . . . . . . . . . . . . . . 54

3.2.2 Applications and examples . . . . . . . . . . . . . . . . . . . . . . . . 55

3.3 Recurrence relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

Page 5: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

CONTENTS 5

3.3.1 Combinatorial problems and recurrence relations. Examples . . . . . 57

3.3.2 Generating functions and recurrence relations . . . . . . . . . . . . . 59

3.3.3 Other methods (algebraic method) . . . . . . . . . . . . . . . . . . . 61

4 Main families of numbers 63

4.1 Fibonacci numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

4.2 Catalan numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

4.3 Partitions of natural numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 67

4.3.1 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

4.3.2 Ordered partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

4.3.3 Partitions and restricted partitions . . . . . . . . . . . . . . . . . . . 68

4.3.4 Partitions of different summands . . . . . . . . . . . . . . . . . . . . 69

4.3.5 Partitions with odd number of summands . . . . . . . . . . . . . . . 70

4.3.6 Ferrers diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

4.4 Bell numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

4.5 Stirling numbers of the first kind . . . . . . . . . . . . . . . . . . . . . . . . 74

4.6 Stirling numbers of the second kind . . . . . . . . . . . . . . . . . . . . . . . 76

5 Graphs 79

5.1 Basic concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

5.2 Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

5.3 Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

5.4 Planarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

5.5 Colorings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

Page 6: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

6 CONTENTS

Page 7: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

Chapter 1

Basic combinatorics

1.1 Combinatorics

Combinatorial theory is the study of methods of counting how many objects there are of agiven description, or of counting in how many ways something can be done, or of countinghow many ways a certain event can occur. For example, the following are some questionsfor combinatorial theory to answer:

1. How many objects are there of a given description?

(a) How many pairs of natural numbers (x, y) are there such that x + y = 10 orx+ y = n?

(b) How many tennis matches will be played in a tournament in which there are 137tennis players?

2. In how many different ways can something be done?

(a) In how many different ways can four people be seated at a circular table?

3. In how many different ways can a certain event occur?

(a) In how many ways can 15 points be obtained after throwing a die four times?

Page 8: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

8 Basic combinatorics

In general, let A be the finite set of elements that satisfy a property. Our aim is tocalculate the number of elements of A, that is, the cardinality of A.

A = x : x satisfies a property P. Calculate |A|.

1.2 Lists

In order to count the number of the elements of a set a first idea is to make a list of theelements. For example,

1. Solutions of an equation:

(a) A = (x, y) ∈ N∗ × N∗ : x+ y = 5List: (0, 5), (1, 4), (2, 3), (3, 2), (4, 1), (5, 0)Therefore, |A| = 6.

(b) (Generalization) A = (x, y) ∈ N∗ × N∗ : x+ y = n, n ∈ N∗List: (0, n), (1, n− 1), (2, n− 2), (3, n− 3), . . . , (n− 1, 1), (n, 0)Therefore, |A| = n+ 1.

(c) (Variation) A = (x, y) ∈ N∗ ×N∗ : x+ y = n, n ∈ N∗, x, y ≥ 2, that is, A is theset of solutions of x+ y = n with x, y ≥ 2 integers.

If n ≤ 3, |A| = 0.

If n ≥ 4, list: (2, n− 2), (3, n− 3), . . . , (n− 2, 2) ⇒ |A| = n− 3.

(d) (Generalization) A = (x, y, z) ∈ N∗ × N∗ × N∗ : x + y + z = n, n ∈ N∗, that is,A is the set of solutions of x+ y + z = n, x, y, z non-negative integers.

List:

xyz

0 0 0 · · · 00 1 2 · · · nn n− 1 n− 2 · · · 0︸ ︷︷ ︸

n+1

1 1 1 · · · 10 1 2 · · · n− 1n− 1 n− 2 n− 3 · · · 0︸ ︷︷ ︸

n

· · ·· · ·· · ·

xyz

· · ·· · ·· · ·

k k k · · · k0 1 2 · · · n− kn− k n− k − 1 n− k − 2 · · · 0︸ ︷︷ ︸

n−k+1

· · ·· · ·· · ·

n− 1 n− 10 11 0︸ ︷︷ ︸

2

n00︸︷︷︸1

Hence,

|A| = (n+ 1) + n + · · · + 1|A| = 1 + 2 + · · · + (n+ 1)

Page 9: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

1.3 Floor and ceiling functions 9

2|A| = (n+ 1)(n+ 2)

|A| = (n+ 1)(n+ 2)

2

(e) (Generalization) A = (x1, x2, . . . , xm) ∈ N∗×N∗×· · ·×N∗ : x1 +x2 + · · ·+xm =n, n ∈ N∗, that is, A is the set of solutions of x1+x2+· · ·+xm = n, x1, x2, . . . , xmnon-negative integers.

Would you try to build the list in this case?

Remarks:

(a) Building the list may be easy, less easy or impracticable.

(b) A list cannot have repetitions or absences (all the elements must be in the listand without repetitions).

(c) Before trying to solve a problem it may be convenient to analyze a particularcase.

2. Multiples of an integer:

(a) A = set of multiples of 4 among the 1871 first natural numbers.

A = x : 1 ≤ x ≤ 1871, x ≡ 0 ( (mod 4)) = 4, 8, 12, 16, . . . , 1868A = 4 · 1, 4 · 2, 4 · 3, 4 · 4, . . . , 4 · 467 ⇒ |A| = 467

(b) An = set of multiples of 4 among the first n natural numbers.

An = 4 · 1, 4 · 2, 4 · 3, 4 · 4, . . . , 4 · c where c is the quotient of dividing n by4 (n = 4c + r, 0 ≤ r < 4). Thus, |An| = c, that is, c is the integer part of n

4

(c =[n4

]).

(c) a ∈ N, An,a = set of multiples of a among the first n natural numbers.

An,a = a · 1, a · 2, a · 3, a · 4, . . . , a · c and |An,a| = c =[na

].

1.3 Floor and ceiling functions

Definition 1.3.1 Let x ∈ R.

bxc = floor function of x = integer part of x = the largest integer not greater than x.

Definition 1.3.2 Let x ∈ R.

dxe = ceiling function of x = the smallest integer not less than x.

Page 10: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

10 Basic combinatorics

Remark 1.3.3 These names and notation were introduced by Keneth E. Iverson in 1962.

Figura:

Properties:

i) bxc = dxe ⇔ x ∈ Z

ii) dxe = bxc+ 1⇔ x /∈ Z

iii) b−xc = −dxe, x ∈ R

iv) d−xe = −bxc, x ∈ R

v) bxc ≤ x ≤ dxe, x ∈ R

Definition 1.3.4 Let x ∈ R.

x = fractional part of x = x− bxc.

Definition 1.3.5 Let x ∈ R.

< x >= pseudofractional part of x = dxe − x.

Remark 1.3.6 x, < x >∈ [0, 1).

Example 1.3.7 Recall that |An,a| = c =[na

]= bn

ac. Notice that the ratio of multiples of a

in 1, 2, . . . , n is|An,a|n

=bnacn

=na− n

a

n=

1

a−nan−−−→n→∞

1

a.

(Notice that na ∈ [0, 1)).

Example 1.3.8 Integer coordinates in a circle

Let An be the set of points whose natural coordinates are in a circle of radius n. Therefore,An = (x, y) ∈ N× N : x2 + y2 ≤ n2. How much is |An|?

Figura

First column: (1, 1), (1, 2), . . . , (1, k) where k is the largest integer such that 12 + k2 ≤n2 ⇔ k2 ≤ n2 − 1⇔ k ≤

√n2 − 1. Therefore, k = b

√n2 − 1c.

Page 11: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

1.3 Floor and ceiling functions 11

Second column: (2, 1), (2, 2), . . . , (2, l) where l is the largest integer such that 22 + l2 ≤n2 ⇔ k2 ≤ n2 − 22 ⇔ k ≤

√n2 − 22. Therefore, k = b

√n2 − 22c.

j column: (j, 1), (j, 2), . . . , (j, r) where r is the largest integer such that j2 + r2 ≤ n2 ⇔r2 ≤ n2 − j2 ⇔ r ≤

√n2 − j2. Therefore, r = b

√n2 − j2c.

Thus, |An| =∑n

j=1b√n2 − j2c.

Example 1.3.9 Let An be the set of squares of area 1u2 in a fourth of a circle. How muchis |An|?

Figura

Area covered by the squares= |An|u2 ≤ area of the fourth of the circle = πn2

4. Hence,

|An| ≤ πn2

4.

On the other hand, if we move the squares one up and one to the right the circle iscovered but the part painted in orange. Therefore, πn2

4≤ |An|+2n−1. Thus, πn2

4−2n+1 ≤

|An| ≤ πn2

4⇒ 1 − 2n−1

πn2

4

≤ |An|πn2

4

≤ 1. Since 2n−1πn2

4

→ 0 when n → ∞, by the sandwich rule,

|An|πn2

4

→ 1 when n→∞. Thus, |An| ∼ πn2

4.

Example 1.3.10 Number of digits in the decimal system.

Given n ∈ N calculate the number of digits of n in the decimal system. For example,n = 1234⇒ d(n) = 4;n = 300⇒ d(n) = 3.

1000 ≤ abcd ≤ 9999 < 10000⇒ 103 ≤ abcd < 104

10d(n)−1 ≤ n < 10d(n) ⇒ log10(10d(n)−1) ≤ log10(n) < log10(10d(n)) ⇒ d(n) − 1 ≤log10(n) < d(n)⇒ d(n)− 1 = blog10(n)c ⇒ d(n) = blog10(n)c+ 1.

Example 1.3.11 Number of integers in (α, β), α, β ∈ R

Let Aα,β = set of integers in the interval (α, β), α, β ∈ R. How much is |Aα,β|?

For example:

α = 2.5, β = 4.7⇒ |Aα,β| = 2

α = 2.5, β = 2.8⇒ |Aα,β| = 0

Figura

Page 12: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

12 Basic combinatorics

Remark: Why is the first integer bαc+ 1 instead of dαe? If α were integer then dαe = α.But the interval is open in α!

Therefore,

Aα,β = bαc+ 1, bαc+ 2, . . . , dβe − 1 = bαc+ 1, bαc+ 2, . . . , bαc+ dβe − 1− bαc.

Thus, |Aα,β| = dβe − 1− bαc.

For example,

α = 2.5, β = 4.7⇒ |Aα,β| = 5− 2− 1 = 2

α = 2.5, β = 2.8⇒ |Aα,β| = 3− 2− 1 = 0

1.4 Tree diagrams

1.4.1 Rule of product

Rule of product: If an event X can happen in x ways and a distinct event Y in y ways thenX and Y can happen in xy ways.

Example 1.4.1 If we can go from Boston to Chicago in 3 ways (x, y, z) and from Chicagoto Dallas in 5 ways (1,2,3,4,5) then the number of ways in which we can go from Boston toChicago to Dallas is 15.

Figura

Figura

There are r1 branches starting from 0 (first generation). There are r2 branches startingfrom each branch of the first generation (second generation). And so on. Finally, there arern branches starting from each branch of the n− 1 generation (n generation). Let Rn be thetotal number of branches in the n generation, that is, Rn is the number of ways from 0 tothe top of the tree.

R1 = r1;R2 = R1 · r2 = r1 · r2; . . . ;Rn = Rn−1 · rn =∏n

i=1 ri.

Another version: Pigeonhole· · ·

1 2 · · · n

Page 13: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

1.4 Tree diagrams 13

If there are c1 ways of filling hole 1, c2 ways of filling hole 2,..., cn ways of filling hole n thenthere are c1 · c2 · . . . · cn ways of filling the pigeonhole.

Example 1.4.2 In order to make up a menu we can select among two different first dishes:A or B, three different second dishes: a,b or c and two different desserts: α or β. How manydifferent menus can we make up? 2 · 3 · 2 = 12 menus.

1.4.2 Samples

Definition 1.4.3 A set is an unordered collection of distinct objects. The objects are calledelements of the set. We use braces to denote a set. For example, the set with elements 1, 2and 3 is denoted 1, 2, 3. Since the elements are not ordered, 1, 2, 3 and 2, 3, 1 are thesame set.

Definition 1.4.4 A sequence is an ordered collection of not necessarily distinct objects. Weuse brackets to denote a sequence. For example, (1, 1, 2). Since the entries are ordered,(1, 1, 2) and (1, 2, 1) are different sequences.

Definition 1.4.5 Let Ω = a1, . . . , an be a set of elements and n ≥ k ≥ 1. A k-samplewithout repetition of Ω is an arrangement of the elements of Ω taken k at a time, where twoarrangements are regarded as different if they differ in composition or in the order of theirelements. In other words, a k-sample without repetition of Ω is a sequence of length k thatcan be formed with the elements in Ω without repeating them.

Let Vn,k denote the number of k-samples without repetition given n distinct objects. Howmuch is Vn,k? We note that we can choose the first element in n ways, the second elementin n− 1 ways,..., the kth element in n− k + 1 ways. By the rule of product,

Vn,k = n(n− 1) · · · (n− k + 1) =n!

(n− k)!.

Example 1.4.6 A certain society has 25 members. The members of the society are to electa president, a vice president, a secretary, and a treasurer. In how many ways is it possibleto select the 4 officers if no member of the society can hold more than one office at a time?

We are to find the number of samples (without repetitions) of 25 members taken 4 at atime. This number is equal to V25,4 = 25 · 24 · 23 · 22 = 303, 600.

Page 14: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

14 Basic combinatorics

Example 1.4.7 In a draw there are 3 prizes: a car, a trip and a basket full of food. 100tickets have been sold, numbered from 1 to 100. For each ticket a ball has been introducedinto a drum. The first number drawn wins the basket, the second wins the trip and thethird, the car.

• How many different possibilities are there?

Basket: 100 possible numbers, trip: 99 possible numbers, car: 98 possible numbers

V100,3 = 100 · 99 · 98 = 970, 200.

• If I bought 5 tickets, how many possibilities would I have of winning the car?

Basket: 99 possible numbers, trip: 98 possible numbers, car: 5 possible numbers

99 · 98 · 5 = 48, 510

• How many possibilities do I have of winning the three prizes?

Basket: 5 possible numbers, trip: 4 possible numbers, car: 3 possible numbers

5 · 4 · 3 = 60

• How many possibilities do I have of winning at least one prize?

We study it later.

Definition 1.4.8 Let Ω = a1, . . . , an be a set of elements and k ≥ 1. A k-sample withrepetition of Ω is a sequence of length k that can be formed with the elements in Ω being ableto repeat them.

Let V Rn,k denote the number of k-samples with repetition given n distinct objects. Howmuch is V Rn,k? We note that we can choose the first element in n ways, the second elementin n ways,..., the kth element in n ways. By the rule of product,

V Rn,k = n · n · · ·n = nk.

Notice that it is not necessary k ≤ n.

Example 1.4.9 • How many numbers of 3 digits can be formed in the decimal system?

− − −10 10 10

→ V R10,3 = 103 = 1, 000

• How many of them are palindromic?

− − −10 10 1

→ V R10,2 = 102 = 100

Page 15: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

1.4 Tree diagrams 15

• How many are even?

− − −10 10 5

→ 5 · V R10,2 = 5 · 102 = 500

Example 1.4.10 How many football pools coupons must we fill in order to be absolutelysure we win? Notice that there are 15 matches and 3 possible results.

V R3,15 = 315 = 14, 348, 907

Example 1.4.11 Let Ω = a, e, o, u, b, c, d.

• A = set of words of 4 letters that can be formed with the alphabet in Ω in such a waythat the first is a consonant and the last a vowel.

− − − −3 7 7 4

→ |A| = 3 · 7 · 7 · 4 = 12 · 49 = 588

• A = set of words of 5 letters that can be formed with the alphabet in Ω in such a waythat there are not equal consecutive letters.

− − − − −7 6 6 6 6

→ |A| = 7 · 6 · 6 · 6 · 6 = 9, 072

Example 1.4.12 A is the set of numbers of 5 different digits starting and finishing in aneven digit.

− − − − −5 8 7 6 4

→ |A| = 5 · 8 · 7 · 6 · 4 = 6, 720

Example 1.4.13 Calculate the number of ways to place 4 distinguishable balls in 3 num-bered boxes in such a way that none of the boxes are empty.

First idea: Place balls 1, 2, 3 one in each box and then ball 4. This is not a good ideabecause 1, 2 3 4 wouldn’t be counted.

Second idea: Select three balls, place them one in each box and place the fourth ball.This is not a good idea because we are counting 1, 4 2 3 and 4, 1 2 3 but they arethe same.

Good idea: Choose the box with two elements (3), select the balls in that box (?), placethe remaining balls one in each box (2). We study it later.

Page 16: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

16 Basic combinatorics

1.4.3 Combinations

Definition 1.4.14 Let Ω = a1, . . . , an be a set of elements and n ≥ k ≥ 1. A k-combination without repetition of Ω is an arrangement of the elements of Ω taken k ata time, where two arrangements are regarded as different only if they differ in composition.In other words, a k-combination without repetition of Ω is a subset of k elements of Ω. Thenumber of k-combinations without repetition of n elements is denoted by the symbol Cn,k.

There is a simple relation between the number Cn,k of k-combinations of n elements and thenumber Vn,k of k-samples. Let’s see it with an example.

Example 1.4.15 Let Ω = a, b, c, d, e. Count the 3-samples without repetition:

One way:

− − −5 4 3

→ V5,3 = 5 · 4 · 3 = 60

Another way:

Choose the three elements and then order the elements:

V5,3 = C5,3 · 3!⇒ C5,3 = V5,33!

= 5·4·33!

=5!2!

3!= 5!

2!3!=(53

).

In general,

Cn,k =Vn,kk!

=

(n

k

)

Example 1.4.16 Calculate the number of ways to place 4 distinguishable balls in 3 num-bered boxes in such a way that none of the boxes are empty.

As we said in example 1.4.13 we can choose the box with two elements (3), select theballs in that box (C4,2), place the remaining balls one in each box (2). Therefore, 3 ·

(42

)· 2 =

3 4!2!2!· 2 = 36.

Example 1.4.17 (Generalization) Calculate the number of ways to place n+ 1 distinguish-able balls in n numbered boxes in such a way that none of the boxes are empty.

First we choose the box with two elements (n), select the balls in that box (Cn+1,2), placethe remaining n− 1 balls one in each box (Vn−1,n−1). Therefore, nCn+1,2Vn−1,n−1.

Page 17: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

1.4 Tree diagrams 17

Example 1.4.18 (Generalization) Calculate the number of ways to place n+ 2 distinguish-able balls in n numbered boxes in such a way that none of the boxes are empty.

Two ways:

1) one box has three balls and the remaining boxes have one ball each

2) two boxes have 2 balls and the remaining boxes have one ball each

1) Choose the box with tree elements (n), select the balls in that box (Cn+2,3), place theremaining n− 1 balls one in each box (Vn−1,n−1). Therefore, nCn+2,3Vn−1,n−1.

2) Choose the double boxes (Cn,2), select the balls in the first double box (Cn+2,2), selectthe balls in the second double box (Cn,2), place the remaining n − 2 balls one in each box(Vn−2,n−2). Therefore, Cn,2Cn+2,2Cn,2Vn−2,n−2.

Thus, the solution is nCn+2,3Vn−1,n−1 + Cn,2Cn+2,2Cn,2Vn−2,n−2.

Proposition 1.4.19 Basic properties of the binomial coefficients

1. Cn,k =(nk

)=

Vn,kk!

=n!

(n−k)!k!

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

2.(nk

)= n!

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

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

nn−k

), k = 0, . . . , n.

Choosing k elements among n is the same as rejecting n− k among n.

3.(n0

)= n!

(n−0)!0! = n!n!·1 = 1.

4.(nn

)= n!

(n−n)!n! = n!1·n! = 1.

5.(n−1k−1

)+(n−1k

)=(nk

), n ≥ 1, k = 0, . . . , n.

6. If k ≥ 1,(nk

)= n

k

(n−1k−1

).

7. If k ≥ 1,(nk

)= n

n−k

(n−1k

).

Proof.- 5.(n−1k−1

)+(n−1k

)= (n−1)!

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

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

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

(n−k−1)!k!

]=

= (n− 1)![

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

(n−k)!k!

]= (n−1)!n

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

(nk

).

6.(nk

)= n!

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

k(n−1)···(n−k+1)

(k−1)···1 = nk

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

k

(n−1k−1

).

7.(nk

)=(

nn−k

)= n

n−k

(n−1

n−k−1

)= n

n−k

(n−1k

).

Page 18: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

18 Basic combinatorics

1.4.4 Permutations

Definition 1.4.20 A permutation of n elements or n-permutation is an n-sample withoutrepetition of n elements, that is, an n-permutation is a sample without repetition of n ele-ments which contains all the n elements. In other words, permutations of n elements areall the possible n-arrangements each of which contains every element once, with two sucharrangements differing only in the order of their elements. The number of n-permutationsis denoted by Pn.

Pn = Vn,n = n(n− 1) · · · 2 · 1 = n!

Definition 1.4.21 A multiset is a generalization of the notion of set in which elements areallowed to appear more than once.

Definition 1.4.22 Let M be a multiset with n1 elements of the first type, n2 elements ofthe second type,..., nk elements of the kth type. The different arrangements of M are thepermutations with repetition. In other words, an permutation with n1 elements of the firsttype, n2 elements of the second type,..., nk elements of the kth type is a sequence formed withn1 elements of the first type, n2 elements of the second type,..., nk elements of the kth type.P (n1, n2, . . . , nk) denotes the number of such permutations.

How much is P (n1, n2, . . . , nk)?

Example 1.4.23 Calculate the number of sequences that can be formed with p zeros andq ones.

− − · · · −p+ q

Choose where to place the zeros: Cp+q,p =(p+qp

).

We get the same choosing the places for the ones: Cp+q,q =(p+qq

).

Example 1.4.24 Calculate the number of sequences that can be formed with p zeros, qones, and r twos.

Choose the places for the zeros and then choose the places for the ones:

Cp+q+r,p · Cq+r,q =(p+q+rp

)·(q+rq

)= (p+q+r)!

(p+q+r−p)!p!(q+r)!

(q+r−q)!q! = (p+q+r)!(q+r)!p!

(q+r)!r!q!

= (p+q+r)!p!q!r!

.

Page 19: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

1.4 Tree diagrams 19

Notice that P (n1, n2, . . . , nk) is the number of sequences that can be formed with n1

elements of the first type, n2 elements of the second type,..., nk elements of the kth type.Let n = n1 + n2 + · · ·+ nk.

P (n1, n2, . . . , nk) =

(n

n1

)(n− n1

n2

)(n− n1 − n2

n3

)· · ·(n− n1 − · · · − nk−2

nk−1

)=

=n!

n1!(n− n1)!

(n− n1)!

n2!(n− n1 − n2)!

(n− n1 − n2)!

n3!(n− n1 − n2 − n3)!· · · (n− n1 − · · · − nk−2)!

nk−1!(n− n1 − · · · − nk−2 − nk−1)!=

=n!

n1!n2! · · ·nk−1!nk!

1.4.5 Combinations with repetitions

Definition 1.4.25 A k-combination of n elements with repetition is a multiset of k elementsamong the n. The number of k-combinations with repetition of n elements is denoted by thesymbol CRn,k.

How much is CRn,k?

Example 1.4.26 How much is CR5,3?

Let Ω = a1, a2, a3, a4, a5 be a set of five elements. We want to form multisets of 3elements. Define A = aα1aα2aα3 : α1, α2, α3 ∈ 1, 2, 3, 4, 5, α1 ≤ α2 ≤ α3. This is theset of multisets of 3 elements of Ω. Thus, CR5,3 = |A|. Define Ω′ = b1, b2, b3, b4, b5, b6, b7and B = bβ1bβ2bβ3 : β1 ∈ 1, 2, 3, 4, 5, β2 ∈ 2, 3, 4, 5, 6, β3 ∈ 3, 4, 5, 6, 7, β1 < β2 < β3.

Define the mapφ : A → B

aα1aα2aα3 → bα1bα2−1bα3−2.

This is a bijection.

Injective: Let φ(aα1aα2aα3) = φ(aγ1aγ2aγ3). Then bα1bα2+1bα3+2 = bγ1bγ2+1bγ3+2 ⇒ α1 =γ1, α2 + 1 = γ2 + 1, α3 + 2 = γ3 + 2⇒ α1 = γ1, α2 = γ2, α3 = γ3 ⇒ aα1aα2aα3 = aγ1aγ2aγ3 .

Surjective: Let bβ1bβ2bβ3 with β1 ∈ 1, 2, 3, 4, 5, β2 ∈ 2, 3, 4, 5, 6, β3 ∈ 3, 4, 5, 6, 7 andβ1 < β2 < β3. Let α1 = β1, α2 = β2 − 1, α3 = β3 − 2. Thus, α1 ∈ 1, 2, 3, 4, 5, α2 ∈1, 2, 3, 4, 5, α3 ∈ 1, 2, 3, 4, 5 and α1 ≤ α2 ≤ α3. Hence, there exists aα1aα2aα3 ∈ A suchthat φ(aα1aα2aα3) = bβ1bβ2bβ3 .

Therefore, the sets A and B both have the same number of elements. Since |B| = C7,3,CR5,3 = |A| = |B| = C7,3.

Page 20: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

20 Basic combinatorics

Example 1.4.27 Let Ω = a, b, c, d. Therefore n = 4. Let k = 3.

a, a, a ↔ 000111

a, a, b ↔ 001011

a, a, c ↔ 001101

a, b, b ↔ 010011

a, b, c ↔ 010101

c, c, d ↔ 110010

Therefore, CR4,3 = number of sequences that can be formed with 3 zeros and 3 ones.This can be calculated choosing three places out of 6, which is

(63

).

For each multiset of k elements there is a sequence formed with k zeros and n− 1 ones,and conversely. Therefore, CRn,k is the number of sequences formed with k zeros and n− 1ones. Thus,

CRn,k = Cn+k−1,k =Vn+k−1,k

k!=

(n+ k − 1)!

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

(n+ k − 1)!

(n− 1)!k!=

(n+ k − 1

k

).

Example 1.4.28 Calculate the number of sequences that can be formed with p zeros andq ones.

CRq+1,p =(q+1+p−1

p

)=(p+qp

).

This is another way of calculating example 1.4.23.

Example 1.4.29 Calculate the number of sequences that can be formed with 2 zeros and3 ones such that there are not consecutive zeros.

∼ 1 ∼ 1 ∼ 1 ∼

Choose 2 of the 4 possible places: C4,2 =(42

)= 4!

2!2!= 6.

Example 1.4.30 (Generalization)

Calculate the number of sequences that can be formed with p zeros and q ones such thatthere are not two consecutive zeros.

Page 21: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

1.5 Factorial powers 21

∼ 1 ∼ 1 ∼ · · · ∼ 1 ∼

Choose p of the possible q + 1 places: Cq+1,p =(q+1p

).

Example 1.4.31 Calculate the number of sequences that can be formed with 2 zeros, 3ones and 4 twos such that the zeros are not consecutive.

Choose a sequence formed by 1s and 2s (place the 1s) and then insert the zeros (placethe 0s in the holes): C7,3C8,2 =

(73

)(82

).

Example 1.4.32 (Generalization)

Calculate the number of sequences that can be formed with p zeros, q ones and r twossuch that there are not two consecutive zeros.

Choose a sequence of 1s and 2s (place the 1s) and then insert the zeros (place the 0s inthe holes): Cq+r,qCq+r+1,p =

(q+rq

)(q+r+1p

).

1.5 Factorial powers

Definition 1.5.1 Let a ∈ C. Its descending or lower or falling factorial (power) of orderk, k ∈ N∗, is

ak =

a(a− 1) · · · (a− k + 1) k ≥ 11 k = 0

Definition 1.5.2 Let a ∈ C. Its ascending or upper or rising factorial (power) of order k,k ∈ N∗, is

ak =

a(a+ 1) · · · (a+ k − 1) k ≥ 11 k = 0

Proposition 1.5.3 Some properties are the following:

1. (a) (−a)k = (−1)kak

(b) (−a)k = (−1)kak

Proof.- (−a)k = (−a)(−a− 1) · · · (−a− k + 1) =

= (−1)a(−1)(a+ 1) · · · (−1)(a+ k − 1) = (−1)kak.

Page 22: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

22 Basic combinatorics

(c) (−a)k = (−1)kak

Proof.- (−a)k = (−a)(−a+ 1) · · · (−a+ k − 1) =

= (−1)a(−1)(a− 1) · · · (−1)(a− k + 1) = (−1)kak.

2. (a) ak+l = ak · al

(b) ak+l = ak · (a− k)l

Proof.- ak+l = a(a− 1) · · · (a− k + 1)(a− k)(a− k − 1) · · · (a− k − l + 1) =

= ak(a− k)l

(c) ak+l = ak · (a+ k)l.

3. a = n ∈ N ∪ 0

(a) If 0 ≤ k ≤ n

nk = n(n− 1) · · · (n− k + 1) = n(n−1)···(n−k+1)(n−k)(n−k−1)···1(n−k)(n−k−1)···1 = n!

(n−k)!

(b) If k > n

nk = 0

Proof.- nk = n(n− 1) · · · (n− n)(n− n− 1) · · · (n− k + 1) = 0.

1.6 Classifications

Rule of sum: Let Ω be a set. If A1, . . . , Ak is a partition of Ω, that is, ∪ki=1Ai = Ω andAi ∩ Aj = ∅ for all i 6= j then

|Ω| = |A1|+ · · ·+ |Ak|.

Classification is useful: 1) sometimes there is no other solution but to classify, 2) we mayfind interesting identities, 3) classification is the main idea to get recurrence relationships.

Example 1.6.1 We have already done this.

A = ways of placing 5 distinguishable balls in 3 numbered boxes such that none of themis empty.

Define A1 = ways in which there are two boxes with two balls each, A2 = ways in whichthere is a box with three balls. Therefore, |A| = |A1|+ |A2|.

Example 1.6.2 Ω = a1, . . . , an. P(Ω) = collection of subsets of Ω = power set of Ω.

Subsets of Ω:

Page 23: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

1.6 Classifications 23

• 0 elements: ∅

• 1 element: a1, a2, . . . , an

• k elements

• n elements: Ω

|P(Ω)| = Cn,0 + Cn,1 + · · ·+ Cn,n =∑n

i=0Cn,i =∑n

i=0

(ni

).

Example 1.6.3 Let Ω = a1, . . . , an. How much is |P(Ω)|?

Set xn = |P(Ω)|.

Subsets that contain an: there are xn−1 = |P(a1, . . . , an−1)|.

Subsets that do not contain an: there are xn−1 = |P(a1, . . . , an−1)|.

Therefore, xn = xn−1 + xn−1 = 2xn−1 = 2 · 2xn−2 = 23xn−3 = · · · = 2n−1x1 = 2n.

By example 1.6.2,

2n =n∑i=0

(n

i

).

Example 1.6.4 an=number of sequences of length n formed with zeros and ones in whichthere are not two consecutive zeros.

a1 = 2 (0, 1)

a2 = 3 (01, 10, 11)

a3 = 5 (010, 011, 101, 110, 111)

We classify by the first element:

Starting with zero: the second number must be 1 so there are an−2.

Starting with one: there are an−1.

Hence,an = an−1 + an−2, n ≥ 3.

Example 1.6.5 (Recurrence relationship of the binomial coefficients)

Page 24: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

24 Basic combinatorics

Let Ω = a1, . . . , an and n ≥ k ≥ 1. Recall that k-combinations without repetition of nelements are the subsets of Ω with k elements.

First type: those that contain an. There are Cn−1,k−1.

Second type: those that do not contain an. There are Cn−1,k.

Therefore, Cn,k = Cn−1,k−1 + Cn−1,k ⇒(nk

)=(n−1k−1

)+(n−1k

).

We get Pascal’s triangle of the binomial coefficients or combinations:(00

)(10

) (11

)(20

) (21

) (22

)(30

) (31

) (32

) (33

)(40

) (41

) (42

) (43

) (44

)Thus,

11 1

1 2 11 3 3 1

1 4 6 4 1

Example 1.6.6 an=number of sequences of length n formed with zeros, ones and twos inwhich there are not two consecutive ones.

a1 = 3 (0, 1, 2)

a2 = 8 (00, 01, 02, 10, 12, 20, 21, 22)

For n ≥ 3:

Starting with 0: there are an−1

Starting with 10: there are an−2

Starting with 12: there are an−2

Starting with 2: there are an−1

Therefore,an = 2an−1 + 2an−2, n ≥ 3.

Example 1.6.7 There are two types of floor tiles: 2x1, 2x2. Let an be the number of waysto tile a rectangular floor of dimension 2xn.

Page 25: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

1.7 The principle of inclusion and exclusion 25

a1 = 1

a2 = 3

We classify the ways to tile by the firs element:

First element 2x1: there are an−1

First elements 2x1, 2x1: there are an−2

First element 2x2: there are an−2

Therefore,

an = an−1 + 2an−2 n ≥ 3.

1.7 The principle of inclusion and exclusion

Notation: A ∩B = AB for simplicity.

Example 1.7.1 Let An = k : 1 ≤ k ≤ n and k is divisible by 2 or 3 = k : 1 ≤ k ≤n, k ≡ 0 (mod 2) ∪ k : 1 ≤ k ≤ n, k ≡ 0 (mod 3).

Denote Bn = k : 1 ≤ k ≤ n, k ≡ 0 (mod 2) and Cn = k : 1 ≤ k ≤ n, k ≡ 0 (mod 3).Is Bn, Cn a partition of An?

It is true that Bn ∪ Cn = An but Bn ∩ Cn 6= ∅. For example 6 ∈ Bn ∩ Cn. So we cannotdeduce that |An| = |Bn|+ |Cn|. But, is there any relationship?

Let us consider the Venn diagram

Figura

|An| = |Bn|+ |Cn| − |BnCn|

|Bn| = bn2 c, |Cn| = bn3c, |BnCn| = bn6 c. Therefore, |An| = bn2 c+ bn

3c − bn

6c.

Example 1.7.2 An = k : 1 ≤ k ≤ n, k ≡ 0 (mod 2)

Bn = k : 1 ≤ k ≤ n, k ≡ 0 (mod 3)

Cn = k : 1 ≤ k ≤ n, k ≡ 0 (mod 5)

Page 26: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

26 Basic combinatorics

How much is |Dn| = |An ∪Bn ∪ Cn|?

Venn diagram:

Figura

|Dn| = |An ∪ Bn ∪ Cn| = |(An ∪ Bn) ∪ Cn| = |(An ∪ Bn)| + |Cn| − |(An ∪ Bn)Cn| =|An| + |Bn| − |AnBn| + |Cn| − |AnCn ∪ BnCn| = |An| + |Bn| − |AnBn| + |Cn| − (|AnCn| +|BnCn| − |AnBnCn|) = |An|+ |Bn|+ |Cn| − |AnBn| − |AnCn| − |BnCn|+ |AnBnCn|.

Thus, |Dn| = bn2 c+ bn3c+ bn

5c − bn

6c − b n

10c − b n

15c+ b n

30c.

Theorem 1.7.3 (The Principle of Inclusion-Exclusion) Let A1, . . . , An be subsets of a finiteset Ω. Then

| ∪ni=1 Ai| =n∑i=1

|Ai| −∑

1≤i<j≤n

|AiAj|+∑

1≤i<j<k≤n

|AiAjAk| − · · ·+

+(−1)r−1∑

1≤i1<i2<···<ir≤n

|Ai1Ai2 · · ·Air |+ · · ·+ (−1)n−1| ∩ni=1 Ai|

Proof.- By induction on n. We have already seen it for n = 2. Suppose it is true forn− 1.

|∪ni=1Ai| = |∪n−1i=1 Ai∪An| = |∪n−1i=1 Ai|+|An|−|(∪n−1i=1 Ai)An| = |∪n−1i=1 Ai|+|An|−|∪n−1i=1 AiAn| =n−1∑i=1

|Ai|−∑

1≤i<j≤n−1

|AiAj|+· · ·+(−1)r−1∑

1≤i1<i2<···<ir≤n−1

|Ai1Ai2 · · ·Air |+· · ·+(−1)n−2|∩n−1i=1 Ai|+

+|An|−

(n−1∑i=1

|AiAn| −∑

1≤i<j≤n−1

|AiAjAn|+ · · ·+ (−1)r−1∑

1≤i1<i2<···<ir≤n−1

|Ai1Ai2 · · ·AirAn|+

+ · · ·+ (−1)n−2| ∩n−1i=1 AiAn|)

=

=n∑i=1

|Ai| −∑

1≤i<j≤n

|AiAj|+∑

1≤i<j<k≤n

|AiAjAk| − · · ·+

+(−1)r−1∑

1≤i1<i2<···<ir≤n

|Ai1Ai2 · · ·Air |+ · · ·+ (−1)n−1| ∩ni=1 Ai|

How many quantities appear in the formula?

1+n+Cn,2+Cn,3+· · ·+Cn,r+· · ·+Cn,n =∑n

k=0Cn,k = 2n (Notice that the 1 correspondsto the quantity on the left).

Page 27: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

1.7 The principle of inclusion and exclusion 27

Example 1.7.4 Suppose that we have n married couples (a man and a woman) in a ball:(M1,W1), . . . , (Mn,Wn). In how many different ways can we pair the men off with the womenso that no man dances with his wife?

Let Ω = all the couples that can be done,

Ω∗ = couples in which no man dances with his wife.

Notice that |Ω| = Pn (M1 : n,M2 : n−1, . . . ,Mn = 1 or it can be seen as an arrangementof 1, . . . , n).

We want to calculate |Ω∗| but it is easier to calculate |Ω∗c|.

Ω∗c = couples in which there is at least one that is a married couple.

Hence, |Ω∗| = |Ω| − |Ω∗c|.

Define Ak = married couple k dances together, k = 1, . . . , n.

Fix married couple i. |Ai| = number of ways to arrange the remainder couples = Pn−1 =(n− 1)!.

Fix married couples i, j. |AiAj| = number of ways to arrange the remainder couples= Pn−2 = (n− 2)!.

Fix married couple i1, . . . , ir. |Ai1 . . . Air | = number of ways to arrange the remaindercouples = Pn−r = (n− r)!.

|A1 . . . An| = P0 = 1.

Thus,

|Ω∗c| =∑n

i=1 |Ai| −∑n

1≤i,j≤n |AiAj| + · · · + (−1)r−1∑n

1≤i1<···<ir≤n |Ai1 . . . Air | + · · · +

(−1)n|A1 . . . An| = n · (n− 1)!−Cn,2 · (n− 2)! + · · ·+ (−1)r−1Cn,r · (n− r)! + · · ·+ (−1)n · 1 =∑ni=1(−1)i−1Cn,i · (n− i)!

Therefore,

|Ω∗| = |Ω| − |Ω∗c| = n!−∑n

i=1(−1)i−1Cn,i · (n− i)! =∑n

i=0(−1)iCn,i · (n− i)!.

Remark 1.7.5 A simpler expression for the principle of inclusion-exclusion: Given ∅ 6= I ⊆1, . . . , n define AI = ∩i∈IAi. Then,

| ∪ni=1 Ai| =∑

∅6=I⊆1,...,n

(−1)|I|−1|AI |.

Page 28: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

28 Basic combinatorics

1.7.1 Euler’s totient or phi (φ) function

Let n ∈ N. Define

An = k ∈ 1, . . . , n : k is prime with n = k ∈ 1, . . . , n : gcd(k, n) = 1.

Euler’s totient or phi function is defined as

φ(n) = |An|

If n = 1, φ(1) = 1.

If n > 1 and n = pα11 p

α22 · · · p

αll is its prime decomposition then

φ(n) = n

(1− 1

p1

)(1− 1

p2

)· · ·(

1− 1

pl

)= n

l∏i=1

(1− 1

pi

).

Example 1.7.6 φ(12) = φ(22 · 3) = 12(1− 1

2

) (1− 1

3

)= 12 · 1

2· 23

= 4.

Remark 1.7.7 Notice that φ(n) is an integer.

Proof.- We can write

An = k ∈ 1, . . . , n : k is not divisible by any pi.

Then

Acn = k ∈ 1, . . . , n : k is divisible by at least one of the pi.

Let

Bi = k ∈ 1, . . . , n : k is divisible by pi, i = 1, . . . , l.

Thus,φ(n) = |An| = n− |Acn| = n− | ∪li=1 Bi| =

= n−

(l∑

i=1

|Bi| −∑

1≤i<j≤l

|BiBj|+ · · ·+ (−1)r−1∑

1≤i1<···<ir≤l

|Bi1 · · ·Bir |+ · · ·+ (−1)l−1|B1 · · ·Bl|

)=

= n−l∑

i=1

n

pi+

∑1≤i<j≤l

n

pi · pj+ · · ·+ (−1)r

∑1≤i1<···<ir≤l

n

pi1 · · · pir+ · · ·+ (−1)l

n

p1 · · · pl=

Page 29: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

1.8 Translations 29

= n

(1−

l∑i=1

1

pi+

∑1≤i<j≤l

1

pi · pj+ · · ·+ (−1)r

∑1≤i1<···<ir≤l

1

pi1 · · · pir+ · · ·+ (−1)l

1

p1 · · · pl

)=

= n

(1− 1

p1

)(1− 1

p2

)· · ·(

1− 1

pl

)= n

l∏i=1

(1− 1

pi

).

1.8 Translations

Definition 1.8.1 To translate a problem is to state an equivalent problem in other terms.

Example 1.8.2 Points in R2 ↔ (x, y) pairs of points in R

Line ↔ ax+ by = c

In this way we translate a geometrical problem in an algebraic one.

Example 1.8.3 Placement of m distinguishable balls in n numbered boxes

• Placement without exclusion (several balls can be placed in the same box)⇔ mappingfrom 1, . . . ,m to 1, . . . , n.

• Placement with exclusion (each box has at most one ball) ⇔ injective mapping from1, . . . ,m to 1, . . . , n.

Example 1.8.4 Placement of m undistinguishable balls in n numbered boxes

00 0 000 ↔ 001101000

• Placement without exclusion (several balls can be placed in the same box)⇔ sequenceformed by m zeros and n− 1 ones.

• Placement with exclusion (each box has at most one ball) ⇔ sequence formed by mzeros and n− 1 ones in which there are not two consecutive zeros.

Example 1.8.5 Let Ω = 1, . . . , n.

Page 30: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

30 Basic combinatorics

If Ω = 1, 2, 3, 4, 5:

∅ ↔ 00000

2 ↔ 01000

2, 5 ↔ 01001

Therefore, subset of Ω↔ sequence of length n formed by zeros and ones.

Example 1.8.6 Let Ω = 1, . . . , n.

Subset of k elements of Ω↔ sequence of length n formed by k ones and n− k zeros.

Example 1.8.7 H-V trajectory = a trajectory formed by flights of the following types:

7−→(x, y) (x+ 1, y)

,(x, y + 1)

↑(x, y)

. Therefore, this is an H-V trajectory:

Figura

Let T(p,q)(0,0) = set of H-V trajectories from (0, 0) to (p, q), with p, q ∈ N. Put 0 for H and

1 for V, so we get a sequence of zeros and ones.

H-V trajectory from (0, 0) to (p, q)↔ sequence of zeros and ones

Example 1.8.8 U-D trajectory = a trajectory formed by flights of the following types:(x, y) (x + 1, y + 1), (x, y) (x + 1, y − 1). Let Θ

(p,q)(0,0)= set of U-D trajectories from

(0, 0) to (p, q), with p, q ∈ N. Let x = number of flights U, y = number of flights D. Thus,x+ y = p and x− y = q. Thus, x = p+q

2, y = p−q

2.

• If p < q then y < 0, so there isn’t any U-D trajectory from (0, 0) to (p, q).

• If p and q have different parity then x and y will not be integers, so there isn’t anyU-D trajectory from (0, 0) to (p, q).

• If p ≥ q ≥ 0 and p and q have the same parity then

U-D trajectory from (0, 0) to (p, q)↔ sequence formed by p+q2

zeros and p−q2

ones.

Page 31: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

1.9 The Dirichlet pigeonhole principle and the salutes lemma 31

1.9 The Dirichlet pigeonhole principle and the salutes

lemma

The Dirichlet Pigeonhole Principle: If m pigeons occupy n pigeonholes and m > n then atleast one will house at least two pigeons.

In mathematical terms, if m > n there is not any injective mapping from a1, . . . , amto b1, . . . , bn.

Example 1.9.1 Let’s prove that in New York there are at least two persons with the samenumber of hairs on the head. Suppose that a person has at most 6 · 106 hairs on the headand that in New York more than 6 · 106 persons live. By the Dirichlet Pigeonhole Principleit follows.

The Salutes Lemma: Let n be the number of guests in a party. Suppose that if a personsays hello to another person, the latter always says hello to the former. Thus, the numberof persons that say hello to an odd number of persons is even.

Therefore, if the number of guests is odd then there is at least one person that says helloto an even number of guests.

Page 32: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

32 Basic combinatorics

Page 33: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

Chapter 2

Combinatorial identities

2.1 Combinatorial identities

2.1.1 Combinatorial identities and proofs

A combinatorial identity is an equality where there are combinatorial numbers. For example,(n

0

)+

(n

1

)+ · · ·+

(n

n

)= 2n, n ≥ 0.

An identity can be proved in different ways:

• Analytically: by induction, reduction to another known equality,...

• Combinatorially: by finding a combinatorial problem and two different counting meth-ods whose results are each side of the equality.

Example 2.1.1 (n

0

)+

(n

1

)+ · · ·+

(n

n

)= 2n, n ≥ 0.

Page 34: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

34 Combinatorial identities

• Combinatorial proof: Let Ω be a set of n elements.

– First counting method:

Subsets of Ω↔ sequences of length n formed with zeros and ones.

There are 2n.

– Second counting method:

Subsets of Ω of k elements:(nk

), k = 0, 1, . . . , n. Therefore, there are

∑nk=0

(nk

)subsets of Ω.

• Analytical proof: By induction on n: For n = 0,(00

)= 1 = 20. Let n ≥ 1 and

assume that the formula is true for n − 1. Having in mind that(nk

)=(n−1k

)+(n−1k−1

),∑n

k=0

(nk

)=(n0

)+[(n−11

)+(n−10

)]+[(n−12

)+(n−11

)]+ · · · +

[(n−1n−1

)+(n−1n−2

)]+(nn

)=(

n−10

)+(n−11

)+(n−10

)+(n−12

)+(n−11

)+ · · ·+

(n−1n−1

)+(n−1n−2

)+(n−1n−1

)= 2(n−10

)+ 2(n−11

)+

· · ·+ 2(n−1n−2

)+ 2(n−1n−1

)= 2

∑n−1k=0

(n−1k

)= 2 · 2n−1 = 2n.

Example 2.1.2 (n

0

)−(n

1

)+

(n

2

)− · · ·+ (−1)n

(n

n

)= 0, n ≥ 1

• Analytical proof: Since(nk

)=(n−1k

)+(n−1k−1

),(n0

)−(n1

)+(n2

)− · · · + (−1)n

(nn

)=(

n0

)−(n−11

)−(n−10

)+(n−12

)+(n−11

)−· · ·+(−1)n−1

(n−1n−1

)+(−1)n−1

(n−1n−2

)+(−1)n

(nn

)= 0.

• Combinatorial proof: We have to prove(n0

)+(n2

)+ · · · =

(n1

)+(n3

)+ · · · , that is,

the number of subsets of 1, . . . , n with an even number of elements is equal to thenumber of subsets of 1, . . . , n with an odd number of elements.

Let P = set of subsets of 1, . . . , n with an even number of elements and I = set ofsubsets of 1, . . . , n with an odd number of elements. Define the map

P → I

A →A \ 1 if 1 ∈ AA ∪ 1 if 1 /∈ A

Since it is a bijection |P| = |I|.

Example 2.1.3

a =

(n

0

)+

(n

2

)+ · · · = 2n−1, b =

(n

1

)+

(n

3

)+ · · · = 2n−1

By the two previous examples a+ b = 2n and a = b. Therefore 2a = 2n and a = 2n−1.

Page 35: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

2.1 Combinatorial identities 35

2.1.2 Basic identities of combinatorial numbers

Recall Proposition 1.4.19:

•(nk

)= n!

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

•(nk

)=(

nn−k

), k = 0, . . . , n.

•(n0

)=(nn

)= 1.

•(nk

)=(n−1k−1

)+(n−1k

), n ≥ 1, k = 0, . . . , n.

•(nk

)= n

k

(n−1k−1

), n ≥ 1, k = 1, . . . , n.

•(nk

)= n

n−k

(n−1k

), n ≥ 1, k = 1, . . . , n.

2.1.3 Pascal’s triangle

Recall Pascal’s triangle: (00

)(10

) (11

)(20

) (21

) (22

)(30

) (31

) (32

) (33

)(40

) (41

) (42

) (43

) (44

)(50

) (51

) (52

) (53

) (54

) (55

)(60

) (61

) (62

) (63

) (64

) (65

) (66

)(70

) (71

) (72

) (73

) (74

) (75

) (76

) (77

)Thus,

11 1

1 2 11 3 3 1

1 4 6 4 11 5 10 10 5 1

1 6 15 20 15 6 11 7 21 35 35 21 7 1

From the triangle we see, for example, that(30

)+(41

)+(52

)+(63

)=(73

). In general,(

n

0

)+

(n+ 1

1

)+

(n+ 2

2

)+ · · ·+

(n+ r

r

)=

(n+ r + 1

r

), n, r ≥ 0.

Page 36: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

36 Combinatorial identities

• Proof 1:(n+ r + 1

r

)=

(n+ r

r

)+

(n+ r

r − 1

)=

(n+ r

r

)+

(n+ r − 1

r − 1

)+

(n+ r − 1

r − 2

)= · · · =

=

(n+ r

r

)+

(n+ r − 1

r − 1

)+

(n+ r − 2

r − 2

)+ · · ·+

(n+ 1

1

)+

(n+ 1

0

)=

=

(n+ r

r

)+

(n+ r − 1

r − 1

)+

(n+ r − 2

r − 2

)+ · · ·+

(n+ 1

1

)+

(n

0

).

• Proof 2 (induction on r): For r = 0(n+00

)= 1 =

(n+0+1

0

). Assume that it is true for

r − 1 and let’s see it for r:(n

0

)+

(n+ 1

1

)+

(n+ 2

2

)+ · · ·+

(n+ r

r

)=

(n+ r

r − 1

)+

(n+ r

r

)=

(n+ r + 1

r

),

where the first equality is true by the induction hypothesis and the second by one ofthe basic combinatorial identities.

2.1.4 Vandermonde’s formula and other identities(n

0

)(m

r

)+

(n

1

)(m

r − 1

)+ · · ·+

(n

r

)(m

0

)=

(n+m

r

), n,m, r ∈ N ∪ 0.

That is,r∑

k=0

(n

k

)(m

r − k

)=

(n+m

r

), n,m, r ∈ N ∪ 0.

Proof.- (by induction on n)

For n = 0,(00

)(mr

)=(mr

), for all r,m ∈ N ∪ 0.

Assume that the formula is true for n− 1 for any r,m. Then(n

0

)(m

r

)+

(n

1

)(m

r − 1

)+ · · ·+

(n

r

)(m

0

)=

=

(n− 1

0

)(m

r

)+

((n− 1

1

)+

(n− 1

0

))(m

r − 1

)+ · · ·+

((n− 1

r

)+

(n− 1

r − 1

))(m

0

)=

=

((n− 1

0

)(m

r

)+

(n− 1

1

)(m

r − 1

)+ · · ·+

(n− 1

r

)(m

0

))+

+

((n− 1

0

)(m

r − 1

)+

(n− 1

1

)(m

r − 2

)+ · · ·+

(n− 1

r − 1

)(m

0

))=

Page 37: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

2.1 Combinatorial identities 37

=

(n− 1 +m

r

)+

(n− 1 +m

r − 1

)=

(n+m

r

).

Proof.- (combinatorial)

Let Ω = a1, . . . , an, b1, . . . , bm, A = a1, . . . , an, B = b1, . . . , bm. The number ofsubsets of Ω with r elements is

(n+mr

).

On the other hand, the number of subsets of Ω with r elements, k of which are in A is(nk

)(mr−k

), for k = 0, . . . , r. Thus,

∑rk=0

(nk

)(mr−k

)=(n+mr

).

Other identities

(n

0

)2

+

(n

1

)2

+ · · ·+(n

n

)2

=

(2n

n

).

Proof.- By Vandermonde’s formula when n = m = r:(n

0

)(n

n

)+

(n

1

)(n

n− 1

)+ · · ·+

(n

n

)(n

0

)=

(2n

n

)

(n

r

)(r

k

)=

(n

k

)(n− kr − k

), n ≥ r ≥ k ≥ 0.

Proof.- (analytical)

n!

r!(n− r)!r!

k!(r − k)!=

n!

k!(n− r)!(r − k)!

(n− k)!

(n− k)!=

(n

k

)(n− kr − k

).

Proof.- (combinatorial)

Let Ω = 1, . . . , n.(nr

)(rk

)= number of pairs (A,B) where A is a subset of Ω with r elements and B is a

subset of A with k elements.

Another strategy is to choose B as a subset of Ω with k elements and add r− k elementsin order to build A:

(nk

)(n−kr−k

).

Page 38: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

38 Combinatorial identities

2.2 Binomial formula

Theorem 2.2.1 Let x, y ∈ C and n = 0, 1, 2, . . .. Then

(x+ y)n =n∑k=0

(n

k

)xkyn−k

Proof.- (by induction on n)

For n = 0, (x + y)0 = 1 and(00

)x0y0 = 1. For n = 1, (x + y)1 = x + y and

(10

)x0y1 +(

11

)x1y0 = y + x. Suppose it is true for n− 1 and let’s see it for n.

(x+ y)n = (x+ y)n−1(x+ y) = x(x+ y)n−1 + y(x+ y)n−1 =

= xn−1∑k=0

(n− 1

k

)xkyn−1−k + y

n−1∑k=0

(n− 1

k

)xkyn−1−k =

=n−1∑k=0

(n− 1

k

)xk+1yn−1−k +

n−1∑k=0

(n− 1

k

)xkyn−k =

=

(n− 1

0

)xyn−1 +

(n− 1

1

)x2yn−2 + · · ·+

(n− 1

n− 1

)xny0+

+

(n− 1

0

)x0yn +

(n− 1

1

)xyn−1 + · · ·+

(n− 1

n− 1

)xn−1y =

=

(n

0

)x0yn +

((n− 1

0

)+

(n− 1

1

))xyn−1 +

((n− 1

1

)+

(n− 1

2

))x2yn−2 + · · ·+

+

((n− 1

n− 2

)+

(n− 1

n− 1

))xn−1y +

(n

n

)xny0 =

=

(n

0

)x0yn+

(n

1

)xyn−1 +

(n

2

)x2yn−2 + · · ·+

(n

n− 1

)xn−1y+

(n

n

)xny0 =

n∑k=0

(n

k

)xkyn−k.

Proof.- (combinatorial)

Notice that

(x+ y)(x+ y) = xx+ xy + yx+ yy,

(x+y)(x+y)(x+y) = (xx+xy+yx+yy)(x+y) = xxx+xxy+xyx+xyy+yxx+yxy+yyx+yyy.

Page 39: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

2.2 Binomial formula 39

For n ≥ 1:

(x+ y)n = (x+ y)(x+ y) · · · (x+ y) = xx · · ·x+ xx · · ·xy + · · · =

∑sequences of length n that can be formed with x and y =

n∑k=0

(n

k

)xkyn−k.

Corolary 2.2.2

(1 + x)n =n∑k=0

(n

k

)xk =

(n

0

)+

(n

1

)x+ · · ·+

(n

n

)xn.

Corolary 2.2.3

(1− x)n =n∑k=0

(n

k

)(−x)k =

n∑k=0

(n

k

)(−1)kxk =

(n

0

)−(n

1

)x+ · · ·+ (−1)n

(n

n

)xn.

Corolary 2.2.4 (n

0

)+

(n

2

)x2 +

(n

4

)x4 + · · · = (1 + x)n + (1− x)n

2.

Proof.- (1 + x)n + (1− x)n = 2((n0

)+(n2

)x2 +

(n4

)x4 + · · ·

).

Corolary 2.2.5 (n

1

)x+

(n

3

)x3 +

(n

5

)x5 + · · · = (1 + x)n − (1− x)n

2.

Proof.- (1 + x)n − (1− x)n = 2((n1

)x+

(n3

)x3 +

(n5

)x5 + · · ·

).

Some combinatorial identities we obtain from the binomial formula:

• x = 1:

– 2n =(n0

)+(n1

)+ · · ·+

(nn

).

– 0 =(n0

)−(n1

)+ · · ·+ (−1)n

(nn

), n ≥ 1.

Page 40: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

40 Combinatorial identities

– 2n−1 =(n0

)+(n2

)+(n4

)+ · · · .

– 2n−1 =(n1

)+(n3

)+(n5

)+ · · · .

• x = i:

(1 + i)n =n∑k=0

(n

k

)ik =

(n

0

)+

(n

1

)i+

(n

2

)i2 + · · ·+

(n

n

)in =

=

(n

0

)−(n

2

)+

(n

4

)−(n

6

)+ · · ·+ (−1)r

(n

2r

)+ · · ·+

+i

((n

1

)−(n

3

)+

(n

5

)−(n

7

)+ · · ·+ (−1)r

(n

2r + 1

)+ · · ·

)= A+Bi,

A =

(n

0

)−(n

2

)+

(n

4

)−(n

6

)+ · · · =

((n

0

)+

(n

4

)+ · · ·

)−((

n

2

)+

(n

6

)+ · · ·

),

B =

(n

1

)−(n

3

)+

(n

5

)−(n

7

)+ · · · =

((n

1

)+

(n

5

)+ · · ·

)−((

n

3

)+

(n

7

)+ · · ·

).

Put

S0 =

(n

0

)+

(n

4

)+ · · · ,

S2 =

(n

2

)+

(n

6

)+ · · · ,

S1 =

(n

1

)+

(n

5

)+ · · · ,

S3 =

(n

3

)+

(n

7

)+ · · · .

Notice that Sj is the number of subsets of 1, 2, . . . , n whose number of elements is≡ j ( (mod 4)), for j = 0, 1, 2, 3. Therefore,

(1 + i)n = (S0 − S2) + (S1 − S3)i.

We call rα = reiα = rcosα + ir sinα. With this notation 1 + i =√

2π4

=√

2eiπ4 and

(1 + i)n = (√

2)neinπ4 = 2

n2 cos nπ

4+ 2

n2 i sin nπ

4. Hence,

S0 − S2 = 2n2 cos

4,

S1 − S3 = 2n2 sin

4.

Moreover, we know that S0 + S2 = S1 + S3 = 2n−1. Thus,

S0 =2n−1 + 2

n2 cos nπ

4

2,

Page 41: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

2.2 Binomial formula 41

S1 =2n−1 + 2

n2 sin nπ

4

2,

S2 =2n−1 − 2

n2 cos nπ

4

2,

S3 =2n−1 − 2

n2 sin nπ

4

2.

• Deriving:

(1 + x)n =n∑k=0

(n

k

)xk ⇒ n(1 + x)n−1 =

n∑k=1

(n

k

)kxk−1, n ≥ 2.

For x = 1:

n2n−1 =n∑k=0

k

(n

k

), n ≥ 2.

For x = −1:

0 =n∑k=0

(−1)k−1k

(n

k

), n ≥ 2.

• Integrating:∫ t

0

(1 + x)ndx =n∑k=0

(n

k

)∫ t

0

xkdx⇒[

(1 + x)n+1

n+ 1

]t0

=n∑k=0

(n

k

)[xk+1

k + 1

]t0

(1 + t)n+1 − 1

n+ 1=

n∑k=0

(n

k

)tk+1

k + 1.

For t = 1:2n+1 − 1

n+ 1=

n∑k=0

1

k + 1

(n

k

).

For t = −1:1

n+ 1=

n∑k=0

(−1)k

k + 1

(n

k

).

Integrating again:∫ x

0

(1 + t)n+1 − 1

n+ 1dt =

n∑k=0

(n

k

)1

k + 1

∫ x

0

tk+1dt⇒

[(1 + t)n+2

(n+ 1)(n+ 2)− t

n+ 1

]x0

=n∑k=0

(n

k

)[tk+2

(k + 1)(k + 2)

]x0

Page 42: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

42 Combinatorial identities

(1 + x)n+2 − 1

(n+ 1)(n+ 2)− x

n+ 1=

n∑k=0

(n

k

)xk+2

(k + 1)(k + 2).

For x = 1:2n+2 − 1

(n+ 1)(n+ 2)− 1

n+ 1=

n∑k=0

(n

k

)1

(k + 1)(k + 2).

For x = −1:−1

(n+ 1)(n+ 2)+

1

n+ 1=

n∑k=0

(n

k

)(−1)k+2

(k + 1)(k + 2).

• Other operations:

(1 + x)n(1 + x)m = (1 + x)n+m is a polynomial identity, so both sides of the equalityhave the same coefficients. Therefore,

r∑i=0

(n

i

)(m

r − i

)=

(n+m

r

),

which is Vandermonde’s formula.

• A little bit more:

∂2

∂x∂y(x+ y)n = n(n− 1)(x+ y)n−2 =

n−1∑k=1

(n

k

)kxk−1(n− k)yn−k−1.

For x = y = 1:

n(n− 1)2n−2 =n∑k=0

k(n− k)

(n

k

).

2.3 Multinomial coefficients

2.3.1 Multinomial coefficients

Definition 2.3.1 Let n ∈ N∪0 and r1, r2, . . . , rm ∈ N∪0 such that r1+r2+· · ·+rm = n.(n

r1, r2, . . . , rm

)=

n!

r1!r2! · · · rm!

Example 2.3.2 (6

3, 2, 1

)=

6!

3!2!1!= 5 · 4 · 3 = 60.

Page 43: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

2.3 Multinomial coefficients 43

Proposition 2.3.3 1. (n

r1, r2

)=

(n

r1

)

2. (n

r1, r2, . . . , rm

)=

(n

r1

)(n− r1r2

)(n− r1 − r2

r3

)· · ·(n− r1 − · · · − rm−2

rm−1

)

Proof.- 2. (n

r1

)(n− r1r2

)(n− r1 − r2

r3

)· · ·(n− r1 − · · · − rm−2

rm−1

)=

=n!

r1!(n− r1)!(n− r1)!

r2!(n− r1 − r2)!(n− r1 − r2)!

r3!(n− r1 − r2 − r3)!· · · (n− r1 − · · · − rm−2)!

rm−1!rm!=

=n!

r1!r2! · · · rm!.

2.3.2 Combinatorial meaning

(n

r1,r2,...,rm

)= n!

r1!r2!···rm!is the number of sequences of length n that can be formed with r1

symbols α1,..., rm symbols αm, which is also the number of ways to place n distinguishableballs in m numbered boxes so that there are r1 balls in the first box, r2 in the second,..., andrm in the last one.

Strategy:

1) choose the places for the α1’s or choose the balls in the first box:(nr1

)2) choose the places for the α2’s or choose the balls in the second box:

(n−r1r2

)3) ...

4) choose the places for the αm−1’s or choose the balls in the penultimate box:(n−r1−···−rm−2

rm−1

)5) choose the places for the αm’s or choose the balls in the last box: 1

Page 44: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

44 Combinatorial identities

2.3.3 Multinomial formula

Theorem 2.3.4 Let x1, x2, . . . , xm ∈ C and n ≥ 0. Then,

(x1 + x2 + · · ·+ xm)n =∑

ri ∈ N ∪ 0r1 + r2 + · · ·+ rm = n

(n

r1, r2, . . . , rm

)xr11 x

r22 · · ·xrmm .

Proof.-

(x1+x2+· · ·+xm)n = (x1+x2+· · ·+xm) · · · (x1+x2+· · ·+xm) =m∑i1=1

m∑i2=1

· · ·m∑

in=1

xi1xi2 · · · xin =

=∑

( number of sequences xi1xi2 · · ·xin in which there are r1 symbols x1, . . . , rm symbols xm)xr11 xr22 · · ·xrmm =

=∑

ri ∈ N ∪ 0r1 + r2 + · · ·+ rm = n

(n

r1, r2, . . . , rm

)xr11 x

r22 · · ·xrmm .

2.3.4 Some applications

1.

mn =∑

ri ∈ N ∪ 0r1 + r2 + · · ·+ rm = n

(n

r1, r2, . . . , rm

).

Proof.- Multinomial formula when x1 = · · · = xm = 1.

2. ∑ri ∈ N ∪ 0

r1 + r2 + r3 + r4 = n

(−1)r3+r4(

n

r1, r2, r3, r4

)= 0, n ≥ 1

Proof.- By the multinomial formula when m = 4

(a+ b+ c+ d)n =∑

ri ∈ N ∪ 0r1 + r2 + r3 + r4 = n

(n

r1, r2, r3, r4

)ar1br2cr3dr4 .

Put a = b = 1, c = d = −1.

Page 45: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

2.4 Generalized binomial formula 45

3. If r1 + · · ·+ rm = n then r1! · · · rm! is a divisor of n!.

Proof.- Since(

nr1,...,rm

)is an integer, r1! · · · rm! is a divisor of n!.

4.[[(m− 1)!]!]m|[m!]!

Proof.- Put r1 = r2 = · · · = rm = (m− 1)! and n = r1 + · · ·+ rm = m(m− 1)! = m!.Thus r1! · · · rm! = [[(m− 1)!]!]m divides [m!]!

Definition 2.3.5

m!! =

m(m− 2)(m− 4) · · · 2 if m ≡ 0 (mod 2)m(m− 2)(m− 4) · · · 1 if m ≡ 1 (mod 2)

is called semifactorial of m.

2.4 Generalized binomial formula

Definition 2.4.1 Let α ∈ R, k ∈ N ∪ 0.(α

k

)=αk

k!=

1 k = 0

α(α−1)···(α−k+1)k!

k ≥ 1

Proposition 2.4.2 1. If α = n ∈ N ∪ 0 then(nk

)= Cn,k; otherwise, if α /∈ N ∪ 0

then(αk

)has no combinatorial meaning.

2. (α

k − 1

)+

k

)=

(α + 1

k

), α ∈ R, k ∈ N ∪ 0.

3. (−αk

)= (−1)k

(α + k − 1

k

)

Proof.- 2)(αk−1

)+(αk

)= αk−1

(k−1)!+αk

k!= αk−1

(k−1)!

[1 + α−k+1

k

]= αk−1

(k−1)!α+1k

= (α+1)α(α−1)···(α−k+2)k!

=(α+1)k

k!=(α+1k

).

3)(−αk

)= (−α)k

k!= (−1)k α

k

k!= (−1)k α(α+1)···(α+k−1)

k!= (−1)k (α+k−1)

k

k!= (−1)k

(α+k−1

k

).

Notice that Cn,k =(nk

)and CRn,k =

(n+k−1

k

)= (−1)k

(−nk

).

Recall now Taylor’s formula for a polynomial:

Page 46: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

46 Combinatorial identities

Theorem 2.4.3 Given a polynomial of degree at most n, p(x) = c0+c1x+c2x2+· · ·+cnxn =∑n

k=0 ckxk, it turns out that ck = p(k)(0)

k!, k = 0, . . . , n and p(x) =

∑nk=0

p(k)(0)k!

xk.

Proof.- Since p(x) =∑n

k=0 ckxk, p(0) = c0 and p(r)(x) =

∑nk=r k(k − 1) · · · (k − r +

1)ckxk−r =

∑nk=r k

rckxk−r for r = 1, . . . , n. Therefore, p(r)(0) = rrcr = r!cr and cr = p(r)(0)

r!.

Let’s apply this theorem to p(x) = (1 + x)n. Note that p(r)(x) = n(n − 1) · · · (n − r +

1)(1 + x)n−r = nr(1 + x)n−r. Thus, cr = p(r)(0)r!

= nr

r!=(nr

). Therefore,

(1 + x)n =n∑r=0

(n

r

)xr.

This is a new proof of Newton’s binomial formula. We are going to generalize this takingf(x) = (1 + x)α. Notice that

• If α = 1 then f(x) = 11+x

and Df = R− 1.

• If α = 12

then f(x) =√

1 + x and Df = [−1,+∞).

• If α = −12

then f(x) = 1√1+x

and Df = (−1,+∞).

What is the domain of f?

Lemma 2.4.4 Let f(x) = (1 + x)α. For every α ∈ R, (−1,+∞) ⊂ Df .

Proof.- Let x ∈ (−1,+∞). Thus, x + 1 > 0, x + 1 = eln(x+1) and (1 + x)α = eα ln(1+x)

exist and is finite. Therefore x ∈ Df .

Moreover, f(x) is derivable in (−1,+∞). It turns out that f (r) = αr(1 + x)α−r, which iscontinuous for x ∈ (−1,+∞), and f (r)(0) = αr. By Taylor-Maclaurin’s Theorem

f(x) =n∑k=0

f (k)(0)

k!xk +Rn(x) with lim

n→∞Rn(x) = 0 when |x| < 1.

Therefore, f(x) = limn→∞∑n

k=0f (k)(0)k!

xk =∑∞

k=0f (k)(0)k!

xk. In our case,

(1 + x)α =∞∑k=0

k

)xk for |x| < 1.

There are some especial cases:

Page 47: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

2.4 Generalized binomial formula 47

• α = n ∈ N ∪ 0(1 + x)n is a polynomial of degree n and the generalized binomial formula is alreadyknown since for k > n

(nk

)= 0.

• α = −1 if |x| < 1

Since (1+x)−1 =∑∞

k=0

(−1k

)xk for |x| < 1, 1

1+x=∑∞

k=0(−1)k(1+k−1k

)xk =

∑∞k=0(−1)kxk.

Thus,1

1 + x= 1− x+ x2 − x3 + x4 − · · ·

Consequently,1

1− x= 1 + x+ x2 + x3 + x4 + · · ·

1

1− x2= 1 + x2 + x4 + x6 + x8 + · · ·

1

1− xr= 1 + xr + x2r + x3r + x4r + · · ·

• α = −2, |x| < 1

(1 + x)−2 = 1(1+x)2

=∑∞

k=0

(−2k

)xk =

∑∞k=0(−1)k

(2+k−1k

)xk =

∑∞k=0(−1)k(k + 1)xk.

Thus,1

(1 + x)2= 1− 2x+ 3x2 − 4x3 + 5x4 − · · ·

Consequently,1

(1− x)2= 1 + 2x+ 3x2 + 4x3 + 5x4 + · · ·

1

(1− x)r= 1 + 2xr + 3x2r + 4x3r + 5x4r + · · ·

• α = −n, n ∈ N ∪ 0(1 + x)−n = 1

(1+x)n=∑∞

k=0

(−nk

)xk =

∑∞k=0(−1)k

(n+k−1

k

)xk =

∑∞k=0CRn,kx

k.

Notice that Cn,k is the coefficient of xk in the series (1 +x)n =∑∞

k=0Cn,kxk and CRn,k

is the coefficient of xk in the series (1− x)−n =∑∞

k=0CRn,kxk.

• α = −12

(1 + x)−12 = 1√

1+x=∑∞

k=0

(− 12k

)xk. Now,

(− 12k

)=

(− 12)k

k!= (−1)k

12( 12+1)( 1

2+2)···( 1

2+k−1)

k!=

(−1)k12

32

52··· 2k−1

2

k!= (−1)k 1·3·5·(2k−1)

2kk!=(−1

2

)k (2k−1)!!k!

= (−1)k 1·2·3···(2k−1)(2k)2kk!2·4·6···(2k) =

(−1)k (2k)!2kk!(2·1)(2·2)(2·3)···(2k) = (−1)k (2k)!

(2kk!)2=(−1

4

)k (2k)!k!k!

=(−1

4

)k (2kk

). Thus,

(1 + x)−12 =

1√1 + x

=∞∑k=0

(2k

k

)(−x

4

)k.

Page 48: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

48 Combinatorial identities

Some applications of the generalized binomial formula are:

• Since for α, β ∈ R and |x| < 1, (1 + x)α(1 + x)β = (1 + x)α+β then[(α

0

)+

1

)x+

2

)x2 + · · ·

] [(β

0

)+

1

)x+

2

)x2 + · · ·

]=

[(α + β

0

)+

(α + β

1

)x+

(α + β

2

)x2 + · · ·

].

The coefficients of xr on the left and right hand sides must be equal. Therefore,(α0

)(βr

)+(α1

)(βr−1

)+ · · ·+

(αr

)(β0

)=(α+βr

)and(

α + β

r

)=

r∑k=0

k

)(β

r − k

)which is the generalized Vandermonde formula.

• Since for α ∈ R and |x| < 1, (1 + x)α(1− x)α = (1− x2)α then[(α

0

)+

1

)x+

2

)x2 + · · ·

] [(α

0

)−(α

1

)x+

2

)x2 − · · ·

]=

[(α

0

)−(α

1

)x2 +

2

)x4 − · · ·

].

Therefore,(α0

)(−1)r

(αr

)+(α1

)(−1)r−1

(αr−1

)+· · ·+

(αr

)(α0

)=

0 r ≡ 1 (mod 2)

(−1)r2

(αr2

)r ≡ 0 (mod 2)

Thus,r∑

k=0

(−1)r−k(α

k

)(α

r − k

)=

0 r ≡ 1 (mod 2)

(−1)r2

(αr2

)r ≡ 0 (mod 2) .

Page 49: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

Chapter 3

Generating functions and recurrencerelations

3.1 Generating functions

3.1.1 Power series

Theorem 3.1.1 (Convergence)

Let (an)n≥0 be a sequence of real or complex numbers,∑∞

n=0 anxn a power series and

ρ = 1

limn sup n√|an|

. Then,

• If ρ = 0 the series converges only for x = 0.

• If ρ > 0:

– For |x| < ρ the series is absolutely convergent.

– For |x| > ρ the series diverges.

– For |x| = ρ nothing can be said (there are cases in which converges and cases inwhich it doesn’t).

Page 50: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

50 Generating functions and recurrence relations

ρ is called the radius of convergence of the series.

Let r = (rn)n≥0 be a sequence of real numbers and Sr = collection of subsequences of rwith limit (finite or infinite). Let L = collection of the limits of the subsequences in Sr. Itturns out that limn sup rn = maxL and limn inf rn = minL.

Example 3.1.2 r ≡ 0, 1, 0, 1, . . ., rn =

0 if n even1 if n odd

L = 0, 1 and limn sup rn = 1, limn inf rn = 0.

Proposition 3.1.3 • Assume that r = (rn)n≥0 has limit, l = limn rn. Then everysubsequence has limit l. Therefore L = l and limn sup rn = l, limn inf rn = l.

• limn inf(−rn) = limn sup rn and limn sup(−rn) = limn inf rn.

• If rn ≤ r′n for all n then limn inf rn ≤ limn inf r′n and limn sup rn ≤ limn sup r′n.

• If limn | anan−1| = l then lim n

√|an| = l.

Example 3.1.4 Let an = αn, n = 0, 1, 2, . . . , α ∈ C. Let∑∞

n=0(αx)n. ρ = 1

limn sup n√|αn|

=

1limn sup |α| = 1

|α| .

• ¡2-¿ If α = 1 then an = 1 for all n and the series is 1 + x + x2 + · · · which is thegeometric series of ratio 1 (ρ = 1).

• ¡3-¿ If α = 0 then the series is 1 + 0x + 0x2 + · · · = 1, which converges for all x(ρ = 1

0=∞).

Example 3.1.5 Let an =(αn

), n = 0, 1, 2, . . ., α ∈ R. Notice that

∣∣∣ anan−1

∣∣∣ =

∣∣∣∣ (αn)( αn−1)

∣∣∣∣ = |α−n+1|n

.

limn

∣∣∣ anan−1

∣∣∣ = limn|α−n+1|

n= 1 and, therefore, limn

n√|an| = 1. Thus, limn sup n

√|an| = 1 and

ρ = 1. Hence,

∑∞n=0

(αn

)xn converges for |x| < 1.

Furthermore, if α is a positive integer, α = m:(m0

),(m1

), . . . ,

(mm

), 0, 0, . . .. limn

n√|an| = 0

and ρ =∞.

∑mn=0

(mn

)xn converges for all x.

Page 51: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

3.1 Generating functions 51

3.1.2 Generating function of a sequence of numbers

Definition 3.1.6 Let a ≡ (ak)k≥0 ≡ (a0, a1, a − 2, . . .) be a sequence of real (complex)numbers. The generating function of a is

ga(x) =∞∑k=0

akxk = a0 + a1x+ a2x

2 + · · ·

in the real (complex) x in which the series converges.

3.1.3 Examples (direct problems)

Example 3.1.7

a ≡ (Cn,k)k≥0 ≡ (Cn,0, Cn,1, Cn,2, . . . , Cn,n, Cn,n+1, Cn,n+2, . . .) ≡

≡((

n

0

),

(n

1

),

(n

2

), . . . ,

(n

n

),

(n

n+ 1

),

(n

n+ 2

), . . .

).

The generating function is

ga(x) =∞∑k=0

Cn,kxk =

n∑k=0

Cn,kxk =

n∑k=0

(n

k

)xk = (1 + x)k, x ∈ R.

Example 3.1.8a ≡ (CRn,k)k≥0.

ga(x) =∞∑k=0

CRn,kxk =

∞∑k=0

(−1)k(−nk

)xk = (1− x)−n, |x| < 1.

Example 3.1.9

a ≡((

α

k

))k≥0

.

ga(x) =∞∑k=0

k

)xk = (1 + x)α, |x| < 1.

Example 3.1.10a ≡ 1, 1, 1, . . .⇒ an = 1 ∀n.

ga(x) =∞∑k=0

xk = 1 + x+ x2 + · · · = 1

1− x, |x| < 1.

Page 52: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

52 Generating functions and recurrence relations

Example 3.1.11

a ≡ 1, 0, 1, 0, 1, 0, . . .⇒ an =

1 n ≡ 0 (mod 2)0 n ≡ 1 (mod 2)

⇒ an =(−1)n + 1

2

ga(x) = 1 + x2 + x4 + · · · = 1

1− x2, |x2| < 1 (⇔ |x| < 1).

Example 3.1.12

a ≡ 1, 0, 0, 1, 0, 0, 1, 0, 0, . . .⇒ an =

1 n ≡ 0 (mod 3)0 otherwise

ga(x) = 1 + x3 + x6 + · · · = 1

1− x3, |x3| < 1 (⇔ |x| < 1).

Example 3.1.13

a ≡ 1, 5, 52, 53, 54, . . .⇒ an = 5n = V R5,n.

ga(x) = 1+5x+52x2+53x3+· · · = 1+5x+(5x)2+(5x)3+· · · = 1

1− 5x, |5x| < 1

(⇔ |x| < 1

5

).

Example 3.1.14

a ≡ 1, r, r2, r3, r4, . . .⇒ an = rn = V Rr,n, r 6= 0.

ga(x) = 1+rx+r2x2+r3x3+· · · = 1+rx+(rx)2+(rx)3+· · · = 1

1− rx, |rx| < 1

(⇔ |x| < 1

r

).

Example 3.1.15

a ≡ a0, a1, . . . , an, 0, 0, . . . .

ga(x) = a0+a1x+a2x2+· · ·+anxn+0xn+1+0xn+2+· · · = a0+a1x+a2x

2+· · ·+anxn, ∀x ∈ R.

Example 3.1.16

a ≡ 1

0!,

1

1!,

1

2!,

1

3!, . . .⇒ an =

1

n!.

ga(x) =1

0!+

1

1!x+

1

2!x2 +

1

3!x3 + · · · = ex, ∀x ∈ R.

Page 53: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

3.1 Generating functions 53

3.1.4 Examples (inverse problems)

Example 3.1.17

ga(x) = (1 + xm)α, |x| < 1.

ga(x) = (1 + xm)α =

0

)+

1

)xm +

2

)x2m +

3

)x3m + · · · .

Thus,

an =

(αnm

)n ≡ 0 (mod m)

0 otherwise

Example 3.1.18

ga(x) = e−x2

=∞∑k=0

(−x2)k

k!= 1− 1

1!x2 +

1

2!x4 − 1

3!x6 + · · · .

Thus,

an =

(−1)

n2

1(n2)!

n ≡ 0 (mod 2)

0 otherwise

Faltan ejemplos.....

3.1.5 Operations with generating functions

Proposition 3.1.19 1. gca(x) = cga(x), ca = (ca0, ca1, . . .).

2. ga+b(x) = ga(x) + gb(x).

3. ga(x)gb(x) = gc(x), ck = a0bk + a1bk−1 + · · ·+ akb0, k = 0, 1, 2, . . ..

Proof.- 1. gca(x) =∑∞

k=0(cak)xk = c

∑∞k=0 akx

k = cga(x).

2. ga(x) + gb(x) =∑∞

k=0 akxk +

∑∞k=0 bkx

k =∑∞

k=0(ak + bk)xk = ga+b(x).

Definition 3.1.20 In the last item of the previous proposition c is the convolution of a andb, which is written c = a ∗ b.

Page 54: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

54 Generating functions and recurrence relations

Example 3.1.21 Let a ≡ (ak)k≥0 with generating function ga(x) defined for |x| < ρ. Letck = a0 + a1 + · · · + ak, k = 0, 1, 2, . . .. Then, c = a ∗ b with b ≡ (1, 1, 1, . . .). Thus,

gc(x) = ga(x)gb(x) = ga(x)(1 + x+ x2 + · · · ) = ga(x)1−x .

Example 3.1.22 Let dk = 2ka0 + 2k−1a1 + · · · + 20ak, k = 0, 1, 2, . . .. Let d = a ∗ b′ withb′ = (20, 21, 22, . . .). Thus, gb′(x) = 1 + 2x+ (2x)2 + · · · = (1− 2x)−1 and gd(x) = ga(x)

1−2x .

Example 3.1.23 Let rk =(α0

)+(α1

)+ · · ·+

(αk

). This is a particular case of Example 3.1.21

when ak =(αk

). Hence, gr(x) = ga(x)

1−x = (1+x)α

1−x .

Example 3.1.24 (Derivatives) Let ρ > 0 and ga(x) =∑∞

k=0 akxk, |x| < ρ (radius of con-

vergence). Then ga is indefinitely derivable in the interval of convergence and g′a(x) =∑∞k=1 kakx

k−1, g′′a(x) =

∑∞k=2 k(k − 1)akx

k−2,..., g(r)a (x) =

∑∞k=r k

rakxk−r. Taking x = 0,

g(r)a (0) = rrar and ar = g

(r)a (0)r!

.

Remark 3.1.25 If ga is the generating function of a ≡ (a0, a1, a2, . . .) then

g(r)a (x) = rrar + (r + 1)rar+1x+ (r + 2)rar+2x2 + · · ·

is the generating function of a(r) ≡ (a(r)0 , a

(r)1 , . . .) with a

(r)k = (r + k)rar+k.

3.2 Generating functions and combinatorial problems

3.2.1 Number of solutions of an equation

Theorem 3.2.1 Let B = b1, b2, . . . ⊆ N ∪ 0 = Z+, C = c1, c2, . . . ⊆ N ∪ 0 =Z+, . . . , H = h1, h2, . . . ⊆ N∪0 = Z+ be k subsets of N∪0 = Z+. Let an = number ofsolutions of x1 + x2 + · · · + xk = n where x1 ∈ B, x2 ∈ C, . . . , xk ∈ H. Then the generatingfunction of (an)n≥0 is

ga(x) =∞∑n=0

anxn = (xb1 + xb2 + · · · )(xc1 + xc2 + · · · ) · · · (xh1 + xh2 + · · · ).

Proof.-

(xb1+xb2+· · · )(xc1+xc2+· · · ) · · · (xh1+xh2+· · · ) =∑r1∈B

∑r2∈C

· · ·∑rk∈H

xr1xr2 · · ·xrk =∞∑n=0

anxn.

Page 55: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

3.2 Generating functions and combinatorial problems 55

Remark 3.2.2 If |x| < 1

|x|b1 + |x|b2 + · · · ≤ 1 + |x|+ |x|2 + · · ·+ |x|b1 + |x|b1+1 + · · ·+ |x|b2 + |x|b2+1 + · · · = 1

1− |x|.

Hence, |x|b1 + |x|b2 + · · · is absolutely convergent. In the same way, |x|c1 + |x|c2 + · · · and|x|h1 + |x|h2 + · · · are absolutely convergent. Thus, ga is well defined for |x| < 1.

3.2.2 Applications and examples

Example 3.2.3 Let an = number of solutions of x1+· · ·+xk = n where x1 ∈ 0, 1, 2, . . ., . . . , xk ∈0, 1, 2, . . .. The generating function of a ≡ (an)n≥0 is

ga(x) = (x0+x1+x2+ · · · )(x0+x1+x2+ · · · ) · · · (x0+x1+x2+ · · · ) = (x0+x1+x2+ · · · )k =

=

(1

1− x

)k= (1− x)k =

∞∑n=0

(−1)n(−kn

)xn.

Thus,

an = (−1)n(−kn

)= (−1)n(−1)n

(k + n− 1

n

)=

(k + n− 1

n

).

Example 3.2.4 Let an = number of ways of gathering n euros with coins or bills of 1 euro,2 euros and 5 euros. Put x1 = number of coins of 1 euro, x2 = number of coins of 2 euros andx3 = number of bills of 5 euros. Then an = number of solutions of x1 + 2x2 + 5x3 = n wherex1, x2, x3 ∈ N ∪ 0 = number of solutions of y1 + y2 + y3 = n where y1 ∈ 0, 1, 2, . . ., y2 ∈0, 2, 4, . . ., y3 ∈ 0, 5, 10, . . .. The generating function of (an)n≥0 is

ga(x) = (x0+x1+x2+· · · )(x0+x2+x4+· · · ) · · · (x0+x5+x10+· · · ) =1

1− x1

1− x2· · · 1

1− x5=

=1

(1 + x)(1− x)2(1− x5)=

A

1 + x+

B

1− x+

C

(1− x)2+Dx4 + Ex3 + Fx2 +Gx+H

1− x5.

Now it can be worked out in order to obtain an.

Example 3.2.5 A die is rolled 10 times. Determine the probability the outcome is 30points.

Let xi be the outcome in the i-th time, 1 ≤ i ≤ 10.

Possible outcomes: (x1, . . . , x10) where xi ∈ 1, . . . , 6, 1 ≤ i ≤ 6. There are 610.

Page 56: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

56 Generating functions and recurrence relations

Favorable outcomes: (x1, . . . , x10) where x1 + · · ·+ x10 = 30.

Set a30 = number of favorable outcomes=number of solutions of x1 + · · · + x10 = 30where xi ∈ 1, . . . , 6, 1 ≤ i ≤ 6.

ga(x) = (x1+x2+· · ·+x6)(10)· · · (x1+x2+· · ·+x6) = (x1+x2+· · ·+x6)10 = x10(1+x+· · ·+x5)10.

a30 is the coefficient of x30 in ga(x), that is, the coefficient of x20 in (1 + x+ · · ·+ x5)10. Let

S = 1 + x+ · · ·+ x5. Then (1− x)S = 1− x6 and S =

1−x61−x x 6= 1

6 x = 1. Thus,

(1 + x+ · · ·+ x5)10 =

(1− x6

1− x

)10

= (1− x6)10(1− x)−10 =

=

(1∑

k=0

0

(10

k

)(−1)kx6k

)(∞∑l=0

(−10

l

)(−1)lxl

).

a30 =

(10

0

)(−1)0

(−10

20

)(−1)20 +

(10

1

)(−1)1

(−10

14

)(−1)14 +

(10

2

)(−1)2

(−10

8

)(−1)8+

+

(10

3

)(−1)3

(−10

2

)(−1)2 =

(10

0

)(29

20

)−(

10

1

)(23

14

)+

(10

2

)(17

8

)−(

10

3

)(11

2

)= 2930455.

Example 3.2.6 In how many ways can a student get a total of 18 points with 6 tasks wherestudents are awarded 0, 2 or 4 points for each task?

Let Ti be the task i, let xi be the score obtained in Ti and an the number of solutionsof x1 + · · · + x6 = n where xi ∈ 0, 2, 4, 1 ≤ i ≤ 6. We want to find a18. The generatingfunction of (an)n≥0 is

ga(x) = (x0 + x2 + x4)(6)· · · (x0 + x2 + x4) = (1 + x2 + x4)6.

Three ways of finding a18:

• (1+x2+x4)6 =(

1−x61−x2

)6= (1−x6)6(1−x2)−6 and going on as in the previous example.

• (1 + x2 + x4)6 =∑

r1+r2+r3=6

(6

r1,r2,r3

)1r1x2r2x4r3 =

∑r1+r2+r3=6

(6

r1,r2,r3

)x2r2+4r3 . Thus

a18 =(

61,1,4

)+(

60,3,3

)= 6!

4!+ 6!

3!3!= 5 · 6 + 5 · 4 = 30 + 20 = 50.

• (1 + x2 + x4)6 = (1 + x2(1 + x2))6 =∑6

k=0

(6k

)(x2(1 + x2))k =

∑6k=0

(6k

)x2k(1 + x2)k =∑6

k=0

(6k

)x2k(∑k

l=0

(kl

)x2l)

=∑6

k=0

∑kl=0

(6k

)(kl

)x2(k+l). Hence, a18 =

(66

)(63

)+(65

)(54

)=

6!3!3!

+ 6·5!4!

= 5 · 4 + 6 · 5 = 20 + 30 = 50.

Page 57: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

3.3 Recurrence relations 57

3.3 Recurrence relations

3.3.1 Combinatorial problems and recurrence relations. Examples

Example 3.3.1 Let an = number of subsets of 1, 2, . . . , n.

a0 = 1, an = 2an−1, n ≥ 1.

Example 3.3.2 Let an = number of sequences of length n formed with 0s and 1s wherethere are not two consecutive 0s.

a0 = 1, a1 = 2, an = an−1 + an−2, n ≥ 2.

Example 3.3.3 Let an = number of ways of tiling an n× 2 floor with 1× 2 and 2× 2 tiles.

a0 = 1, a1 = 1, an = an−1 + 2an−2, n ≥ 2.

Example 3.3.4 Let an = number of subsets of 1, 2, . . . , n in which there are not twoconsecutive integers.

a0 = 1, a1 = 2, an = an−1 + an−2, n ≥ 2.

Example 3.3.5 Let an = number of ways of climbing a stair of n steps if in each move weclimb 1 or 2 steps.

a0 = 1, a1 = 1, an = an−1 + an−2, n ≥ 2.

Example 3.3.6 (Tower of Brahma or Tower of Hanoi) The Tower of Hanoi (also called theTower of Brahma or Lucas’ Tower) is a mathematical game or puzzle. It consists of threerods, and a number of disks of different sizes which can slide onto any rod. The puzzle startswith the disks in a neat stack in ascending order of size on one rod, the smallest at thetop, thus making a conical shape. The objective of the puzzle is to move the entire stack toanother rod, obeying the following rules:

• Only one disk may be moved at a time.

• Each move consists of taking the upper disk from one of the rods and sliding it ontoanother rod, on top of the other disks that may already be present on that rod.

Page 58: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

58 Generating functions and recurrence relations

• No disk may be placed on top of a smaller disk.

Let an = the minimum number of moves to solve the problem when there are n disks.

a1 = 1, an = 2an−1 + 1, n ≥ 2.

Example 3.3.7 Let an = number of regions in the plane that are determined by n linesthat are concurrent in pairs but there are not three that intersect at a single point.

a0 = 1, a1 = 2, a2 = 4, an = an−1 + n, n ≥ 3.

Example 3.3.8 Let Tn = number of points that are necessary to build a triangle of n rowsas the following:

• T1 = 1• • T2 = 3

• • • T3 = 6• • • • T4 = 10

• • • • • T5 = 15• • • • • • T6 = 21

T0 = 0, Tn = Tn−1 + n, n ≥ 1.

Example 3.3.9 Let an = number of maps f : 1, . . . , n → 1, . . . , n such that f f =identity.

Notice that:

• f(1) = 1, there are an−1

• f(1) = 2⇒ f(2) = 1, there are an−2

• ...

• f(1) = n⇒ f(n) = 1, there are an−2

Therefore, a1 = 1, a2 = 2, an = an−1 + (n− 1)an−2, n ≥ 2.

When we have a recurrence relation and enough initial values we can virtually get anyterm an of the sequence. But, can we give an explicit formula for an in terms of n?

Page 59: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

3.3 Recurrence relations 59

Example 3.3.10 Related to Example 3.3.8, we saw that T0 = 0, Tn = Tn−1 + n, n ≥ 1.Therefore, T0 = 0, T1 = 0 + 1 = 1, T2 = 0 + 1 + 2 = 3, T3 = 0 + 1 + 2 + 3 = 6,T4 = 0 + 1 + 2 + 3 + 4 = 10,.... Thus, Tn = 0 + 1 + 2 + · · ·+ (n− 1) + n. Since this can be

written also as Tn = n+ (n− 1) + (n− 2) + · · ·+ 1 + 0, 2Tn = n(n+ 1) and Tn = n(n+1)2

.

Example 3.3.11 Suppose we are given the following recurrence relation a0 = a, an =αan−1 + β, n ≥ 1.

• If α = 1 then an = an−1+β, n ≥ 1 is an arithmetic progression with common differenceβ.

• If β = 0 then an = αan−1 is a geometric progression with common ratio α.

a0 = a,

a1 = αa+ β,

a2 = α(αa+ β) + β = α2a+ β(1 + α),

a3 = α(α2a+ β(1 + α)) + β = α3a+ β(1 + α + α2).

By induction on n, an = αn + β(1 + α + α2 + · · ·+ αn−1) =

αn + β 1−αn

1−α α 6= 1

a+ nβ α = 1.

Example 3.3.12 Let a0 = a, a1 = b, an = αan−1 + βan−2, n ≥ 2, α, β constants and β 6= 0.

a2 = αa1 + βa0 = αb+ βa,

a3 = αa2 + βa1 = α(αb+ βa) + βb = b(α2 + β) + αβa,

a4 = αa3 + βa2 = α(b(α2 + β) + αβa) + β(αb+ βa) = b(α3 + 2βα) + a(α2β + β2).

It is not as simple as the previous example. We have to find another method.

3.3.2 Generating functions and recurrence relations

The method is, given the recurrence relation find the generating function in order to obtainan. We see it with some examples:

Page 60: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

60 Generating functions and recurrence relations

Example 3.3.13 Let a0 = a, an = αan−1+β, n ≥ 1. Let g(x) = a0+a1x+a2x2+a3x

3+ · · ·be the generating function of (an)n≥0. Suppose |x| < 1.

g(x) = a0 + (αa0 + β)x+ (αa1 + β)x2 + (αa2 + β)x3 + · · · =

= a0 + αx(a0 + a1x+ a2x2 + · · · ) + βx(1 + x+ x2 + · · · ) = a0 + αxg(x) + βx

1

1− x.

Thus,

g(x) =a0 + β x

1−x

1− αx=

a

1− αx+

βx

(1− x)(1− αx).

If α = 1, βx(1−x)2 = βx(1 − x)−2 = βx

∑∞k=0

(−2k

)(−1)kxk =

∑∞k=0(k + 1)βxk+1 =∑∞

k=0 kβxk. Moreover, a

1−x = a∑∞

k=0 xk. Thus, g(x) =

∑∞k=0(a + kβ)xk. Therefore,

an = a+ nβ, n ≥ 0.

If α 6= 1, βx(1−x)(1−αx) = A

1−x + B1−αx . Thus, βx = A(1 − αx) + B(1 − x). For x = 1,

β = A(1−α) and A = β1−α . For x = 1

α, βα

= B(1− 1α

). Thus, B =βα

1− 1α

= − β1−α . On the other

hand, βx(1−x)(1−αx) = A

1−x + B1−αx = A

∑∞k=0 x

k+B∑∞

k=0 αkxk =

∑∞k=0(A+Bαk)xk. Moreover,

a1−αx =

∑∞k=0 aα

kxk. Hence, g(x) =∑∞

k=0(A + (B + a)αk)xk and an = A + (B + a)αn =β

1−α + (− β1−α + a)αn = aαn + β(1−αn)

1−α .

Example 3.3.14 Let a0 = a, a1 = b, an = αan−1 + βan−2, n ≥ 2, α, β constants and β 6= 0.Let g(x) = a0 +a1x+a2x

2 +a3x3 + · · · be the generating function of (an)n≥0, x ∈ Dg. Thus,

g(x) = a0 + a1x+ (αa1 + βa0)x2 + (αa2 + βa1)x

3 + · · · =

= a0 +a1x+αx(a1x+a2x2 + · · · )+βx2(a0 +a1x+ · · · ) = a0 +a1x+αx(g(x)−a0)+βx2g(x).

Thus,

g(x) =a0 + (a1 − αa0)x

1− αx− βx2.

If α = 1, β = 2, a0 = 1, a1 = 1 then an = an−1 + 2an−2 = number of ways to tile an n × 2floor with 1× 2 and 2× 2 tiles. The generating function is

g(x) =1

1− x+ 2x2=

1

(1 + x)(1− 2x)=

A

1 + x+

B

1− 2x= A

∞∑k=0

(−1)kxk +B∞∑k=0

2kxk =

=∞∑k=0

(A(−1)k +B2k)xk.

Page 61: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

3.3 Recurrence relations 61

On the one hand, 1 = A(1−2x)+B(1+x) so 1 = 3B2

and B = 23, and 1 = 3A, A = 1

3. Thus,

g(x) =∞∑k=0

1

3((−1)k + 2k+1)xk.

Thus, an = (−1)n+2n+1

3.

Example 3.3.15 a0 = a, a1 = b, a2 = c, an = αan−1 +βan−2 +γan−3, n ≥ 3, α, β, γ ∈ Z, γ 6=0.

g(x) = a0+a1x+a2x2+· · · = a0+a1x+a2x

2+(αa2+βa1+γa0)x3+(αa3+βa2+γa1)x

4+· · · =

= a0 + a1x+ a2x2 + αa2x

3 + αa3x4 + · · ·+ βa1x

3 + βa2x4 + · · ·+ γa0x

3 + γa1x4 + · · · =

= a0 + a1x+ a2x2 + αx(g(x)− a0 − a1x) + βx2(g(x)− a0) + γx3g(x).

Thus,

g(x) =a0 + a1x+ a2x

2 + αx(−a0 − a1x) + βx2(−a0)1− αx− βx2 − γx3

=a+ (b− αa)x+ (c− bα− aβ)x2

1− αx− βx2 − γx3.

Example 3.3.16 a0 = a, a1 = b, an = αan−1 + βan−2 + γ, n ≥ 2.

g(x) = a0 + a1x+ a2x2 + · · · = a0 + a1x+ (αa1 + βa0 + γ)x2 + (αa2 + βa1 + γ)x3 + · · · =

= a0 + a1x+ αx(a1x+ a2x2 + · · · ) + βx2(a0 + a1x+ · · · ) + γx2(1 + x+ · · · ) =

= a0 + a1x+ αx(g(x)− a0) + βx2g(x) + γx21

1− x.

Thus,

g(x) =a0 + (a1 − αa0)x+ γ x2

1−x

1− αx− βx2.

If γ = (γn)n≥0 then

g(x) =a0 + (a1 − αa0)x+ x2gγ(x)

1− αx− βx2.

3.3.3 Other methods (algebraic method)

Let a0 = a, a1 = b, an = αan−1 + βan−2, n ≥ 2.

• S = (xn)n≥0 : xn = αxn−1 + βxn−2∀n ≥ 2. S is a vector space over C.

Page 62: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

62 Generating functions and recurrence relations

• e1 = (1, 0, 0, . . .) ∈ S, e2 = (0, 1, 0, . . .) ∈ S. It turns out that e1, e2 is a basis for S.Therefore, dimS = 2. Now we look for bases of S with known general term.

• Recurrence characteristic equation: x2 = αx + β or x2 − αx − β = 0. If r is a rootof this equation then the progression (rn)n≥0 ∈ S, because rn − αrn−1 − βrn−2 =rn−2(r2 − αr − β) = rn−2 · 0 = 0.

• 1. If the characteristic equation has two different roots r1 and r2, that is, α2+4β 6= 0,then (rn1 )n≥0, (r

n2 )n≥0 ∈ S and it is easy to see that they are linearly independent.

Thus, they form a basis of S. Therefore, any sequence of S can be uniquely formedas a linear combination of them. We get an = λrn1 + µrn2 such that a = λ+ µ andb = λr1 + µr2.

2. If the characteristic equation has a double root r = α2

then it is easy to see that(nrn)n≥0 ∈ S and that it is linearly independent of (rn)n≥0. Therefore they forma basis for S. Thus, an = λrn + µnrn such that a = λ and b = λr + µr.

Example 3.3.17 a0 = 0, a1 = 1, an = an−1 + an−2, n ≥ 2.

The characteristic equation is x2 − x − 1 = 0. The roots are x1 = 1+√5

2and x2 = 1−

√5

2.

Thus, an = λx − 1 + µx2 with 0 = λ + µ and 1 = λx1 + µx2. Working it out λ = 1√5

and

µ = − 1√5. Hence, an = 1√

5

(1+√5

2

)n− 1√

5

(1−√5

2

)n.

Page 63: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

Chapter 4

Main families of numbers

4.1 Fibonacci numbers

Suppose that we have a rabbit. Every year, except for the first one, each rabbit gives birthto a new rabbit. We call the number of rabbits alive at year n, Fn. Thus,

F0 = 0F1 = 1 R1

F2 = 1 R1

F3 = 2 R1, R11

F4 = 3 R1, R12, R11

F5 = 5 R1, R13, R12, R11, R111

F6 = 8 R1, R14, R13, R12, R121, R11, R112, R111

Fn is formed by starting with the Fn−1 rabbits alive last year and adding the babies thatcan only come from the Fn−2 rabbits alive two years ago. Hence,

F0 = 0, F1 = 1, Fn = Fn−1 + Fn−2, n ≥ 2.

The generating function is

F (x) =x

1− x− x2.

Page 64: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

64

The explicit expression for Fn is

Fn =1√5

[(1 +√

5

2

)n

(1−√

5

2

)n].

Some properties:

• Partial sums

1.

F0 + F1 + · · ·+ Fn = Fn+2 − 1, n ≥ 0

Proof.- By induction on n: It is true for n = 0. Assume that it is verified forn− 1.

F0 + F1 + · · ·+ Fn−1 + Fn = Fn+1 − 1 + Fn = Fn+2 − 1.

Another proof.- Fn+2 = Fn+1 +Fn ⇒ Fn = Fn+2− Fn+1. Thus, F0 +F1 +F2 +· · ·+Fn = F2−F1 +F3−F2 +F4−F3 + · · ·+Fn+2−Fn+1 = Fn+2−F1 = Fn+2−1.

2.

(n+ 1)F0 + nF1 + · · ·+ 2Fn−1 + Fn = Fn+4 − (n+ 3)

Proof.- We know that F0 = F2 − 1, F0 + F1 = F3 − 1, F0 + F1 + F2 = F4 −1,..., F0 + F1 + · · · + Fn = Fn+2 − 1. Summing these n + 1 expressions we get(n + 1)F0 + nF1 + · · · + 2Fn−1 + Fn = F2 + F3 + F4 + · · · + Fn+2 − (n − 1) =Fn+4 − 1− F0 − F1 − (n− 1) = Fn+4 − 1− 0− 1− (n− 1) = Fn+4 − (n− 3).

3.

F0 + F2 + · · ·+ F2n = F2n+1 − 1

Proof.- By induction on n: It is true for n = 0. Assuming the result true forn− 1, F0 + F2 + · · ·+ F2n = F2(n−1)+1 − 1 + F2n = F2n−1 + F2n − 1 = F2n+1 − 1.

Another proof.- Fn+2 = Fn+1 +Fn ⇒ Fn+1 = Fn+2−Fn. Thus, F0 +F2 + · · ·+F2n = F0 − 1 + F3 − F0 + F5 − F3 + · · ·+ F2n+1 − F2n−1 = F2n+1 − 1.

4.

F1 + F3 + · · ·+ F2n−1 = F2n

Proof.- F1+F3+· · ·+F2n−1 = (F0+F1+F2+· · ·+F2n)−(F0+F2+F4+· · ·+F2n) =(F2n+2 − 1)− (F2n+1 − 1) = F2n.

5.n∑k=0

(n+ 1− k)F2k = F2n+2 − (n+ 1)

Page 65: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

4.2 Catalan numbers 65

Proof.- We know that F0 = F1 − 1, F0 + F2 = F3 − 1, F0 + F2 + F4 = F5 − 1,...,F0 + F2 + F4 + · · · + F2n = F2n+1 − 1. Summing these n + 1 expressions we get(n+ 1)F0 + nF2 + (n− 1)F4 + · · ·+ F2n = F1 + F3 + F5 + · · ·+ F2n+1− (n+ 1) =F2n+2 − (n+ 1).

• Products, divisibility, ...

1.

Fn+m = Fm · Fn+1 + Fm−1 · Fn, n ≥ 0,m ≥ 1

Proof.- By induction on m, for m = 1, F1 ·Fn+1 +F0 ·Fn = Fn+1. So it is true forall n ≥ 0. For m = 2, F2·Fn+1+F1·Fn = Fn+1+Fn = Fn+2 for all n ≥ 0. Assumingthe result true for m−2 and m−1, that is, Fn+m−2 = Fm−2 ·Fn+1 +Fm−3 ·Fn truefor all n ≥ 0 and Fn+m−1 = Fm−1 ·Fn+1+Fm−2 ·Fn true for all n ≥ 0, we show thatFn+m = Fn+m−1 +Fn+m−2 = Fm−1 ·Fn+1 +Fm−2 ·Fn +Fm−2 ·Fn+1 +Fm−3 ·Fn =Fn+1(Fm−1 + Fm−2) + Fn(Fm−3 + Fm−2) = Fn+1 · Fm + Fn · Fm−1 for all n ≥ 0.

2.

Fkn is a multiple of Fn, k ≥ 1

Proof.- By induction on k, it is true for k = 1. Fkn = Fn+(k−1)n = F(k−1)n ·Fn+1+F(k−1)n−1 · Fn. By induction hypothesis F(k−1)n is a multiple of Fn, so is Fkn.

3.

F2n+1 = F 2n+1 + F 2

n

Proof.- F2n+1 = Fn+1 · Fn+1 + Fn · Fn.

4.2 Catalan numbers

Catalan numbers are

Cn =1

n+ 1

(2n

n

), n = 0, 1, 2, 3, . . . .

Thus,

C0 = 11

(00

)= 1,

C1 = 12

(21

)= 2

2= 1,

C2 = 13

(42

)= 6

3= 2,

C3 = 14

(63

)= 6·5·4

3!·4 = 5, ...

Page 66: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

66

Recall Θ(p,q)(0,0)= set of U-D trajectories from (0, 0) to (p, q), with p, q ∈ N. If p ≥ q ≥ 0

and p and q have the same parity then an U-D trajectory from (0, 0) to (p, q) can be seen

as a sequence formed by p+q2

zeros and p−q2

ones. Therefore, |Θ(p,q)(0,0)| =

( pp+q2

). In particular,

if q = 0 and p = 2n, |Θ(2n,0)(0,0) | =

(2nn

).

We call Θn = Θ(2n,0)(0,0) , Θ∗n = set of “super” U-D trajectories, that is, set of U-D trajectories

from (0, 0) to (2n, 0) with y ≥ 0, and Θ∗∗n = set of “extra-super” U-D trajectories, that is,set of U-D trajectories from (0, 0) to (2n, 0) with y > 0 except for the initial and final points.

Examples: figuras

How much is |Θ∗n|? Let’s calculate |Θ∗n| = |Θn−Θ∗n|. We have already seen that any U-Dtrajectory from (0, 0) to (2n, 0) that crosses y = 0 can be translated to an U-D trajectory

from (0,−2) to (2n, 0). Thus, |Θn − Θ∗n| = |Θ(2n,0)(0,−2)| = |Θ(2n,2)

(0,0) | =(

2nn+1

). Hence, |Θ∗n| =

|Θn| − |Θn − Θ∗n| =(2nn

)−(

2nn+1

)= 1

n+1

(2nn

)= Cn. Therefore, Cn is the number of “super”

U-D trajectories from (0, 0) to (2n, 0).

How much is |Θ∗∗n |? Notice that any “extra-super” U-D trajectory from (0, 0) to (2n, 0)can be translated into a “super” U-D trajectory from (1, 1) to (2n− 1, 1), which can be seenas a “super” U-D trajectory from (0, 0) to (2n− 2, 0).

Figura

Therefore, |Θ∗∗n | = |Θ∗n−1| = Cn−1. Therefore, Cn−1 is the number of “extra-super” U-Dtrajectories from (0, 0) to (2n, 0).

How many “super” U-D trajectories from (0, 0) to (2n, 0) are there such that they touchOX for the first time in (2k, 0), k = 1, 2, . . . , n? There are |Θ∗∗k | · |Θ∗n−k| = Ck−1Cn−k. Thus,

Cn =n∑k=1

Ck−1Cn−k.

Therefore,

C0 = 1, Cn = C0Cn−1 + C1Cn−2 + · · ·+ Cn−1C0, n ≥ 1.

The generating function is

c(x) =∞∑n=0

Cnxn, |x| < 1

4, x 6= 0.

c(x) · c(x) = (∑∞

n=0Cnxn) (∑∞

n=0Cnxn) = (C0 +C1x+C2x

2 + · · · )(C0 +C1x+C2x2 + · · · ) =

C0C0+(C0C1+C1C0)x+(C0C2+C1C1+C2C0)x2+· · ·+(C0Cn+C1Cn−1+· · ·+CnC0)x

n+· · · =

Page 67: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

4.3 Partitions of natural numbers 67

C1+C2x+C3x2+· · ·+Cn+1x

n+· · · = c(x)−C0

x. Thus, c(x)2 = c(x)−C0

xand xc(x)2−c(x)+1 = 0.

Therefore, c(x) = 1±√1−4x2x

. Since limx→0+1+√1−4x2x

=∞,

c(x) =

1−√1−4x2x

|x| < 14, x 6= 0

1 x = 0

There are some combinatorial problems related to Catalan numbers. One of them is thetriangularization of convex polygons with numbered vertices.

Figura

Triangularization is a decomposition of the convex polygon in triangles with disjointinteriors and whose vertices are vertices of the polygon.

Figuras

Let Tn be the number of possible triangularizations of a polygon with n + 2 sides andnumbered vertices v1, v2, . . . , vn+2.

Notice that two consecutive vertices are related in a triangle. We can classify in terms ofthe third vertex. If v1, v2 are the two fixed vertices then we can get v1v2vl, l = 3, . . . , n+ 2.For each k = 1, . . . , n we would get the number of triangularizations that can be madewith vertices v2, v3, . . . , vk+2 times the number of triangularizations that can be made withvertices vk+2, . . . , vn+2, v1.

Figura

Therefore,

Tn =n∑k=1

Tk−1Tn−k.

If we set T0 = 1 then Tn = Cn.

4.3 Partitions of natural numbers

4.3.1 Definition

Definition 4.3.1 Let n ∈ N = 1, 2, ldots. A partition of n is an expression of n as sumof natural numbers.

Page 68: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

68

Two partitions are considered identical if they only differ in the order of the summands.For example, 2 + 1 ≡ 1 + 2. If two partitions that only differ in the order are considereddifferent then they are ordered partitions.

4.3.2 Ordered partitions

Let Πn be the number of ordered partitions of n.

Π1 = 1,

Π2 = 2 (2, 1 + 1),

Π3 = 4 (3, 2 + 1, 1 + 2, 1 + 1 + 1),

Π4 = 8 (4, 3 + 1, 2 + 2, 2 + 1 + 1, 1 + 3, 1 + 2 + 1, 1 + 1 + 2, 1 + 1 + 1 + 1).

Conjecture: Is Πn = 2n−1 for every n ≥ 1?

We classify according to the number of summands:

• 1 summand: 1 (n)

• 2 summands ((n− 1) + 1, (n− 2) + 2, . . . , 1 + (n− 1))

• k summands: number of solutions of x1 + x2 + · · ·+ xk = n with x1, x2, . . . , xk ∈ N

• n summands: 1 (1 + 1 + · · ·+ 1)

How many are there?

Number of solutions of x1 + x2 + · · · + xk = n with xi ∈ N ≡ number of solutionsof (1 + y1) + (1 + y2) + · · · + (1 + yk) = n with yi ∈ N ∪ 0 ≡ number of solutions ofy1 + y2 + · · ·+ yk = n− k with yi ∈ N ∪ 0 =

(n−k+k−1

k−1

)=(n−1k−1

). Thus,

Πn =n∑k=1

(n− 1

k − 1

)= 2n−1, n ≥ 1.

4.3.3 Partitions and restricted partitions

Let Pn be the number of partitions of n. Let P<k>n be the number of partitions of n with

at most k summands. We set P0 = 1 and P<k>0 = 1. It is clear that Pn ≤ Πn = 2n−1.

Moreover, if k ≥ n, P<k>n = Pn.

Page 69: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

4.3 Partitions of natural numbers 69

Theorem 4.3.2 The generating function of (P<k>n )n≥0 is

P<k>(x) =1

1− x1

1− x2· · · 1

1− xk=

k∏r=1

1

1− xr, |x| < 1.

Proof.- Let yi be the number of summands equal to i, i = 1, . . . , k. We can write1y1 + 2y2 + · · · + kyk = n, yi ∈ N ∪ 0. Thus, P<k>

n is the number of solutions of thatequation, or the number of solutions of x1 + · · ·+ xk = n with xi ∈ 0, i, 2i, . . .. Therefore,the generating function is P<k>(x) = (1+x+x2+· · · )(1+x2+x4+· · · ) · · · (1+xk+x2k+· · · ) =1

1−x1

1−x2 · · ·1

1−xk =∏k

r=11

1−xr , |x| < 1.

Theorem 4.3.3 For |x| < 12

limk→∞|P (x)− P<k>(x)| = 0

with P (x) the generating function of (Pn)n≥0. That is,

P (x) = limk→∞

P<k>(x) = limk→∞

k∏r=1

1

1− xr=∞∏r=1

1

1− xr.

Proof.- Recall that Pn ≤ 2n−1 ≤ 2n. Therefore, the convergence radius of P (x) =∑∞n=0 Pnx

n is at least 12. Set |x| < 1

2. P (x)−P<k>(x) =

∑∞n=0(Pn−P<k>

n )xn =∑k

n=0(Pn−P<k>n )xn +

∑∞n=k+1(Pn − P<k>

n )xn =∑∞

n=k+1(Pn − P<k>n )xn. Thus, |P (x) − P<k>(x)| ≤∑∞

n=k+1 |Pn−P<k>n ||xn| ≤

∑∞n=k+1 2n|x|n =

∑∞n=k+1 |2x|n = |2x|k+1

∑∞n=0 |2x|n = |2x|k+1 1

1−|2x| .

Hence, 0 ≤ |P (x)−P<k>(x)| ≤ |2x|k+1

1−|2x| . Since limk→∞|2x|k+1

1−|2x| = 0, we get the desired result.

4.3.4 Partitions of different summands

Let Dn be the number of partitions of n with different summands and D<k>n be the number

of partitions of n with different summands and at most k. We set D0 = 1 and D<k>0 = 1.

Notice that D<k>n ≤ Dn ≤ Pn ≤ Πn = 2n−1 and if n ≤ k then D<k>

n = Dn.

Theorem 4.3.4 The generating function of (D<k>n )n≥0 is

D<k>(x) = (1 + x)(1 + x2) · · · (1 + xk) =k∏r=1

(1 + xr)

and D<k>n is the coefficient of xn in D<k>(x).

Page 70: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

70

Proof.- Let yi be the number of i such that 1y1 + 2y2 + · · · + kyk = n, yi ∈ 0, 1.D<k>n is the number of solutions of that equation, which is also the number of solutions of

x1 + · · · + xk = n, xi ∈ 0, i. Hence, the generating function of (D<k>n )n≥0 is D<k>(x) =

(1 + x)(1 + x2) · · · (1 + xk) =∏k

r=1(1 + xr).

Theorem 4.3.5 For |x| < 12

limk→∞|D(x)−D<k>(x)| = 0

with D(x) the generating function of (Dn)n≥0. That is,

D(x) = limk→∞

D<k>(x) = limk→∞

k∏r=1

(1 + xr) =∞∏r=1

(1 + xr).

4.3.5 Partitions with odd number of summands

Let On be the number of partitions of n with odd number of summands and let O<k>n be the

number of partitions of n with odd number of summands and at most k. We set O0 = 1 andO<k>

0 = 1. It is clear that O<k>n ≤ On ≤ Pn ≤ Πn = 2n−1. Moreover, if k ≥ n, O<k>

n = On

and O<2l−1>n = O<2l>

n .

Theorem 4.3.6 The generating function of (O<2l−1>n )n≥0, l ≥ 1, is

O<2l−1>(x) =1

1− x1

1− x3· · · 1

1− x2l−1=

l∏r=1

1

1− x2r−1, |x| < 1

and D<2l−1>n is the coefficient of xn in O<2l−1>(x). Moreover, the generating function of

(O<2l>n )n≥0, l ≥ 1, is O<2l>(x) = O<2l−1>(x).

Proof.- Let yi be the number of i such that 1y1 + 3y2 + 5y3 + · · · + (2l − 1)yl = n,yi ∈ 0, 1, 2, . . .. O<2l−1>

n is the number of solutions of that equation, which is also thenumber of solutions of x1 + · · · + xl = n, xi ∈ 0, 2i− 1, 4i− 1, . . .. Hence, the generatingfunction of (O<2l−1>

n )n≥0 is O<2l−1>(x) = (1 +x+x2 + · · · )(1 +x3 +x6 + · · · ) · · · (1 +x2l−1 +

x4l−2 + · · · ) = 11−x

11−x3 · · ·

11−x2l−1 =

∏lr=1

11−x2r−1 , |x| < 1.

Theorem 4.3.7 For |x| < 12

limk→∞|O(x)−O<2l−1>(x)| = 0

Page 71: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

4.3 Partitions of natural numbers 71

with O(x) the generating function of (On)n≥0. That is,

O(x) = limk→∞

O<2l−1>(x) = limk→∞

k∏r=1

1

1− x2r−1=∞∏r=1

1

1− x2r−1.

Corolary 4.3.8 For |x| < 12, D(x) = O(x) and Dn = On for all n.

Proof.- For |x| < 12D(x) =

∏∞r=1(1 + xr) =

∏∞r=1

(1+xr)(1−xr)(1−xr) =

∏∞r=1

(1−x2r)(1−xr) =

1−x21−x

1−x41−x2

1−x61−x4 · · · =

11−x

11−x3

11−x5 · · · =

∏∞r=1

11−x2r−1 = O(x).

We could generalize the above taking A = a1 < a2 < a3 < · · · ⊆ N, αn as the numberof partitions of n with summands in A and α<k>n as the number of partitions of n withsummands in A and at most k summands.

4.3.6 Ferrers diagrams

Example 4.3.9 Ferrers diagram of the partition 13 = 5 + 3 + 2 + 2 + 1:

13 = 5 +3 +2 +2 +1

In general,n = x1 · · · · · ·

+x2 · · · · · · +x3 · · · · · ·

......

+xk · · ·

Characteristics of a Ferrers diagram of a partition of n:

• The total number of circles is n.

• The number of rows is the number of summands.

• The number of columns is the greatest summand.

Page 72: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

72

Definition 4.3.10 Let π be a partition of n. The conjugate of pi, pit, is a partition whoseFerrers diagram is the transpose of the Ferrers diagram of π.

Theorem 4.3.11 The number of partitions of n into k summands is equal to the numberof partitions of n into summands at most k.

Proof.- The mapPartitions of n → Partitions of n

π → πt

is a bijection. Therefore the number of partitions of n into k summands is equal to thenumber of partitions of n into summands at most k.

Definition 4.3.12 A partition π of n is self-conjugate if πt = π, that is, if the Ferrersdiagram is symmetric with respect to the main diagonal.

Example 4.3.1310 = 4

+3 +2 +1

How many self-conjugate partitions of n are there? There are as many as the number ofpartitions of n into an odd number of different summands.

Figura

4.4 Bell numbers

Definition 4.4.1 Let Ω be a finite set. A partition of Ω is a collection of subsets of Ω,A1, A2, . . . , Ak, such that:

1. Ai 6= ∅ for all i.

2. They are pairwise disjoint, i.e., Ai ∩ Aj = ∅ if i 6= j.

3. Their union is Ω, i.e., Ω = ∪ki=1Ai.

Page 73: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

4.4 Bell numbers 73

Definition 4.4.2 Let B0 = 1 and Bn be the number of partitions of a set of n elements,n ≥ 1. B0, B1, B2, . . . are called the Bell numbers.

Example 4.4.3 • n = 1 Ω = 1, B1 = 1, (1)

• n = 2 Ω = 1, 2, B2 = 2, (1, 2, 1, 2)

• n = 3 Ω = 1, 2, 3, B3 = 5,

(1, 2, 3, 1, 2, 3, 1, 3, 2, 2, 3, 1, 1, 2, 3)

Our aim is to obtain a recurrence relation. Let Ω = 1, 2, . . . , n. Let A1 be any subsetof Ω that contains the element 1. There are

(n−1k−1

)sets A1 that have k elements, with

k = 1, . . . , n. Once A1 is fixed there are Bn−k partitions of Ω − A1. Therefore, Bn =∑nk=1

(n−1k−1

)Bn−k =

∑nk=0

(n−1n−k

)Bn−k. Thus,

Bn =

(n− 1

0

)B0 +

(n− 1

1

)B1 + · · ·

(n− 1

n− 1

)Bn−1.

This can be written as

Bn =[ (

n−10

) (n−11

)· · ·

(n−1n−1

) ]

B0

B1...

Bn−1

.We can make use of the Pascal’s triangle to calculate the Bell numbers

11 1

1 2 11 3 3 1

1 4 6 4 11 5 10 10 5 1

1 6 15 20 15 6 11 7 21 35 35 21 7 1

B0 = 1, B1 = 1, B2 = 2, B3 = 5, B4 = 15, B5 = 52, . . ..

Theorem 4.4.4Bn+1

n!=Bn

n!∗ 1

n!.

Page 74: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

74

Proof.- Bn+1 =(n0

)B0 +

(n1

)B1 + · · ·

(nn

)Bn = n!

0!n!B0 + n!

1!(n−1)!B1 + · · · + n!n!0!

Bn =

n!(B0

0!1n!

+ B1

1!1

(n−1)! + · · ·+ Bnn!

10!

)= n!

(Bnn!∗ 1n!

). Thus, Bn+1

n!= Bn

n!∗ 1n!.

The generating function is B(x) =∑∞

n=0Bnn!xn. Hence, B′(x) =

∑∞n=1

Bnn!nxn−1 =∑∞

n=1Bn

(n−1)!xn−1 =

∑∞n=0

Bn+1

n!xn =

∑∞n=0

(Bnn!∗ 1n!

)xn. Thus, since ex

∑∞n=0

xn

n!, B′(x) =

B(x)ex, which is a linear differential equation. As B′(x)B(x)

= ex, lnB(x) = ex + C and

B(x) = eex+C . Moreover B(0) = B0 = 1. So, 1 = e1+C , 0 = 1 + C and C = −1.

Thus,B(x) = ee

x−1.

4.5 Stirling numbers of the first kind

Consider the following

x0 = 1 = x0

x1 = x = x1

x2 = x(x+ 1) = x1 + x2

x3 = x(x+ 1)(x+ 2) = (x1 + x2)(x+ 2) = 2x1 + 3x2 + x3

...

xn = x(x+ 1) · · · (x+ n− 1) = Sn,0 + Sn,1x1 + Sn,2x

2 + · · ·+ Sn,nxn =

∑nk=0 Sn,kx

k.

Definition 4.5.1 Sn,0, Sn,1, . . . , Sn,n are the Stirling numbers of the first kind.

Notice that xn = (−1)n(−x)n = (−1)n∑n

k=0 Sn,k(−x)k = (−1)n∑n

k=0(−1)kSn,kxk =∑n

k=0(−1)n+kSn,kxk.

Let R[x] be the vector space of polynomials in the indeterminate x with real coefficientsand Rn[x] the vector subspace of polynomials of degree at most n. Then B = 1, x, x2, . . .,B = 1, x1, x2, . . . and B = 1, x1, x2, . . . are bases of R[x] and Bn = 1, x, x2, . . . , xn,Bn = 1, x1, x2, . . . , xn and Bn = 1, x1, x2, . . . , xn are bases of Rn[x].

Definition 4.5.2 For n = 0, 1, 2, . . . denote by

[n0

],

[n1

],

[n2

], . . . ,

[nn

]the coordi-

nates of xn with respect to the canonical basis Bn. In other words,

[nk

]is the coefficient

Page 75: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

4.5 Stirling numbers of the first kind 75

of xk in xn = x(x+ 1) · · · (x+ n− 1). Therefore,

[nk

]= Sn,k.

Proposition 4.5.3 1.

xn =n∑k=0

[nk

]xk.

2. If k > n then

[nk

]= 0.

3. [nn

]= 1, n ≥ 0.

4. [00

]= 1.

5. If n ≥ 1 then

[n1

]= (n− 1)!

6. [n

n− 1

]=

(n

2

).

7. [nk

]=

[n− 1k − 1

]+ (n− 1)

[n− 1k

].

Proof.-

5. Notice that if p(x) = a0 + a1x + · · · + anxn then p′(x) = a1 + 2a2x + · · · + nanx

n−1

and p′(0) = a1. Put p(x) = xn = x(x + 1)(x + 2) · · · (x + n − 1) =∑n

k=0

[nk

]xk.

Since p′(x) = (x+ 1)(x+ 2) · · · (x+ n− 1) + x∗, p′(0) = 1 · 2 · · · · · (n− 1) = (n− 1)!.

Therefore,

[n1

]= (n− 1)!.

6. Let p(x) = a0+a1x+· · ·+anxn. p(1u

)= a0+ a1

u+· · ·+ an

unand unp

(1u

)= una0+un−1a1+

· · ·+an. Call q(u) = unp(1u

). Hence, an−1 = q′(0). In our case, put p(x) = xn = x(x+

1)(x+2) · · · (x+n−1). Thus, q(u) = unp(1u

)= un 1

u

(1u

+ 1) (

1u

+ 2)· · ·(1u

+ n− 1)

=

un 1u1+uu

1+2uu· · · 1+(n−1)u

u= (1 + u)(1 + 2u) · · · (1 + (n − 1)u). Deriving, q′(u) = (1 +

2u) · · · (1+(n−1)u)+2(1+u)(1+3u) · · · (1+(n−1)u)+3(1+u)(1+2u)(1+4u) · · · (1+

Page 76: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

76

(n−1)u)+· · ·+(n−1)(1+u) · · · (1+(n−2)u). Hence,

[n1

]= 1+2+3+· · ·+(n−1) =

n(n−1)2

=(n2

).

7. Since xn = x(x+1)(x+2) · · · (x+n−1) = xn−1(x+n−1), xn =

(∑n−1k=0

[n− 1k

]xk)

(x+

n − 1) =∑n−1

k=0

[n− 1k

]xk+1 +

∑n−1k=0(n − 1)

[n− 1k

]xk. The coefficient of xk on

the right hand side is

[n− 1k − 1

]+ (n− 1)

[n− 1k

].

4.6 Stirling numbers of the second kind

Definition 4.6.1 For n ≥ 0 the numbers

n0

,

n1

, . . . are the coordinates of xn with

respect to B = 1, x1, x2, . . ., that is, xn =∑∞

k=0

nk

xk. These numbers are called the

Stirling numbers of the second kind.

Proposition 4.6.2 1. If k > n then

nk

= 0.

2. 00

= 1,

n0

= 0,

n1

= 1,

n2

= 2n−1−1,

n3

=

3n−1 + 1

2−2n−1.

3. nn

= 1, n ≥ 0.

4. nk

=

n− 1k − 1

+ k

n− 1k

.

Proof.-

Page 77: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

4.6 Stirling numbers of the second kind 77

2. Since xn =∑n

k=0

nk

xk, for n = 0 we get

00

= 1 and when x = 0,

n0

= 0

for n ≥ 1. Moreover, when x = 1, 1 =

n0

+

n1

=

n1

. In the same way,

when x = 2, 2n = 2

n1

+ 2

n2

= 2 + 2

n2

. Thus,

n2

= 2n−1 − 1. For

x = 3, 3n = 3

n1

+ 3 · 2

n2

+ 3 · 2 · 1

n3

= 3 + 6

(2n−1 − 1 +

n3

).

Hence,

n3

= 3n−1+1

2− 2n−1.

4. Notice that xn = xn−1x =

(∑n−1k=0

n− 1k

xk)x =

∑n−1k=0

n− 1k

xk(x−k+k) =∑n−1

k=0

n− 1k

xk+1 +

∑n−1k=0 k

n− 1k

xk. The coefficient of xk on the right hand

side is

n− 1k − 1

+ k

n− 1k

.

Let 1 2 3 4 5 6 7 8 9 10 11 12 be a sequence and 4 3 7 5 6 9 2 8 1 12 11 10 be apermutation. This permutation can be seen as a union of several cycles:

Figura

We define a(n, k) as the number of permutations of n elements that can be formed in

such a way that there are k cycles. We can see that a(n, k) =

[nk

]. On the one hand, the

number of permutations of n elements that can be formed in such a way that there are ncycles is 1 and the number of permutations of n elements that can be formed in such a waythat there are 0 cycles is 0 unless n = 0. Thus, a(n, n) = 1 for all n and a(n, 0) = 0 for n ≥ 1.On the other hand, we can classify the cycles: In the first kind we consider the permutationsin which 1 is fixed. There are as many as permutations of the other elements (n−1) that haveto generate k−1 cycles (a(n−1, k−1)). In the second kind we consider the permutations inwhich the first cycle has more elements: we must choose the permutation of 2, . . . , n with kcycles and insert 1 ((n−1)a(n−1, k)). Therefore, a(n, k) = a(n−1, k−1)+(n−1)a(n−1, k).

Define b(n, k) as the number of partitions of 1, 2, . . . , n in k subsets.

Example 4.6.3 b(4, 2) = 7 because if 1, 2, 3, 4:

1, 2, 3, 4, 2, 1, 3, 4, 3, 1, 2, 4, 4, 1, 2, 3, 1, 2, 3, 4, 1, 3, 2, 4,1, 4, 2, 3.

Page 78: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

78

Notice that b(n, 0) = 0 for n ≥ 1 and b(n, n) = 1 for n ≥ 1. We can set b(0, 0) = 1. Wecan classify the partitions according to element 1: First kind, those in which 1 is a subset;there are b(n− 1, k − 1). Second kind, we choose a partition of 2, . . . , n in k subsets andwe insert element 1; there are kb(n− 1, k). Therefore, b(n, k) = b(n− 1, k− 1) +kb(n− 1, k).

Therefore,

nk

= b(n, k).

Let c(n, k) be the number of ways to put n distinguishable balls in k numbered boxeswith no empty boxes. We can choose a partition of 1, 2, . . . , n in k subsets and put the k

subsets of balls in the k boxes, that is, c(n, k) =

nk

k!.

Page 79: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

Chapter 5

Graphs

5.1 Basic concepts

Definition 5.1.1 A graph consists of two finite sets, V and E. Each element of V is calleda vertex. The elements of E, called edges, are unordered pairs of vertices.

Example 5.1.2 V = 1, 2, 3, 4, E = 1, 2, 2, 3, 2, 4, 3, 4.

Figura

Definition 5.1.3 Two graphs are said to be isomorphic if there is a one-to-one correspon-dence between their vertices, which carries over to become a one-to-one correspondence be-tween their edges.

Example 5.1.4 Let V = 1, 2, 3, 4, 5, E = 1, 2, 1, 5, 2, 4, 3, 4 and V ′ = a, b, c, d, e,E ′ = c, d, c, e, a, b, d, b. These graphs are isomorphic by the one-to-one correspon-dence:

1↔ c, 2↔ d, 3↔ a, 4↔ b, 5↔ e.

Page 80: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

80 Graphs

We can obtain similar structures by altering our definition in various ways.

Definition 5.1.5 By replacing our set E with a set of ordered pairs of vertices, we obtaina directed graph or digraph. Each edge of a digraph has a specific orientation.

Example 5.1.6 Let V = 1, 2, 3, 4, 5, E = (1, 2), (1, 5), (2, 4), (3, 4).

Figura

Definition 5.1.7 If we allow repeated elements in our set of edges, technically replacing ourset E with a multiset, we obtain a multigraph.

Example 5.1.8 Let V = 1, 2, 3, 4, 5, 6,

E = 1, 2, 1, 2, 1, 2, 1, 3, 3, 5, 3, 5, 4, 6, 5, 6.

Figura

Definition 5.1.9 By allowing edges to connect a vertex to itself (“loops”), we obtain apseudograph.

Example 5.1.10 Let V = 1, 2, 3, 4, 5, 6,

E = 1, 2, 1, 4, 2, 3, 2, 6, 3, 6, 4, 4, 4, 5, 6, 6.

Figura

Definition 5.1.11 Allowing our edges to be arbitrary subsets of vertices gives us hyper-graphs.

Example 5.1.12 Let V = 1, 2, 3, 4, 5, 6,

E = 1, 1, 6, 6, 2, 3, 4, 5, 6, 3, 5, 2, 1, 2, 4, 5.

Figura

Definition 5.1.13 By allowing V or E to be an infinite set, we obtain infinite graphs.

Page 81: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

5.1 Basic concepts 81

Example 5.1.14 Let V = N, E = i, i+ 1 : i ∈ N.

Figura

Let G = V,E be a graph.

Definition 5.1.15 The order of a graph G is the cardinality of V : |V |.

Definition 5.1.16 The size of a graph G is the cardinality of E: |E|.

Example 5.1.17 LetG = V,E with V = 1, 2, 3, 4, 5 and E = 1, 3, 1, 4, 2, 4, 2, 5, 3, 5.The order of G is 5 and the size is 5.

Definition 5.1.18 Given two vertices u and v, if u, v ∈ E, then u and v are said to beadjacent. If u, v /∈ E, u and v are nonadjacent.

Definition 5.1.19 If an edge e has a vertex v as an endpoint, we say that v and e areincident.

Example 5.1.20 In the previous example, 1 and 2 are nonadjacent vertices while 1 and 3are adjacent. Moreover, vertex 1 and edge 1, 3 are incident.

Definition 5.1.21 The neighborhood of a vertex v, denoted by N(v), is the set of verticesadjacent to v:

N(v) = x ∈ V : v, x ∈ E.

Example 5.1.22 In the previous example, N(1) = 3, 4, N(2) = 4, 5, N(3) = 1, 5,N(4) = 1, 2, N(5) = 2, 3.

Definition 5.1.23 The degree of a vertex v, denoted by deg(v), is the number of edgesincident with v. That is,

deg(v) = |e ∈ E : ∃x ∈ V such that e = v, x|.

In simple graphs, this is the same as the cardinality of the neighborhood of v. We say thata vertex is even/odd if its degree is even/odd.

Page 82: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

82 Graphs

Definition 5.1.24 The maximum degree of a graph G, denoted by ∆(G), is defined to be

∆(G) = maxdeg(v) : v ∈ V .

Similarly,

Definition 5.1.25 The minimum degree of a graph G, denoted by δ(G), is defined to be

δ(G) = mindeg(v) : v ∈ V .

Example 5.1.26 deg(1) = 2, deg(2) = 2, deg(3) = 2, deg(4) = 2, deg(5) = 2,∆(G) =2, δ(G) = 2.

Theorem 5.1.27 Let G be a graph or a multigraph with |E| edges and the vertices v1, v2, . . ..Then

deg(v1) + deg(v2) + · · · = 2|E|

Corolary 5.1.28 Every graph or multigraph has an even number of odd vertices.

Special types of graphs:

Definition 5.1.29 The complete graph on n vertices, denoted by Kn, is the graph of ordern where uv ∈ E for all u and v ∈ V .

Definition 5.1.30 The empty graph on n vertices, denoted by En, is the graph of order nwhere E is the empty set.

Definition 5.1.31 Given a graph G, the complement of G, denoted by G, is the graph whosevertex set is the same as G’s and whose edge set consists of all the edges that are not presentin G.

Definition 5.1.32 A graph G is regular if every vertex has the same degree. G is said tobe regular of degree r (or r-regular) if deg(v) = r for all vertices v in G.

Complete graphs of order n are regular of degree n − 1, and empty graphs are regular ofdegree 0.

Page 83: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

5.2 Paths 83

Definition 5.1.33 A graph H is a subgraph of a graph G if V (H) ⊆ V (G) and E(H) ⊆E(G). In this case we write H ⊆ G and we say that G contains H.

Definition 5.1.34 A graph G is bipartite if its vertex set can be partitioned into two setsX and Y in such a way that every edge of G has one vertex in X and another in Y . In thiscase, X and Y are called the partite sets.

A bipartite graph with partite sets X and Y is called a complete bipartite graph if itsedge set is of the form E = x, y : x ∈ X, y ∈ Y (that is, if every possible connection of avertex of X with a vertex of Y is present in the graph). Such a graph is denoted by K|X|,|Y |.

5.2 Paths

Definition 5.2.1 A path in a graph is a sequence of distinct vertices v1, v2, . . . , vk such thatvivi+1 ∈ E for i = 1, 2, . . . , k − 1.

Definition 5.2.2 The length of a path is the number of edges on the path.

Example 5.2.3 1, 3, 5, 2, 4 is a path.

Definition 5.2.4 A cycle or circuit in a graph is a sequence of vertices w1, w2, . . . , wr−1, wrsuch that w1, w2, . . . , wr−1 is a path, w1 = wr, and wr−1wr ∈ E.

Essentially, a cycle is a closed path. The length of a cycle is defined to be the number ofedges on the cycle. When we speak of an odd/even cycle, we mean that the cycle has anodd/even length.

Definition 5.2.5 A graph is connected if every pair of vertices can be joined by a path.

Informally, if one can pick up an entire graph by grabbing just one vertex, then the graph isconnected.

Example 5.2.6 The graph in the example is connected.

Page 84: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

84 Graphs

Definition 5.2.7 Each maximal connected piece of a graph is called a connected component.

Theorem 5.2.8 A graph of order at least two is bipartite if and only if it contains no oddcycles.

Definition 5.2.9 A path that goes through each vertex of the graph exactly once is calledHamiltonian path.

Definition 5.2.10 If the path ends up back at the same vertex it started at is called aHamiltonian cycle.

Definition 5.2.11 A path that traverses each edge of a graph is called an Euler path.

Definition 5.2.12 If a cycle includes each edge of a graph it is called an Euler cycle.

Theorem 5.2.13 If a graph or a multigraph has an Euler cycle then all its vertices areeven.

Theorem 5.2.14 If a graph or a multigraph has an Euler path then at most two of itsvertices are odd.

Theorem 5.2.15 Any connected graph or multigraph with no odd vertices possesses an Eulercycle.

Theorem 5.2.16 Any connected graph or multigraph with exactly 2 odd vertices containsan Euler path.

5.3 Trees

Definition 5.3.1 A tree is a connected graph that contains no cycles.

Theorem 5.3.2 In every tree there is at least one vertex that has degree equal to 1.

Page 85: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

5.3 Trees 85

Remark 5.3.3 We are excluding, of course, the trivial tree with only one vertex; it cannothave any edges at all.

Theorem 5.3.4 Every tree with n vertices has exactly n− 1 edges.

Theorem 5.3.5 Between any two vertices in a tree there is one and only one path.

Theorem 5.3.6 If two nonadjacent vertices of a tree are connected by an edge the resultinggraph will contain a cycle.

Theorem 5.3.7 If any edge is deleted from a tree the resulting graph is not connected.

Theorem 5.3.8 If a graph is connected and has n vertices and n− 1 edges then it is a tree.

Theorem 5.3.9 If a graph has no cycles, has n vertices, and n− 1 edges then it is a tree.

Definition 5.3.10 Given any two vertices in a tree A and B we define the distance from Ato B to be the number of edges in the unique path from A to B.

Definition 5.3.11 A labeled tree is one in which each vertex has a name.

Two such trees are equivalent only if each corresponding vertex and edge has the same label.

Theorem 5.3.12 The number of trees in which v1 has degree d1 + 1, v2 has degree d2 + 1,. . . , vn has degree dn + 1 is exactly the multinomial coefficient(

n− 2

d1, d2, . . . , dn

)

Theorem 5.3.13 The numbers a1, a2, . . . , an (each an integer greater than 0) are the degreesof the vertices of some tree if and only if they add up to 2(n− 1).

Theorem 5.3.14 (Cayley’s formula) The total number of labeled trees with n vertices isnn−2.

Page 86: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

86 Graphs

Definition 5.3.15 A rooted tree is a tree whose first vertex has degree 1.

Definition 5.3.16 A rooted tree is trivalent if every vertex has degree 1 or 3.

Theorem 5.3.17 The number of ordered rooted trivalent trees of order n is the (n − 1)stCatalan number

Cn−1 =1

n

(2n− 2

n− 1

)

Theorem 5.3.18 The number of ordered rooted trees with n-vertices is the (n−2)nd Catalannumber

Cn−2 =1

n− 1

(2n− 4

n− 2

)

5.4 Planarity

Definition 5.4.1 A graph G is said to be planar if it can be drawn in the plane in such away that pairs of edges intersect only at vertices, if at all. If G has no such representation,G is called nonplanar.

Definition 5.4.2 A drawing of a planar graph G in the plane in which edges intersect onlyat vertices is called planar representation or a planar embedding of G.

Definition 5.4.3 Given a planar representation of a graph G, a region is a maximal sectionof the plane in which any two points can be joined by a curve that does not intersect any partof G.

Definition 5.4.4 The bound degree of a region R, denoted by b(R), is the number of edgesthat bound region R.

The number of regions in a planar representation of a graph does not depend on the repre-sentation itself.

Theorem 5.4.5 (Euler’s formula) In a planar connected graph let |E| be the number ofedges, |V | the number of vertices, and |R| the number of regions. Then

|V | − |E|+ |R| = 2.

Page 87: Silvia Marcaida Bengoechea - UPV/EHU · 8 Basic combinatorics In general, let Abe the nite set of elements that satisfy a property. Our aim is to calculate the number of elements

5.5 Colorings 87

Theorem 5.4.6 K3,3 is nonplanar.

Theorem 5.4.7 If G is a planar graph with n ≥ 3 vertices and q edges, then q ≤ 3n − 6.Furthermore, if equality holds, then every region is bounded by 3 edges.

Theorem 5.4.8 K5 is nonplanar.

Theorem 5.4.9 If G is a planar graph then G contains a vertex of degree at most 5. Thatis, δ(G) ≤ 5.

Definition 5.4.10 A polyhedron is a solid that is bounded by flat surfaces.

Polyhedra can be associated to graphs in a very natural way: the vertices and edges ofthe solid make up its skeleton, and the skeleton can be viewed as a graph. An interestingproperty of these skeleton graphs is that they are planar.

Definition 5.4.11 A polyhedron is regular if its faces are mutually congruent, regular poly-gons and if the number of faces meeting at a vertex is the same for every vertex. They arealso known as Platonic solids.

Theorem 5.4.12 There are exactly five regular polyhedra.

5.5 Colorings

Definition 5.5.1 Given a graph G, a k-coloring of the vertices of G is a partition of thevertex set V into k sets C1, C2, . . . , Ck such that for all i, no pair of vertices from Ci areadjacent. If such a partition exists, G is said to be k-colorable.

Definition 5.5.2 Given a graph G, the chromatic number of G, denoted by χG, is thesmallest integer k such that G is k-colorable.

Theorem 5.5.3 (Four Color Theorem) Every planar graph is 4-colorable.

Theorem 5.5.4 (Five Color Theorem) Every planar graph is 5-colorable.