Recurrence Relations

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 a n be the number of bacteria at the end of n hours. First, we have a 0 =5 since there are initially 5 bacteria. Second, we have a n =2 · a n-1 whenever n is a positive integer, since the number of bacteria doubles every hour. The first equation in the above (i.e., a 0 =5) is often referred to as the initial condition, and the second equation (i.e., a n =2 · a n-1 ) is referred to as the re- currence relation. The most important observation is that this recurrence relation, together with the initial condition, can uniquely determine the value of a n for all nonnegative integers n. For example, to find a 5 , as shown below, we may apply 1

description

Mathematical Science

Transcript of Recurrence Relations

Page 1: Recurrence Relations

Chapter 3. Recurrence Relations

In this section, we are going to learn a technique that can be used to solve manychallenging counting problems. This technique was developed based on a powerfulproblem-solving strategy called divide-and-conquer, with which a given problemis first divided into one or more smaller problems and then conquered by using thesolutions of those smaller problems. To make it happen, what we usually need is arecurrence 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 byusing recurrence relations.

Example 1 The number of bacteria in a colony doubles every hour. If a colonybegins 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 · an−1

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 · an−1) is referred to as the re-currence relation. The most important observation is that this recurrence relation,together with the initial condition, can uniquely determine the value of an for allnonnegative integers n. For example, to find a5, as shown below, we may apply

1

Page 2: Recurrence Relations

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= 2 · 2 · 2 · 2 · 2 · 5= 160

Therefore, there are 160 bacteria at the end of 5 hours. Furthermore, from theabove computations, we can guess out that the explicit formulae for an is

an = 5 · 2n

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, a1, a2, · · · , an, · · ·

There are at least three ways to write a sequence. First, we may write the first fewterms 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 writethe above sequence as

an = 5 · 2n−1, ∀n ≥ 1

The third way is the one we have seen earlier, using a recurrence relation togetherwith an initial condition. So, we may write the above sequence as

a0 = 5, an = 2 · an−1, ∀n ≥ 1.

For many counting problem, we essentially need to find out a sequence of anwritten in the second way, i.e., an explicit formulae for an. Consider the countingproblem in Example 1, if we already know an = 5 · 2n−1, then it would be supereasy 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.

2

Page 3: Recurrence Relations

- In the first step, find a recurrence relation and an initial condition to writethe sequence of an in the third way that we just mentioned above. This stepis referred to as modeling with recurrence relations.

- In the second step, find the explicit formula for an from the recurrence rela-tion and the initial condition obtained in the first step. This step is referredto as solving recurrence relations.

How to do the first step? How to do the second step? We will answer them one byone in the next three weeks. Let us start with the general definition of recurrencerelation and initial conditions.

Definition 2 A recurrence relation for a sequence a0, a1, a2, · · · , an, · · · is a for-mula that relates each term an to certain of its predecessors, an−1, an−2, · · · , an−k,where k is a nonnegative integer no larger than n. The initial conditions for sucha recurrence relation specify the values of a0, a1, a2, · · · , ak−1.

Example 3 An arithmetic sequence is a sequence with the recurrence relation

an = an−1 + 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 · an−1, ∀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 bankyielding 11% per year with interest compounded annually. How much will be inthe account after 20 years?

To solve this problem, let Pn denote the amount in the account after n years. Sincethe amount in the account after n years shall be equal to the amount in the accountafter n − 1 years plus interest for the n-th year, the sequence {Pn} satisfies thefollowing recurrence relation:

Pn = Pn−1 + 0.11× Pn−1 = 1.11× Pn−1.

3

Page 4: Recurrence Relations

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 20years, there are 10000× 1.1120 dollars in the account.

Example 6 The Tower of Hanoi is a puzzle of the late nineteenth century inventedby the French mathematician Edouard Lucas. In this puzzle, there are three pegsmounted on a board together with disks of different sizes.

- Initially, these disks are placed on the first peg in order of size, with thelargest at the bottom.

- The rules of the puzzle allow disks to be moved one at a time from one pegto 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 ofHanoi problem with n disks. At this moment, we totally have no idea what theexplicit formula is for Hn. Luckily, we have an indirect way to find an explicitformula using a two-step procedure.

4

Page 5: Recurrence Relations

First, we try to set up a recurrence relation for the sequence of Hn. In order totransfer the largest disk to the third peg, we have to first transfer the top n−1 disksto the second peg, which requires the minimum Hn−1 moves (although we don’tknow how to make these moves yet). At this point, the pegs and disks are as seen inthe 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 thefigure 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 againrequires the minimum Hn−1 moves (and, once again, we still don’t know how tomake these moves). Now we can see from the figure below that all the disks areplaced on the third peg in order of size, with the largest at the bottom. In total, it

requires 2 · Hn−1 + 1 to transfer all the n disks to the third peg. Moreover, weobserve that it is impossible to do so with fewer moves. Therefore, we shall havethe following equation

Hn = 2 ·Hn−1 + 1,

5

Page 6: Recurrence Relations

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 onemove when n = 1.

In the second step of solving the entire puzzle, we need to find an explicitformula that ’respect’ the recurrence relation just found in the first step. Here, weuse an iterative approach (i.e., repeatedly apply the recurrence relation) to do so,as detailed below.

Hn = 2 ·Hn−1 + 1= 2(2 ·Hn−2 + 1) + 1 = 22 ·Hn−2 + 2 + 1= 22(2 ·Hn−3 + 1) + 2 + 1 = 23 ·Hn−3 + 22 + 2 + 1...= 2n−1 ·H1 + 2n−2 + 2n−3 + · · ·+ 2 + 1= 2n−1 + 2n−2 + 2n−3 + · · ·+ 2 + 1

In the above, we have used the recurrence relation repeatedly to express Hn interms of previous terms of the sequence. To obtain the last equal sign, we used theinitial condition H1 = 1. Thus,

Hn = 2n−1 + 2n−2 + 2n−3 + · · ·+ 2 + 1

To continue, we multiply both sides of the above equation by two to obtain

2 ·Hn = 2 · (2n−1+2n−2+2n−3+ · · ·+2+1) = 2n+2n−1+2n−2+ · · ·+4+2

and then find the difference

2 ·Hn−Hn = 2n+2n−1+2n−2+ · · ·+4+2−(2n−1+2n−2+2n−3+ · · ·+2+1)

After all the common terms are taken away from the right-hand side in the aboveequation, we finally obtain

Hn = 2n − 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 pegto the third peg. Moreover, it is not possible to do so with fewer than 7 moves (ofcourse, you need to follow the game rule).

What is the minimum number of moves to transfer 5 disks? Now we can answerthis question very quickly: it is 31. However, do you know which moves they are?

6

Page 7: Recurrence Relations

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 everymove can be done very quickly in one second. How long will it take? It is an easyquestion. 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 secondto transfer a small number of 64 disks, it will take you more than 500 billion yearsto 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 Fi-bonacci, posed the following problem. Suppose that a young pair of rabbits (oneof 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 pairevery month.

- No rabbits ever die.

How many rabbits will there be at the end of n month?

7

Page 8: Recurrence Relations

Let fn be the number of pairs of rabbits after n months. First, we know thatthe 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 ofrabbits 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 ofpairs at the end of n − 1 months, which shall be given by fn−1. Then, we take alook at the number of new pairs born during the n-th month. Because only pairsof rabbits of at least two months old can have a newborn pair, the pairs of rabbitsthat can have a newborn pair during the n-th month must be all those pairs existingon the island at the end of (n− 2) months. Therefore, there will be fn−2 newbornpairs during the n-th month. In total, there are fn−1 + fn−2 pairs of rabbits on theisland at the end of n months. Therefore, we obtain the following equation

fn = fn−1 + fn−2, ∀n ≥ 3

which defines a recurrence relation. For this recurrence relation, we need two initialequations 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 relationand 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 solutionbefore we start to learn some new mathematical techniques to solve it next week.

8

Page 9: Recurrence Relations

Example 8 Compute the number of 0-1 bit strings of length n that do not have twoconsecutive 0s.

Let an denote the number of 0-1 bit strings of length n that do not have twoconsecutive 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. Belowwe 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 bitstring valid if it does not have two consecutive 0s. Since a valid bit string must notend with two consecutive bits 00, we distinguish two cases to count the number anof 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 bits10.

Two observations thus follows. First, a valid bit string either belongs to the firstcase (i.e., ending with a bit 1) or belongs to the second case (i.e., ending with twobits 00). Second, any valid bit string that belongs to one case could not belong tothe other case. This is because there is no bit string ending with a bit 1 and alsoending with two bits 10 simultaneously. Note that these two observations allow usto apply the sum rule in counting.

Let us focus on counting the number of the valid bit strings belonging to thefirst case. We notice that, given any valid bit string of length n that ends with abit 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 wewould obtain a valid bit string of length n which ends with a bit 1. Consequently,

9

Page 10: Recurrence Relations

the number of the valid bit strings of length n that ends with a bit 1 shall be equalto the number of valid bit strings of length (n − 1). Since the latter number isgiven by an−1 following the definition, there are also an−1 many valid bit stringsof length n that ends with a bit 1.

Now we turn to counting the number of the valid bit strings belonging to thesecond case. We can have similar observations as in the first case. Given any validbit 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 necessaryto 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 stringof length n which ends with two bits 10. Consequently, the number of the valid bitstrings of length n that ends with two bits 10 shall be equal to the number of validbit strings of length (n − 2). Since the latter number is given by an−2, there arealso an−2 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, wecan know that there are in total an−1 + an−2 many valid bit strings of length n.Therefore, we obtain the following equation

an = an−1 + an−2, ∀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 solvethe above recurrence relation will be deferred until the next lecture. Of course, ifn is small, we can still easily find the value of an. For instance, if n = 6, thena6 = 21, which means that there are 21 bit strings of length 6 that do not have twoconsecutive 0s.

Example 9 A computer system considers a string of decimal digits a valid code-word 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

Page 11: Recurrence Relations

As you might have known, we shall count such codewords by using a recur-rence relation. Let an be the number of valid n-digit codewords. Note that a1 = 9because there are 10 one-digit strings, among which only one string (i.e., the string0) 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 stringcan be obtained from strings of (n−1) digits. We distinguish ten cases, dependingon what the last digit is.

- Case I: We count the number of the valid n-digit codewords that end with adigit 0.

- Case II: We count the number of the valid n-digit codewords that end with adigit 1.

- Case III: We count the number of the valid n-digit codewords that end witha digit 2.

- Case IV: We count the number of the valid n-digit codewords that end witha digit 3.

...

- Case X: We count the number of the valid n-digit codewords that end with adigit 9.

Let us first consider the first case. We notice that, given any valid n-digitcodeword 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 numberof 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 thatends with a digit 0. Therefore, the number of the valid n-digit codewords that endwith 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 knowthat an (n − 1)-digit codeword is either valid or invalid but not both. Hence, thetotal 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 10n−1 many (n− 1)-digit codewords in total. How many valid (n− 1)-digit codewords are there? It is given by an−1. Finally, we obtain the number ofthe invalid (n− 1)-digit codewords being 10n−1− an−1, which is also the numberof the valid n-digit codewords that end with a digit 0.

11

Page 12: Recurrence Relations

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 1shall be equal to the total number of the valid (n − 1)-digit codewords. The latternumber is given by an−1.

We skip the discussions on the remaining cases. But, we can know that thereare an−1 many valid n-digit codewords in each of the remaining cases, just like inthe second case above.

In total, by the sum rule, there are the valid n-digit codewords as many as

an = 10n−1 − an−1 + 9 · an−1 = 8 · an−1 + 10n−1,

which defines a recurrence relation as follows:

an = 8 · an−1 + 10n−1, ∀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 theFibonacci sequence, the sequence for solving the Tower of Hanoi, the arithmeticsequences, and the geometric sequences. We also learned how to find explicit for-mulae 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 animportant class of sequences. These sequences are defined by recurrence relationsthat express the terms of a sequence as linear combinations of previous terms. Inparticular, the Fibonacci sequence is such a sequence, in which each term is thesum of two preceding terms.

2.1 Linear Homogeneous Recurrence Relations with Constant Coef-ficients

Definition 10 A second-order linear homogeneous recurrence relation with con-stant coefficients is a recurrence relation of the form

an = Aan−1 +Ban−2,

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 termsan−1 and an−2 (requiring B ̸= 0).

12

Page 13: Recurrence Relations

- linear because an−1 and an−2 appear in separate terms and to the first power.

- homogeneous because the total degree of each term is the same. Thus, thereis no constant term.

- with constant coefficients because both A and B are constant real numbersthat do not vary with n.

It is easy to check from the definition that

- The recurrence relation fn = fn−1 + fn−2 is a second-order linear homoge-neous recurrence relation with constant coefficients.

- The recurrence relation an = an−1 + a2n−2 is not linear, as we have an−2 tothe second power.

- The recurrence relation Hn = 2Hn−1 + 1 is not homogeneous, as there is aconstant term on the right-hand side.

- The recurrence relation Hn = 2Hn−1 is not second-order, as there is no termHn−2 on the right-hand side.

- The recurrence relation cn = n · cn−1 + cn−2 does not have constant coeffi-cients 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 initialconditions needed?

Definition 11 Finding the explicit formula for a recurrence relation is often re-ferred to as solving the recurrence relation. Thus, a sequence {an} given by theexplicit formula is called a solution of a recurrence relation if its terms satisfy boththe recurrence relation and the associated initial conditions.

It is worth noting that, given a recurrence relation and its associated initial condi-tions, there is only one unique solution {an}. It is not possible to have two differentsequences that could satisfy a same recurrence relation and the same initial condi-tions simultaneously. In other words, we simply say that the solution is unique.

Definition 12 Given a second-order linear homogeneous recurrence relation withconstant coefficients

an = Aan−1 +Ban−2,

13

Page 14: Recurrence Relations

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 recurrencerelation.

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 corre-sponding recurrence relation.

We know from Linear Algebra that the characteristic equation in the aboveeither has two distinct roots or has only one root with multiplicity two. In otherwords, if we let r1 and r2 denote the two roots of the characteristic equation, thenwe have two cases: either r1 ̸= r2 or r1 = r2. In the first case, also called thedistinct-roots case, each root has multiplicity one. In the second case, also calledthe single-root case, the only root has multiplicity two. As we shall see below, thecharacteristic roots play an important role in finding the explicit formula for therecurrence relation.

2.1.1 The Distinct-Roots Case

Theorem 13 Let an = Aan−1 + Ban−2 be a second-order linear homogeneousrecurrence relation with constant coefficients. Suppose that its characteristic equa-tion r2 − Ar − B = 0 has two distinct roots r1 and r2. Then, the unique solutionof the recurrence relation an = Aan−1+Ban−2 is the sequence {an} given by theexplicit formula

an = h1rn1 + h2r

n2 , ∀n,

where h1 and h2 are two constant real numbers such that

h1 =a1 − a0r2r1 − r2

and h2 =a0r1 − a1r1 − 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 = h1rn1 + h2r

n2 satisfies the two initial conditions.

(II) an = h1rn1 + h2r

n2 satisfies the recurrence relation an = Aan−1 +Ban−2.

14

Page 15: Recurrence Relations

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

h1r01 + h2r

02 = h1 + h1 =

a1 − a0r2r1 − r2

+a0r1 − a1r1 − r2

=a0r1 − a0r2r1 − r2

= a0.

Then, we let n = 1 to obtain

h1r11+h2r

12 = h1r1+h2r2 =

a1 − a0r2r1 − r2

·r1+a0r1 − a1r1 − r2

·r2 =a1r1 − a1r2r1 − r2

= a1.

Therefore, the explicit formula an = h1rn1 +h2r

n2 holds for both n = 0 and n = 1.

In other words, an = h1rn1 + h2r

n2 satisfies the two initial conditions.

To show (II), we first know that

r21 = 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 = h1r

n1 + h2r

n2 that

an−1 = h1rn−11 + h2r

n−12 and an−2 = h1r

n−21 + h2r

n−22 .

It hence follows that

Aan−1 +Ban−2 = A(h1r

n−11 + h2r

n−12

)+B

(h1r

n−21 + h2r

n−22

)= h1r

n−21 (Ar1 +B) + h2r

n−22 (Ar2 +B)

= h1rn−21 r21 + h2r

n−22 r22

= h1rn1 + h2r

n2

= an.

This indicates that the explicit formula an = h1rn1 + h2r

n2 satisfies the recurrence

relation an = Aan−1 +Ban−2.In conclusion, the sequence {an} defined by the explicit formula an = h1r

n1 +

h2rn2 is a solution of the recurrence relation an = Aan−1 +Ban−2. Moreover, we

know it is the only solution. �

Example 14 What is the solution of the recurrence relation

an = an−1 + 2an−2

with a0 = 2 and a1 = 7?

15

Page 16: Recurrence Relations

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 computingthem in the above theorem, we can use the following approach. We first let n = 0to 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 = 22 · 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 = an−1 + 2an−2

with a0 = 1 and a1 = 8?

As shown in the previous example, the characteristic equation of the recurrencerelation an = an−1 + 2an−2 is

r2 − r − 2 = 0,

which has two distinct roots r1 = 2 and r2 = −1. Hence, the explicit formula foran is given by

an = h1 · 2n + h2 · (−1)n.

16

Page 17: Recurrence Relations

Next we use the initial conditions to find the values of h1 and h2 in the same wayas we have done in the previous example. Then, we obtain two equations{

h1 + h2 = 12 · 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 relationfn = fn−1 + fn−2 with the initial conditions f1 = 1 and f2 = 1. The corre-sponding characteristic equation

r2 − r − 1 = 0,

which has two distinct roots

r1 =1 +

√5

2and r2 =

1−√5

2.

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

fn = h1

(1 +

√5

2

)n

+ h2

(1−

√5

2

)n

.

Once again, we need the initial conditions to determine the values for h1 and h2.So, we have

f1 = h1

(1 +

√5

2

)+ h2

(1−

√5

2

)= 1

and

f2 = h1

(1 +

√5

2

)2

+ h2

(1−

√5

2

)2

= 1,

which give two linear equations as follows: h1

(1+

√5

2

)+ h2

(1−

√5

2

)= 1

h1

(1+

√5

2

)2+ h2

(1−

√5

2

)2= 1

17

Page 18: Recurrence Relations

By solving them, we obtain

h1 =1√5

and h2 = − 1√5.

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

fn =1√5

(1 +

√5

2

)n

− 1√5

(1−

√5

2

)n

, ∀n ≥ 1.

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+√5

2 and 1−√5

2 are related to the golden ratio of Greek mathematics.

Example 17 What is the solution of the recurrence relation

an = an−1 + an−2

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 = Aan−1 + Ban−2 be a second-order linear homogeneousrecurrence relation with constant coefficients. Suppose that its characteristic equa-tion r2 − Ar − B = 0 has only a single root r0. Then, the unique solution of therecurrence relation an = Aan−1 + Ban−2 is the sequence {an} given by the ex-plicit formula

an = h1 rn0 + h2 nr

n0 , ∀n,

where h1 and h2 are two constant real numbers such that

h1 = a0 and h2 =a1 − a0r0

r0.

Note that we already know the values of a0 and a1 because they are given in theinitial conditions of the recurrence relation.

Proof: For a complete proof, once again we need to prove the following two things:

18

Page 19: Recurrence Relations

(I) an = h1 rn0 + h2 nr

n0 satisfies the two initial conditions.

(II) an = h1 rn0 +h2 nr

n0 satisfies the recurrence relation an = Aan−1+Ban−2.

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

h1r00 + h2 · 0 · r00 = h1 = a0.

Then, we let n = 1 to obtain

h1r10 + h2 · 1 · r10 = h1r0 + h2r0 = a0r0 +

a1 − a0r0r0

· r0 = a1.

Therefore, the explicit formula an = h1 rn0 + h2 nr

n0 holds for both n = 0 and

n = 1. In other words, an = h1 rn0 + h2 nr

n0 satisfies the two initial conditions.

To show (II), we first know that

r20 = 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, weshall have that

r2 −Ar −B = (r − r0)2 = r2 − 2r0r + r20,

which implies thatA = 2r0 and B = −r20.

On the other hand, we know from the explicit formula an = h1rn1 + h2r

n2 that

an−1 = h1 rn−10 + h2 (n− 1)rn−1

0 and an−2 = h1 rn−20 + h2 (n− 2)rn−2

0 .

19

Page 20: Recurrence Relations

It hence follows that

Aan−1 +Ban−2 = A[h1r

n−10 + h2(n− 1)rn−1

0

]+B

[h1r

n−20 + h2(n− 2)rn−2

0

]= h1r

n−20 (Ar0 +B) + h2r

n−20 [A(n− 1)r0 +B(n− 2)]

= h1rn−20 r20 + h2r

n−20 [n(Ar0 +B)− (Ar0 + 2B)]

= h1rn0 + h2r

n−20

[nr20 − (2r20 − 2r20)

]= h1r

n0 + h2r

n−20

(nr20)

= h1rn0 + h2 nr

n0

= an.

This indicates that the explicit formula an = h1 rn0+h2 nr

n0 satisfies the recurrence

relation an = Aan−1 +Ban−2.In conclusion, the sequence {an} defined by the explicit formula an = h1 r

n0 +

h2 nrn0 is the only solution of the recurrence relation an = Aan−1 +Ban−2. �

Example 19 What is the solution of the recurrence relation

an = 6an−1 − 9an−2

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 explicitformula 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 asbefore, we first let n = 0 to obtain

a0 = h1 · 30 + h2 · 0 · 30 = h1 = 1

20

Page 21: Recurrence Relations

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 = 12 · 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 thisexplicit formula as

an = (1 + n)3n.

Example 20 Find the solution to the recurrence relation

an = 10an−1 − 25an−2

with the initial conditions a0 = 2 and a1 = 4.

Now it’s your turn to find the solution.

21

Page 22: Recurrence Relations

2.2 Linear Nonhomogeneous Recurrence Relations with Constant Co-efficients

In this section, we will learn how to find the explicit formula for the recurrencerelations that are not homogeneous.

Definition 21 A second-order linear nonhomogeneous recurrence relation withconstant coefficients is a recurrence relation of the form

an = Aan−1 +Ban−2 + F (n),

where A and B are constant real numbers, B ̸= 0, and F (n) is a function depend-ing only on n but not identically zero.

If B = 0, then it becomes a first-order recurrence relation. If F (n) is identicallyzero for all n, then it becomes a homogeneous recurrence relation.

Definition 22 Let an = Aan−1 + Ban−2 + F (n) be a second-order linear non-homogeneous recurrence relation with constant coefficients. Then, the recurrencerelation

an = Aan−1 +Ban−2,

is called the associated second-order homogeneous recurrence relation.

We will see that the associated homogeneous recurrence relation plays an im-portant role in the solution of the nonhomogeneous recurrence relation. Followingthe definitions in the above, we can easily verify the following.

- The recurrence relation an = an−1 − an−2 + 1301 is a second-order linearnonhomogeneous recurrence relation with constant coefficients. Its asso-ciated second-order linear homogeneous recurrence relation with constantcoefficients is an = an−1 − an−2.

- The recurrence relation an = 1301an−1+an−2+n2+n+1 is a second-orderlinear nonhomogeneous recurrence relation with constant coefficients. Its as-sociated second-order linear homogeneous recurrence relation with constantcoefficients is an = 1301an−1 + an−2.

- The recurrence relation an = an−1 + an−2 +1301n is a second-order linearnonhomogeneous recurrence relation with constant coefficients. Its asso-ciated second-order linear homogeneous recurrence relation with constantcoefficients is an = an−1 + an−2.

22

Page 23: Recurrence Relations

In the previous section, a solution refers to an explicit formula that is requiredto satisfy both the recurrence relation and all the initial conditions. In order tohelp solve the nonhomogeneous recurrence relations, we first present the followingdefinition.

Definition 23 Given a second-order linear nonhomogeneous recurrence relationan = Aan−1 +Ban−2 + F (n) with constant coefficients, an explicit formula a

(p)n

is said to be a particular solution if it satisfies this nonhomogeneous recurrencerelation an = Aan−1 + Ban−2 + F (n), but not necessarily satisfies the initialconditions.

If a(p)n happens to also satisfy all the initial conditions, then it will become the

solution of the given nonhomogeneous recurrence relation. Please do not confusethe particular solution with the solution.

As for the homogeneous recurrence relations, we distinguish two cases to studythe solution of the nonhomogeneous recurrence relations.

2.2.1 The Distinct-Roots Case

Theorem 24 Let an = Aan−1 +Ban−2 + F (n) be a second-order linear nonho-mogeneous recurrence relation with constant coefficients. We suppose that,

- for the associated second-order linear homogeneous recurrence relation an =Aan−1+Ban−2, its characteristic equation r2−Ar−B = 0 has two distinctroots r1 and r2; and

- the nonhomogeneous recurrence relation an = Aan−1+Ban−2+F (n) hasa particular solution a

(p)n .

Then, the unique solution of the nonhomogeneous recurrence relation an = Aan−1+Ban−2 + F (n) is the sequence {an} given by the explicit formula

an = h1rn1 + h2r

n2 + a(p)n , ∀n,

where h1 and h2 are two constant real numbers such that

h1 + h2 + a(p)0 = a0 and h1r1 + h2r2 + a

(p)1 = a1.

Unfortunately, this theorem does not tell us how to find a particular solution ofthe nonhomogeneous recurrence relation. Let us first try an example before weproceed to prove it.

23

Page 24: Recurrence Relations

Example 25 What is the solution of the recurrence relation

an = 5an−1 − 6an−2 + 7n

with a0 =10920 and a1 =

48320 ?

The given recurrence relation is the second-order linear nonhomogeneous recur-rence relation with constant coefficients, and its associated second-order linear ho-mogeneous recurrence relation is

an = 5an−1 − 6an−2.

The corresponding characteristic equation of this homogeneous recurrence relationis

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 recur-rence 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 nonhomoge-neous recurrence relation. Because F (n) = 7n is the n-th power of a constant, areasonable trial solution is

a(p)n = c · 7n,

where c is a constant to be determined. To determine the value for c, since a(p)n =

c · 7n is a particular solution of the nonhomogeneous recurrence relation, we knowfrom the definition that

a(p)n = 5a(p)n−1 − 6a

(p)n−2 + 7n, ∀n.

It then follows that

c · 7n = 5 · c · 7n−1 − 6 · c · 7n−2 + 7n, ∀n,

and49 · c = 35 · c− 6 · c+ 49,

and finally,20 · c = 49.

24

Page 25: Recurrence Relations

Therefore, we have c = 4920 , so that the particular solution of the nonhomogeneous

recurrence relation isa(p)n =

49

20· 7n.

Now it is the time to apply the above theorem. The unique solution of thenonhomogeneous recurrence relation an = 5an−1 − 6an−2 + 7n is the sequence{an} given by the explicit formula

an = h1 · 2n + h2 · 3n +49

20· 7n, ∀n,

where h1 and h2 are two constant real numbers such that

h1 · 20 + h2 · 30 +49

20· 70 = a0 and h1 · 21 + h2 · 31 +

49

20· 71 = a1.

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 = 109

20 and a1 = 48320 ) for

the nonhomogeneous recurrence relation, we obtain two equations that can be usedto find the values of h1 and h2:

h1 + h2 +4920 = 109

20

h1 · 2 + h2 · 3 + 4920 · 7 = 483

20

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

an = 2 · 2n + 3n +49

20· 7n, ∀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 sucha 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:

(I) an = h1rn1 + h2r

n2 + a

(p)n satisfies the two initial conditions.

(II) an = h1rn1 + h2r

n2 + a

(p)n satisfies the nonhomogeneous recurrence relation

an = Aan−1 +Ban−2 + F (n).

1We will discuss how to find a particular solution later at the end of this chapter.

25

Page 26: Recurrence Relations

To show (I), it is obvious because it is already required in the theorem (please referto the two equations used to determine the values of h1 and h2).

To show (II), we first know that

r21 = 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 = h1r

n1 + h2r

n2 + a

(p)n that

an−1 = h1rn−11 + h2r

n−12 + a

(p)n−1 and an−2 = h1r

n−21 + h2r

n−22 + a

(p)n−2.

Moreover, since a(p)n is a particular solution of the nonhomogeneous recurrence

relation, we know that

a(p)n = Aa(p)n−1 +Ba

(p)n−2 + F (n).

It hence follows that

Aan−1 +Ban−2 + F (n)

= A(h1r

n−11 + h2r

n−12 + a

(p)n−1

)+B

(h1r

n−21 + h2r

n−22 + a

(p)n−2

)+ F (n)

= h1rn−21 (Ar1 +B) + h2r

n−22 (Ar2 +B) +

(Aa

(p)n−1 +Ba

(p)n−2 + F (n)

)= h1r

n−21 r21 + h2r

n−22 r22 + a(p)n

= h1rn1 + h2r

n2 + a(p)n

= an.

This verifies that the explicit formula an = h1rn1 + h2r

n2 + a

(p)n satisfies the recur-

rence relation an = Aan−1 +Ban−2 + F (n).In conclusion, the sequence {an} defined by the explicit formula an = h1r

n1 +

h2rn2 +a

(p)n is the only solution of the recurrence relation an = Aan−1+Ban−2+

F (n). �

2.2.2 The Single-Root Case

Theorem 26 Let an = Aan−1 +Ban−2 + F (n) be a second-order linear nonho-mogeneous recurrence relation with constant coefficients. We suppose that,

26

Page 27: Recurrence Relations

- for the associated second-order linear homogeneous recurrence relation an =Aan−1 +Ban−2, its characteristic equation r2 −Ar−B = 0 has only onesingle root r0; and

- the nonhomogeneous recurrence relation an = Aan−1+Ban−2+F (n) hasa particular solution a

(p)n .

Then, the unique solution of the nonhomogeneous recurrence relation an = Aan−1+Ban−2 + F (n) is the sequence {an} given by the explicit formula

an = h1rn0 + h2 nr

n0 + a(p)n , ∀n,

where h1 and h2 are two constant real numbers such that

h1 + a(p)0 = a0 and h1r0 + h2r0 + a

(p)1 = a1.

The proof can be done by using the same arguments as proving the previous theo-rem, and is left to the reader as an exercise.

Example 27 What is the solution of the recurrence relation

an = 6an−1 − 9an−2 + 2n

with a0 = 1 and a1 = 2?

The given recurrence relation in the above is the second-order linear nonhomo-geneous recurrence relation with constant coefficients, and its associated second-order linear homogeneous recurrence relation is

an = 6an−1 − 9an−2.

The corresponding characteristic equation of this homogeneous recurrence relationis

r2 − 5r + 6 = 0.

Since r2 − 6r+ 9 = (r− 3)2, there is a single root r0 = 3. Hence, the solution ofthe 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 homoge-neous recurrence relation. So, we cannot determine the values for h1 and h2 at thismoment.

27

Page 28: Recurrence Relations

To apply the above theorem, we need a particular solution of the nonhomoge-neous 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 forc and d, since a

(p)n = c · n + d is a particular solution of the nonhomogeneous

recurrence relation, we know from the definition that

a(p)n = 6a(p)n−1 − 9a

(p)n−2 + 2n, ∀n.

It then follows that

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

andc · 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 possibleonly 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 = 1

2 and d = 32 . Thus, a particular solution of the nonhomogeneous

recurrence relation isa(p)n =

n

2+

3

2.

Now it is the time to apply the above theorem. The unique solution of thenonhomogeneous recurrence relation an = 6an−1 − 9an−2 + 2n is the sequence{an} given by the explicit formula

an = h1 · 3n + h2 · n3n +n

2+

3

2, ∀n,

where h1 and h2 are two constant real numbers such that

h1 · 30 + h2 · 0 · 30 +0

2+

3

2= a0 and h1 · 31 + h2 · 1 · 31 +

1

2+

3

2= a1.

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

Page 29: Recurrence Relations

nonhomogeneous recurrence relation, we obtain two equations that can be used tofind the values of h1 and h2:

h1 +32 = 1

h1 · 3 + h2 · 3 + 2 = 2

By solving them, we obtain h1 = −12 and h2 =

12 . It thus follows that

an = −1

2· 3n +

1

2· n3n +

n

2+

3

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 insolving a linear non-homogeneous recurrence relation. In this section we shalllearn how to find a particular solution when the function F (n) is the product of apolynomial in n and the n-th power of a constant, i.e., F (n) is in the form of

F (n) = (dtnt + dt−1n

t−1 + · · ·+ d1n+ d0) · sn

where dt, dt−1, . . . , d1, d0 and s are real numbers. Below is the main theorem weneed to memorize.

Theorem 28 Let an = Aan−1 +Ban−2 + F (n) be a second-order linear nonho-mogeneous recurrence relation with constant coefficients such that

F (n) = (dtnt + dt−1n

t−1 + · · ·+ d1n+ d0) · sn

where dt, dt−1, . . . , d1, d0 and s are all constant real numbers. We distinguishthree cases below.

(I) If s is not a root of the characteristic equation of the associated linear homo-geneous recurrence relation an = Aan−1+Ban−2, then there is a particularsolution of the form

a(p)n = (ptnt + pt−1n

t−1 + · · ·+ p1n+ p0) · sn.

(II) If s is one of the two distinct roots of the characteristic equation of theassociated linear homogeneous recurrence relation an = Aan−1 + Ban−2,then there is a particular solution of the form

a(p)n = (ptnt + pt−1n

t−1 + · · ·+ p1n+ p0) · n · sn.

29

Page 30: Recurrence Relations

(III) If s is the only root of the characteristic equation of the associated linearhomogeneous recurrence relation an = Aan−1 + Ban−2, then there is aparticular solution of the form

a(p)n = (ptnt + pt−1n

t−1 + · · ·+ p1n+ p0) · n2 · sn.

In the above, the values of pt, pt−1, . . . , p1, p0 will be determined by using thegiven linear non-homogeneous recurrence relation an = Aan−1+Ban−2+F (n).

Example 29 Find a particular solution of the linear non-homogeneous recurrencerelation an = 6an−1 − 9an−2 + F (n) in each of the following cases:

(a) when F (n) = 3n;

(b) when F (n) = n3n;

(c) when F (n) = n22n;

(d) when F (n) = n2 + 1.

First note that the associated homogeneous recurrence relation of the given non-homogeneous recurrence relation is an = 6an−1−9an−2+F (n). Its correspondingcharacteristic equation is r2 = 6r−9, which has a single root r0 = 3 of multiplicitytwo.

For (a), we can see that F (n) = d0 · sn where d0 = 1 and s = 3. Then, by theabove theorem, there is a particular solution of the form

a(p)n = p0 · n2 · 3n.

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

tion, we know from its definition that a(p)n shall satisfy the given non-homogeneousrecurrence relation an = 6an−1 − 9an−2 + F (n); that is,

a(p)n = 6a(p)n−1 − 9 · a(p)n−2 + F (n).

It hence follows that

p0 · n2 · 3n = 6 · p0 · (n− 1)2 · 3n−1 − 9p0 · (n− 2)2 · 3n−2 + 3n.

Note that we already used a(n−1)n = p0 ·(n−1)2 ·3n−1, a(n−2)

n = p0 ·(n−2)2 ·3n−2,and F (n) = 3n in the above. We simplify the expressions in the above equation toobtain

p0 · n2 = 2 · p0 · (n− 1)2 − p0 · (n− 2)2 + 1,

30

Page 31: Recurrence Relations

and finally,2 · p0 = 1.

By solving this equation, we have p0 = 12 . Finally, we find a particular solution of

the linear non-homogeneous recurrence relation an = 6an−1 − 9an−2 + 3n as

a(p)n =1

2· n2 · 3n.

Now let us turn out attention to case (b). Since F (n) = n3n, it can be writtenas 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 relationan = 6an−1 − 9an−2 + n3n in the form of

a(p)n = (p1 · n+ p0) · n2 · 3n.

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

(p1·n+p0)·n2·3n

= 6 ·(p1 ·(n−1)+p0) ·(n−1)2 ·3n−1−9 ·(p1 ·(n−2)+p0) ·(n−2)2 ·3n−2+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 necessarilyimplies that

6 · p1 − 1 = 0

2 · p0 − 6 · p1 = 0

By solving the above linear equations, we obtain p1 = 16 and p0 = 1

2 . Finally,we find a particular solution of the linear non-homogeneous recurrence relationan = 6an−1 − 9an−2 + n3n as

a(p)n =

(1

6· n+

1

2

)· n2 · 3n.

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 ofthe characteristic equation. Therefore, there is a particular solution of the givennon-homogeneous recurrence relation an = 6an−1 − 9an−2 +n22n in the form of

a(p)n = (p2 · n2 + p1 · n+ p0) · 2n.

31

Page 32: Recurrence Relations

It follows that

(p2·n2+p1·n+p0)·2n

= 6·(p2·(n−1)2+p1·(n−1)+p0)·2n−1−9·(p2·(n−2)2+p1·(n−2)+p0)·2n−2+n22n

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 necessarilyimplies 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 recurrencerelation an = 6an−1 − 9an−2 + n22n as

a(p)n = (4 · n2 + 48 · n+ 192) · 2n.

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 recurrencerelation an = 6an−1 − 9an−2 + n2 + 1 in the form of

a(p)n = (p2 · n2 + p1 · n+ p0) · 1n = p2 · n2 + 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, n ≥ 2.

Once again, this last equation shall hold for all integers n ≥ 2, which necessarilyimplies that

4 · p2 − 1 = 0

4 · p1 − 24 · p2 = 0

30 · p2 − 12 · p1 + 4 · p0 − 1 = 0

32

Page 33: Recurrence Relations

By solving the above linear equations, we obtain p2 = 14 , p1 = 3

2 and p0 = 238 .

Finally, we find a particular solution of the linear non-homogeneous recurrencerelation an = 6an−1 − 9an−2 + n22n as

a(p)n =1

4· n2 +

3

2· n+

23

8.

THAT’S ALL. HOPE YOU ENJOY COUNTING.

Any questions or suggestions please email to [email protected].

33