COMPSCI 225:
Discrete Structures in Mathematics and Computer Science

Induction and Recursion

Induction

The well-ordering property

Link copied

The following fundamental fact about the set of integers {0,1,2,}\{ 0, 1, 2, \dots \} is useful for proofs. It leads to the idea of proof by induction.

Theorem 3.1 (The Well-Ordering Property) Every nonempty set of nonnegative integers has a least element.

Mathematical induction

Link copied

Many theorems are that a statement P(n)P(n) is true for all positive integers nn (here, P(n)P(n) is a predicate or propositional function). Mathematical induction is a technique for proving theorems of this kind. In other words, mathematical induction is used to prove propositions of the form nP(n)\forall n\, P(n) , where the universe of discourse is the set {0,1,2,}\{ 0, 1 , 2, \dots \} of non-negative integers, or sometimes the set {1,2,}\{ 1, 2, \dots \} .

A proof by mathematical induction that P(n)P(n) is true for every positive integer nn consists of two steps:

Basis step The proposition P(0)P(0) (or sometimes P(1)P(1) ) is shown to be true.

Inductive step The implication

P(n)P(n+1)P(n) \rightarrow P(n + 1 )

is shown to be true for every non-negative integer nn .

The inductive hypothesis

Link copied

Here P(n)P(n) is called the inductive hypothesis. When we complete both steps of a proof by mathematical induction, we have proved that P(n)P(n) is true for all positive integers nn ; that is, we have shown that nP(n)\forall n\, P(n) is true.

Expressed as a rule of inference, this proof technique can be stated as

[P(0)n(P(n)P(n+1))]nNP(n)[P( 0 ) \wedge \forall n (P(n) \rightarrow P(n + 1 ))] \rightarrow \forall n \in \N \, P(n)

How to write a proof by induction

Link copied

The first step in the proof is to show that P(0)P(0) is true. This amounts to showing that the particular statement P(n)P(n) obtained when nn is replaced by 00 is true.

The next step is to show that P(n)P(n+1)P(n) \rightarrow P(n + 1) is true for every positive integer nn . This can be done by assuming that P(n)P(n) is true and showing that under this hypothesis P(n+1)P(n + 1 ) must also be true.

The final step of the proof is to invoke the “principle of mathematical induction” which implies the theorem n,P(n)\forall n, P(n) is true.

Example 3.1.Link copied When doing an inductive proof, think of a (business) letter format.

Let P(n)P(n) be the statement ”…”.

P(m)P(m) is true because …

Assume P(k),P(k), for some kmk \geq m , is true:

Here is an argument that P(k+1)P(k+1) must be true, assuming that P(k)P(k) is true. …

Thus, by the principle of mathematical induction,

P(n)P(n) is true for every integer nmn\geq m .

Although we are taking m=0m=0 in this discussion it is sometimes convenient to start with m=1m=1 , or m=2m=2 , etc.

Important remark

Link copied

In a proof by mathematical induction it is not assumed that P(n)P(n) is true for all positive integers! It is only shown that if P(n)P(n) is true, then P(n+1)P(n + 1) is also true, that is, P(n)P(n+1)P(n) \rightarrow P(n+1) . Thus, a proof by mathematical induction is not a circular argument.

When we use mathematical induction to prove a theorem, we first show that P(0)P(0) is true. Then we know that P(1)P(1) is true, since P(0)P(0) implies P(1)P(1) . Further, we know that P(2)P(2) is true, since P(1)P(1) implies P(2)P(2) . Continuing along these lines, we see that P(k)P(k) is true, for any positive integer kk .

The domino illustration

Link copied

A way to illustrate the principle of mathematical induction is to consider an infinite row of dominoes, labelled 1,2,3,,n1, 2, 3, \ldots, n , where each domino is standing up. Let P(n)P(n) be the proposition that domino nn is knocked over. If P(1)P(1) is true (meaning: the first domino is knocked over), and if P(n)P(n+1) P(n) \rightarrow P(n + 1 ) is true (meaning: if the thth domino is knocked over then it also knocks over the (n+1)(n + 1 ) -th domino), then all the dominoes are knocked over.

Why mathematical induction is valid

Link copied

The validity of mathematical induction as a proof technique comes from the well-ordering property of the natural numbers.

Suppose we know that P(0)P( 0 ) is true and that the proposition P(n)P(n+1)P(n) \rightarrow P(n + 1 ) is true for all positive integers n.n. To show that P(n)P(n) must be true for all positive integers, assume that there is at least one positive integer for which P(n)P(n) is false.

We will use a variety of examples to illustrate how theorems are proved using mathematical induction. (Many theorems proved in this section via mathematical induction can be proved using different methods. However, it is worthwhile to try to prove a theorem in more than one way, since one method of attack may succeed whereas another approach may not.)

Summation example

Link copied

Mathematical induction is often used to verify summation formulae.

Example 3.2.Link copied Use mathematical induction to prove that the sum of the first nn odd positive integers is n2n^{2} .

Solution.

Let P(n)P(n) denote the proposition that the sum of the first nn odd positive integers is n2n^2 .

Basis step: P(0)P(0) is the claim that the sum of the first zero odd positive integers is 02=00^2 = 0 . This is true.

Some students may be more comfortable starting with n=1n=1 in this case. P(1)P(1) states that the sum of the first odd positive integer is 121^2 . This is true since the sum of the first odd positive integer is 11 .

Inductive step: Show that P(n)P(n+1)P(n)\rightarrow P(n+1) is true nZ+\forall n\in\Z^{+} . Suppose that P(n)P(n) is true for a positive integer nn ; that is

1+3+5++(2n1)=n21+3+5+\dots+(2n-1)=n^2

(Note that the nthn^{th} odd positive integer is (2n1)(2n-1) , since this integer is obtained by adding 22 a total number of n1n-1 times to 11 ). We must show that P(n+1)P(n+1) is true, assuming that P(n)P(n) is true. Note that P(n+1)P(n+1) is the statement that

1+3+5++(2n1)+(2n+1)=(n+1)21+3+5+\dots+(2n-1)+(2n+1)=(n+1)^2

So, assuming that P(n)P(n) is true, it follows that 1+3+5++(2n1)+(2n+1)1+3+5+\dots+(2n-1)+(2n+1) */}

=[1+3+5++(2n1)]+(2n+1)=n2+(2n+1)=(n+1)2\begin{array}{rcl} \qquad & = & \left[1+3+5+\dots+(2n-1)\right]+(2n+1)\\ & = & n^2+(2n+1)\\ & = & (n+1)^2\\ \end{array}

This shows that P(n+1)P(n+1) follows from P(n)P(n) . Note that we used the inductive hypothesis P(n)P(n) in the second equality to replace the sum of the first nn odd positive integers by n2n^2 . Since P(1)P(1) is true and the implication P(n)P(n+1)P(n)\rightarrow P(n+1) is true nZ+\forall n\in\Z^{+} , the principle of mathematical induction shows that P(n)P(n) is true for all positive integers nn .


Example 3.3.Link copied Use mathematical induction to show that
1+2+22++2n=2n+111+2+2^{2}+\cdots +2^{n}=2^{n+1}-1

for all nonnegative integers nn .

Inequality example

Link copied

The next example uses the principle of mathematical induction to prove an inequality.


Example 3.4.Link copied Use mathematical induction to prove the inequality
n<2nn < 2^{n}

for all positive integers nn .

Divisibility examples

Link copied
Example 3.5.Link copied Let xx be a fixed integer. Use mathematical induction to prove that, for all integers n1n \ge 1 ,
xn1=(x1)(xn1+xn2++x+1).x^n - 1 = (x-1 )( x^{n-1} + x^{n-2} + \cdots + x + 1 ).

[Hint: xn+11=(x1)xn+(xn1)x^{n+1} - 1 = (x-1)x^n + (x^{n} - 1 ) .]


Example 3.6.Link copied Use mathematical induction to prove that n3nn^{3} - n is divisible by 3 whenever nn is a positive integer.

Number of subsets example

Link copied
Example 3.7.Link copied Use mathematical induction to show that if SS is a finite set with nn elements, then SS has 2n2^{n} subsets.

Factorial example

Link copied
Example 3.8.Link copied Use mathematical induction to prove that 2n<n!2^n < n! for every positive integer nn with n4n\geq 4 .

Geometric examples

Link copied
Example 3.9.Link copied Let nn be a positive integer. Show that any 2n×2n2^{n}\times 2^{n} chessboard with one square removed can be tiled using L-shaped pieces, where these pieces cover three squares at a time.
Example 3.10.Link copied A finite number of straight lines divides the plane into regions. Prove that these regions can be coloured using two colours so that adjacent regions (i.e., regions that meet in more than just one corner) do not have the same colour.

Basis at other than 0 or 1

Link copied

Sometimes we need to show that P(n)P(n) is true for n=k,k+1,k+2,n = k, k + 1, k + 2, \ldots , where kk is an integer other than 0 or 1. We can use mathematical induction to accomplish this as long as we change the basis step.

Example 3.11.Link copied Prove using induction that if n>4n > 4 is an integer then n2>n+16n^2 > n + 16 .

The second principle of mathematical induction

There is another form of mathematical induction that is often useful in proofs. With this form we use the same basis step as before, but we use a different inductive step. We assume that P(k)P(k) is true for all values k=1,,nk = 1,\ldots, n and show that P(n+1)P(n + 1 ) must also be true based on this assumption. This is called the second principle of mathematical induction. We summarize the two steps used to show that P(n)P(n) is true for all positive integers n:n:

Basis step: The proposition P(1)P(1) is shown to be true.

Inductive step: It is shown that

[P(1)P(2)P(n)]P(n+1)[P(1) \wedge P(2) \wedge \cdots \wedge P(n)] \rightarrow P(n + 1 )

is true for every positive integer nn .

The two forms of mathematical induction are equivalent; that is, each can be shown to be a valid proof technique assuming the other. We leave it as an exercise for the student to show this.


Example 3.12.Link copied Show that if nn is an integer greater than 11 , then nn can be written as the product of primes.

Solution.

Let P(n)P(n) denote the proposition that nn can be written as a product of primes.

Basis step: P(2)P(2) is true since it can be written as the product of one prime, itself.

Inductive step: Assume that P(k)P(k) is true for all positive integers kk with knk\leq n . To complete the inductive step it must be shown that P(n+1)P(n+1) is true under this assumption. There are two cases to consider, namely, when n+1n+1 is prime and when n+1n+1 is composite. If n+1n+1 is prime then we can immediately see that P(n+1)P(n+1) is true. Otherwise n+1n+1 is composite and thus can be written as a product of two positive integers aa and bb with 2ab<n+12\leq a\leq b<n+1 . By the induction hypothesis, both aa and bb can be written as the product of primes. Thus, if n+1n+1 is composite, then it can be written as the product of primes, namely, those primes in the factorizations of aa and bb .


Example 3.13.Link copied Prove that every amount of postage of 12 cents or more can be formed using just 4-cent and 5-cent stamps.

Loop invariant theorem

Consider a segment of computer program of the form

While GG do BB

The condition GG is called the guard and BB is called the body. An iteration of the loop is one execution of BB . The loop terminates when the guard condition becomes false.

A statement SS is a loop invariant if, whenever SS is true before an iteration, SS remains true after the iteration.


Example 3.14.Link copied The following is an inefficient algorithm to compute the quotient and remainder:

Input: m,nPm, n \in \mathbb{P}

  1. Set q=0q = 0 and r=nr = n

  2. While (rmr \ge m ) do

    • q=q+1q = q + 1
    • r=rmr = r - m

Let SS be the statement n=mq+rn = mq + r . Then SS is true at the beginning of the loop and SS stays true through the body of the loop.


Theorem 3.2 (Loop invariant theorem) Let SS be an invariant of the loop “while GG do BB “. Suppose SS is true on the first entry into the loop. Then SS stays true at every iteration of the loop, and if the loop terminates then SS is true after the last iteration.


Recursive definitions

Sometimes it is difficult to define an object explicitly. However, it may be easy to define this object in terms of itself. This process is called recursion_.

We can use recursion to define sequences, functions, and sets. In previous discussions, we specified the terms of a sequence using an explicit formula.

Example 3.15.Link copied The sequence of powers of 2 is given by an=2na_{n} = 2^{n} for n=0,1,2,n = 0, 1, 2, \ldots However, this sequence can also be defined by giving the first term of the sequence, namely, a0=1a_{0} = 1 , and a rule for finding a term of the sequence from the previous one, namely, an+1=2ana_{n+ 1} = 2a_{n} for n=0,1,2,n = 0, 1, 2, \ldots .

Recursively defined functions

Link copied

To define a function with the set of nonnegative integers as its domain,

  1. Specify the value of the function at zero (and possibly 1, 2, … ).

  2. Give a rule for finding its value at an integer from its values at smaller integers.

Such a definition is called a recursive or iterative or inductive definition.


Example 3.16.Link copied Suppose that ff is defined recursively by
f(0)=3,f(n+1)=2f(n)+3.\begin{array}{rcl} f (0) & = & 3,\\ f(n + 1) & = & 2f(n) + 3.\\ \end{array}

Find f(1),f(2),f(3)f (1), f (2), f (3) , and f(4)f (4) .


Example 3.17.Link copied Give an inductive definition of the factorial function F(n)=n!F(n) = n! .

Specifying the first few values of a function

Link copied

In some recursive definitions of functions, the values of the function at the first kk positive integers are specified, and a rule is given for the determining the value of the function at larger integers from its values at some or all of the preceding kk integers.

Example 3.18.Link copied The Fibonacci numbers, f0,f1,f2,,f_{0}, f_{1}, f_{2}, \ldots, are defined by the equations f0=0,f1=1f_{0}=0, f_{1}=1 , and
fn=fn1+fn2f_{n}=f_{n-1}+f_{n-2}

for n=2,3,4,n=2,3,4,\ldots . What are the Fibonacci numbers f2,f3,f4,f5,f6f_{2}, f_{3}, f_{4}, f_{5}, f_{6} ?


Example 3.19.Link copied

Show that fn>αn2f_{n}>\alpha^{n-2} , where \α=(1+5)/2\alpha =(1+\sqrt{5})/2 , whenever n3n\geq 3 .

(Hint: first show that α2=1+α\alpha^2=1+\alpha )

Recurrence relations

Consider the following type of counting problem:

Example 3.20.Link copied How many bit strings of length nn do not contain two consecutive zeros?
Example 3.21.Link copied The number of bacteria in a colony doubles every hour. If a colony begins with five bacteria, how many will be present in nn hours?

Recurrence relations introduction

Link copied

In the previous section we discussed how sequences can be defined recursively. Recursive definitions can be used to solve counting problems. When they are, the rule for finding terms from those that precede them is called a recurrence relation.

Definition 3.1 A recurrence relation for the sequence {an}\{a_{n}\} is a formula that expresses ana_{n} in terms of one or more of the previous terms of the sequence, namely, a0,a1,,an1a_{0}, a_{1}, \ldots, a_{n-1} , for all integers nn with nn0n \geq n_{0} where n0n_{0} is a nonnegative integer.

A sequence is called a solution of a recurrence relation if its terms satisfy the recurrence relation.


Example 3.22.Link copied Let {an}\{a_{n}\} be a sequence that satisfies the recurrence relation an=an1an2a_{n} = a_{n-1} - a_{n-2} for n=2,3,4,n = 2, 3, 4, \ldots , and suppose that a0=3a_{0} = 3 and a1=5a_{1} = 5 . What are a2a_{2} and a3a_{3} ?

Example 3.23.Link copied Determine whether the sequence {an}\{a_n\} is a solution of the recurrence relation an=2an1an2a_n = 2a_{n-1}- a_{n-2} for n=2,3,4,n = 2, 3, 4, \ldots , where an=3na_n = 3n for every nonnegative integer nn . Answer the same question where an=2na_n = 2^n and where an=5.a_n = 5.

Initial conditions

Link copied

The initial conditions for a sequence specify the terms that precede the first term where the recurrence relation takes effect.

The recurrence relation and initial conditions uniquely determine a sequence. This is the case since a recurrence relation, together with initial conditions, provide a recursive definition of the sequence. Any term of the sequence can be found from the initial conditions using the recurrence relation a sufficient number of times. However, there are better ways for computing the terms of certain classes of sequences defined by recurrence relations and initial conditions.

We can use recurrence relations to model a wide variety of problems, such as finding compound interest, counting rabbits an island, determining the number of moves in the tower of Hanoi puzzle, and counting bit strings with certain properties.

Compound interest

Link copied
Example 3.24.Link copied 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 30 years?

Rabbits and the Fibonacci numbers

Link copied

The next example shows how the population of rabbits on an island can be modelled using a recurrence relation.

Example 3.25.Link copied Consider the following problem, which was originally posed by Leonardo di Pisa, also known as Fibonacci, in the 13th century in his book_ Liber abaci. _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 each month. Find a recurrence relation for the number of pairs of rabbits on the island after nn months, assuming that no rabbits ever die.

The towers of Hanoi

Link copied

The next example involves a famous puzzle.

Example 3.26.Link copied A popular puzzle of the late 19th century, called the Towers of Hanoi, consists of three pegs mounted on a board together with discs of different sizes.

Initially these discs are placed on the first peg in order of size, with the largest on the bottom. The rules of the puzzle allow discs to be moved one at a time from one peg to another as long as a disc is never placed on top of a smaller disc.

The goal of the puzzle is to have all the discs on the second peg in order of size, with the largest on the bottom.

Let HnH_{n} denote the number of moves needed to solve the Towers of Hanoi problem with nn discs. Set up a recurrence relation for the sequence {Hn}\{H_{n}\} .


Non-consecutive 00 ‘s

Example 3.27.Link copied Find a recurrence relation and give initial conditions for the number of bit strings of length nn that do not have two consecutive 0’s. How many such bit strings are there of length five?

Codewords

Link copied

The next example shows how a recurrence relation can be used to model the number of codewords that are allowable using certain validity checks.

Example 3.28.Link copied A computer system considers a string of decimal digits a valid codeword if it contains an even number of 0 digits. For instance, 1230407869 is valid, whereas 120987045608 is not valid.

Let ana_{n} be the number of valid nn -digit codewords. Find a recurrence relation for ana_{n} .


Solving recurrence relations

A wide variety of recurrence relations occur in models. Some of these recurrence relations can be solved using iteration or some other ad hoc technique. However, one important class of recurrence relations can be explicitly solved in a systematic way. These are recurrence relations that express the terms of a sequence as linear combinations of previous terms.

Linear homogeneous recurrence relations

Link copied

Definition 3.2 A linear homogeneous recurrence relation of degree kk with constant coefficients is a recurrence relation of the form

an=c1an1+c2an2++ckanka_{n} = c_{1}a_{n-1}+c_{2}a_{n-2}+\cdots +c_{k}a_{n-k}

where c1,c2,,ckc_{1}, c_{2}, \ldots, c_{k} are real numbers, and ck0.c_{k}\not = 0.

The recurrence relation in the definition is linear since the right-hand side is a sum of constant multiples of the previous terms of the sequence. The recurrence relation is homogeneous since no terms occur that are not multiples of the aja_{j} ‘s. The coefficients of the terms of the sequence are all constants, rather than functions that depend on nn . The degree is kk because ana_{n} is expressed in terms of the previous kk terms of the sequence.

A consequence of the second principle of mathematical induction is that a sequence satisfying the recurrence relation in the definition is uniquely determined by this recurrence relation and the kk initial conditions

a0=C0,a1=C1,,ak1=Ck1.a_{0}=C_{0},a_{1}=C_{1},\ldots,a_{k-1}=C_{k-1}.

Linear homogeneous recurrence relations are studied for two reasons. First, they often occur in modelling of problems. Second, they can be systematically solved.


Solving linear homogeneous recurrence relations

The basic approach for solving linear homogeneous recurrence relations is to look for solutions of the form an=rna_{n} = r^{n} , where rr is a constant. Note that an=rna_{n} = r^{n} is a solution of the recurrence relation

an=c1an1+c2an2++ckanka_{n} = c_{1}a_{n-1}+c_{2}a_{n-2}+\cdots + c_{k}a_{n-k}

if and only if

rn=c1rn1+c2rn2++ckrnk.r^{n}=c_{1}r^{n-1}+c_{2}r^{n-2}+\cdots + c_{k}r^{n-k}.

Characteristic equation

Link copied

When both sides of this equation are divided by rnkr^{n-k} and the right-hand side is subtracted from the left, we obtain the equivalent equation

rkc1rk1c2rk2ck1rck=0r^{k} - c_{1} r^{k-1} - c_{2}r^{k-2}-\cdots - c_{k-1}r- c_{k} = 0

Consequently, the sequence {an}\{a_{n}\} with an=rna_{n} = r^{n} is a solution if and only if rr is a solution of this last equation, which is called the characteristic equation of the recurrence relation. The solutions of this equation are called the characteristic roots of the recurrence relation. As we will see, these characteristic roots can be used to give an explicit formula for all the solutions of the recurrence relation.

Linear homogeneous recurrence relations of degree two: distinct roots

Link copied

We now turn our attention to linear homogeneous recurrence relations of degree two. First, consider the case when there are two distinct characteristic roots.

Theorem 3.3 Let c1c_{1} and c2c_{2} be real numbers. Suppose that r2c1rc2=0r^{2} - c_{1}r - c_{2} = 0 has two distinct roots r1r_{1} and ” r2r_{2} . Then the sequence {an}\{a_{n}\} is a solution of the recurrence relation

an=c1an1+c2an2a_{n} = c_{1}a_{n-1}+c_{2}a_{n-2}

if and only if an=β1r1n+β2r2na_{n} = \beta_{1} r_{1}^{n}+\beta_{2}r_{2}^{n} for n=0,1,2,n = 0,1,2,\ldots , where β1\beta_{1} and β2\beta_{2} are constants.

Proof: See lecture

The actual procedure for solving the recurrence relation

an=c1an1+c2an2a_n=c_1a_{n-1}+c_2a_{n-2}

with initial values a0a_0 and a1a_1 is the following (provided that the roots of the characteristic equation are distinct.):

Step 1 : Identify the characteristic polynomial p(x)p(x) and find its roots r1r_1 and r2r_2

Step 2 : If r1r2r_1\not= r_2 then the general solution is of the form

an=β1r1n+β2r2na_n=\beta_1 r_1^n+\beta_2 r_2^n

where β1\beta_1 and β2\beta_2 are constants.

Step 3 : Determine the values of β1\beta_1 and β2\beta_2 by using the initial conditions a0a_0 and a1a_1 .


Example 3.29.Link copied Solve the recurrence relation
an+2+2an+13an=0a_{n+2}+2a_{n+1}-3a_n=0

with initial values a0=1a_0=1 and a1=1a_1=-1 .

Solution

Step 1 Determine the characteristic equation by substituting an=rna_n=r^n and factoring out rnr^n __

rn+2+2rn+13rn=0r2+2r3=0(r+3)(r1)=0\begin{array}{rcl} r^{n+2}+2r^{n+1}-3r^n&=&0\\ r^2+2r-3&=&0\\ (r+3)(r-1)&=&0\\ \end{array}

Take r1=3r_1=-3 and r2=1r_2=1 .

Step 2 The general solution is

an=β1(3)n+β2(1)na_n=\beta_1 (-3)^n+\beta_2 (1)^n

Step 3 Using the initial values a0=1a_0=1 and a1=1a_1=-1 we obtain

a0=1=β1+β2(n=0)a1=1=β23β1(n=1)\begin{array}{lcl} a_0=1=\beta_1+\beta_2&\qquad&(n=0)\\ a_1=-1=\beta_2-3\beta_1&\qquad&(n=1)\\ \end{array}

and this gives us β1=β2=12\beta_1=\beta_2=\frac{1}{2} . Thus an=12+12(3)n,n0a_n=\frac{1}{2}+\frac{1}{2}(-3)^n,\qquad n\geq0 is the unique solution to the given recurrence relation.


Example 3.30.Link copied What is the solution of the recurrence relation
an=an1+2an2a_{n} = a_{n-1} + 2a_{n-2}

with a0=2a_{0} = 2 and a1=7a_{1} = 7 ?


Example 3.31.Link copied Find an explicit formula for the Fibonacci numbers.

Linear homogeneous recurrence relations of degree two: one root of multiplicity two

Link copied

Theorem 4.2 does not apply when there is one characteristic root of multiplicity two. This case can be handled using the following theorem.

Theorem 3.4 Let c1c_{1} and c2c_{2} be real numbers with c20c_{2}\not = 0 . Suppose that r2c1rc2=0r^{2} - c_{1}r - c_{2} = 0 has only one root r1r_{1} . A sequence {an}\{a_{n}\} is a solution of the recurrence relation an=c1an1+c2an2a_{n} = c_{1}a_{n-1} + c_{2}a_{n-2} if and only if an=β1r1n+β2nr1na_{n} = \beta_{1}r_{1}^{n} + \beta_{2}nr_{1}^{n} , for n=0,1,2,n = 0, 1, 2, \ldots , where β1\beta_{1} and β2\beta_{2} are constants.

The actual procedure for solving the recurrence relation

an=c1an1+c2an2a_n=c_1a_{n-1}+c_2a_{n-2}

with initial values a0a_0 and a1a_1 is the following (provided that the roots of the characteristic equation are not distinct):

Step 1 : Identify the characteristic polynomial p(x)p(x) and find its roots r1r_1 and r2r_2

Step 2 : If r1=r2r_1=r_2 then the general solution is of the form

an=β1r1n+β2nr1n=(β1+nβ2)r1na_n=\beta_1 r_1^n+\beta_2nr_1^n = (\beta_1 + n \beta_2) r_1^n

where β1\beta_1 and β2\beta_2 are constants.

Step 3 : Determine the values of β1\beta_1 and β2\beta_2 by using the initial conditions a0a_0 and a1a_1 .


Example 3.32.Link copied Solve the recurrence relation
an+2an1+an2=0a_n+2a_{n-1}+a_{n-2}=0

with initial values a0=1a_0=1 and a1=3a_1=-3 .


Example 3.33.Link copied What is the solution of the recurrence relation
an=6an19an2a_{n} = 6a_{n-1} - 9a_{n-2}

with initial conditions a0=1a_{0} = 1 and a1=6a_{1} = 6 ?