Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
COS 341 Discrete Mathematics
Advanced Counting
1
Administrative Issues
• Textbook update:
• Bookstore will get one additional copy of textbook.
• Copies will be available at Triangle, 150 Nassau Street
(Tel: 609 924 4630) for $35 beginning today. They are
open M-F 8am-6pm.
• Updated collaboration policy
• Tutoring ?
• Readings for this week: Matousek and Nesetril, Chapter 10
2
Inclusion-Exclusion principle
A
B
C
| A∪ B ∪C | = | A| + | B | + | C |
- | A∩ B | - | A∩C | - | B ∩C |
+ | A∩ B ∩C |
3
Inclusion-Exclusion principle
| A1 ∪ A2 ∪
∪ An |
=
n
n
∑| A | - ∑
i
i =1
+
1≤i1 ≤i2 ≤n
n
∑
1≤i1 ≤i2 ≤i3 ≤n
-
| Ai1 ∩ Ai2 |
| Ai1 ∩ Ai2 ∩ Ai3 |
+(-1) n−1 | A1 ∩ A2 ∩
∩ An |
4
Hatcheck lady problem
n gentlemen arrive at a party and leave their hats in the
cloak room. On their departure, the hatcheck lady absentmindedly hands back a hat to each man at random.
What is the probability that none of the men receives their
own hat ?
• n! ways of assigning hats back to men
• What fraction of these assignments are such that
no man receives his own hat ?
5
Hatcheck lady
•
•
•
•
Number hats and men 1,2,..,n
π(i): number of hat received by ith man
π is a permutation
Index i with π(i) = i is a fixed point of π
• D(n): number of permutations with no fixed point
6
Enter inclusion-exclusion
• Sn: set of all permutations
• Ai = {π ∈ Sn : π(i) = i }
• ∪i Ai : bad permutations
| Ai |= (n −1)!
| Ai ∩ Aj |= (n −1)!
| Ai1 ∩ Ai2 ∩
∩ Aik |= (n − k )!
7
Enter inclusion-exclusion
| Ai1 ∩ Ai2 ∩
| A1 ∪ A2 ∪
∩ Aik |= (n − k )!
n
∪ An | = ∑ (−1)
k −1
k =1
n
= ∑ (−1)
k −1
k =1
D(n) = n !− | A1 ∪ A2 ∪
n
(n − k )!
k
n!
k!
∪ An |
n! n!
n n!
= n !− + − + (−1)
1! 2!
n!
1 1
1
n
= n !1− + − + (−1)
1! 2!
n !
8
Finishing up
1 1
1− + −
1! 2!
n!
D ( n) ≈
e
1
converges to e−1
+ (−1)
n!
n
Probability that nobody gets their hat back
converges to the constant e-1 = 0.36787
independent of the number of men !
9
Algebraic derivation of identities on
binomial coefficients
Binomial Theorem:
n k
(1 + x) = ∑ x
k =0 k
n
n
n n
n 2
n n−1 n n
x + x + … +
x
= +
+
x
0 1
2
n −1
n
Equality of two polynomials implies equality of
corresponding coefficients
10
Algebraic derivation of identities on
binomial coefficients
2
n 2n
=
∑
n
k =0 k
n
n
n
(1 + x) (1 + x) = (1 + x)
2n
n
coefficient of x on LHS
n
n
n
n
n
n
+
+
= +
n −1 2
n − 2
n 1
0
n
n
+
0
n
n
n
= ∑
k =0 k n − k
n
11
Algebraic derivation of identities on
binomial coefficients
2
n 2n
=
∑
n
k =0 k
n
n
n
(1 + x) (1 + x) = (1 + x)
2n
n
n
coefficient of x on LHS = ∑
k
n
k
−
k =0
n
n
2n
coefficient of x on RHS = ∑
k =0 n
n
n
12
Algebraic derivation of identities on
binomial coefficients
n
n
(−1)
= ?
∑
k n − k
k =0
n
k
n
n
2 n
(1− x) (1 + x) = (1− x )
n
n
coefficient of x on LHS = ∑ (−1)
n − k
k
k =0
n
n
k
0
when n odd
n
coefficient of x on RHS =
n/2 n
(−1)
n even
n / 2
13
Algebraic derivation of identities on
binomial coefficients
n
(−1) k = ?
∑
k
k =0
n
k
n
k k
(1− x) = ∑ (−1) x
k
k =0
n
n
n
n
d
d
n
(1− x) = ∑ (−1) k x k
dx
dx k =0 k
−n(1− x)
n−1
n
= ∑ (−1) k k ⋅ x k −1
k =0 k
n
14
Algebraic derivation of identities on
binomial coefficients
n
(−1) k = ?
∑
k
k =0
n
−n(1− x)
k
n−1
n
k
k −1
= ∑ (−1) k ⋅ x
k =0 k
n
substitute x = 1
n
0 = ∑ (−1) k
k
k =0
n
k
15
Power series
Infinite series of the form a0 + a1 x + a2 x 2 +
1
= 1+ x + x2 +
1− x
Series converges for x in the interval (-1,1)
Function contains all the information about series
Differentiate k times and substitute x=0,
we get k! times coefficient of xk
1
Taylor series of the function
at x = 0
1- x
16
Power series
(a0 , a1 , a2 ,…) : sequence of real numbers
|an |≤ K
n
For any number x ∈ (− K1 , K1 ), the series
∞
a ( x) = ∑ i=0 ai ⋅ x converges
i
Values of a(x) in arbitrarily small neighborhod of 0
uniquely determine (a0 , a1 , a2 ,…)
(n)
a (0)
an =
n!
17
Generating functions
(a0 , a1 , a2 ,…) : sequence of real numbers
Generating function of this sequence is
∞
the power series a( x) = ∑ i=0 ai ⋅ x
i
18
Generating function basics
What is the generating function of the sequence
(1, 12 , 13 , 14 , ) ?
1 + 12 x + 13 x 2 + 14 x3 +
ln(1− x)
−
x
2
3
x+ x+ x + x +
1
2
1
3
1
4
1 + 1!1 x + 2!1 x 2 + 3!1 x3 +
= − ln(1− x)
= ex
19
Generating function toolkit:
Generalized binomial theorem
r r (r −1)(r − 2)… (r − k + 1)
=
k
k!
r
(1 + x) is the generating function
r r r r
,
,
,
, …
for the sequence
0 1 2 3
r r r
The power series + x + x
0 1 2
2
r
+
x
3
3
+…
always converges for all | x |< 1
20
Negative binomial coefficients ?
r
−r + k −1
−r + k −1
k
k
= (−1)
(
1)
=
−
k
k
−r −1
n-1 n n+1
1
=
+
x
+
x
n
n-1 n-1 n-1
(1− x)
1
= 1+ x + x +
1− x
2
+
n+k-1
+
x
n-1
k
+…
2
21
Operations on power series
• Addition
(a0 + b0 , a1 + b1 ,…) has generating function a ( x) + b( x)
• Multiplication by fixed real number
(αa0 , αa1 ,…) has generating function αa ( x)
• Shifting the sequence
(0,… 0 , a0 , a1 ,…) has generating function x n a ( x)
n×
• Shifting to the left
22
• Substituting αx for x
(a0 , αa1 , α 2 a2 …) has generating function a (αx)
(1, 2, 4,8,…) has generating function ?
• Substitute xn for x
(1,1, 2, 2, 4, 4, 8, 8,…) has generating function ?
1
x
+
2
1- 2 x
1− 2 x 2
23
• Integration and differentiation
(a0 , 2a1 ,3a2 …) has generating function ?
(0,a0 , 12 a1 , 13 a2 …) has generating function ?
• Multiplication of generating functions
24