Anda di halaman 1dari 33

Chapter 3.

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

the recurrence relation repeatedly until a0 is reached.


a5 =
=
=
=
=
=
=

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

The initial condition is P0 = 10, 000.


As we can see, the sequence of Pn is a geometric sequence with the constant
r = 1.11. Thus, the explicit formula for Pn is
Pn = 10000 1.11n .
Inserting n = 20 into the formula Pn = 10000 1.11n shows that after 20
years, there are 10000 1.1120 dollars in the account.
Example 6 The Tower of Hanoi is a puzzle of the late nineteenth century invented
by the French mathematician Edouard Lucas. In this puzzle, there are three pegs
mounted on a board together with disks of different sizes.
- Initially, these disks are placed on the first peg in order of size, with the
largest at the bottom.
- The rules of the puzzle allow disks to be moved one at a time from one peg
to another as long as a disk is never placed on top of a smaller disk.
- The goal of the puzzle is to have all the disks on the third peg in order of size,
with the largest at the bottom.
What is the minimum number of moves required?

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.

First, we try to set up a recurrence relation for the sequence of Hn . In order to


transfer the largest disk to the third peg, we have to first transfer the top n 1 disks
to the second peg, which requires the minimum Hn1 moves (although we dont
know how to make these moves yet). At this point, the pegs and disks are as seen in
the figure below. Now we can use only one move to transfer the largest disk from

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,

which defines a recurrence relation. The initial condition is


H1 = 1,
since we can transfer one disk from the first peg to the third peg with only one
move when n = 1.
In the second step of solving the entire puzzle, we need to find an explicit
formula that respect the recurrence relation just found in the first step. Here, we
use an iterative approach (i.e., repeatedly apply the recurrence relation) to do so,
as detailed below.
Hn = 2 Hn1 + 1
= 2(2 Hn2 + 1) + 1 = 22 Hn2 + 2 + 1
= 22 (2 Hn3 + 1) + 2 + 1 = 23 Hn3 + 22 + 2 + 1
..
.
= 2n1 H1 + 2n2 + 2n3 + + 2 + 1
= 2n1 + 2n2 + 2n3 + + 2 + 1
In the above, we have used the recurrence relation repeatedly to express Hn in
terms of previous terms of the sequence. To obtain the last equal sign, we used the
initial condition H1 = 1. Thus,
Hn = 2n1 + 2n2 + 2n3 + + 2 + 1
To continue, we multiply both sides of the above equation by two to obtain
2 Hn = 2 (2n1 + 2n2 + 2n3 + + 2 + 1) = 2n + 2n1 + 2n2 + + 4 + 2
and then find the difference
2Hn Hn = 2n +2n1 +2n2 + +4+2(2n1 +2n2 +2n3 + +2+1)
After all the common terms are taken away from the right-hand side in the above
equation, we finally obtain
Hn = 2 n 1
which is the explicit formula for Hn . For instance, if n = 3, then H3 = 23 1 = 7,
which means that we can use only 7 moves to transfer 3 disks from the first peg
to the third peg. Moreover, it is not possible to do so with fewer than 7 moves (of
course, you need to follow the game rule).
What is the minimum number of moves to transfer 5 disks? Now we can answer
this question very quickly: it is 31. However, do you know which moves they are?
6

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.

2 Solving Linear Recurrence Relations


We have seen how to define sequences by using recurrence relations, such as the
Fibonacci sequence, the sequence for solving the Tower of Hanoi, the arithmetic
sequences, and the geometric sequences. We also learned how to find explicit formulae for some of these sequences by using an iterative approach. In this section,
we will learn a systematic approach that can be used to find explicit formula for an
important class of sequences. These sequences are defined by recurrence relations
that express the terms of a sequence as linear combinations of previous terms. In
particular, the Fibonacci sequence is such a sequence, in which each term is the
sum of two preceding terms.

2.1 Linear Homogeneous Recurrence Relations with Constant Coefficients


Definition 10 A second-order linear homogeneous recurrence relation with constant coefficients is a recurrence relation of the form
an = Aan1 + Ban2 ,
where A and B are constant real numbers and B = 0.
In the above definition, the recurrence relation is called
- second-order because an is expressed in terms of the previous two terms
an1 and an2 (requiring B = 0).
12

- 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

we define the characteristic equation of this relation as


r2 Ar B = 0.
The solutions of this equation are called the characteristic roots of the recurrence
relation.
The characteristic equation in the above can also be equivalently written as
r2 = Ar + B.
You might want to compare the characteristic equation in this form with its corresponding recurrence relation.
We know from Linear Algebra that the characteristic equation in the above
either has two distinct roots or has only one root with multiplicity two. In other
words, if we let r1 and r2 denote the two roots of the characteristic equation, then
we have two cases: either r1 = r2 or r1 = r2 . In the first case, also called the
distinct-roots case, each root has multiplicity one. In the second case, also called
the single-root case, the only root has multiplicity two. As we shall see below, the
characteristic roots play an important role in finding the explicit formula for the
recurrence relation.
2.1.1 The Distinct-Roots Case
Theorem 13 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 two distinct roots r1 and r2 . Then, the unique solution
of the recurrence relation an = Aan1 + Ban2 is the sequence {an } given by the
explicit formula
an = h1 r1n + h2 r2n , n,
where h1 and h2 are two constant real numbers such that
h1 =

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

To show (I), we first let n = 0 to obtain


h1 r10 + h2 r20 = h1 + h1 =

a0 r1 a0 r2
a1 a0 r2 a0 r1 a1
+
=
= a0 .
r1 r2
r1 r2
r1 r2

Then, we let n = 1 to obtain


h1 r11 +h2 r21 = h1 r1 +h2 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 r22 = Ar2 + B

because r1 and r2 are roots of the characteristic equation r2 Ar B = 0. Then,


we know from the explicit formula an = h1 r1n + h2 r2n that
an1 = h1 r1n1 + h2 r2n1

and

an2 = h1 r1n2 + h2 r2n2 .

It hence follows that


(
)
(
)
Aan1 + Ban2 = A h1 r1n1 + h2 r2n1 + B h1 r1n2 + h2 r2n2
= h1 r1n2 (Ar1 + B) + h2 r2n2 (Ar2 + B)
= h1 r1n2 r12 + h2 r2n2 r22
= h1 r1n + h2 r2n
= an .
This indicates that the explicit formula an = h1 r1n + h2 r2n satisfies the recurrence
relation an = Aan1 + Ban2 .
In conclusion, the sequence {an } defined by the explicit formula an = h1 r1n +
n
h2 r2 is a solution of the recurrence relation an = Aan1 + Ban2 . Moreover, we
know it is the only solution.

Example 14 What is the solution of the recurrence relation
an = an1 + 2an2
with a0 = 2 and a1 = 7?
15

The corresponding characteristic equation of this recurrence relation is


r2 r 2 = 0.
Since r2 r 2 = (r 2)(r + 1), there are two distinct roots r1 = 2 and r2 = 1.
Hence, the explicit formula for an is given by
an = h1 2n + h2 (1)n .
How to find the values of h1 and h2 ? Although there are formula for computing
them in the above theorem, we can use the following approach. We first let n = 0
to obtain
a0 = h1 20 + h2 (1)0 = h1 + h2 = 2
and then let n = 1 to obtain
a1 = h1 21 + h2 (1)1 = 2 h1 h2 = 7.
As a result, we obtain two equations with only two unknown variables h1 and h2 .
That is,
{
h1 + h2
= 2
2 h1 h2 = 7
By solving them, we obtain h1 = 3 and h2 = 1. It follows that
an = 3 2n (1)n .
This is the explicit formula that we want to find.
Example 15 What is the solution of the recurrence relation
an = an1 + 2an2
with a0 = 1 and a1 = 8?
As shown in the previous example, the characteristic equation of the recurrence
relation an = an1 + 2an2 is
r2 r 2 = 0,
which has two distinct roots r1 = 2 and r2 = 1. Hence, the explicit formula for
an is given by
an = h1 2n + h2 (1)n .

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

Therefore, the explicit formula for Fibonacci numbers can be written as


(
(
)n
)n
1+ 5
1 5
fn = h1
+ h2
.
2
2
Once again, we need the initial conditions to determine the values for h1 and h2 .
So, we have
(
(
)
)
1+ 5
1 5
f1 = h1
+ h2
=1
2
2
and

(
f2 = h1

(
)2
)2
1+ 5
1 5
+ h2
= 1,
2
2

which give two linear equations as follows:


( )
( )

h1 1+ 5 + h2 1 5
= 1
2
2
( )2
( )2
h1 1+ 5 + h2 1 5
= 1
2
2
17

By solving them, we obtain


1
h1 =
5

and

1
h2 = .
5

Finally, we can know that the Fibonacci numbers are given by


(
(
)n
)n
1
1+ 5
1 5
1
fn =

, 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

(I) an = h1 r0n + h2 nr0n satisfies the two initial conditions.


(II) an = h1 r0n + h2 nr0n satisfies the recurrence relation an = Aan1 + Ban2 .
To show (I), we first let n = 0 to obtain
h1 r00 + h2 0 r00 = h1 = a0 .
Then, we let n = 1 to obtain
h1 r01 + h2 1 r01 = h1 r0 + h2 r0 = a0 r0 +

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

an2 = h1 r0n2 + h2 (n 2)r0n2 .

It hence follows that


]
]
[
[
Aan1 + Ban2 = A h1 r0n1 + h2 (n 1)r0n1 + B h1 r0n2 + h2 (n 2)r0n2
= h1 r0n2 (Ar0 + B) + h2 r0n2 [A(n 1)r0 + B(n 2)]
= h1 r0n2 r02 + h2 r0n2 [n(Ar0 + B) (Ar0 + 2B)]
[
]
= h1 r0n + h2 r0n2 nr02 (2r02 2r02 )
(
)
= h1 r0n + h2 r0n2 nr02
= h1 r0n + h2 nr0n
= an .
This indicates that the explicit formula an = h1 r0n +h2 nr0n satisfies the recurrence
relation an = Aan1 + Ban2 .
In conclusion, the sequence {an } defined by the explicit formula an = h1 r0n +
h2 nr0n is the only solution of the recurrence relation an = Aan1 + Ban2 . 
Example 19 What is the solution of the recurrence relation
an = 6an1 9an2
with a0 = 1 and a1 = 6?
The corresponding characteristic equation of this recurrence relation is
r2 6r + 9 = 0.
Since r2 6r + 9 = (r 3)2 , there is a single root r0 = 3. Hence, the explicit
formula for an is given by
an = h1 3n + h2 n 3n .
How to find the values of h1 and h2 this time? Applying the same technique as
before, we first let n = 0 to obtain
a0 = h1 30 + h2 0 30 = h1 = 1
20

and then let n = 1 to obtain


a1 = h1 31 + h2 1 31 = 3 h1 + 3 h2 = 6.
As a result, we obtain two equations with only two unknown variables h1 and h2 .
That is,
{
h1
= 1
2 h1 + h2 = 2
By solving them, we obtain h1 = 1 and h2 = 1. It follows that
an = 3n + n3n .
This is the explicit formula that we want to find. Alternatively, you may write this
explicit formula as
an = (1 + n)3n .
Example 20 Find the solution to the recurrence relation
an = 10an1 25an2
with the initial conditions a0 = 2 and a1 = 4.
Now its your turn to find the solution.

21

2.2 Linear Nonhomogeneous Recurrence Relations with Constant Coefficients


In this section, we will learn how to find the explicit formula for the recurrence
relations that are not homogeneous.
Definition 21 A second-order linear nonhomogeneous recurrence relation with
constant coefficients is a recurrence relation of the form
an = Aan1 + Ban2 + F (n),
where A and B are constant real numbers, B = 0, and F (n) is a function depending only on n but not identically zero.
If B = 0, then it becomes a first-order recurrence relation. If F (n) is identically
zero for all n, then it becomes a homogeneous recurrence relation.
Definition 22 Let an = Aan1 + Ban2 + F (n) be a second-order linear nonhomogeneous recurrence relation with constant coefficients. Then, the recurrence
relation
an = Aan1 + Ban2 ,
is called the associated second-order homogeneous recurrence relation.
We will see that the associated homogeneous recurrence relation plays an important role in the solution of the nonhomogeneous recurrence relation. Following
the definitions in the above, we can easily verify the following.
- The recurrence relation an = an1 an2 + 1301 is a second-order linear
nonhomogeneous recurrence relation with constant coefficients. Its associated second-order linear homogeneous recurrence relation with constant
coefficients is an = an1 an2 .
- The recurrence relation an = 1301an1 +an2 +n2 +n+1 is a second-order
linear nonhomogeneous recurrence relation with constant coefficients. Its associated second-order linear homogeneous recurrence relation with constant
coefficients is an = 1301an1 + an2 .
- The recurrence relation an = an1 + an2 + 1301n is a second-order linear
nonhomogeneous recurrence relation with constant coefficients. Its associated second-order linear homogeneous recurrence relation with constant
coefficients is an = an1 + an2 .

22

In the previous section, a solution refers to an explicit formula that is required


to satisfy both the recurrence relation and all the initial conditions. In order to
help solve the nonhomogeneous recurrence relations, we first present the following
definition.
Definition 23 Given a second-order linear nonhomogeneous recurrence relation
(p)
an = Aan1 + Ban2 + F (n) with constant coefficients, an explicit formula an
is said to be a particular solution if it satisfies this nonhomogeneous recurrence
relation an = Aan1 + Ban2 + F (n), but not necessarily satisfies the initial
conditions.
(p)

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,

where h1 and h2 are two constant real numbers such that


(p)

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

Example 25 What is the solution of the recurrence relation


an = 5an1 6an2 + 7n
with a0 =

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)

where c is a constant to be determined. To determine the value for c, since an =


c 7n is a particular solution of the nonhomogeneous recurrence relation, we know
from the definition that
(p)

(p)

an(p) = 5an1 6an2 + 7n ,

n.

It then follows that


c 7n = 5 c 7n1 6 c 7n2 + 7n ,
and
49 c = 35 c 6 c + 49,
and finally,
20 c = 49.

24

n,

Therefore, we have c =
recurrence relation is

49
20 ,

so that the particular solution of the nonhomogeneous

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,

where h1 and h2 are two constant real numbers such that


h1 20 + h2 30 +

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

By solving them, we obtain h1 = 2 and h2 = 1. It thus follows that


an = 2 2n + 3n +

49 n
7 ,
20

n,

This is the explicit formula that we want to find.


As we can see that the key to solving a nonhomogeneous recurrence relation is
finding a particular solution. However, there is no general method for finding such
a particular solution.1 Now let us go back to prove the theorem in the above.
Proof: For a complete proof, we need to prove the following two things:
(p)

(I) an = h1 r1n + h2 r2n + an satisfies the two initial conditions.


(p)

(II) an = h1 r1n + h2 r2n + an satisfies the nonhomogeneous recurrence relation


an = Aan1 + Ban2 + F (n).
1

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 r22 = Ar2 + B

because r1 and r2 are roots of the characteristic equation r2 Ar B = 0. Then,


(p)
we know from the explicit formula an = h1 r1n + h2 r2n + an that
(p)

an1 = h1 r1n1 + h2 r2n1 + an1

and

(p)

an2 = h1 r1n2 + h2 r2n2 + an2 .

(p)

Moreover, since an is a particular solution of the nonhomogeneous recurrence


relation, we know that
(p)

(p)

an(p) = Aan1 + Ban2 + F (n).


It hence follows that
Aan1 + Ban2 + F (n)
(
)
(
)
(p)
(p)
= A h1 r1n1 + h2 r2n1 + an1 + B h1 r1n2 + h2 r2n2 + an2 + F (n)
(
)
(p)
(p)
= h1 r1n2 (Ar1 + B) + h2 r2n2 (Ar2 + B) + Aan1 + Ban2 + F (n)
= h1 r1n2 r12 + h2 r2n2 r22 + a(p)
n
= h1 r1n + h2 r2n + an(p)
= an .
(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

- for the associated second-order linear homogeneous recurrence relation an =


Aan1 + Ban2 , its characteristic equation r2 Ar B = 0 has only one
single root r0 ; 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 r0n + h2 nr0n + a(p)
n ,

n,

where h1 and h2 are two constant real numbers such that


(p)

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.

It then follows that


c n + d = 6 [c (n 1) + d] 9 [c (n 2) + d] + 2n,

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,

where h1 and h2 are two constant real numbers such that


h1 30 + h2 0 30 +

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

nonhomogeneous recurrence relation, we obtain two equations that can be used to


find the values of h1 and h2 :

= 1
h1 + 32

h1 3 + h2 3 + 2 = 2

By solving them, we obtain h1 = 12 and h2 = 12 . It thus follows that


1
1
n 3
an = 3n + n3n + + ,
2
2
2 2

n,

This is the explicit formula that we want to find.


2.2.3 Finding a particular solution
As you have seen in the above, a particular solution plays an important role in
solving a linear non-homogeneous recurrence relation. In this section we shall
learn how to find a particular solution when the function F (n) is the product of a
polynomial in n and the n-th power of a constant, i.e., F (n) is in the form of
F (n) = (dt nt + dt1 nt1 + + d1 n + d0 ) sn
where dt , dt1 , . . . , d1 , d0 and s are real numbers. Below is the main theorem we
need to memorize.
Theorem 28 Let an = Aan1 + Ban2 + F (n) be a second-order linear nonhomogeneous recurrence relation with constant coefficients such that
F (n) = (dt nt + dt1 nt1 + + d1 n + d0 ) sn
where dt , dt1 , . . . , d1 , d0 and s are all constant real numbers. We distinguish
three cases below.
(I) If s is not a 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 ) sn .
n = (pt n + pt1 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

In the above, the values of pt , pt1 , . . . , p1 , p0 will be determined by using the


given linear non-homogeneous recurrence relation an = Aan1 + Ban2 + F (n).
Example 29 Find a particular solution of the linear non-homogeneous recurrence
relation an = 6an1 9an2 + F (n) in each of the following cases:
(a) when F (n) = 3n ;
(b) when F (n) = n3n ;
(c) when F (n) = n2 2n ;
(d) when F (n) = n2 + 1.
First note that the associated homogeneous recurrence relation of the given nonhomogeneous recurrence relation is an = 6an1 9an2 +F (n). Its corresponding
characteristic equation is r2 = 6r9, which has a single root r0 = 3 of multiplicity
two.
For (a), we can see that F (n) = d0 sn where d0 = 1 and s = 3. Then, by the
above theorem, there is a particular solution of the form
2
n
a(p)
n = p0 n 3 .
(p)

Since an is a particular solution of the given non-homogeneous recurrence rela(p)


tion, we know from its definition that an shall satisfy the given non-homogeneous
recurrence relation an = 6an1 9an2 + F (n); that is,
(p)

(p)

an(p) = 6an1 9 an2 + F (n).


It hence follows that
p0 n2 3n = 6 p0 (n 1)2 3n1 9p0 (n 2)2 3n2 + 3n .
(n1)

(n2)

Note that we already used an


= p0 (n1)2 3n1 , an
= p0 (n2)2 3n2 ,
n
and F (n) = 3 in the above. We simplify the expressions in the above equation to
obtain
p0 n2 = 2 p0 (n 1)2 p0 (n 2)2 + 1,
30

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 .

Once again, by the definition of the particular solution, we have


(p1 n+p0 )n2 3n
= 6(p1 (n1)+p0 )(n1)2 3n1 9(p1 (n2)+p0 )(n2)2 3n2 +n3n
and finally,
(6 p1 1) n + (2 p0 6 p1 ) = 0,

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

By solving the above linear equations, we obtain p1 = 61 and p0 = 21 . Finally,


we find a particular solution of the linear non-homogeneous recurrence relation
an = 6an1 9an2 + n3n as
(
)
1
1
(p)
n+
n2 3n .
an =
6
2
For (c), we have F (n) = (d2 n2 + d1 n + d0 ) sn where d2 = 1, d1 =
d0 = 0, and s = 2. Unlike in the previous two cases, s is no longer the root of
the characteristic equation. Therefore, there is a particular solution of the given
non-homogeneous recurrence relation an = 6an1 9an2 + n2 2n in the form of
2
n
a(p)
n = (p2 n + p1 n + p0 ) 2 .

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 .

Let us look at (d). We have F (n) = (d2 n2 + d1 n + d0 ) sn where d2 = 1,


d1 = 0, d0 = 1, and s = 1. Note that s is not the root of the characteristic equation.
Therefore, there is a particular solution of the given non-homogeneous recurrence
relation an = 6an1 9an2 + n2 + 1 in the form of
2
n
2
a(p)
n = (p2 n + p1 n + p0 ) 1 = p2 n + p1 n + p0 .

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

By solving the above linear equations, we obtain p2 = 41 , p1 = 23 and p0 = 23


8 .
Finally, we find a particular solution of the linear non-homogeneous recurrence
relation an = 6an1 9an2 + n2 2n as
an(p) =

1 2 3
23
n + n+ .
4
2
8

T HAT S ALL . H OPE YOU ENJOY COUNTING .

Any questions or suggestions please email to chenxin@ntu.edu.sg.

33

Anda mungkin juga menyukai