Advanced Counting Methods: Definition 1
Advanced Counting Methods: Definition 1
Introduction
Definition 1: If 𝑎 and 𝑏 are integers with 𝑎 ≠ 0, we say that 𝑎 divides 𝑏 if there is an integer 𝑐 such
𝑏
that 𝑏 = 𝑎𝑐 (or equivalently, if 𝑎 is an integer). When 𝑎 divides 𝑏 we say that 𝑎 is a factor or divisor of
𝑏, and that 𝑏 is a multiple of 𝑎. The notation 𝑎 ∣ 𝑏 denotes that 𝑎 divides 𝑏. We write 𝑎 | 𝑏 when 𝑎 does
not divide 𝑏.
Note: Let 𝑛 and 𝑑 be positive integers. How many positive integers not exceeding 𝑛 are divisible by 𝑑?
The positive integers divisible by 𝑑 are all the integers of the form 𝑑𝑘, where 𝑘 is a positive integer.
Hence, the number of positive integers divisible by 𝑑 that do not exceed 𝑛 equals the number of integers
𝑛 𝑛
𝑘 with 0 < 𝑑𝑘 ≤ 𝑛 or with 0 < 𝑘 ≤ 𝑑 . Therefore, there are ⌊𝑑⌋ positive integers not exceeding 𝑛 that
are divisible by 𝑑.
1
Note: - The inclusion – exclusion principle is used to solve problems that ask for the number of elements
in a set that have none of ‘𝑛’ properties 𝑝1 , 𝑝2 , − − −, 𝑝𝑛 , denoted by 𝑁(𝑝1 ′ 𝑝2 ′ − − − 𝑝𝑛 ′ ) and defined
by
𝑁(𝑝1 ′ 𝑝2 ′ − − − 𝑝𝑛 ′ ) = 𝑁 − |𝐴1 ∪ 𝐴2 ∪ 𝐴3 ∪ − − − 𝐴𝑛 | , where 𝑁 is the no of elements which
belong to the universal set (𝑈) and 𝐴𝑖 ∈ 𝑈 and 𝐴𝑖 has property 𝑝𝑖
Example 1: 12 balls are painted in the following ways: 2 are painted red, 1 is painted blue, 1 is painted
white, 2 are painted red & blue, 1 is painted red & white and 3 are painted red, blue & white. How many
balls are not painted?
Solution:- Let 𝑝1 , 𝑝2 , 𝑝3 denotes the properties that a ball is painted red, blue, white respectively; then
𝑁(𝑝1 ) = 8, 𝑁(𝑝2 ) = 6, 𝑁(𝑝3 ) = 5, 𝑁(𝑝1 𝑝2 ) = 5, 𝑁(𝑝1 𝑝3 ) = 4 ,
𝑁(𝑝2 𝑝3 ) = 3, 𝑁(𝑝1 𝑝2 𝑝3 ) = 3
Then 𝑁(𝑝1 ′ 𝑝2 ′ 𝑝3 ′ ) = 𝑁 − |𝐴1 ∪ 𝐴2 ∪ 𝐴3 |
= 𝑁 − ( 𝑁(𝑝1 ) + 𝑁(𝑝2 ) + 𝑁(𝑝3 ) − 𝑁(𝑝1 𝑝2 −𝑁(𝑝1 𝑝3 ) − 𝑁(𝑝2 𝑝3 ) + 𝑁(𝑝1 𝑝2 𝑝3 ))
= 12– [8 + 6 + 5– 4– 3 + 3] = 2
Example 2: 1. Determine the number of positive integer ‘𝑛’ where 1 ≤ 𝑛 ≤ 100 and 𝑛 is not divisible
by 2, 3, 5.
Solution:- Here 𝑈 = {1, 2, 3, − − −, 100}, 𝑁 = 100,
For 𝑛 ∈ 𝑈, 𝑛 satisfies: 𝑝2 if 𝑛 is divisible by 2.
𝑝3 if 𝑛 is divisible by 3.
𝑝5 if 𝑛 is divisible by 5.
Note: - ⌊𝑥⌋ = is the greatest integer 𝑙 such that 𝑙 ≤ 𝑥.
100 100
Now, 𝑁(𝑝2 ) = ⌊ ⌋ = 50 , 𝐴2 = {2, 4, 6, − − −}, 𝑁(𝑝2 𝑝3 ) = ⌊ ⌋ = 16
2 6
100 100
𝑁(𝑝3 ) = ⌊ ⌋ = 33, 𝐴3 = {3, 6, 9, − − −}, 𝑁(𝑝2 𝑝5 ) = ⌊ 10 ⌋ = 10
3
100 100
𝑁(𝑝5 ) = ⌊ ⌋ = 20, 𝐴5 = {5, 10, 15, − − −}, 𝑁(𝑝3 𝑝5 ) = ⌊ 15 ⌋ = 6
5
100
𝑁(𝑝2 𝑝3 𝑝5 ) = ⌊ 30 ⌋ = 3
2
2. Using question (1);
i) Find the number of positive integers that are not divisible by 2 nor by 5 but are divisible by 3?
ii) Find the number of positive integers that are not divisible by 5 but are divisible
by 2 &3
Solution:- i) 𝑁(𝑝2 ′ 𝑝3 𝑝5 ′ ) = 𝑁(𝑝3 ) − 𝑁(𝑝2 𝑝3 ) − 𝑁(𝑝3 𝑝5 ) + 𝑁(𝑝2 𝑝3 𝑝5) = 33-16-6+3
ii) 𝑁(𝑝2 𝑝3 𝑝5 ′ ) = 𝑁(𝑝2 𝑝3 ) − 𝑁(𝑝2 𝑝3 𝑝5 ) = 16 − 3 = 13
3
4.3 Solution of recurrence relation
4.3.1 Homogeneous first order recurrence relation
Form: 𝑎𝑛 = 𝑟𝑎𝑛−1 , 𝑛 ≥ 1, 𝑎0 = 𝐴, 𝑟 is constant.
Its general solution is 𝑎𝑛 = 𝐴𝑟 𝑛
Example 5: Solve the recurrence relation
a) 𝑎𝑛 = 3𝑎𝑛−1 , 𝑛 ≥ 1, 𝑎0 = 5
b) 𝑎𝑛 = 7𝑎𝑛−1 , 𝑛 ≥ 1, 𝑎2 = 98
c) 𝑎𝑛 = 𝑛𝑎𝑛−1 , 𝑛 ≥ 1, 𝑎0 = 1
Solution:- a) Since 𝑟 = 3, 𝐴 = 5, then 𝑎𝑛 = 5(3𝑛 ) is the solution
b) Since 𝑟 = 7, 𝐴 = 𝑎0 = 2 because 𝑎2 = 7𝑎1 𝑎𝑛𝑑 𝑎1 = 7𝑎0 ⟹ 𝑎0 = 2
Then 𝑎𝑛 = 2(7𝑛 ) is the solution
c) Since the coefficient of 𝑎𝑛−1 = 𝑛 , which is not constant, we can not use the above
formula.
𝑎1 = 1, 𝑎0 = 1, 𝑎2 = 2𝑎1 = 2.1, 𝑎3 = 3𝑎2 = 3.2 , 𝑎4 = 4𝑎3 = 4.3.2 = 4!
𝑎5 = 5! . Thus 𝑎𝑛 = 𝑛!
4.3.2 Homogeneous second order recurrence relation
Form: 𝑐0 𝑎𝑛 + 𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 = 0, 𝑛 ≥ 2,. . . (∗)
where 𝑐0 , 𝑐1 , 𝑐2 ∈ ℝ (real no), 𝑐0 , 𝑐2 ≠ 0
First we assume for solutions of the form 𝑎𝑛 = 𝐴𝑟 𝑛 , where 𝐴, 𝑟 ≠ 0 and substituting
in to the above equation (∗), we have
𝑐0 𝐴𝑟 𝑛 + 𝑐1 𝐴𝑟 𝑛−1 + 𝑐2 𝐴𝑟 𝑛−2 = 0
⟹ 𝑐0 𝑟 2 + 𝑐1 𝑟 + 𝑐2 = 0 . . . . . . . (∗∗)
which is called the characteristic equation of the recurrence relation.
Then we may have two roots, 𝑟1 and 𝑟2 are called the characteristic roots.
For these roots we have 3 cases:
Case1:- Distinct real roots
In this case the general solution of the recurrence relation is
𝑎𝑛 = 𝑏1 𝑟1 𝑛 + 𝑏2 𝑟2 𝑛 , where 𝑏1 , 𝑏2 are arbitrary constants.
Example 6:- Solve the recurrence relations
a) 𝑎𝑛 + 𝑎𝑛−1 − 6𝑎𝑛−2 = 0, 𝑛 ≥ 2 , 𝑎0 = −1 , 𝑎1 = 8
b) 𝑎𝑛 = 𝑎𝑛−1 + 2𝑎𝑛−2 , 𝑛 ≥ 2 , 𝑎0 = 2 , 𝑎1 = 7
c) 𝑎𝑛+2 = 𝑎𝑛+1 + 𝑎𝑛 , 𝑛 ≥ 0 , 𝑎0 = 0 , 𝑎1 = 1
4
Solution:- a) Let 𝑎𝑛 = 𝑐𝑟 𝑛 with 𝑐, 𝑟 ≠ 0. Then substitute this on
𝑎𝑛 + 𝑎𝑛−1 − 6𝑎𝑛−2 = 0, we have 𝑐𝑟 𝑛 + 𝑐𝑟 𝑛−1 − 6𝑐𝑟 𝑛−2 = 0
⟹ 𝑟2 + 𝑟 − 6 = 0
⟹ 𝑟 = 2 𝑜𝑟 𝑟 = −3
Here we have two distinct real roots, so, we can 𝑎𝑛 = 2𝑛 and 𝑎𝑛 = (−3)𝑛 which are both solutions.
They are linearly independent solutions because one is not a multiple of the other, i.e, there is no real
constant 𝑘 such that (−3)𝑛 = 𝑘(2)𝑛 for all 𝑛𝜖ℕ.
Therefore its general solution is the form 𝑎𝑛 = 𝑏1 2𝑛 + 𝑏2 (−3)𝑛 , where 𝑏1 , 𝑏2 are arbitrary constants.
Now to determine 𝑏1 and 𝑏2 , use 𝑎0 = −1, 𝑎1 = 8 .
If 𝑎0 = −1 = 𝑏1 20 + 𝑏2 (−3)0 ⟹ −1 = 𝑏1 + 𝑏2
If 𝑎1 = 8 = 𝑏1 21 + 𝑏2 (−3)1 ⟹ 8 = 2𝑏1 − 3𝑏2
Solve this system of equations, we have 𝑏1 = 1, 𝑏2 = −2
∴ 𝑎𝑛 = 2𝑛 − 2(−3)𝑛 for 𝑛 ≥ 0 is its general solution.
b) Let 𝑎𝑛 = 𝑐𝑟 𝑛 with 𝑐, 𝑟 ≠ 0. Then substitute this on 𝑎𝑛 = 𝑎𝑛−1 + 2𝑎𝑛−2,
we have 𝑐𝑟 𝑛 = 𝑐𝑟 𝑛−1 + 2𝑐𝑟 𝑛−2
⟹ 𝑟2 − 𝑟 − 2 = 0
⟹ 𝑟 = −1 𝑜𝑟 𝑟 = 2
Here we have two distinct real roots, so, we can 𝑎𝑛 = 2𝑛 and 𝑎𝑛 = (−1)𝑛 which are both solutions.
They are linearly independent solutions because one is not a multiple of the other, i.e, there is no real
constant 𝑘 such that (−1)𝑛 = 𝑘(2)𝑛 for all 𝑛𝜖ℕ.
Therefore its general solution is the form 𝑎𝑛 = 𝑏1 2𝑛 + 𝑏2 (−1)𝑛 , where 𝑏1 , 𝑏2 are arbitrary constants.
Now to determine 𝑏1 and 𝑏2 , use 𝑎0 = 2, 𝑎1 = 7 .
If 𝑎0 = 2 = 𝑏1 20 + 𝑏2 (−1)0 ⟹ 2 = 𝑏1 + 𝑏2
If 𝑎1 = 7 = 𝑏1 21 + 𝑏2 (−1)1 ⟹ 7 = 2𝑏1 − 𝑏2
Solve this system of equations, we have 𝑏1 = 3, 𝑏2 = −1
∴ 𝑎𝑛 = 3(2𝑛 ) − 1(−1)𝑛 for 𝑛 ≥ 0 is its general solution.
5
𝑛 𝑛
1−√5 1+√5
Here we have two distinct real roots, so, we can 𝑎𝑛 = ( ) and 𝑎𝑛 = ( ) which are both
2 2
solutions. They are linearly independent solutions because one is not a multiple of the other, i.e, there is
𝑛 𝑛
1−√5 1+√5
no real constant 𝑘 such that ( ) = 𝑘( ) for all 𝑛𝜖ℕ.
2 2
𝑛 𝑛
1−√5 1+√5
Therefore its general solution is the form 𝑎𝑛 = 𝑏1 ( ) + 𝑏2 ( ) , where 𝑏1 , 𝑏2 are arbitrary
2 2
constants.
Now to determine 𝑏1 and 𝑏2 , use 𝑎0 = 0, 𝑎1 = 1 .
0 0
1−√5 1+√5
If 𝑎0 = 0 = 𝑏1 ( ) + 𝑏2 ( ) ⟹ 0 = 𝑏1 + 𝑏2 ⟹ 𝑏1 = −𝑏2
2 2
1 1
1−√5 1+√5 1−√5 1+√5
If 𝑎1 = 1 = 𝑏1 ( ) + 𝑏2 ( ) ⟹ 1 = 𝑏1 ( ) + 𝑏2 ( )
2 2 2 2
1 1
Solve this system of equations, we have 𝑏1 = − , 𝑏2 =
√5 √5
𝑛 𝑛
1 1−√5 1 1+√5
∴ 𝑎𝑛 = − ( ) + ( ) for 𝑛 ≥ 0 is its general solution.
√5 2 √5 2
6
(𝑐𝑜𝑠𝜃 + 𝑖𝑠𝑖𝑛𝜃)𝑛 = 𝑐𝑜𝑠𝑛𝜃 + isin 𝑛𝜃 ; 𝑛 ≥ 0
If 𝑧 = 𝑥 + 𝑖𝑦 ∈ ℂ ; 𝑧 ≠ 0, where ℂ is complex number, y
7
b) Let 𝑎𝑛 = 𝑏𝑟 𝑛 , 𝑤ℎ𝑒𝑟𝑒 𝑏, 𝑟 ≠ 0 𝑎𝑛𝑑 𝑛 ≥ 0. Then 𝑎𝑛 = 2(𝑎𝑛−1 − 𝑎𝑛−2 ) becomes
𝑏𝑟 𝑛 = 2(𝑏𝑟 𝑛−1 − 𝑏𝑟 𝑛−2 )
⟹ 𝑟 𝑛 = 2(𝑟 𝑛−1 − 𝑟 𝑛−2 ) , since divide both side by 𝑏.
⟹ 𝑟 2 − 2𝑟 + 2 = 0
⟹ 𝑟1 = 1 + 𝑖, 𝑟2 = 1 − 𝑖 , Now since x = 1, y = 1, then 𝑟 = √2
Then the general solution is 𝑎𝑛 = 𝑏1 (1 + 𝑖)𝑛 + 𝑏2 (1 − 𝑖)𝑛
𝑛 𝑛 𝑛
⟹ 𝑎𝑛 = (√2) [𝑏1 (𝑐𝑜𝑠𝜋4 + 𝑖 𝑠𝑖𝑛𝜋4) + 𝑏2 (𝑐𝑜𝑠−𝜋
4
+ 𝑖 𝑠𝑖𝑛−𝜋
4
) ]
𝑛
= (√2) [𝑏1 (𝑐𝑜𝑠𝑛𝜋
4
+ 𝑖 𝑠𝑖𝑛𝑛𝜋
4
) + 𝑏2 (𝑐𝑜𝑠𝑛𝜋
4
− 𝑖 𝑠𝑖𝑛𝑛𝜋
4
)]
𝑛
= (√2) [(𝑏1 + 𝑏2 )𝑐𝑜𝑠𝑛𝜋
4
+ (𝑏1 − 𝑏2 )𝑖 𝑠𝑖𝑛𝑛𝜋
4
]
𝑛
= (√2) [𝑐1 𝑐𝑜𝑠𝑛𝜋
4
+ 𝑐2 𝑠𝑖𝑛𝑛𝜋
4
], where 𝑐1 = 𝑏1 + 𝑏2 , 𝑐2 = (𝑏1 − 𝑏2 )𝑖
To find 𝑐1 𝑎𝑛𝑑 𝑐2 , use initial condition, i.e.
0
𝑎0 = 1 = (√2) [𝑐1 𝑐𝑜𝑠 0 + 𝑐2 𝑠𝑖𝑛 0] ⟹ 𝑐1 = 1
1
𝑎1 = 2 = (√2) [𝑐1 𝑐𝑜𝑠𝜋4 + 𝑐2 𝑠𝑖𝑛𝜋4] ⟹ 2 = √2(𝑐1 √2
2
+ 𝑐2 √2
2
)
⟹ 2 = 𝑐1 + 𝑐2 ⟹ 𝑐2 = 1
𝑛
Thus the general solution is 𝑎𝑛 = (√2) [𝑐𝑜𝑠𝑛𝜋
4
+ 𝑠𝑖𝑛𝑛𝜋
4
].
c)Let 𝑎𝑛 = 𝑏𝑟 𝑛 , 𝑤ℎ𝑒𝑟𝑒 𝑏, 𝑟 ≠ 0 𝑎𝑛𝑑 𝑛 ≥ 0.Then 𝑎𝑛+2 + 4𝑎𝑛+1 + 16𝑎𝑛 = 0 becomes
𝑏𝑟 𝑛+2 + 4𝑏𝑟 𝑛+1 + 16𝑏𝑟 𝑛 = 0
⟹ 𝑟 2 + 4𝑟 + 16 = 0
⟹ 𝑟1 = −2 + 2√3 𝑖, 𝑟2 = −2 − 2√3 𝑖
Since 𝑥 = −2 𝑎𝑛𝑑 𝑦 = 2√3, 𝑟 = 4
Then the general solution is 𝑎𝑛 = 𝑏1 (−2 + 2√3𝑖)𝑛 + 𝑏2 (−2 − 2√3𝑖)𝑛
2𝜋 2𝜋 𝑛 −2𝜋 −2𝜋 𝑛
⟹ 𝑎𝑛 = 4𝑛 [𝑏1 (𝑐𝑜𝑠 + 𝑖 𝑠𝑖𝑛 ) + 𝑏2 (𝑐𝑜𝑠 + 𝑖 𝑠𝑖𝑛 ) ]
3 3 3 3
2𝜋 2𝜋 𝑛 2𝜋 2𝜋 𝑛
= 4𝑛 [𝑏1 (𝑐𝑜𝑠 + 𝑖 𝑠𝑖𝑛 ) + 𝑏2 (𝑐𝑜𝑠 − 𝑖 𝑠𝑖𝑛 ) ]
3 3 3 3
8
2𝑛𝜋 2𝑛𝜋
= 4𝑛 [𝑐1 𝑐𝑜𝑠 + 𝑐2 𝑠𝑖𝑛 ], where 𝑐1 = 𝑏1 + 𝑏2 , 𝑐1 = (𝑏1 − 𝑏2 )𝑖
3 3
7√3
⟹ 𝑐2 =
3
2𝑛𝜋 7√3 2𝑛𝜋
Hence the general solution is 𝑎𝑛 = 4𝑛 [2𝑐𝑜𝑠 + 𝑠𝑖𝑛 ].
3 3 3
9
35
Thus 𝑎𝑛 (ℎ) = 7𝑛
4
10
Solution:- 1st find 𝑎𝑛 (ℎ) ?
Let 𝑎𝑛 = 𝑐𝑟 𝑛 , where 𝑐, 𝑟 ≠ 0 and substitute on homogeneous. We have
𝑐𝑟 𝑛 = 6𝑐𝑟 𝑛−1 − 9𝑐𝑟 𝑛−2
⟹ 𝑟 𝑛 − 6𝑟 + 9 = 0
⟹ (𝑟 − 3)𝑛 = 0 has a single root with multiplicity 2. ∴ 𝑎𝑛 (ℎ) = 𝑏1 3𝑛 + 𝑏2 𝑛3𝑛
2nd find 𝑎𝑛 (𝑝) ?
Since 𝑟 = 3 is a root with multiplicity 𝑚 = 2, but 𝑟 = 2 is not a root of charactrstic equation for
homogeneous.Then
𝑎𝑛 (𝑝) has the form 𝑛2 𝐴3𝑛 if 𝑓(𝑛) = 3𝑛
𝑎𝑛 (𝑝) has the form 𝑛2 (𝑝1 𝑛 + 𝑝2 )3𝑛 if 𝑓(𝑛) = 𝑛3𝑛
𝑎𝑛 (𝑝) has the form (𝑝2 𝑛2 + 𝑝1 𝑛 + 𝑝0 )2𝑛 if 𝑓(𝑛) = 𝑛2 2𝑛
𝑎𝑛 (𝑝) has the form 𝑛2 (𝑝2 𝑛2 + 𝑝1 𝑛 + 𝑝0 )3𝑛 if 𝑓(𝑛) = (𝑛 + 1)2 3𝑛
4.5 Method of undetermined coefficients
The method of undetermined coefficients (uc) is a procedure for finding a particular solution 𝑎𝑛 (𝑝) of a
recurrence relation of the form: 𝑐0 𝑎𝑛 + 𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + . . . + 𝑐𝑘 𝑎𝑛−𝑘 = 𝑓(𝑛) --------------- (*)
𝑐0, 𝑐1 , 𝑐2 , . . . , 𝑐𝑘 are real numbers, 𝑐0, 𝑐𝑘 ≠ 0 and 𝑘 ∈ 𝑁
The method requires that the function 𝑓(𝑛) in the equation (*) be one of the following three forms:
11
Solution:- a) Let 𝑎𝑛 (ℎ) = 𝐴𝑟 𝑛 , where 𝐴 is constant, 𝑟 ≠ 0. and substitute this on the
homogeneous 𝑎𝑛 = 3𝑎𝑛−1, we have 𝑎𝑛 (ℎ) = 𝐴3𝑛
since 𝑓(𝑛) = 2𝑛 is a polynomial with degree 1, 𝑎𝑛 (𝑝) is a linear function in 𝑛, i.e, 𝑎𝑛 (𝑝) =
𝑐 𝑛 + 𝑑, where 𝑐, 𝑑 are constants.Then
𝑎𝑛 = 3𝑎𝑛−1 + 2𝑛 becomes 𝑐 𝑛 + 𝑑 = 3(𝑐(𝑛 − 1) + 𝑑) + 2𝑛
⟹ 𝑐 𝑛 + 𝑑 = 3𝑐 𝑛 − 3𝑐 + 3𝑑 + 2𝑛
⟹ (3𝑐 + 2 − 𝑐)𝑛 − 3𝑐 = 𝑑 − 3𝑑
⟹ (2𝑐 + 2)𝑛 + (2𝑑 − 3𝑐) = 0
⟹ (2𝑐 + 2) = 1 and (2𝑑 − 3𝑐) = 0
−3
⟹ 𝑐 = −1, 𝑑 =
2
3
Thus 𝑎𝑛 (𝑝) = − 𝑛 − is a particular solution.
2
3
All solutions are the form 𝑎𝑛 = 𝑎𝑛 (ℎ) + 𝑎𝑛 (𝑝) = 𝑏1 3𝑛 − 𝑛 − 2
b) To find 𝑎𝑛 (ℎ)
Let 𝑎𝑛 = 𝑐𝑟 𝑛 , where 𝑐, 𝑟 ≠ 0 and substitute on 𝑎𝑛 = 5𝑎𝑛−1 − 6𝑎𝑛−2 , we have
𝑐𝑟 𝑛 = 5𝑐𝑟 𝑛−1 − 6𝑐𝑟 𝑛−2
⟹ 𝑟 2 − 5𝑟 + 6 = 0
5±√25−24
⟹𝑟= 2
Thus the roots are 𝑟1 = 3, 𝑟2 = 2
12