• No results found

Properties of generating functions

N/A
N/A
Protected

Academic year: 2022

Share "Properties of generating functions"

Copied!
59
0
0

Loading.... (view fulltext now)

Full text

(1)

CS 207m: Discrete Structures (Minor)

Lecture 11 – Counting and Combinatorics

Generating functions and Principle of Inclusion-Exclusion

Feb 16 2018

(2)

Last few classes

Basic counting techniques and applications

1. Sum and product, bijection, double counting principles 2. Binomial coefficients and binomial theorem, Pascal’s

triangle

3. Permutations and combinations with/without repetitions 4. Counting subsets, relations, Handshake lemma

5. Stirling’s approximation: Estimating n!

6. Recurrence relations and one method to solve them.

7. Solving recurrence relations via generating functions.

(3)

Properties of generating functions

Definition

The(ordinary) generating function for a sequencea0, a1, . . .∈R is the infinite seriesφ(x) =P

k=0akxk.

I Let f(x) =P

k=0akxk,g(x) =P

k=0bkxk. Then 1. Iff(x) =g(x), thenak=bk for allk.

2. f(x) +g(x) =P

k=0(ak+bk)xk, 3. f(x)g(x) =P

k=0(Pk

j=0ajbk−j)xk, 4. dxd (P

k=0akxk) =P

k=1(kak)xk−1

I Let u∈R,k∈Z≥0, Thenextended binomial coefficient uk is defined as uk

= u(u−1)...(u−k+1)

k! ifk >0 and = 1 ifk= 0.

I What if u=−nforn∈N?

The extended binomial theorem Letu∈R, (1 +x)u =P

k=0 u k

xk. If you don’t like this, takex∈R,|x|<1.

(4)

Properties of generating functions

Definition

The(ordinary) generating function for a sequencea0, a1, . . .∈R is the infinite seriesφ(x) =P

k=0akxk.

I Let f(x) =P

k=0akxk,g(x) =P

k=0bkxk. Then 1. Iff(x) =g(x), thenak=bk for allk.

2. f(x) +g(x) =P

k=0(ak+bk)xk, 3. f(x)g(x) =P

k=0(Pk

j=0ajbk−j)xk, 4. dxd (P

k=0akxk) =P

k=1(kak)xk−1

I Let u∈R,k∈Z≥0, Thenextended binomial coefficient uk is defined as uk

= u(u−1)...(u−k+1)

k! ifk >0 and = 1 ifk= 0.

I What if u=−nforn∈N?

The extended binomial theorem Letu∈R, (1 +x)u =P

k=0 u k

xk. If you don’t like this, takex∈R,|x|<1.

(5)

Properties of generating functions

Definition

The(ordinary) generating function for a sequencea0, a1, . . .∈R is the infinite seriesφ(x) =P

k=0akxk.

I Let f(x) =P

k=0akxk,g(x) =P

k=0bkxk. Then 1. Iff(x) =g(x), thenak=bk for allk.

2. f(x) +g(x) =P

k=0(ak+bk)xk, 3. f(x)g(x) =P

k=0(Pk

j=0ajbk−j)xk, 4. dxd (P

k=0akxk) =P

k=1(kak)xk−1

I Let u∈R,k∈Z≥0, Thenextended binomial coefficient uk is defined as uk

= u(u−1)...(u−k+1)

k! ifk >0 and = 1 ifk= 0.

I What if u=−nforn∈N?

The extended binomial theorem Letu∈R, (1 +x)u =P

k=0 u k

xk.

If you don’t like this, takex∈R,|x|<1.

(6)

Properties of generating functions

Definition

The(ordinary) generating function for a sequencea0, a1, . . .∈R is the infinite seriesφ(x) =P

k=0akxk.

I Let f(x) =P

k=0akxk,g(x) =P

k=0bkxk. Then 1. Iff(x) =g(x), thenak=bk for allk.

2. f(x) +g(x) =P

k=0(ak+bk)xk, 3. f(x)g(x) =P

k=0(Pk

j=0ajbk−j)xk, 4. dxd (P

k=0akxk) =P

k=1(kak)xk−1

I Let u∈R,k∈Z≥0, Thenextended binomial coefficient uk is defined as uk

= u(u−1)...(u−k+1)

k! ifk >0 and = 1 ifk= 0.

I What if u=−nforn∈N? The extended binomial theorem

(7)

Simple examples using generating functions

Standard identities:

I 1

1−ax =P k=0akxk

I 1

1−xr =P k=0xrk

I ex=P k=0xk

k!

(8)

Solving Catalan numbers using generating functions

Catalan Numbers C(n) =

n−1

X

i=1

C(i)C(n−i) for n >1,C(0) = 0, C(1) = 1.

(9)

Solving Catalan numbers using generating functions

Catalan Numbers C(n) =

n−1

X

i=1

C(i)C(n−i) for n >1,C(0) = 0, C(1) = 1.

I Let φ(x) =P

k=1C(k)xk.

(10)

Solving Catalan numbers using generating functions

Catalan Numbers C(n) =

n−1

X

i=1

C(i)C(n−i) for n >1,C(0) = 0, C(1) = 1.

I Let φ(x) =P

k=1C(k)xk.

I Now considerφ(x)2.

I φ(x)2 = (P

k=1C(k)xk)(P

k=1C(k)xk)

= (P k=2

Pk−1

i=1 C(i)C(k−i)xk)

= (P

k=2C(k)xk) =φ(x)−x

(11)

Solving Catalan numbers using generating functions

Catalan Numbers C(n) =

n−1

X

i=1

C(i)C(n−i) for n >1,C(0) = 0, C(1) = 1.

I Let φ(x) =P

k=1C(k)xk.

I Now considerφ(x)2.

I φ(x)2 = (P

k=1C(k)xk)(P

k=1C(k)xk)

= (P k=2

Pk−1

i=1 C(i)C(k−i)xk)

= (P

k=2C(k)xk) =φ(x)−x

I Solving for φ(x) we get, φ(x) = 12(1±(1−4x)1/2)

I But since φ(0) = 0, we have

φ(x) = 12(1−(1−4x)1/2) = 12+ (−12(1−4x)1/2).

(12)

Catalan numbers

Recall: Extended binomial theorem Letα∈R,(1 +x)α=P

n=0 α n

xn, where αn

= α(α−1)...(α−n+1)

n! .

(13)

Catalan numbers

Recall: Extended binomial theorem Letα∈R,(1 +x)α=P

n=0 α n

xn, where αn

= α(α−1)...(α−n+1)

n! .

I P

k=1C(k)xk=φ(x) = 12 + (−12(1−4x)1/2) =

1

2 + (−12P k=0

1/2 k

(−4x)k).

(14)

Catalan numbers

Recall: Extended binomial theorem Letα∈R,(1 +x)α=P

n=0 α n

xn, where αn

= α(α−1)...(α−n+1)

n! .

I P

k=1C(k)xk=φ(x) = 12 + (−12(1−4x)1/2) =

1

2 + (−12P k=0

1/2 k

(−4x)k).

I The coefficient of xk is C(k) =−12 1/2k (−4)k

=−12(12(12−1)(12 −2). . .(12 −k+ 1))(−4)k!k

=−12(12)(−32)(−52). . .(−2k−32 ))(−4)k!k

(15)

Catalan numbers

Recall: Extended binomial theorem Letα∈R,(1 +x)α=P

n=0 α n

xn, where αn

= α(α−1)...(α−n+1)

n! .

I P

k=1C(k)xk=φ(x) = 12 + (−12(1−4x)1/2) =

1

2 + (−12P k=0

1/2 k

(−4x)k).

I The coefficient of xk is C(k) =−12 1/2k (−4)k

=−12(12(12−1)(12 −2). . .(12 −k+ 1))(−4)k!k

=−12(12)(−32)(−52). . .(−2k−32 ))(−4)k!k

I C(k) =(−1)2k+1k(−4)k! k ·1·3· · ·(2k−3)

(16)

Catalan numbers

Recall: Extended binomial theorem Letα∈R,(1 +x)α=P

n=0 α n

xn, where αn

= α(α−1)...(α−n+1)

n! .

I P

k=1C(k)xk=φ(x) = 12 + (−12(1−4x)1/2) =

1

2 + (−12P k=0

1/2 k

(−4x)k).

I The coefficient of xk is C(k) =−12 1/2k (−4)k

=−12(12(12−1)(12 −2). . .(12 −k+ 1))(−4)k!k

=−12(12)(−32)(−52). . .(−2k−32 ))(−4)k!k

I C(k) =(−1)2k+1k(−4)k! k ·1·3· · ·(2k−3)

I C(k) =2k+11·4k·k!·1.2....(2k−3)(2k−2)

2k−1(k−1)! = k!(k−1)!(2k−2)!.

(17)

Catalan numbers

Recall: Extended binomial theorem Letα∈R,(1 +x)α=P

n=0 α n

xn, where αn

= α(α−1)...(α−n+1)

n! .

I P

k=1C(k)xk=φ(x) = 12 + (−12(1−4x)1/2) =

1

2 + (−12P k=0

1/2 k

(−4x)k).

I The coefficient of xk is C(k) =−12 1/2k (−4)k

=−12(12(12−1)(12 −2). . .(12 −k+ 1))(−4)k!k

=−12(12)(−32)(−52). . .(−2k−32 ))(−4)k!k

I C(k) =(−1)2k+1k(−4)k! k ·1·3· · ·(2k−3)

I C(k) =2k+11·4k·k!·1.2....(2k−3)(2k−2)

2k−1(k−1)! = k!(k−1)!(2k−2)!. Thus, thenth Catalan number is given by C(n) = n!(n−1)!(2n−2)! = 1n 2n−2n−1

(18)

Other applications of generating functions

I What is the number of ways ak of selecting kelements from an nelement set if repetitions are allowed?

I Letφ(x) =P k=0akxk.

I Observe thatφ(x) = (1 +x+x2+. . .)n= (1x)−n

I Expand this by the extended binomial theorem and compare coefficients ofxk.

I ak= −nk

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

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

I (H.W)What if there must be 1 element of each type?

I Proving binomial identities: Show thatPn k=0

n k

2

= 2nn .

I Compare coefficients ofxn in (1 +x)2n= ((1 +x)n)2.

(19)

Other applications of generating functions

I What is the number of ways ak of selecting kelements from an nelement set if repetitions are allowed?

I Letφ(x) =P k=0akxk.

I Observe thatφ(x) = (1 +x+x2+. . .)n= (1x)−n

I Expand this by the extended binomial theorem and compare coefficients ofxk.

I ak= −nk

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

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

I (H.W)What if there must be 1 element of each type?

I Proving binomial identities: Show thatPn k=0

n k

2

= 2nn .

I Compare coefficients ofxn in (1 +x)2n= ((1 +x)n)2.

(20)

Other applications of generating functions

I What is the number of ways ak of selecting kelements from an nelement set if repetitions are allowed?

I Letφ(x) =P k=0akxk.

I Observe thatφ(x) = (1 +x+x2+. . .)n= (1x)−n

I Expand this by the extended binomial theorem and compare coefficients ofxk.

I ak= −nk

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

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

I (H.W)What if there must be 1 element of each type?

I Proving binomial identities: Show thatPn k=0

n k

2

= 2nn .

I Compare coefficients ofxn in (1 +x)2n= ((1 +x)n)2.

(21)

Other applications of generating functions

I What is the number of ways ak of selecting kelements from an nelement set if repetitions are allowed?

I Letφ(x) =P k=0akxk.

I Observe thatφ(x) = (1 +x+x2+. . .)n= (1x)−n

I Expand this by the extended binomial theorem and compare coefficients ofxk.

I ak= −nk

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

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

I (H.W)What if there must be 1 element of each type?

I Proving binomial identities: Show thatPn k=0

n k

2

= 2nn .

I Compare coefficients ofxn in (1 +x)2n= ((1 +x)n)2.

(22)

Other applications of generating functions

I What is the number of ways ak of selecting kelements from an nelement set if repetitions are allowed?

I Letφ(x) =P k=0akxk.

I Observe thatφ(x) = (1 +x+x2+. . .)n= (1x)−n

I Expand this by the extended binomial theorem and compare coefficients ofxk.

I ak= −nk

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

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

I (H.W)What if there must be 1 element of each type?

I Proving binomial identities: Show thatPn k=0

n k

2

= 2nn .

I Compare coefficients ofxn in (1 +x)2n= ((1 +x)n)2.

(23)

Other applications of generating functions

I What is the number of ways ak of selecting kelements from an nelement set if repetitions are allowed?

I Letφ(x) =P k=0akxk.

I Observe thatφ(x) = (1 +x+x2+. . .)n= (1x)−n

I Expand this by the extended binomial theorem and compare coefficients ofxk.

I ak= −nk

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

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

I (H.W)What if there must be 1 element of each type?

I Proving binomial identities: Show thatPn k=0

n k

2

= 2nn .

I Compare coefficients ofxn in (1 +x)2n= ((1 +x)n)2.

(24)

Other applications of generating functions

I What is the number of ways ak of selecting kelements from an nelement set if repetitions are allowed?

I Letφ(x) =P k=0akxk.

I Observe thatφ(x) = (1 +x+x2+. . .)n= (1x)−n

I Expand this by the extended binomial theorem and compare coefficients ofxk.

I ak= −nk

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

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

I (H.W)What if there must be 1 element of each type?

I Proving binomial identities: Show thatPn k=0

n k

2

= 2nn .

I Compare coefficients ofxn in (1 +x)2n= ((1 +x)n)2.

(25)

Other applications of generating functions

I What is the number of ways ak of selecting kelements from an nelement set if repetitions are allowed?

I Letφ(x) =P k=0akxk.

I Observe thatφ(x) = (1 +x+x2+. . .)n= (1x)−n

I Expand this by the extended binomial theorem and compare coefficients ofxk.

I ak= −nk

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

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

I (H.W)What if there must be 1 element of each type?

I Proving binomial identities: Show thatPn k=0

n k

2

= 2nn .

I Compare coefficients ofxn in (1 +x)2n= ((1 +x)n)2.

(26)

Applications of generating functions

Solving recurrence relations

I Number of subsets of a set of size n,

I Fibonacci sequence,

I Catalan numbers: C(n) = n!(n−1)!(2n−2)! = n1 2n−2n−1

Some more practice problems:

1. (H.W) How many ways can a convex n-sided polygon be cut into triangles by adding non-intersecting diagonals (i.e., connecting vertices with non-crossing lines)? Write a recurrence and solve it!

2. (H.W) Write a recurrence for the number of derrangements. That is, no. of ways to arrange nletters inton addressed envelopes such that no letter goes to the correct envelope.

(27)

Applications of generating functions

Solving recurrence relations

I Number of subsets of a set of size n,

I Fibonacci sequence,

I Catalan numbers: C(n) = n!(n−1)!(2n−2)! = n1 2n−2n−1

Some more practice problems:

1. (H.W) How many ways can a convex n-sided polygon be cut into triangles by adding non-intersecting diagonals (i.e., connecting vertices with non-crossing lines)? Write a recurrence and solve it!

2. (H.W) Write a recurrence for the number of derrangements. That is, no. of ways to arrange nletters inton addressed envelopes such that no letter goes to the correct envelope.

(28)

Applications of generating functions

Solving recurrence relations

I Number of subsets of a set of size n,

I Fibonacci sequence,

I Catalan numbers: C(n) = n!(n−1)!(2n−2)! = n1 2n−2n−1

Some more practice problems:

1. (H.W) How many ways can a convex n-sided polygon be cut into triangles by adding non-intersecting diagonals (i.e., connecting vertices with non-crossing lines)? Write a recurrence and solve it!

2. (H.W) Write a recurrence for the number of derrangements.

That is, no. of ways to arrange nletters inton addressed envelopes such that no letter goes to the correct envelope.

(29)

Principle of Inclusion-Exclusion (PIE)

A simple example:

I If in a class nstudents like physics,m students like biology and k students who like both, and` like neither, then how many students are there in the class?

I Of course, this also counts the no. who were too lazy to lift their hands!

Theorem: Principle of Inclusion-Exclusion (PIE) LetA1, A2, . . . , Anbe finite sets. Then,

|A1∪. . .∪An|= X

1≤i≤n

|Ai| − X

1≤i<j≤n

|Ai∩Aj|

+ X

1≤i<j<k≤n

|Ai∩Aj ∩Ak| −. . .+ (−1)n+1|A1∩. . .∩An|

(30)

Principle of Inclusion-Exclusion (PIE)

A simple example:

I If in a class nstudents like physics,m students like biology and k students who like both, and` like neither, then how many students are there in the class?

I Of course, this also counts the no. who were too lazy to lift their hands!

Theorem: Principle of Inclusion-Exclusion (PIE) LetA1, A2, . . . , Anbe finite sets. Then,

|A1∪. . .∪An|= X

1≤i≤n

|Ai| − X

1≤i<j≤n

|Ai∩Aj|

+ X

1≤i<j<k≤n

|Ai∩Aj ∩Ak| −. . .+ (−1)n+1|A1∩. . .∩An|

(31)

Principle of Inclusion-Exclusion (PIE)

A simple example:

I If in a class nstudents like physics,m students like biology and k students who like both, and` like neither, then how many students are there in the class?

I Of course, this also counts the no. who were too lazy to lift their hands!

Theorem: Principle of Inclusion-Exclusion (PIE) LetA1, A2, . . . , An be finite sets. Then,

|A1∪. . .∪An|= X

1≤i≤n

|Ai| − X

1≤i<j≤n

|Ai∩Aj|

+ X

1≤i<j<k≤n

|Ai∩Aj ∩Ak| −. . .+ (−1)n+1|A1∩. . .∩An|

(32)

Number of surjections

I How many surjections are there from [n] ={1, . . . , n}to [m] ={1, . . . , m}?

(33)

Number of surjections

I How many surjections are there from [n] ={1, . . . , n}to [m] ={1, . . . , m}?

I # surjections = total #functions - those that miss some element in range.

(34)

Number of surjections

I How many surjections are there from [n] ={1, . . . , n}to [m] ={1, . . . , m}?

I # surjections = total #functions - those that miss some element in range.

I Let Ai={f : [n]→[m]|i6∈Range(f)}

I Then, # surjections =mn− | ∪i∈[m]Ai|.

(35)

Number of surjections

I How many surjections are there from [n] ={1, . . . , n}to [m] ={1, . . . , m}?

I # surjections = total #functions - those that miss some element in range.

I Let Ai={f : [n]→[m]|i6∈Range(f)}

I Then, # surjections =mn− | ∪i∈[m]Ai|.

Theorem: Principle of Inclusion-Exclusion (PIE) LetA1, A2, . . . , An be finite sets. Then,

|A1∪. . .∪An|= X

1≤i≤n

|Ai| − X

1≤i<j≤n

|Ai∩Aj|

+ X

1≤i<j<k≤n

|Ai∩Aj ∩Ak| −. . .+ (−1)n+1|A1∩. . .∩An|

(36)

Number of surjections

I How many surjections are there from [n] ={1, . . . , n}to [m] ={1, . . . , m}?

I # surjections = total #functions - those that miss some element in range.

I Let Ai={f : [n]→[m]|i6∈Range(f)}

I Then, # surjections =mn− | ∪i∈[m]Ai|.

I | ∪i∈[m]Ai|=P

1≤i≤m|Ai| −P

1≤i<j≤m|Ai∩Aj|+ P

1≤i<j<k≤m|Ai∩Aj∩Ak| −. . .+ (−1)m+1|A1∩. . .∩Am|

(37)

Number of surjections

I How many surjections are there from [n] ={1, . . . , n}to [m] ={1, . . . , m}?

I # surjections = total #functions - those that miss some element in range.

I Let Ai={f : [n]→[m]|i6∈Range(f)}

I Then, # surjections =mn− | ∪i∈[m]Ai|.

I | ∪i∈[m]Ai|=P

1≤i≤m|Ai| −P

1≤i<j≤m|Ai∩Aj|+ P

1≤i<j<k≤m|Ai∩Aj∩Ak| −. . .+ (−1)m+1|A1∩. . .∩Am|

I But now what is |Ai|,|Ai∩Aj|,|Ai∩Aj∩Ak|, . . .?

(38)

Number of surjections

I How many surjections are there from [n] ={1, . . . , n}to [m] ={1, . . . , m}?

I # surjections = total #functions - those that miss some element in range.

I Let Ai={f : [n]→[m]|i6∈Range(f)}

I Then, # surjections =mn− | ∪i∈[m]Ai|.

I | ∪i∈[m]Ai|=P

1≤i≤m|Ai| −P

1≤i<j≤m|Ai∩Aj|+ P

1≤i<j<k≤m|Ai∩Aj∩Ak| −. . .+ (−1)m+1|A1∩. . .∩Am|

I But now what is |Ai|,|Ai∩Aj|,|Ai∩Aj∩Ak|, . . .?

I |Ai|= (m−1)n,|Ai∩Aj|= (m−2)n...

(39)

Number of surjections

I How many surjections are there from [n] ={1, . . . , n}to [m] ={1, . . . , m}?

I # surjections = total #functions - those that miss some element in range.

I Let Ai={f : [n]→[m]|i6∈Range(f)}

I Then, # surjections =mn− | ∪i∈[m]Ai|.

I | ∪i∈[m]Ai|=P

1≤i≤m|Ai| −P

1≤i<j≤m|Ai∩Aj|+ P

1≤i<j<k≤m|Ai∩Aj∩Ak| −. . .+ (−1)m+1|A1∩. . .∩Am|

I But now what is |Ai|,|Ai∩Aj|,|Ai∩Aj∩Ak|, . . .?

I |Ai|= (m−1)n,|Ai∩Aj|= (m−2)n...

I What about the summation? terms 1≤i < j ≤m=

(40)

Number of surjections

I How many surjections are there from [n] ={1, . . . , n}to [m] ={1, . . . , m}?

I # surjections = total #functions - those that miss some element in range.

I Let Ai={f : [n]→[m]|i6∈Range(f)}

I Then, # surjections =mn− | ∪i∈[m]Ai|.

I | ∪i∈[m]Ai|=P

1≤i≤m|Ai| −P

1≤i<j≤m|Ai∩Aj|+ P

1≤i<j<k≤m|Ai∩Aj∩Ak| −. . .+ (−1)m+1|A1∩. . .∩Am|

I But now what is |Ai|,|Ai∩Aj|,|Ai∩Aj∩Ak|, . . .?

I |Ai|= (m−1)n,|Ai∩Aj|= (m−2)n...

I What about the summation? terms 1≤i < j ≤m= m2

(41)

Proof of PIE

Theorem: Principle of Inclusion-Exclusion (PIE) LetA1, A2, . . . , An be finite sets. Then,

|A1∪. . .∪An|= X

1≤i≤n

|Ai| − X

1≤i<j≤n

|Ai∩Aj|

+ X

1≤i<j<k≤n

|Ai∩Aj ∩Ak| −. . .+ (−1)n+1|A1∩. . .∩An|

Proof: (H.W): Prove PIE by induction.

I We will show that each element in the union is counted exactly once in the r.h.s

I Let abelong to exactlyr of the setsA1, . . . , An.

I Then ais counted 1r

times byP

|Ai|, etc.

I Thus, overall count = r1

r2

+. . .(−1)r+1 rr .

I What is this number?! =1!

(42)

Proof of PIE

Theorem: Principle of Inclusion-Exclusion (PIE) LetA1, A2, . . . , An be finite sets. Then,

|A1∪. . .∪An|= X

1≤i≤n

|Ai| − X

1≤i<j≤n

|Ai∩Aj|

+ X

1≤i<j<k≤n

|Ai∩Aj ∩Ak| −. . .+ (−1)n+1|A1∩. . .∩An|

Proof:

I We will show that each element in the union is counted exactly once in the r.h.s

I Let abelong to exactlyr of the setsA1, . . . , An.

I Then ais counted 1r

times byP

|Ai|, etc.

I Thus, overall count = r1

r2

+. . .(−1)r+1 rr .

I What is this number?! =1!

(43)

Proof of PIE

Theorem: Principle of Inclusion-Exclusion (PIE) LetA1, A2, . . . , An be finite sets. Then,

|A1∪. . .∪An|= X

1≤i≤n

|Ai| − X

1≤i<j≤n

|Ai∩Aj|

+ X

1≤i<j<k≤n

|Ai∩Aj ∩Ak| −. . .+ (−1)n+1|A1∩. . .∩An|

Proof:

I We will show that each element in the union is counted exactly once in the r.h.s

I Let abelong to exactlyr of the setsA1, . . . , An.

I Then ais counted 1r

times byP

|Ai|, etc.

I Thus, overall count = r1

r2

+. . .(−1)r+1 rr .

I What is this number?! =1!

(44)

Proof of PIE

Theorem: Principle of Inclusion-Exclusion (PIE) LetA1, A2, . . . , An be finite sets. Then,

|A1∪. . .∪An|= X

1≤i≤n

|Ai| − X

1≤i<j≤n

|Ai∩Aj|

+ X

1≤i<j<k≤n

|Ai∩Aj ∩Ak| −. . .+ (−1)n+1|A1∩. . .∩An|

Proof:

I We will show that each element in the union is counted exactly once in the r.h.s

I Let abelong to exactlyr of the setsA1, . . . , An.

I Then ais counted 1r

times byP

|Ai|, etc.

I Thus, overall count = r1

r2

+. . .(−1)r+1 rr .

I What is this number?! =1!

(45)

Proof of PIE

Theorem: Principle of Inclusion-Exclusion (PIE) LetA1, A2, . . . , An be finite sets. Then,

|A1∪. . .∪An|= X

1≤i≤n

|Ai| − X

1≤i<j≤n

|Ai∩Aj|

+ X

1≤i<j<k≤n

|Ai∩Aj ∩Ak| −. . .+ (−1)n+1|A1∩. . .∩An|

Proof:

I We will show that each element in the union is counted exactly once in the r.h.s

I Let abelong to exactlyr of the setsA1, . . . , An.

I Then ais counted 1r

times byP

|Ai|, etc.

I Thus, overall count = r1

r2

+. . .(−1)r+1 rr .

I What is this number?! =1!

(46)

Proof of PIE

Theorem: Principle of Inclusion-Exclusion (PIE) LetA1, A2, . . . , An be finite sets. Then,

|A1∪. . .∪An|= X

1≤i≤n

|Ai| − X

1≤i<j≤n

|Ai∩Aj|

+ X

1≤i<j<k≤n

|Ai∩Aj ∩Ak| −. . .+ (−1)n+1|A1∩. . .∩An|

Proof:

I We will show that each element in the union is counted exactly once in the r.h.s

I Let abelong to exactlyr of the setsA1, . . . , An.

I Then ais counted 1r

times byP

|Ai|, etc.

=1!

(47)

Proof of PIE

Theorem: Principle of Inclusion-Exclusion (PIE) LetA1, A2, . . . , An be finite sets. Then,

|A1∪. . .∪An|= X

1≤i≤n

|Ai| − X

1≤i<j≤n

|Ai∩Aj|

+ X

1≤i<j<k≤n

|Ai∩Aj ∩Ak| −. . .+ (−1)n+1|A1∩. . .∩An|

Proof:

I We will show that each element in the union is counted exactly once in the r.h.s

I Let abelong to exactlyr of the setsA1, . . . , An.

I Then ais counted 1r

times byP

|Ai|, etc.

I Thus, overall count = r1

r2

+. . .(−1)r+1 rr .

I What is this number?! =1!

(48)

Applications of PIE

I How many integral solutions does x1+x2+x3 = 11 have where 0≤x1 ≤3,0≤x2≤4,0≤x3 ≤6?

I Number of derangements of a set with nelements

I That is, no. of ways to arrange n letters into n addressed envelopes such that no letter goes to the correct envelope.

(49)

Number of derangements

Formally, aderangement is a permutation of objects that leaves no object in its original position.

Theorem

LetDn denote the number of derangements of [n].

Dn=n!

n

X

i=0

(−1)i i!

I Dn = (total # permutations of [n]) - (# permutations of [n] that fix at least 1 element)

I Apply PIE on latter term, lets call itP, let P(i, j) denote permutations which fixi, j and so on.

I P = X

1≤i≤n

P(i)− X

1≤i<j≤n

P(i, j) +. . .+ (−1)nP(1, . . . , n).

I But P(i) = (n−1)!,P(i, j) = (n−2)!, . . .

I P = n

1

(n−1)!− n

2

(n−2)!. . .+ (−1)n+1 n

n

(n−n)!

I Thus,Dn=n!(1−1!1 +2!1 . . .+ (−1)nn!1)

(50)

Number of derangements

Formally, aderangement is a permutation of objects that leaves no object in its original position.

Theorem

LetDn denote the number of derangements of [n].

Dn=n!

n

X

i=0

(−1)i i!

I Dn = (total # permutations of [n]) - (# permutations of [n] that fix at least 1 element)

I Apply PIE on latter term, lets call itP, let P(i, j) denote permutations which fixi, j and so on.

I P = X

1≤i≤n

P(i)− X

1≤i<j≤n

P(i, j) +. . .+ (−1)nP(1, . . . , n).

I But P(i) = (n−1)!,P(i, j) = (n−2)!, . . .

I P = n

1

(n−1)!− n

2

(n−2)!. . .+ (−1)n+1 n

n

(n−n)!

I Thus,Dn=n!(1−1!1 +2!1 . . .+ (−1)nn!1)

(51)

Number of derangements

Theorem

LetDn denote the number of derangements of [n].

Dn=n!

n

X

i=0

(−1)i i!

I Dn = (total # permutations of [n]) - (# permutations of [n] that fix at least 1 element)

I Apply PIE on latter term, lets call itP, let P(i, j) denote permutations which fixi, j and so on.

I P = X

1≤i≤n

P(i)− X

1≤i<j≤n

P(i, j) +. . .+ (−1)nP(1, . . . , n).

I But P(i) = (n−1)!,P(i, j) = (n−2)!, . . .

I P = n

1

(n−1)!− n

2

(n−2)!. . .+ (−1)n+1 n

n

(n−n)!

I Thus,Dn=n!(1−1!1 +2!1 . . .+ (−1)nn!1)

(52)

Number of derangements

Theorem

LetDn denote the number of derangements of [n].

Dn=n!

n

X

i=0

(−1)i i!

I Dn = (total # permutations of [n]) - (# permutations of [n] that fix at least 1 element)

I Apply PIE on latter term, lets call itP, let P(i, j) denote permutations which fixi, j and so on.

I P = X

1≤i≤n

P(i)− X

1≤i<j≤n

P(i, j) +. . .+ (−1)nP(1, . . . , n).

I But P(i) = (n−1)!,P(i, j) = (n−2)!, . . .

I P = n

1

(n−1)!− n

2

(n−2)!. . .+ (−1)n+1 n

n

(n−n)!

I Thus,Dn=n!(1−1!1 +2!1 . . .+ (−1)nn!1)

(53)

Number of derangements

Theorem

LetDn denote the number of derangements of [n].

Dn=n!

n

X

i=0

(−1)i i!

I Dn = (total # permutations of [n]) - (# permutations of [n] that fix at least 1 element)

I Apply PIE on latter term, lets call itP, let P(i, j) denote permutations which fixi, j and so on.

I P = X

1≤i≤n

P(i)− X

1≤i<j≤n

P(i, j) +. . .+ (−1)nP(1, . . . , n).

I But P(i) = (n−1)!,P(i, j) = (n−2)!, . . .

I P = n

1

(n−1)!− n

2

(n−2)!. . .+ (−1)n+1 n

n

(n−n)!

I Thus,Dn=n!(1−1!1 +2!1 . . .+ (−1)nn!1)

(54)

Number of derangements

Theorem

LetDn denote the number of derangements of [n].

Dn=n!

n

X

i=0

(−1)i i!

I Dn = (total # permutations of [n]) - (# permutations of [n] that fix at least 1 element)

I Apply PIE on latter term, lets call itP, let P(i, j) denote permutations which fixi, j and so on.

I P = X

1≤i≤n

P(i)− X

1≤i<j≤n

P(i, j) +. . .+ (−1)nP(1, . . . , n).

I But P(i) = (n−1)!,P(i, j) = (n−2)!, . . .

I P = n

1

(n−1)!− n

2

(n−2)!. . .+ (−1)n+1 n

n

(n−n)!

I Thus,Dn=n!(1−1!1 +2!1 . . .+ (−1)nn!1)

(55)

Number of derangements

Theorem

LetDn denote the number of derangements of [n].

Dn=n!

n

X

i=0

(−1)i i!

I Dn = (total # permutations of [n]) - (# permutations of [n] that fix at least 1 element)

I Apply PIE on latter term, lets call itP, let P(i, j) denote permutations which fixi, j and so on.

I P = X

1≤i≤n

P(i)− X

1≤i<j≤n

P(i, j) +. . .+ (−1)nP(1, . . . , n).

I But P(i) = (n−1)!,P(i, j) = (n−2)!, . . .

I P = n

1

(n−1)!− n

2

(n−2)!. . .+ (−1)n+1 n

n

(n−n)!

I Thus,Dn=n!(1−1!1 +2!1 . . .+ (−1)nn!1)

References

Related documents

I Limitations of regular languages: Examples of non-regular languages and how to show non-regularity using pumping

confirm ()

function is defined at a fixed set of sample points on the shape. Levy

i) To study the distribution and morphology of CD1a positive Langerhans cells in human lung tissue in obstructive pulmonary diseases, benign and malignant diseases

An ecad of a plant species is a population of individuals which although belong to the same genetic stock (genetically similar) but differ in vegetative

When T e for many ions can be determined, it is possible to make a plot of T e against ionization potential, which can be used to determine the T e for ions for which only

With this general formula one can determine the partial derivatives of H ð0Þ for any given m, in terms of H ðnÞ functions, which in turn can be easily computed using the

◮ A high level description of the significance of ideas, what they could further lead to. Last chance to