Recurrence Relations
In this section, we are going to learn a technique that can be used to solve many
challenging counting problems. This technique was developed based on a powerful
problem-solving strategy called divide-and-conquer, with which a given problem
is first divided into one or more smaller problems and then conquered by using the
solutions of those smaller problems. To make it happen, what we usually need is a
recurrence relation between the given problem and the smaller problems.
1 Recurrence Relations
In this section we study a variety of counting problems that can be modeled by
using recurrence relations.
Example 1 The number of bacteria in a colony doubles every hour. If a colony
begins with 5 bacteria, how many will be present in n hours?
To solve this problem, we let an be the number of bacteria at the end of n hours.
First, we have
a0 = 5
since there are initially 5 bacteria. Second, we have
an = 2 an1
whenever n is a positive integer, since the number of bacteria doubles every hour.
The first equation in the above (i.e., a0 = 5) is often referred to as the initial
condition, and the second equation (i.e., an = 2 an1 ) is referred to as the recurrence relation. The most important observation is that this recurrence relation,
together with the initial condition, can uniquely determine the value of an for all
nonnegative integers n. For example, to find a5 , as shown below, we may apply
2 a4
2 2 a3
2 2 2 a2
2 2 2 2 a1
2 2 2 2 2 a0
222225
160
Therefore, there are 160 bacteria at the end of 5 hours. Furthermore, from the
above computations, we can guess out that the explicit formulae for an is
an = 5 2 n
Mathematical induction can be used to prove that this formula is correct.
If we put all the an in a row, we will obtain a sequence of numbers
a0 , a 1 , a2 , , a n ,
There are at least three ways to write a sequence. First, we may write the first few
terms only, with the expectation that the general patterns are obvious. For instance,
we may write the above sequence as
5 20 , 5 21 , 5 22 , 5 23 ,
Second, we may give an explicit formula for its n-th term an . So, we may write
the above sequence as
an = 5 2n1 , n 1
The third way is the one we have seen earlier, using a recurrence relation together
with an initial condition. So, we may write the above sequence as
a0 = 5, an = 2 an1 , n 1.
For many counting problem, we essentially need to find out a sequence of an
written in the second way, i.e., an explicit formulae for an . Consider the counting
problem in Example 1, if we already know an = 5 2n1 , then it would be super
easy to find the number of bacteria at the end of 5 hours. However, as we can see,
how to directly find the explicit formula is often very challenging.
Alternatively, there is an indirect method to find the explicit formula for an ,
using the following two-step procedure.
- In the first step, find a recurrence relation and an initial condition to write
the sequence of an in the third way that we just mentioned above. This step
is referred to as modeling with recurrence relations.
- In the second step, find the explicit formula for an from the recurrence relation and the initial condition obtained in the first step. This step is referred
to as solving recurrence relations.
How to do the first step? How to do the second step? We will answer them one by
one in the next three weeks. Let us start with the general definition of recurrence
relation and initial conditions.
Definition 2 A recurrence relation for a sequence a0 , a1 , a2 , , an , is a formula that relates each term an to certain of its predecessors, an1 , an2 , , ank ,
where k is a nonnegative integer no larger than n. The initial conditions for such
a recurrence relation specify the values of a0 , a1 , a2 , , ak1 .
Example 3 An arithmetic sequence is a sequence with the recurrence relation
an = an1 + c, n 1
where c is a constant. Then, the explicit formula for an is
an = a0 + c n.
Example 4 A geometric sequence is a sequence with the recurrence relation
an = r an1 , n 1
where r is a constant. Then, the explicit formula for an is
an = a0 rn .
Example 5 Suppose that a person deposits $10,000 in a savings account at a bank
yielding 11% per year with interest compounded annually. How much will be in
the account after 20 years?
To solve this problem, let Pn denote the amount in the account after n years. Since
the amount in the account after n years shall be equal to the amount in the account
after n 1 years plus interest for the n-th year, the sequence {Pn } satisfies the
following recurrence relation:
Pn = Pn1 + 0.11 Pn1 = 1.11 Pn1 .
3
Let Hn denote the minimum number of moves required to solve the Tower of
Hanoi problem with n disks. At this moment, we totally have no idea what the
explicit formula is for Hn . Luckily, we have an indirect way to find an explicit
formula using a two-step procedure.
the first peg to the third peg, resulting in the pegs and disks as illustrated in the
figure below. The first n 1 disks remain on the second pegs. Finally, we have to
transfer the top n 1 disks from the second peg to the third peg, which once again
requires the minimum Hn1 moves (and, once again, we still dont know how to
make these moves). Now we can see from the figure below that all the disks are
placed on the third peg in order of size, with the largest at the bottom. In total, it
requires 2 Hn1 + 1 to transfer all the n disks to the third peg. Moreover, we
observe that it is impossible to do so with fewer moves. Therefore, we shall have
the following equation
Hn = 2 Hn1 + 1,
This question remains very challenging, and is left to the readers as an exercise.
You may go to http://www.mazeworks.com/hanoi to play this game.
Here is a funny stuff. Suppose that we want to transfer 64 disks and that every
move can be done very quickly in one second. How long will it take? It is an easy
question. It will take
H64 = 264 1 = 18, 446, 744, 073, 709, 551, 615
seconds to complete the transfer. In other words, by making one move per second
to transfer a small number of 64 disks, it will take you more than 500 billion years
to get it done, so the world should survive a while longer that it already has.
Example 7 In the thirteen century, Leonardo Pisano, commonly known as Fibonacci, posed the following problem. Suppose that a young pair of rabbits (one
of each sex) is placed on an island.
- A pair of rabbits does not breed until they are two months old.
- After they are two months old, each pair of rabbits produces another pair
every month.
- No rabbits ever die.
How many rabbits will there be at the end of n month?
Let fn be the number of pairs of rabbits after n months. First, we know that
the number of pairs of rabbits on the island at the end of the first month is f1 = 1.
Since this pair does not breed during the first two months, the number of pairs of
rabbits on the island is still one pair at the end of the second month, that is, f2 = 1.
To find the number of pairs after n months, let us take a look at the number of
pairs at the end of n 1 months, which shall be given by fn1 . Then, we take a
look at the number of new pairs born during the n-th month. Because only pairs
of rabbits of at least two months old can have a newborn pair, the pairs of rabbits
that can have a newborn pair during the n-th month must be all those pairs existing
on the island at the end of (n 2) months. Therefore, there will be fn2 newborn
pairs during the n-th month. In total, there are fn1 + fn2 pairs of rabbits on the
island at the end of n months. Therefore, we obtain the following equation
fn = fn1 + fn2 , n 3
which defines a recurrence relation. For this recurrence relation, we need two initial
equations in order to uniquely determine the value for each fn . They are
f1 = 1,
and f2 = 1.
The first few terms of the sequence defined by the above recurrence relation
and the initial conditions are:
1, 1, 2, 3, 5, 8, 13, 21, 34,
This is the famous Fibonacci sequence.
The next question is how to find an explicit formula for the Fibonacci sequence,
i.e., find an explicit formula for each fn ? You may have a try to find out the solution
before we start to learn some new mathematical techniques to solve it next week.
Example 8 Compute the number of 0-1 bit strings of length n that do not have two
consecutive 0s.
Let an denote the number of 0-1 bit strings of length n that do not have two
consecutive 0s. If n = 1, then we know from exhaustive enumeration that a1 = 2.
If n = 2, then we can also know from exhaustive enumeration that a2 = 3. Below
we list the three bit strings of length 2 that do not have two consecutive 0s:
0 1,
1 0,
1 1.
How to count the number an for any integer n 3? For brevity, let us call a bit
string valid if it does not have two consecutive 0s. Since a valid bit string must not
end with two consecutive bits 00, we distinguish two cases to count the number an
of all the valid bit strings.
- Case I: We count the number of the valid bit strings that end with a bit 1.
- Case II: We count the number of the valid bit strings that end with two bits
10.
Two observations thus follows. First, a valid bit string either belongs to the first
case (i.e., ending with a bit 1) or belongs to the second case (i.e., ending with two
bits 00). Second, any valid bit string that belongs to one case could not belong to
the other case. This is because there is no bit string ending with a bit 1 and also
ending with two bits 10 simultaneously. Note that these two observations allow us
to apply the sum rule in counting.
Let us focus on counting the number of the valid bit strings belonging to the
first case. We notice that, given any valid bit string of length n that ends with a
bit 1, its substring comprising of the first (n 1) bits is a valid bit string of length
(n 1) (this valid string is not necessary to end with a bit 1). On the other hand,
given any valid bit string of length (n 1), if we append it with a bit 1, then we
would obtain a valid bit string of length n which ends with a bit 1. Consequently,
9
the number of the valid bit strings of length n that ends with a bit 1 shall be equal
to the number of valid bit strings of length (n 1). Since the latter number is
given by an1 following the definition, there are also an1 many valid bit strings
of length n that ends with a bit 1.
Now we turn to counting the number of the valid bit strings belonging to the
second case. We can have similar observations as in the first case. Given any valid
bit string of length n that ends with two bits 10, its substring comprising of the first
(n 2) bits is a valid bit string of length (n 2) (this valid string is not necessary
to end with two bits 10). On the other hand, given any valid bit string of length
(n 2), if we append it with two bits 10, then we would obtain a valid bit string
of length n which ends with two bits 10. Consequently, the number of the valid bit
strings of length n that ends with two bits 10 shall be equal to the number of valid
bit strings of length (n 2). Since the latter number is given by an2 , there are
also an2 many valid bit strings of length n that ends with two bits 10.
Combining all the bit strings in these two cases by using the sum rule, we
can know that there are in total an1 + an2 many valid bit strings of length n.
Therefore, we obtain the following equation
an = an1 + an2 , n 3,
which defines a recurrence relation. Its initial conditions are
a1 = 2,
and a2 = 3.
The discussion on how to find the explicit formula for an or, say, how to solve
the above recurrence relation will be deferred until the next lecture. Of course, if
n is small, we can still easily find the value of an . For instance, if n = 6, then
a6 = 21, which means that there are 21 bit strings of length 6 that do not have two
consecutive 0s.
Example 9 A computer system considers a string of decimal digits a valid codeword if it contains an even number of 0 digits. For instance, 0123047869 is valid,
whereas 120987045608 is not valid. How many valid n-digit codewords are there?
10
As you might have known, we shall count such codewords by using a recurrence relation. Let an be the number of valid n-digit codewords. Note that a1 = 9
because there are 10 one-digit strings, among which only one string (i.e., the string
0) is not valid. We further call a codeword invalid if it is not valid.
To derive a recurrence relation, we need to consider how a valid n digit string
can be obtained from strings of (n 1) digits. We distinguish ten cases, depending
on what the last digit is.
- Case I: We count the number of the valid n-digit codewords that end with a
digit 0.
- Case II: We count the number of the valid n-digit codewords that end with a
digit 1.
- Case III: We count the number of the valid n-digit codewords that end with
a digit 2.
- Case IV: We count the number of the valid n-digit codewords that end with
a digit 3.
..
.
- Case X: We count the number of the valid n-digit codewords that end with a
digit 9.
Let us first consider the first case. We notice that, given any valid n-digit
codeword that ends with a digit 0, its substring comprising of the first (n 1)
digits would be an invalid (n 1)-digit codeword (i.e., containing an odd number
of 0 digits instead). On the other hand, given any invalid (n 1)-digit codeword,
if we append it with a digit 0, then we would obtain a valid n-digit codeword that
ends with a digit 0. Therefore, the number of the valid n-digit codewords that end
with a digit 0 shall be equal to the number of the invalid (n 1)-digit codewords.
Now we turn to count the number of the invalid (n 1)-digit codewords. We know
that an (n 1)-digit codeword is either valid or invalid but not both. Hence, the
total number of the (n 1)-digit codewords is equal to the number of the valid
(n 1)-digit codewords plus the number of the invalid (n 1)-digit codewords.
How many (n 1)-digit codewords are there in total? It is a problem of counting
(n 1)-permutations from a set of 10 elements with repetition allowed. Therefore,
there are 10n1 many (n 1)-digit codewords in total. How many valid (n 1)digit codewords are there? It is given by an1 . Finally, we obtain the number of
the invalid (n 1)-digit codewords being 10n1 an1 , which is also the number
of the valid n-digit codewords that end with a digit 0.
11
Now we turn to the second case. By the similar arguments presented above,
we can know that the number of the valid n-digit codewords that end with a digit 1
shall be equal to the total number of the valid (n 1)-digit codewords. The latter
number is given by an1 .
We skip the discussions on the remaining cases. But, we can know that there
are an1 many valid n-digit codewords in each of the remaining cases, just like in
the second case above.
In total, by the sum rule, there are the valid n-digit codewords as many as
an = 10n1 an1 + 9 an1 = 8 an1 + 10n1 ,
which defines a recurrence relation as follows:
an = 8 an1 + 10n1 , n 2.
The initial condition is a1 = 9.
- linear because an1 and an2 appear in separate terms and to the first power.
- homogeneous because the total degree of each term is the same. Thus, there
is no constant term.
- with constant coefficients because both A and B are constant real numbers
that do not vary with n.
It is easy to check from the definition that
- The recurrence relation fn = fn1 + fn2 is a second-order linear homogeneous recurrence relation with constant coefficients.
- The recurrence relation an = an1 + a2n2 is not linear, as we have an2 to
the second power.
- The recurrence relation Hn = 2Hn1 + 1 is not homogeneous, as there is a
constant term on the right-hand side.
- The recurrence relation Hn = 2Hn1 is not second-order, as there is no term
Hn2 on the right-hand side.
- The recurrence relation cn = n cn1 + cn2 does not have constant coefficients for all the terms.
Also note that there shall have two initial conditions for this recurrence relation.
They give values for the first two terms a0 and a1 . Why are there exactly two initial
conditions needed?
Definition 11 Finding the explicit formula for a recurrence relation is often referred to as solving the recurrence relation. Thus, a sequence {an } given by the
explicit formula is called a solution of a recurrence relation if its terms satisfy both
the recurrence relation and the associated initial conditions.
It is worth noting that, given a recurrence relation and its associated initial conditions, there is only one unique solution {an }. It is not possible to have two different
sequences that could satisfy a same recurrence relation and the same initial conditions simultaneously. In other words, we simply say that the solution is unique.
Definition 12 Given a second-order linear homogeneous recurrence relation with
constant coefficients
an = Aan1 + Ban2 ,
13
a1 a0 r2
r1 r2
and
h2 =
a0 r1 a1
.
r1 r2
Although the proof is not required in this course, it does not hurt to have a look.
Proof: For a complete proof, we need to prove the following two things:
(I) an = h1 r1n + h2 r2n satisfies the two initial conditions.
(II) an = h1 r1n + h2 r2n satisfies the recurrence relation an = Aan1 + Ban2 .
14
a0 r1 a0 r2
a1 a0 r2 a0 r1 a1
+
=
= a0 .
r1 r2
r1 r2
r1 r2
a0 r1 a1
a1 r1 a1 r2
a1 a0 r2
r1 +
r2 =
= a1 .
r1 r2
r1 r2
r1 r2
Therefore, the explicit formula an = h1 r1n + h2 r2n holds for both n = 0 and n = 1.
In other words, an = h1 r1n + h2 r2n satisfies the two initial conditions.
To show (II), we first know that
r12 = Ar1 + B
and
16
Next we use the initial conditions to find the values of h1 and h2 in the same way
as we have done in the previous example. Then, we obtain two equations
{
h1 + h2
= 1
2 h1 h2 = 8
By solving them, we obtain h1 = 3 and h2 = 2. It follows that
an = 3 2n 2 (1)n .
This is the explicit formula that we want to find.
Example 16 Find an explicit formula for Fibonacci sequence.
Recall that the sequence of Fibonacci numbers satisfies the recurrence relation
fn = fn1 + fn2 with the initial conditions f1 = 1 and f2 = 1. The corresponding characteristic equation
r2 r 1 = 0,
which has two distinct roots
1+ 5
r1 =
2
and
1 5
r2 =
.
2
(
f2 = h1
(
)2
)2
1+ 5
1 5
+ h2
= 1,
2
2
h1 1+ 5 + h2 1 5
= 1
2
2
( )2
( )2
h1 1+ 5 + h2 1 5
= 1
2
2
17
and
1
h2 = .
5
, n 1.
2
2
5
5
Surprisingly, even though the formula for fn involves the irrational number
5, the Fibonacci
numbers
are all integers. It is also interesting to note that the
numbers 1+2 5 and 12 5 are related to the golden ratio of Greek mathematics.
Example 17 What is the solution of the recurrence relation
an = an1 + an2
with a1 = 1 and a2 = 3?
The question is left to the reader as an exercise.
2.1.2 The Single-Root Case
Now we consider the case where the characteristic equation has a single root r0 .
This root is said to have multiplicity two.
Theorem 18 Let an = Aan1 + Ban2 be a second-order linear homogeneous
recurrence relation with constant coefficients. Suppose that its characteristic equation r2 Ar B = 0 has only a single root r0 . Then, the unique solution of the
recurrence relation an = Aan1 + Ban2 is the sequence {an } given by the explicit formula
an = h1 r0n + h2 nr0n , n,
where h1 and h2 are two constant real numbers such that
h1 = a0
and
h2 =
a1 a0 r0
.
r0
Note that we already know the values of a0 and a1 because they are given in the
initial conditions of the recurrence relation.
Proof: For a complete proof, once again we need to prove the following two things:
18
a1 a0 r0
r0 = a1 .
r0
Therefore, the explicit formula an = h1 r0n + h2 nr0n holds for both n = 0 and
n = 1. In other words, an = h1 r0n + h2 nr0n satisfies the two initial conditions.
To show (II), we first know that
r02 = Ar0 + B
because r0 are the root of the characteristic equation r2 Ar B = 0. Moreover,
because r0 are the only root of the characteristic equation r2 Ar B = 0, we
shall have that
r2 Ar B = (r r0 )2 = r2 2r0 r + r02 ,
which implies that
A = 2r0
and B = r02 .
On the other hand, we know from the explicit formula an = h1 r1n + h2 r2n that
an1 = h1 r0n1 + h2 (n 1)r0n1
and
19
21
22
If an happens to also satisfy all the initial conditions, then it will become the
solution of the given nonhomogeneous recurrence relation. Please do not confuse
the particular solution with the solution.
As for the homogeneous recurrence relations, we distinguish two cases to study
the solution of the nonhomogeneous recurrence relations.
2.2.1 The Distinct-Roots Case
Theorem 24 Let an = Aan1 + Ban2 + F (n) be a second-order linear nonhomogeneous recurrence relation with constant coefficients. We suppose that,
- for the associated second-order linear homogeneous recurrence relation an =
Aan1 +Ban2 , its characteristic equation r2 ArB = 0 has two distinct
roots r1 and r2 ; and
- the nonhomogeneous recurrence relation an = Aan1 + Ban2 + F (n) has
(p)
a particular solution an .
Then, the unique solution of the nonhomogeneous recurrence relation an = Aan1 +
Ban2 + F (n) is the sequence {an } given by the explicit formula
an = h1 r1n + h2 r2n + a(p)
n ,
n,
h1 + h2 + a0 = a0
(p)
and h1 r1 + h2 r2 + a1 = a1 .
Unfortunately, this theorem does not tell us how to find a particular solution of
the nonhomogeneous recurrence relation. Let us first try an example before we
proceed to prove it.
23
109
20
and a1 =
483
20 ?
The given recurrence relation is the second-order linear nonhomogeneous recurrence relation with constant coefficients, and its associated second-order linear homogeneous recurrence relation is
an = 5an1 6an2 .
The corresponding characteristic equation of this homogeneous recurrence relation
is
r2 5r + 6 = 0.
Since r2 5r + 6 = (r 2)(r 3), there are two distinct roots r1 = 2 and r2 = 3.
Hence, the solution of the homogeneous recurrence relation can be written as
h1 2n + h2 3n .
Note that we do not have initial conditions for the associated homogeneous recurrence relation. So, we cannot determine the values for h1 and h2 at this moment.
To apply the above theorem, we need a particular solution of the nonhomogeneous recurrence relation. Because F (n) = 7n is the n-th power of a constant, a
reasonable trial solution is
n
a(p)
n =c7 ,
(p)
(p)
n.
24
n,
Therefore, we have c =
recurrence relation is
49
20 ,
49 n
7 .
20
Now it is the time to apply the above theorem. The unique solution of the
nonhomogeneous recurrence relation an = 5an1 6an2 + 7n is the sequence
{an } given by the explicit formula
a(p)
n =
an = h1 2n + h2 3n +
49 n
7 ,
20
n,
49 0
7 = a0
20
h1 21 + h2 31 +
and
49 1
7 = a1 .
20
As you can see, the above two equations are obtained by letting n = 0 and n = 1,
483
respectively. Using the given initial conditions (i.e., a0 = 109
20 and a1 = 20 ) for
the nonhomogeneous recurrence relation, we obtain two equations that can be used
to find the values of h1 and h2 :
= 109
h1 + h2 + 49
20
20
h1 2 + h2 3 +
49
20
7 =
483
20
49 n
7 ,
20
n,
We will discuss how to find a particular solution later at the end of this chapter.
25
To show (I), it is obvious because it is already required in the theorem (please refer
to the two equations used to determine the values of h1 and h2 ).
To show (II), we first know that
r12 = Ar1 + B
and
(p)
(p)
(p)
This verifies that the explicit formula an = h1 r1n + h2 r2n + an satisfies the recurrence relation an = Aan1 + Ban2 + F (n).
In conclusion, the sequence {an } defined by the explicit formula an = h1 r1n +
(p)
n
h2 r2 + an is the only solution of the recurrence relation an = Aan1 + Ban2 +
F (n).
2.2.2 The Single-Root Case
Theorem 26 Let an = Aan1 + Ban2 + F (n) be a second-order linear nonhomogeneous recurrence relation with constant coefficients. We suppose that,
26
n,
h1 + a0 = a0
and
(p)
h1 r0 + h2 r0 + a1 = a1 .
The proof can be done by using the same arguments as proving the previous theorem, and is left to the reader as an exercise.
Example 27 What is the solution of the recurrence relation
an = 6an1 9an2 + 2n
with a0 = 1 and a1 = 2?
The given recurrence relation in the above is the second-order linear nonhomogeneous recurrence relation with constant coefficients, and its associated secondorder linear homogeneous recurrence relation is
an = 6an1 9an2 .
The corresponding characteristic equation of this homogeneous recurrence relation
is
r2 5r + 6 = 0.
Since r2 6r + 9 = (r 3)2 , there is a single root r0 = 3. Hence, the solution of
the homogeneous recurrence relation can be written as
h1 3n + h2 n 3n .
Once again, note that we do not have initial conditions for the associated homogeneous recurrence relation. So, we cannot determine the values for h1 and h2 at this
moment.
27
To apply the above theorem, we need a particular solution of the nonhomogeneous recurrence relation. Because F (n) = 2n is a polynomial in n of degree one,
a reasonable trial solution is
a(p)
n = c n + d,
where c and d are two constants to be determined. To determine the values for
(p)
c and d, since an = c n + d is a particular solution of the nonhomogeneous
recurrence relation, we know from the definition that
(p)
(p)
a(p)
n = 6an1 9an2 + 2n,
n.
n,
and
c n + d = 3 c n + 12 c 3 d + 2n,
n,
and finally,
(4 c 2) n = 12 c 4 d,
n.
Note that the above equation shall hold for all the integers n 2. This is possible
only when we have both
4 c 2 = 0 and 12 c 4 d = 0.
They give two equations of the two unknown variables c and d. By solving them,
we obtain c = 21 and d = 32 . Thus, a particular solution of the nonhomogeneous
recurrence relation is
n 3
a(p)
+ .
n =
2 2
Now it is the time to apply the above theorem. The unique solution of the
nonhomogeneous recurrence relation an = 6an1 9an2 + 2n is the sequence
{an } given by the explicit formula
an = h1 3n + h2 n3n +
n 3
+ ,
2 2
n,
0 3
+ = a0
2 2
and
h1 31 + h2 1 31 +
1 3
+ = a1 .
2 2
As you can see, the above two equations are obtained by letting n = 0 and n = 1,
respectively. Using the given initial conditions (i.e., a0 = 1 and a1 = 2) for the
28
= 1
h1 + 32
h1 3 + h2 3 + 2 = 2
n,
(II) If s is one of the two distinct roots of the characteristic equation of the
associated linear homogeneous recurrence relation an = Aan1 + Ban2 ,
then there is a particular solution of the form
an(p) = (pt nt + pt1 nt1 + + p1 n + p0 ) n sn .
29
(III) If s is the only root of the characteristic equation of the associated linear
homogeneous recurrence relation an = Aan1 + Ban2 , then there is a
particular solution of the form
t
t1
a(p)
+ + p1 n + p0 ) n2 sn .
n = (pt n + pt1 n
(p)
(n2)
and finally,
2 p0 = 1.
By solving this equation, we have p0 = 21 . Finally, we find a particular solution of
the linear non-homogeneous recurrence relation an = 6an1 9an2 + 3n as
a(p)
n =
1 2 n
n 3 .
2
Now let us turn out attention to case (b). Since F (n) = n3n , it can be written
as F (n) = (d1 n + d0 ) sn where d1 = 1, d2 = 0, and s = 3. Therefore,
there is a particular solution of the given non-homogeneous recurrence relation
an = 6an1 9an2 + n3n in the form of
2
n
a(p)
n = (p1 n + p0 ) n 3 .
n 2.
Note that this last equation shall hold for all integers n 2, which necessarily
implies that
= 0
6 p1 1
2 p0 6 p1 = 0
31
It follows that
(p2 n2 +p1 n+p0 )2n
= 6(p2 (n1)2 +p1 (n1)+p0 )2n1 9(p2 (n2)2 +p1 (n2)+p0 )2n2 +n2 2n
and finally that
(p2 4) n2 + (p1 12 p2 ) n + (24 p2 6 p1 + p0 ) = 0,
n 2.
Once again, this last equation shall hold for all integers n 2, which necessarily
implies that
p2 4
= 0
p1 12 p2
= 0
24 p2 6 p1 + p0 = 0
By solving the above linear equations, we obtain p2 = 4, p1 = 48 and p0 = 192.
Finally, we find a particular solution of the linear non-homogeneous recurrence
relation an = 6an1 9an2 + n2 2n as
2
n
a(p)
n = (4 n + 48 n + 192) 2 .
It follows that
p2 n2 +p1 n+p0
= 6 (p2 (n 1)2 + p1 (n 1) + p0 ) 9 (p2 (n 2)2 + p1 (n 2) + p0 ) + n2 + 1
and finally that
(4 p2 1) n2 + (4 p1 24 p2 ) n + (30 p2 12 p1 + 4 p0 1) = 0,
Once again, this last equation shall hold for all integers n
implies that
4 p2 1
=
4 p1 24 p2
=
30 p2 12 p1 + 4 p0 1 =
32
n 2.
2, which necessarily
0
0
0
1 2 3
23
n + n+ .
4
2
8
33