Chapter 3 ; Enumerative Analysis
Chapter 3 ; Enumerative Analysis
ENUMERATIVE ANALYSIS
Dr. E. Mujuni
June 7, 2021
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Contents
1 Introduction
2 Basic Counting Principles
The Sum Rule
The Product Rule
3 Principle of Inclusion-Exclusion
4 Recurrence Relations
Definitions & Terminologies
First Order Linear Recurrence Relations
The 2nd Order Linear Homogeneous Relation
Non-Homogeneous Recurrence Relations
Examples of Applications of Recurrence Relations
5 Generating Functions
Introduction
Definitions and Techniques
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Contents
1 Introduction
2 Basic Counting Principles
The Sum Rule
The Product Rule
3 Principle of Inclusion-Exclusion
4 Recurrence Relations
Definitions & Terminologies
First Order Linear Recurrence Relations
The 2nd Order Linear Homogeneous Relation
Non-Homogeneous Recurrence Relations
Examples of Applications of Recurrence Relations
5 Generating Functions
Introduction
Definitions and Techniques
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Contents
1 Introduction
2 Basic Counting Principles
The Sum Rule
The Product Rule
3 Principle of Inclusion-Exclusion
4 Recurrence Relations
Definitions & Terminologies
First Order Linear Recurrence Relations
The 2nd Order Linear Homogeneous Relation
Non-Homogeneous Recurrence Relations
Examples of Applications of Recurrence Relations
5 Generating Functions
Introduction
Definitions and Techniques
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Contents
1 Introduction
2 Basic Counting Principles
The Sum Rule
The Product Rule
3 Principle of Inclusion-Exclusion
4 Recurrence Relations
Definitions & Terminologies
First Order Linear Recurrence Relations
The 2nd Order Linear Homogeneous Relation
Non-Homogeneous Recurrence Relations
Examples of Applications of Recurrence Relations
5 Generating Functions
Introduction
Definitions and Techniques
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Contents
1 Introduction
2 Basic Counting Principles
The Sum Rule
The Product Rule
3 Principle of Inclusion-Exclusion
4 Recurrence Relations
Definitions & Terminologies
First Order Linear Recurrence Relations
The 2nd Order Linear Homogeneous Relation
Non-Homogeneous Recurrence Relations
Examples of Applications of Recurrence Relations
5 Generating Functions
Introduction
Definitions and Techniques
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Math Library has 40 textbooks on Calculus and 50 textbooks on
Discrete Mathematics. How many ways can a student select/choose
a book
Solution:
1 The first task is to select a Calculus Book. A student can select
in 40 different ways.
2 Second task is to select a Discrete Book. A student can select in
50 different ways
Therefore, by the sum rule, a student can select a book 40 + 50 = 90
different ways.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Math Library has 40 textbooks on Calculus and 50 textbooks on
Discrete Mathematics. How many ways can a student select/choose
a book
Solution:
1 The first task is to select a Calculus Book. A student can select
in 40 different ways.
2 Second task is to select a Discrete Book. A student can select in
50 different ways
Therefore, by the sum rule, a student can select a book 40 + 50 = 90
different ways.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Math Library has 40 textbooks on Calculus and 50 textbooks on
Discrete Mathematics. How many ways can a student select/choose
a book
Solution:
1 The first task is to select a Calculus Book. A student can select
in 40 different ways.
2 Second task is to select a Discrete Book. A student can select in
50 different ways
Therefore, by the sum rule, a student can select a book 40 + 50 = 90
different ways.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Math Library has 40 textbooks on Calculus and 50 textbooks on
Discrete Mathematics. How many ways can a student select/choose
a book
Solution:
1 The first task is to select a Calculus Book. A student can select
in 40 different ways.
2 Second task is to select a Discrete Book. A student can select in
50 different ways
Therefore, by the sum rule, a student can select a book 40 + 50 = 90
different ways.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
We can extend the Sum rule to more than two tasks. Suppose the
tasks T1 , T2 , . . . , Tn can respectively be done in m1 , m2 , . . . , mn and
no two of these can be done at the same time. Then the number of
ways to do one of these tasks is m1 + m2 + . . . + mn different ways.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
What is the value of k after the code below has been executed: k:=0
for i:=1 to n1 do
k:=k+1
for i:=1 to n2 do
k:=k+1
for i:=1 to n3 do
k:=k+1
.
.
for i:=1 to nm do
k:=k+1
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Solution
Example
How many different ways to construct a bit string of length 7.
Solution
Each of the seven bits can be chosen in two ways, since each bit is
either 0 or 1. Therefore, by the product rule, there are
2 × 2 × 2 × 2 × 2 × 2 × 2 = 27 = 128 different bit string of length 7
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
What is the value of k after the following code has been executed:
k:=0
for i:=0 to n1 do
for i:=0 to n2 do
for i:=0 to n3 do
...
for i:=0 to nm do
k:=k+1
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Solution
Principle of
Inclusion-Exclusion
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
How many bits of length four either start with a 1 or end with two bits
00 are there?
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Solution
|A1 ∪A2 ∪A3 | = |A1 |+|A2 |+|A3 |−|A1 ∩A2 |−|A1 ∩A3 |−|A2 ∩A3 |+|A1 ∩A2 ∩A3 |
(2)
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
. . . + (−1)n+1 |A1 ∩ A2 ∩ . . . ∩ An |
Before proving the above the above theorem, we present basic few
formulas.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
n!
C(n, r ) =
r !(n − r )!
Proof Exercise
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Corollary
(b) 0 = n0 − n1 + 2 + . . . + (−1)n nn
Proof Exercise
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
r r r r r r
− + − + . . . + (−1) =0
0 1 2 3 r
Hence
r r r r r
1= = − + − . . . + (−1)r +1
0 1 2 3 r
Example
Determine the number of positive integers n, where 1 ≤ n ≤ 100 and
n is divisible by 2, 3 or 5.
Solution
Let A, B and C be the set of positive integers n , 1 ≤ n ≤ 100,
divisible by 2 ,3 and 5, respectively. Then the answer is |A ∪ B ∪ C|.
We now introduce the following notation. For x ∈ <, let bxc denote
the largest integer smallest than x. For example, b3.13c = 3,
b34.98c = 34 and b23.45c = 23
Then |A| = b 100 100 100
2 c = 50, |B| = b 3 c = b33.33c = 33, |C| = b 5 c = 20,
100 100 100
|A ∩ B| = b 2×3 c = b 6 c = 16, |A ∩ C| = b 2×5 c = 10,
100 100
|B ∩ C| = b 3×5 c = 6 and |A ∩ B ∩ C| = b 2×3×5 c = 3. Apply the
Inclusion-Exclusion principle we get
|A ∪ B ∪ C| = 50 + 33 + 20 − 16 − 10 − 6 + 3 = 74. Therefore, there
are 74 numbers from 1 to 100 divisible by 2, 3 or 5.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Determine the number of prime number not exceeding hundred (100).
Solution
Note that a non prime number is drivable by a prime number not
exceeding its square root. So the prime numbers not exceeding 100
are not divisible by 2, 3, 5 and 7.
Let A1 , A2 , A3 and A4 be the set of integers (≤ 100) that are divisible
0 0 0 0
by 2, 3, 5 and 7, respectively. Let A1 A2 A3 A4 be the set of positive
number not exceeding 100 divisible to none of 2,3,5 and 7.
0 0 0 0
|A1 A2 A3 A4 | = |U| − |A1 ∪ A2 ∪ A2 ∪ A4 |. (4)
Where U is the set of all positive number greater than 1 but not
exceeding 100.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Determine the number of prime number not exceeding hundred (100).
Solution
Note that a non prime number is drivable by a prime number not
exceeding its square root. So the prime numbers not exceeding 100
are not divisible by 2, 3, 5 and 7.
Let A1 , A2 , A3 and A4 be the set of integers (≤ 100) that are divisible
0 0 0 0
by 2, 3, 5 and 7, respectively. Let A1 A2 A3 A4 be the set of positive
number not exceeding 100 divisible to none of 2,3,5 and 7.
0 0 0 0
|A1 A2 A3 A4 | = |U| − |A1 ∪ A2 ∪ A2 ∪ A4 |. (4)
Where U is the set of all positive number greater than 1 but not
exceeding 100.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
However 2, 3,5, and 7 are also prime. Therefore The total number of prime
number is 21 + 4 = 25.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
In a certain village there are five villages. An engineer is to device a
system of two-ways road so that after the system is completed, no
village is isolated. In how many ways the engineer do this?
Solution
Call these village v1 , v2 , v3 , v4 and v5 . So, we seek the number of
simple graphs on 5 vertices without isolated vertex. Consequently, we
want to count situation like (a), (b) in Figure 1, but no situation (c).
v2 v2 v2
v1
s s v1
s s v1
s s
Figure:
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Recurrence Relations
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Definition
A recurrence relation for the sequence {an } is a formula that
expresses an in terms of one or more of the previous terms of the
sequence, namely, a0 , a1 , a2 , . . . , an−1 for all integers n ≤ 0. A
sequence is called a solution of a recurrence relation if its terms
satisfy the recurrence relation.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Let {an } be a sequence that satisfies the recurrence relation
an = an−1 − an−2 for n = 2, 3, . . ., and suppose that a0 = 3 and
a1 = 5. What are a2 and a3 .
Solution
We see from the recurrence relation that a2 = a1 − a0 = 5 − 3 = 2
and a3 = a2 − a1 = 2 − 5 = −3.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Definition
Let k ∈ Z + , and cn (6= 0), cn−1 , cn−2 , . . . , cn−k (6= 0) be real numbers. If
an , n ≥ 0, is a discrete numerical function, then
Example
The relation an = 5an−1 is the first order linear homogeneous
relation.
The relation fn = fn−1 + 2fn−3 is the 3rd order linear
homogeneous recurrence.
Example
2
The relation an = an−1 + an−2 is not linear.
The recurrence nn = nbn−1 does not have constant coefficients.
The recurrenceHn = 2Hn−1 + 1 is nonhomogenous.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
The relation an = 5an−1 is the first order linear homogeneous
relation.
The relation fn = fn−1 + 2fn−3 is the 3rd order linear
homogeneous recurrence.
Example
2
The relation an = an−1 + an−2 is not linear.
The recurrence nn = nbn−1 does not have constant coefficients.
The recurrenceHn = 2Hn−1 + 1 is nonhomogenous.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
an+1 = 3an
an+1 = 3an , n ≤ 0, a0 = 5
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
a0 = 5
a1 = 3a0 = 3(5)
a2 = 3a1 = 3(3a0 ) = 32 a0
a3 = 3a1 = 3(3a1 ) = 33 a0
..
.
an = 3a1 == 3n a0
Therefore
an = 3a1 == 3n a0 (5)
Equation 5 is called the general solution of the given recurrence
relation. If we wwish to compute a10 , simply calculate
a10 = 310 · · · 5 = 295, 245
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Solve the recurrence relation an = 7an−1 , n ≤ 1, a2 = 98
Solution
an = a0 7n is a general solution. Since a2 = 98, it follows that
98 = a0 72 . This implies that a0 = 2. Hence, a particular solution is
an = 2(7n ).
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
2
Find a12 if an+1 = 5an2 , where n ≥ 0, a0 = 2.
Solution
Let bn = an2 . Then bn+1 = 5b√ n , n ≤ 0, b0 = 4, which implies that
bn = 4 · · · 5n . Hence an = 2( 5)n , n ≥ 0, a0 = 2. Hence
a12 = 31, 250
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
an = Cr n
Simplify 7, to obtain
r 2 + c1 r + c2 = 0 (8)
which is a quadratic equation. Equation 8 is called the Characteristic
equation of the relation.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Theorem
Let c1 and c2 be real numbers. Suppose that r 2 + c1 r + c2 = 0 has
two distinct roots r1 and r2 . Then the sequence {an } is a solution of
the recurrence relation an + c1 an−1 + c2 an−2 = 0 if and only if
an = α1 r1n + α2 r2n for n = 0, 1, 2, . . . , where α1 and α2 are constants.
an + an−1 − 6an−2 = 0, n ≥ 2, a0 = 1, a1 = 2
Solution
Let an = Cr n , C, r 6= 0. So we obtain Cr n + Cr n−1 − 6r r −2 = 0.
Hence r 2 + r − 6 = 0, which implies r1 = 2 and r2 = −3.
Since we have two distinct real roots, an = 2n and (−3)n are both
solution. Since they are linearly independent, an = C1 2n + C2 (−3)n ,
where C1 and C2 are constants.
With a0 = 1 and a1 = 2, then we have
a0 = C1 (2)0 + C2 (−3)0 = C1 + C2 = 1
1 1
a1 = C1 (2) + C2 (−3) = 2C1 − 3C2 = 2
Example
Solve the recurrence relation
Fn+2 = Fn+1 + Fn , n ≤ 0, F0 = 0, F1 = 1
Solution
Let Fn = Cr n , Cr 6= 0, n ≥ 0. We substitute
√
in the relation,
√
we get
r 2 − r − 1 = 0. This implies r1 = 1+2 5 and r2 = 1−2 5 . So the general
solution is √ √
1+ 5 n 1− 5 n
Fn = C1 ( ) + C2 ( )
2 2
With F0 = 0 and F1 = 1, C1 = √1 and C1 = √1 , the unique solution is
5 5
√ √
1+ 5 n 1− 5 n
Fn = ( √ ) − ( √ )
2 5 2 5
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
an = 4an−1 − 4an−2 , n ≥ 2, a0 = 1, a1 = 3
Solution
Let an = Cr n , where C, r 6= 0. Then the characterist equation of the
relation is
r 2 − 4r + 4 = 0.
The roots of the characterist equation are r1 = r2 = 2.
In this case, the general solution is
an = C1 (2)n + C2 n(2)n
Example
√
Determine (1 + i 3)10
Solution √
Let z = 1 + i 3. Then z = 2(cos π3 + i sin π3 ). Hence,
π π
z 10 = 210 (cos + i sin )10
3 3
10π 10π
= 210 (cos + i sin )
3 3
4π 4π
= 210 (cos + i sin )
3 √ 3
1 3
= 210 (− − i )
2 √2
= −29 (1 + i 3)
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Solve the recurrence relation
an = 2an−1 − 2an−2 , n ≥ 2, a0 = 1 a1 = 2
Solution
Let an = Cr 2 , C, t 6= 0. So r 2 − 2r + 2 = 0. Hence r1 = 1 + i and
r2 = 1 − i. Consequently, the general solution is
an = C1 (1 + i)n + C2 (1 − i)n ,
This yields
√ π π √ π π
an = C1 ( 2)n (cos + i sin )n + C2 ( 2)n (cos − i sin )n
4 4 4 4
√ n π π n π π n
= ( 2) (C1 (cos + i sin ) + C2 (cos − i sin ) )
4 4 4 4
√ n nπ nπ nπ nπ
= ( 2) (C1 (cos + i sin ) + C2 (cos − i sin ))
4 4 4 4
√ n nπ nπ
= ( 2) (k1 cos + k2 sin )
4 4
where k1 = C1 + C2 and k2 = i(C1 − C2 ) With a0 = 1 and a1 = 2, we
find k1 = 1 and k2 = 1. Therefore, the unique solution is
√ nπ nπ
an = ( 2)n (cos + sin )
4 4
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
an = an−1 + f (n)
a1 = a0 + f (1)
a2 = a0 + f (1) + f (2)
a3 = a0 + f (1) + f (2) + f (3)
..
.
n
X
an = a0 + f (1) + f (2) + f (3) . . . + f (n) = a0 + f (i)
i=1
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Solve the relation
an − an−1 = 3n2 , n ≥ 1, a0 = 7
Solution
n
X n
X
an = a0 + f (i) = 7 + 3 i2
i=1 i=1
1
= 7 + n(n + 1)(2n + 1)
2
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Undetermined coefficient
(h)
For either equation 9 and equation 10 let an and denotes the
(p)
general solution associated with homogenous, and let an be a
(p)
solution of the given non-homogenous relation (an is called a
(h) (p)
Particular solution). Then an = an + an is the general solution
of the given solution.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Undetermined coefficient
(h)
For either equation 9 and equation 10 let an and denotes the
(p)
general solution associated with homogenous, and let an be a
(p)
solution of the given non-homogenous relation (an is called a
(h) (p)
Particular solution). Then an = an + an is the general solution
of the given solution.
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
an − 3an−1 = 5(7n ), n ≥ 1, a0 = 2.
Solution
(h)
The solution of the associated homogeneous relation is an = C(3n ).
(p)
Since f (n) = 7(5n ), we seek a particular solution an of the form A.7n .
(p)
As an is to be a solution of the given nonhomogeneous relation, we
(p)
replace an = A(7n ) into the given relation and find that
A(7n ) − an−1 = 5(7n ), n ≥ 1, a0 = 2.
35 (p) 35 n
which implies, 7A − 3A = 35. So A = 4 and an = 4 7 = 54 7n+1 .
The general solution is
5 n+1
an = C(3n ) + 7 .
4
With a0 = 2 we find C = − 27
4 and
27 n 5 5 1
an = − (3 ) + 7n+1 = 7n+1 − (3n+3 )
4 4 4 4
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
an − 3an−1 = 5(7n ), n ≥ 1, a0 = 2.
Solution
(h)
The solution of the associated homogeneous relation is an = C(3n ).
(p)
Since f (n) = 7(5n ), we seek a particular solution an of the form A.7n .
(p)
As an is to be a solution of the given nonhomogeneous relation, we
(p)
replace an = A(7n ) into the given relation and find that
A(7n ) − an−1 = 5(7n ), n ≥ 1, a0 = 2.
35 (p) 35 n
which implies, 7A − 3A = 35. So A = 4 and an = 4 7 = 54 7n+1 .
The general solution is
5 n+1
an = C(3n ) + 7 .
4
With a0 = 2 we find C = − 27
4 and
27 n 5 5 1
an = − (3 ) + 7n+1 = 7n+1 − (3n+3 )
4 4 4 4
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
an − 3an−1 = 5(7n ), n ≥ 1, a0 = 2.
Solution
(h)
The solution of the associated homogeneous relation is an = C(3n ).
(p)
Since f (n) = 7(5n ), we seek a particular solution an of the form A.7n .
(p)
As an is to be a solution of the given nonhomogeneous relation, we
(p)
replace an = A(7n ) into the given relation and find that
A(7n ) − an−1 = 5(7n ), n ≥ 1, a0 = 2.
35 (p) 35 n
which implies, 7A − 3A = 35. So A = 4 and an = 4 7 = 54 7n+1 .
The general solution is
5 n+1
an = C(3n ) + 7 .
4
With a0 = 2 we find C = − 27
4 and
27 n 5 5 1
an = − (3 ) + 7n+1 = 7n+1 − (3n+3 )
4 4 4 4
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Solve the recurrence relation
an − 3an−1 = 5(3n ), n ≥ 1, a0 = 2
Solution
(h) (h)
As in Example 20, an = C(3n ), but here an and f (n) are not linearly
(p)
independent. As a result, we consider a particular solution an of the
n (p) n
form An(3 ). Substituting an = An(3 ) into the given relation we
have
Hence
(h) (p)
an = an + an = (C + 5n)3n , n ≥ 2.
With a0 = 2, the unique solution is
an = (2 + 5n)3n
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example 1
Assume that the population of a country in 2015 was 7 million and
has been growing 2.5% a year
1 Set up a recurrence relation for the number of population of the
country n years after 2015.
2 Find an explicit formula for the population of the country n year
after 2015.
3 What will the population of the country be in 2021?
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Solution
1 Let pn be the population after n years. Then
2.5
pn = pn−1 + pn−1
100
That is,
pn = 1.025pn−1
2 Solving the above equation,we obtain pn = p0 (1.025)n . Since
p0 = 7, 000, 000, it follows P0 = 4, 271, 897. Hence,
pn = 7, 000, 000(1.025n )
3 n = 2021 − 2015 = 6. Therefore
p6 = 7, 000, 000(1.025)6
= 8, 117, 854
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example 2
Mr. Johnson has taken a loan of 9,000,000 for a bank, and he is
required to pay back the money in 48 months. Suppose that 1.5% is
the interest rate per month for the loan.
1 Formulate this a recurrence relation in order to determine the
constant payment P that Mr. Johnson must make every month.
2 Solve the recurrence relation in (b)(i).
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Solution
1 Let an denote the amount still owed on the loan at the end of the
nth period. Then at the end of the (n + 1)st period, the amount
Paul still owes on his loan is an (amount he owed at the nth
period)+ ran (the interest that accrued during the (n + 1)st
period)-P (the payment she made at the end of the (n + 1)st
period). This gives the recurrence relation
an+1 = an + ran − P, 0 ≤ n ≤ T − 1, a0 = S, aT = 0.
Solution, cont...
(h) (p)
2 For this relation, an = c(1 + r )n , while an = A, since −P is a
solution of the associated non-homogeneous relation. With
(p)
an = A, we find
A − (1 + r )A = −P,
so A = Pr . From a0 = S, we obtain an = (S − P/r )(1 + r )n + P/r ,
0 ≤ n ≤ T.
Since 0 = aT = (S − P/r )(1 + r )T + P/r , it follows that
Example 3
On the first day of a new year, Joseph deposits $1000 in an account
that pays 6% interest compounded monthly. At the beginning of each
month he adds $200 to his account. If he continues to do this for the
next four years (so that he makes 47 additional deposits of $200),
how much will his account be worth exactly four years after he
opened it?
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Solution
Let pn be the value of the account n months after January 1 of the
year the account is started.
p0 = 1000
p1 = (1.005)p0 + 200
pn+1 = 1.005pn + 200 0 ≤ n ≤ 46.
(h)
The homogeneous solution is pn = C(1.005)n and The particular
(p)
solution is pp = A.
Generating Functions
b
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Introduction
Example
Flora has 12 oranges and she wants to distribute these oranges to
her three children, Grace, Mary and Frank, so that Grace gets at least
4, Mary and Frank get at least 2, but Frank gets no more than 5. How
many ways Flora can distribute the oranges?
Solution
We are looking for integer solution to
x1 + x2 + x3 = 12, 4 ≤ x1 , 2 ≤ x2 , 2 ≤ x3 ≤ 5
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
If there is at least 24 of each color Red, Green, White and Black
beans. How many ways can a child select 24 of these beans so that
he can has an even number of white and at least six black beans.
Solution
Polynomial associated with bean colors are:
Red: x 0 + x 1 + x 2 + . . . + x 24 = 1 + x + x 2 + . . . + x 24
Green: x 0 + x 1 + x 2 + . . . + x 24 = 1 + x + x 2 + . . . + x 24
White: x 0 + x 2 + x 4 + . . . + x 24 = 1 + x 2 + x 4 + . . . + x 24
Black: x 6 + x 7 + x 8 + . . . + x 24
The answer to the problem is the coefficient of x 24 in the generating
function
f (x) =
(1 + x + x 2 + . . . + x 24 )2 (1 + x 2 + x 4 + . . . + x 24 )(x 6 + x 7 + x 8 + . . . + x 24 )
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
If there is at least 24 of each color Red, Green, White and Black
beans. How many ways can a child select 24 of these beans so that
he can has an even number of white and at least six black beans.
Solution
Polynomial associated with bean colors are:
Red: x 0 + x 1 + x 2 + . . . + x 24 = 1 + x + x 2 + . . . + x 24
Green: x 0 + x 1 + x 2 + . . . + x 24 = 1 + x + x 2 + . . . + x 24
White: x 0 + x 2 + x 4 + . . . + x 24 = 1 + x 2 + x 4 + . . . + x 24
Black: x 6 + x 7 + x 8 + . . . + x 24
The answer to the problem is the coefficient of x 24 in the generating
function
f (x) =
(1 + x + x 2 + . . . + x 24 )2 (1 + x 2 + x 4 + . . . + x 24 )(x 6 + x 7 + x 8 + . . . + x 24 )
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
How many integer solutions are there for the equation
x1 + x2 + x3 + x4 = 25, 0 ≤ xi (1 ≤ i ≤ 4)
Solution
The answer to this problem is the coefficient of x 25 in the generating
function
f (x) = (1 + x + x 2 + . . . + x 25 )4
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
What is the generating function of the sequence
1, 1, 1, 1, 1, 1, 1, 1?
Example
What is the generating function of the sequence
1, 1, 1, 1, 1, 1, 1, 1?
Example
What is the generating function of the sequence
1, 1, 1, 1, 1, 1, 1, 1?
Example
By the Binomial
Theorem,
(1 + x)n = n0 + n1 x + n2 x 2 + . . . + n−1
n
+ nn x n . So (1 + x)n is
n−1
x
the generating function for the sequence n0 , n1 , n2 , . . . n−1
n
n
, n
Example
1
P∞ 1
For |x| < 1, 1−x = 1 + x + x 2 + x 3 + . . . = k=0 x k . So f (x) = 1−x is
the generating function for the sequence 1, 1, 1, 1, . . .
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
From Example 27
∞
1 X
= 1 + x + x2 + x3 + . . . = xk.
1−x
k=0
1
So f (x) = 1−x . Taking derivative on both side, we get
1
P∞ 1
(1−x)2
= 1 + 2x + 3x 2 + 4x 3 + . . . = k=0 x k . So f (x) = 1−x .
1
Consequently, f (x) = (1−x) 2 is the generating function for the
sequence 1, 2, 3, 4, ....
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Find −7
5 .
Solution
−n
= (−1)r n+rr −1 . Substitute n = 7 and r = 5 to obtain
r
−7 5 7+5−1 11 11!
= (−1) = −1 =− = −462
5 5 5 5!6!
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Hence, (1 + x)−n = −n −n −n −n
2 3
0 + 1 x + 2 x + 3 x . . .. Therefore,
−n
1
−n
f (x) = (1+x)n is a generating function of the sequence 0 , 1 ,
−n
−n
2 , 3 , ...
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
1
Find the coefficient of x 5 in (1−2x)7
Solution
Let y = −2x, then by Example 30,
∞ ∞
X −7 X −7
(1 + y )−7 = yr = (2x)r .
r r
r =0 r =0
∞
1 r n+r −1
X
= (−1) (−x)r
(1 − x)n r
r =0
∞
X n+r −1 r
= x
r
r =0
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Example
Find the coefficient of x 5 in f (x) = (1 + 3x)−1/3
Solution
∞
X (−1/3)(−1/3 − 1)(−1/3 − 2) . . . (−1/3 − r + 1) r r
(1+3x)−1/3 = 1+ ( 3 x ).
r!
r =1
Example
Determine the coefficient of x 15 in f (x) = (x 2 + x 3 + x 4 + x 5 + . . .)4
Example
Theorem
P∞ k
P∞ k
Let f (x) = P k=0 ak x and f (x) = k=0 bk x . Then
∞ k
f (x).g(x) = k=0 ck x , where
ck = a0 bk + a1 bk−1 + a2 bk−2 + . . . + ak−1 b1 + ak b0
Introduction Basic Counting Principles Principle of Inclusion-Exclusion Recurrence Relations Generating Functions
Solution of Example 34
The choice for the number of oranges each child receives is given by
(x 3 + x 4 + x 5 + x 6 + x 7 + x 8 ). Since there are 4 children, the resulting
generating function is
f (x) = (x 3 + x 4 + x 5 + x 6 + x 7 + x 8 )4
= x 12 (1 + x + x 2 + x 3 + x 4 + x 5 )4
4
1 − x6
12
= x
1−x
g(x) = (1 − x)−4 = −4 −4 −4 2
0 + 1 (−x) + 2 (−x) + . . .
12 6 4 −4
Hence, the coefficient of x in (1 − x ) (1 − x) , by above theorem,
is
−4 4 −4 4 −4 15 4 9 4
1 − + = − + = 125
12 1 6 2 0 12 1 6 2