0% found this document useful (0 votes)
17 views

AdvanceCountingCh4 (1)

Uploaded by

Amanu Teach
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

AdvanceCountingCh4 (1)

Uploaded by

Amanu Teach
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Chapter-4: Advance Counting

January 14, 2025


Advance Counting

Inclusion-Exclusion Principle
Recurrence Relations
Second-Order Linear Homogeneous Recurrence Relations
with Constant Coefficients
Linear Second-Order Nonhomogeneous Recurrence
Relations withe constant coefficients
4.1 Inclusion-Exclusion Principle

Principle of Inclusion and Exclusion is a way to avoid


over counting
The inclusion-exclusion principle for two set: A and B can
be expressed as |A ∪ B| = |A| + |B| − |A ∩ B|

Inclusion-exclusion principle for 3 sets: A, B, C :


|A ∪ B ∪ C | = |A| + |B| + |C | − |A ∩ B| − |A ∩ C | − |B ∩ C |
+ |A ∩ B ∩ C |
Example
In a class of students taking a computer course, the following
were observed. Out of a total of 50 students 35 know C++ , 23
know Java, 18 know Python, 15 know both C++ and Java, 12
know both C++ and Python, 8 know both Java and Python,
45 knows at least one of the three languages.
(a) How many students know none of the three languages?
(b) How many students know all of the three languages?

Solution
(a) |U| = 50, |C ∪ J ∪ P| = 45 ⇒ |C ∩ J ∩ P| = 50 − 45 = 5
(b) 45 = 35 + 23 + 18 − 15 − 12 − 8 + x ⇒ x = 4
We want a system that generalizes further and doesn’t
necessarily deal explicitly with sets.
Definition
Let c1 , c2 be conditions on a finite set S with |S| = N
N(c1 ) =Number of elements in S satisfying c1
N(c2 ) =Number of elements satisfying c2
N(c1 c2 ) =Number of elements satisfying c1 and c2
N(c1 or c2 ) =Number of elements satisfying c1 or c2
= N(c1 ) + N(c2 ) − N(c1 c2 )
N(c¯1 ) = N − N(c1 ) Number of elements not satisfying c1 .
N(c¯1 c¯2 ) =Number of elements not satisfying c1 and c2
N(c¯1 c¯2 ) = Number of elements not c1 and not c2
= N − N(c1 ) − Nc2 + N(c1 c2 )
Example
How many bit strings of length 6 either start with a 1 or end
with 00?

Solution
N(c1 )= No of strings of length 6 starts with a 1.
N(c2 )= No of strings of length 6 ends with 00.
N(c1 c2 )= No of strings of length 6 starts with 1 and ends
with 00.
N(c1 ) =1 × 2 × 2 × 2 × 2 2 = 32
|{z} |{z} |{z} |{z} |{z}
0,1 0,1 0,1 0,1 0,1
N(c2 ) = 2 × 2 × 2 × 2 ×1 × 1 = 16
|{z} |{z} |{z} |{z}
0,1 0,1 0,1 0,1
N(c1 c2 ) = 1 × 2 × 2 × 2 × 1 × 1 = 8
|{z} |{z} |{z} |{z} |{z} |{z}
1 0,1 0,1 0,1 0 0
N(c1 or c2 ) = N(c1 )+N(c2 )−N(c1 c2 ) = 32+16−8 = 40
The Principle of Inclusion-Exclusion
Let S be a set with |S| = N and conditions ci , 1 ≤ i ≤ t
The number of elements of S that satisfy none of the
conditions ci , 1 ≤ i ≤ t is denoted by N = N(c¯1 c¯2 · · · c¯t ),
is given by

N =N − [N(c1 ) + N(c2 ) + · · · + N(ct )]


+ [N(c1 c2 ) + N(c1 c3 ) + · · · + N(ct−1 ct )]
− [N(c1 c2 c3 ) + · · · + N(ct−2 ct−1 ct )]
+ · · · + (−1)t N(c1 c2 · · · ct )
X X X
N =N − N(ci ) + N(ci cj ) − N(ci cj ck )
1≤i≤t 1≤i<j≤t 1≤i<j<k≤t
t
+ · · · (−1) N(c1 c2 · · · ct )

The number of elements in S that satisfy at least one


condition ci , is given by
N(c1 or c2 or · · · or ct ) = N − N
We write: S0 = N

S1 = N(c1 ) + N(c2 ) + · · · + N(ct )


S2 = N(c1 c2 ) + · · · + N(c1 ct ) + N(c2 c3 ) + · · · + N(ct−1 ct )
N(ci1 ci2 · · · cik ), 1 ≤ k ≤ t
P
In general, Sk =
 
t
Sk has k
entries.
N = S0 − S1 + S2 − S3 + · · · + (−1)t St .

Example
How many n ∈ {1, 2, · · · , 100} is n not divisible by 2,3, and 5?

(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 and 3
Solution
S = {1, 2, 3, · , 100}, and N = 100.
For n ∈ S, n satisfies
condition c1 if n is divisible by 2.
condition c2 if n is divisible by 3.
condition c3 if n is divisible by 5.

N(c1 ) = ⌊ 100
2 ⌋ = 50 N(c1 c3 ) = ⌊ 100
10 ⌋ = 10

N(c2 ) = ⌊ 100
3 ⌋ = 33 N(c2 c3 ) = ⌊ 100
15 ⌋ = 6

N(c3 ) = ⌊ 100
5 ⌋ = 20 N(c1 c2 c3 ) = ⌊ 100
30 ⌋ = 3

N(c1 c2 ) = ⌊ 100
6 ⌋ = 16
Then the answer to this problem is N(c¯1 c¯2 c¯3 ).
Applying the principle of inclusion and exclusion, we find
N(c¯1 c¯2 c¯3 ) = N − S1 + S2 − S3
= N − [N(c1 ) + N(c2 ) + N(c2 )]
+ [N(c1 c2 ) + N(c1 c3 ) + N(c2 c3 )] − N(c1 c2 c3 )
= 100 − [50 + 33 + 20] + [16 + 10 + 6] − 3
= 26
Example
How many integer solutions are there to
x1 + x2 + x3 = 17,
where 0 ≤ xi ≤ 7, for 1 ≤ i ≤ 3.

Solution
Conditions: ci : xi ≥ 8
⇒ c¯i : xi ≤ 7
N(c¯1 c¯2 c¯3 ) = N − [N(c1 ) + N(c2 ) + N(c3 )]
+ [N(c1 c2 ) + N(c1 c3 ) + N(c2 c3 )] − N(c1 c2 c3 )
   
3+17−1 19
N= 17
= 17
= 19 × 9 = 171 = S0
c1 : x1 + x2 + x3 = 17, x1 ≥ 8, x2 ≥ 0, x3 ≥ 0.
x1′ + 8 + x2 + x3 = 17, x1′ ≥ 0, x2 ≥ 0, x3 ≥ 0.
x1′ + x2 + x3 = 9, x1′ ≥ 0, x2 ≥ 0, x3 ≥ 0.
   
3+9−1 11
⇒ N(c1 ) = 9
= 9
= 5(11) = 55
 
11
All conditions are the same, so N(c2 ) = 9
= N(c3 )
  
We can generalize S1 = 31 11 9
= 3(55) = 165
c1 c2 : x1 + x2 + x3 = 17, x1 ≥ 8, x2 ≥ 8, x3 ≥ 0
x1′ + 8 + x2′ + 8 + x3 = 17, xi′ ≥ 0, x2′ ≥ 0, x3 ≥ 0
x1′ + x2′ + x3 = 1, xi′ ≥ 0, x2′ ≥ 0, x3 ≥ 0
   
N(c1 c2 ) = 3+1−1
1
= 31 = 3
Because all the conditions are the same,
N(c1 c3 ) = 3 = N(c2 c3 )
  
We can generalize S2 = 32 31 = 9
Is it possible to have all the x ’s ≥ 8? No it’s not possible.
Because x1 + x2 + x3 has at least 24. N(c1 c2 c3 ) = 0 = S3
N(c¯1 c¯2 c¯3 ) = S0 − S1 + S2 − S3 = 171 − 165 + 9 − 0
= 15 number of integer solutions.
Number of onto functions from A to B with
|A| = m ≥ n = |B|
Total number of functions from A to B: nm
− Number of not onto functions from A to B
Number of onto function from A to B
Let A = {a1 , a2 , · · · , am },
B = {b1 , b2 · · · , bn }, and
S = the set of all functions from f : A → B.
Then N = |S| = S0 = nm .
Let ci (1 ≤ i ≤ n) be the condition on S where a function
f : A → B satisfies ci if bi is not in the range of f .
N(c¯i )=No of functions in S that have bi in their range
N(c¯1 c¯2 · · · c¯n )=No of onto functions f : A → B.
N(ci ) = (n − 1)m , because each element of B, except bi ,
can be used as the second component.
N(ci cj ) = (n − 2)m , 1 ≤ i < j ≤ n
 
n
S1 = [N(c1 ) + N(c2 ) · · · + N(cn )] = 1
(m − 1)n
 
S2 = [N(c1 c2 ) + N(c1 c3 ) · · · + N(cn−1 cn )] = n2 (n − 2)m
In general for each 1 ≤ k ≤ n, !
n
(n − k)m
X
Sk = N(ci1 ci2 · · · cik ) =
1≤i1 <i2 <···<ik ≤n k
By the principle of Inclusion and Exclusion, the number of
onto function from A to B is
N(c¯1 c¯2 · · · c¯n ) = S0 − S1 + S2 − S3 + · · · (−1)n Sn
! !
m n n
=n − (n − 1)m + (n − 2)m
1 2
!
n
− (n − 3)m + · · · + (−1)n (n − n)m
3
n
!
i n
(n − i)m
X
N(c¯1 c¯2 · · · c¯n ) = (−1)
i=0 i
For m < n, N(c¯1 c¯2 · · · c¯n ) = 0
The number of onto functions from A to B with
|A| = m ≥ n = |B| is given by
n
!
i n
(n − i)m
X
(−1)
i=0 i

Let |A| = 5 and |B| = 2. Then the number of


functions from A to B is ——–
onto functions from A to B is ——
one to one functions from A to B is ——
Example
Let |A| = 4 and |B| = 3. Then find the number of onto
functions from A to B.

Solution: |A| = m = 4 > 3 = n = |B|


n 3
! !
n i 3
(n − i)m = (−1)i (3 − i)4
X X
No onto fns = (−1)
i=0 i i=0 i
! ! !
4 3 3 3
=3 − (3 − 1)4 + (3 − 2)4 − (3 − 3)4
1 2 3
= 81 − 48 + 3 = 36
To find the cardinality of the union of n sets:
Include the cardinalities of the sets.
Exclude the cardinalities of the pairwise intersections.
Include the cardinalities of the triple-wise intersections.
Exclude the cardinalities of the quadruple-wise
intersections.
Include the cardinalities of the quintuple-wise
intersections.
Continue, until the cardinality of the n-tuple-wise
intersection is included (if n is odd) or excluded (n even).
Exercise

1 LetS = {1, 2, 3, 4, 5}. Then


(a) How many subsets are there?
(b) How many subsets are there of cardinality 3?
(c) How many subsets have {3, 4} as a subset?
(d) How many subsets of S contain at least one odd?
(e) How many subsets of S contain exactly one odd?
2 In how many ways can we arrange 15 flowers on 3 shelves
where each shelf has at least one, but not more than 6?
3 For how many n ∈ {1, 2, 3, · · · , 1000} is n a multiple of
3, 5, 0r 8?
4 If |A| = 4 and |B| = 4, then
(i) How many one to one functions from A to B.
(ii) How many onto functions fromA onto B.
4.2 Recurrence Relations

A sequence is an ordered list of numbers.


A recursive definition of a sequence specifies
Initial conditions
Recurrence relation
Definitions
A recurrence relation( or difference equation) for the
sequence {an } is an equation expressing an in terms of one or
more of the previous terms of the sequence: a0 , a1 , · · · , an−1 .
In the most general form, recurrence equation is defined
an = f (an−1 , an−2 , · · · , a0 ).
where f is a function.
A sequence is called a solution of a recurrence relation if its
terms satisfy the recurrence relation.
Method of solution
There are several methods for solving Recurrence: three of
which are popular
1 Repeated substitution method

2 Characteristic root method

3 Generating function method

Repeated substitution method:


It is also called re-substitution
We use when the recurrence relation is order 1:
a0 = c0 , an = c1 (n)an−1 + f (n)
Steps:
1 Substitute the values of an−1 in the equation, then the
values of an−2 , then the values of an−3 etc.
• These values are obtained from the given recurrence
equation by replacing n by n-1, n-2, etc in the defined
equation.
2 Guess the solution

3 prove the guessed result by mathematical induction.


Example: Consider the recurrence a0 = 1, an = 2an−1
an = 2an−1 , an−1 = 2an−2
= 2 (2an−2 ) = 22 an−2 , an−2 = 2an−3
= 22 (2an−3 ) = 23 an−3 , an−3 = 2an−4
For i, an = 2i an−i ,
i = n, an = 2n an−n = 2n a0 = 2n
Guess: an = 2n is the solution of the recurrence relation
(
(i) a0 = 20 = 20 = 1
Proof:
(ii) 2an−1 = 21 2n−1 = 2n = an
Characteristic Root Method
This method is suitable to solve linear recurrence relations
with constant coefficients.
A linear nonhomogeneous recurrence relation of order
k with constant coefficients has the form:

c0 an + c1 an−1 + c2 an−2 + · · · ck an−k = f (n), (1)

where ci′ s are real constants, n ≥ k, and c0 , ck , f (n) ̸= 0.


If f (n) = 0, then then the equation

c0 an + c1 an−1 + c2 an−2 + · · · ck an−k = 0 (2)

is the associated homogeneous of equation (1)


Example
a) an = 3an−1 − an−2 + n :
order 2, coefficients constant (c0 = 1, c1 = −3, c2 = 1) ,
nonhomogeneous (f (n) = n ̸= 0).
2
b) an = an−1 + 2an−2 : order 2, non linear.
c) an = nan−1 :
order 1, linear, homogeneous (f (n) = 0), not with
constant coefficients (c0 = 1, c1 = −n).
(
F0 = 0, F1 = 1
(d) The Fibonacci sequence:
Fn = Fn−1 + Fn−2 , n ≥ 2
Order 2, Homogeneous (f (n) = 0),
Coefficients constant (c0 = 1, c1 = −1, c2 = −1)
Steps to solve Linear Nonhomogeneous Recurrence Relations:
c0 an + c1 an−1 + c2 an−2 + · · · ck an−k an−k = f (n), n ≥ k
1. Find the general homogeneous solution an(h) to
c0 an + c1 an−1 + c2 an−2 + · · · ck an−k an−k = 0
2. Find the particular solution an(p) for nonhomogeneous:
c0 an + c1 an−1 + c2 an−2 + · · · ck an−k an−k = f (n)
3. Write the general nonhomogeneous solution:

an = an(h) + an(p) (3)


To find the general homogeneous solution an(h) for
c0 an + c1 an−1 + c2 an−2 + · · · ck an−k an−k = 0 :
Look for solutions of the form: an = x n , x =constant.
c0 an + c1 an−1 + c2 an−2 + · · · ck an−k an−k = 0, n ≥ k
c0 x n + c1 x n−1 + c2 x n−2 + · · · + ck x n−k = 0
Dividing both sides by x n−k , we have
c0 x k − c1 x k−1 + c2 x k−2 + · · · + ck = 0
which is called the characteristic equation.

Example
What is the characteristic equation of
an − an−1 − 4an−2 + 4an−3 = 0?
Solution
The characteristic equation is r 3 − r 2 − 4r + 4 = 0

Theorem
Let x be a root of the characteristic equation. Then
an = cx n , c ̸= 0, satisfies the recurrence relation.
If an = r1n , an = r2n , · · · , an = rkn are solutions for
c0 an + c1 an−1 + · · · + ck an−k = 0 for n ≥ k, then
an = A1 r1n + A2 r2n + · · · + Ak rkn is also a solution,
where A′i s are arbitrary constants and ri′ s non zero
constants.
4.3 Second-Order Linear Homogeneous Recurrence
Relations with Constant Coefficients

A second order linear homogeneous recurrence relation


with constant coefficients can be written as

c0 an + c1 an−1 + c2 an−2 = 0, n≥2 (4)

where c0 ̸= 0, c1 , c2 ̸= 0 are constants.


Substituting an = cx n , x , c ̸= 0 constants, into equation
(5), we obtain

c0 x 2 + c1 x + c2 = 0 (5)

Equation (6) is called the characteristic equation.


The roots r1 , r2 of the characteristic equation
c0 x 2 + c1 x + c2 = 0 determine the following three cases:
(h)
1 r1 , r2 are distinct real numbers: an = A(r1n ) + B(r2n )
(h)
2 r1 , r2 are real, but r1 = r2 : an = r1n (A + Bn)
3 r1 , r2 are complex conjugate pairs a ± ib:
(h)
an = r n (A cos(nθ) + B sin(nθ))
  ,
√ −1 b
2 2
where r = |a + ib| = a + b and θ = tan a
In all cases r1 and r2 are called the characteristic roots.
Steps to solve 2nd order linear homogeneous
recurrence relation with constant coefficients:

Step-1 Write the characteristic equation: c0 x 2 + c1 x + c2 = 0


Step-2 Solve the characteristic equation:
q
−c1 ± c12 − 4c0 c2
x=
2c0
q q
−c1 − c12 − 4c0 c2 −c1 + c12 − 4c0 c2
r1 = , r2 =
2c0 2c0
Step-3 Write the general homogeneous solution:
Step-4 Determined A and B using the given conditions.
Example
1 Solve the recurrence relation
(a) an = 3an−1 , n ≥ 1, a0 = 5.
(b) 2an+2 − 11an+1 + 5an = 0, n ≥ 0, a0 = 2, a1 = −8.
(c) an+2 = 4an+1 − 4an , n ≥ 0, a0 = 1, a2 = 3.
(d) an = 2 (an−1 − an−2 ) , n ≥ 2, a0 = 1, a1 = 2.
(e) an+2 + 4an = 0, n ≥ 0, a0 = 2, a1 = 5.
2 Determine the constants b and c if an = c1 + c2 (7n ),
n ≥ 0 is a general solution of an+2 + ban+1 + can = 0

Solution
(a) a0 = 5, an = 3an−1 , n ≥ 1 :
X’c equation: x − 3 = 0 ⇒ r = 3.
General solution solution: an = A (3n ) .
Give Condition: a0 = 5 ⇒ A30 = 5 ⇒ A = 5.
So the solution is an = 5 · 3n .
(b) 2an+2 − 11an+1 + 5an = 0, n ≥ 0, a0 = 2, a1 = −8.
X’c equation: 2x 2 − 11x + 5 = 0 ⇒ x = 12 or x = 5.
General solution: an = A (2−n ) + B (5n ) .
(
a0 = 2 ⇒ A+B =2
Given Conditions:
a1 = −8 ⇒ A2 + 5B = −8
B = −2, A = 4.
Thus the solution is an = 22−n − 2 (5n ).
(c) an+2 = 4an+1 − 4an , n ≥ 0, a0 = 1, a2 = 3.
X’c equation: r 2 − 4r + 4 = 0 ⇒ r = 2.
General solution: an = (A + Bn) 2n .
(
a0 = 1 ⇒ A = 1
Given Conditions: 1
a1 = 3 ⇒ (A + B) 2 = 3 → B = 2
Hence the solution is an = (2 + n)2n−1 .
(d) a0 = 1, a1 = 2, an = 2 (an−1 − an−2 ) , n ≥ 2.
X’c equation: r 2 − 2r + 2 = 0 ⇒ r = 1 ± i.
√  
r = 2 and θ = tan−1 11 = π4
h i
General solution: an = 2n/2 A cos( π4 n) + B sin( π4 n) .
(
a0 = 1 ⇒ A = 1
Conditions:
a1 = 2 ⇒ A + B = 2 ⇒ B = 1
n
h    i
π π
Solution: an = 2 2 cos 4
n + sin 4
n .
(e) an+2 + 4an = 0. n ≥ 0, a0 = 2, a1 = 5
X’c equation: x 2 + 4 = 0 ⇒ x = ±4i
r = 4, θ = π/2
h    i
nπ nπ
General solution: an = 4n A cos 2
+ B sin 2
(
a0 = 2 ⇒ A = 2
Conditions: 5
a1 = 5 ⇒ 4B = 5, B = 4
h    i

Solution: an = 4n−1 8 cos 2
+ 5 sin nπ
2
2. an = c1 + c2 (7n ), is solution of an+2 + ban+1 + can = 0
X.c’s equation: (x − 1)(x − 7) = 0 or x 2 − 8x + 7 = 0
So the recurrence equation is an+2 − 8an+1 + 7an = 0
b=-8, and c=7

Exercise: Solve the following recurrence relation:


1 Solve an+2 − 4an = 0, n ≥ 0, a0 = 0, a1 = 4.
2 If a0 = 0, a1 = 1, a2 = 4 and a3 = 37 satisfying the
recurrence relation an+2 + ban+1 + can = 0, where n ≥ 0
and b, c are constants, determine b, c and solve.
4.4 Linear Second-Order Nonhomogeneous
Recurrence Relations with constant coefficients

Given a linear second order nonhomogeneous recurrence


relation with Constant Coefficients:
c0 an + c1 an−1 + c2 an−2 = f (n), c0 , ck ̸= 0.
Let an(h) be the general solution to the homogeneous part.
If f (n) = an pt (n) cos(nβ) or f (n) = an pt (n) sin(nβ) and
p(n) polynomial of degree t, then the particular solution is
an(p) = ns an (At nt + · · · + A1 n + A0 ) cos(nβ)
,
+ ns an (Bt nt + · · · + B0 ) sin(nβ)
where At , · · · , A0 , Bt , · · · , B0 are undetermined
coefficients, and
s = 0 if a is not a root of the characteristic equation.
s = 1 if a is one of two roots of the X’s equation
s = 2 if a is repeated root of the X’s equation
Nonhomogeneous Particular solution, an(p)
term, f(n)
c-constant A0
n A1 n + A0
n2 A2 n2 + A1 n + A0
bnn b n (A1 n + A0 )
b n n2 b n (A2 n2 + A1 n + A0 )
nb n cos(nβ) (A1 n + A0 )b n cos(nβ) + (B1 n + B0 )b n sin(nβ
Example
Solve an+1 = an + n, n ≥ 0, a0 = 3.

Solution
X’c equation: x − 1 = 0 ⇒ x = 1
General homogeneous solution: an(h) = A(1n ) = A
Particular solution: an(p) = n(A1 n + A0 ) = A1 n2 + A0 n
Find A1 , A0 , by substituting
an(p) = A1 n2 + A0 n in an+1 = an + n
(p)
an+1 = A1 (n + 1)2 + A0 (n + 1)
= An2 + (2A1 + A0 )n + (A1 + A0 )
an(p) = A1 n2 + A0 n
(p)
an+1 a− n(n) = 2A1 n + (A1 + A0 ) = n
(
2A1 = 1 ⇒ A1 = 12
A1 + A0 = 0 ⇒ A0 = −A1 = − 21
an(p) = 12 (n2 − n)
an = an(h) + an(p) = A + 12 (n2 − n)
Since a0 = 3 = A
Therefore an = 3 + 12 (n2 − n) is the solution.

Example
Solve an+2 − 6an+1 + 9an = 12(3n ), where n ≥ 0,
and a0 = 1, a1 = 4

Solution
X’C equation: x 2 − 6x + 9 = (x − 3)2 = 0 ⇒ x = 3
General homogeneous solution: an(h) = (A + Bn)3n
f (n) = 12(3n ) ⇒ an(p) = A0 n2 (3n )
(p) (p)
an+2 − 6an+1 + 9an(p) = A0 (n + 2)2 3n+2 − 6A0 (n + 1)2 3n+1
+ 9A0 n2 (3n )
 
= 3n+2 A0 2n2 − 2n2 + 4n − 4n + 4 − 2
 
= 2A0 3n+2
2A0 (3n+2 ) = 12(3n ) ⇒ A0 = 32
an(p) = 23 n2 (3n ) = 2n2 (3n−1 )
∴ an = (A + Bn)3n + 2n2 3n−1 is a general solution.
General solution: an = (A + Bn)3n + 2n2 3n−1 , n ≥ 0
Conditions: a0 = 1, a1 = 4
(
a0 = 1 ⇒ A = 1
a1 = 4 ⇒ (A + B) 3 + 2 = 4, B = − 31
Thus an = (2n2 − n + 3)3n−1 is the solution of the
recurrence relation an+2 − 6an+1 + 9an = 12(3n ), n ≥ 0,
and a0 = 1, a1 = 4
Steps to solve: c0 an + c1 an−1 + c2 an−2 = f (n), n ≥ 2,
a 0 = x0 , a 1 = x1 .
1 Write the X’c equation: c0 x 2 + c1 x + c2 = 0
replace an by x 2 , an−1 by x 1 = x , and an−2 by x 0 = 1,

−c1 ± c12 −4c0 c2
2 Solve the X’c equation: x = 2c0
3 Write the general homogeneous solution an(h)
(h)
an = Ar1n + Br2n for r1̸= r2 real roots
(h) n
c1 c1
an = (A + Bn) − 2c 0
for r1 = r2 = − 2c 0
(h)
an = [A cos(nθ) + B sin(nθ)] r n for
x = a ± ib = r (cos θ + i sin θ)
4. Guess an(p) , particular solution using f (n) and X’c roots.
For example, an − an−2 = 3n2n , n ≥ 2, a0 = 2, a1 = 6.
(p)
f (n) = 3n2n and an = ns (A1 n + A0 ) 2n , where
s=0 if 2 is not a root of the X’c equation
s=1 if 2 is a root of the X’c equation
s=2 if 2 is a repeated root of the X’c equation
X’c equation: x 2 − 1 = 0 ⇒ x = ±1
s=0 since 2 is not a root to the X’c equation.
(h)
an = A(1)n + B(−1)n = A + B(−1)n
(p)
an = (A1 n + A0 ) 2n , A1 , A0 undetermined coefficients.
5. Determine the values of the undetermined coefficents: by
substituting an(p) in the given recurrence relation.
an(p) = (A1 n + A0 ) 2n
(p)
an−2 = [A1 (n − 2) + A0 ] 2n−2
(p)
an(p) − an−2 = (4A1 n + 4A0 − A1 n + 2A1 − A0 ) 2n−2 = 3n2n
(3A1 n + 2A1 + 3A0 ) 2n−2 = 12n2n−2
(
3A1 = 12 ⇒ A1 = 4
2A1 + 3A0 = 0 ⇒ A0 = − 38
 
8
an(p) = 4n − 3
2n is the particular solution.
6. Write the general solution:  
(h) (p) 8
an = an + an = A + B(−1)n + 4n − 3 2n
7. Use the given conditions to find the values of the
arbitrary constants.
Conditions: a0
= 2, a1 = 6
 a0 = 2 ⇒ A + B − 83 = 2


a1 = 6 ⇒ A − B + 83 = 6

2A = 8 ⇒ A = 4

2
B= 3
 
an = 4 + 23 (−1)n + 4n − 8
3
2n is the solution.

Exercise
Solve the following recurrence relations
2
1 an+1 an = n , n ≥ 0, a0 = 1.
n
2 an − 2an−1 + an=2 = 2 , n ≥ 2, a0 = 1, a1 = 2.
Example (Application of Recurrence Relations: Bacteria)
The number of bacteria in a colony doubles every hour. If the
colony begins with 5 bacteria, how many present in n hours?
Find the recursive definition and solution
Solution
Recursive definition:
an = 2an−1 , n ≥ 1,
a0 = 5
Solution:
an = 2an−1
an = 2 (2an−2 ) = 22 an−2
an = 2 (2 (an−3 )) = 23 an−3
···
Example (Application of Recurrence Relations: Interest)
The bank pays 12% annual interest compounded monthly. You
initially invest 1000 Birr. Find the recursive definition and
explicit solution.
How much money is in the account after 1 year?

Solution
The sequence is a geometric sequence with first term
a0 = 100 and common ratio r = 1.01
Recursive definition:
a0 = 100, an = (1.01) an−1
Solution of the recurrence relation: an = 1000(1.01)n

You might also like