Discrete Chapter 2
Discrete Chapter 2
Chapter- two
Recurrence Relations
INTRODUCTION
A wide variety of recurrence relations occur in models. Some of these recurrence relations
can be solved using iteration or some other techniques. 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. A
recursive algorithm is one in which objects are defined in terms of other objects of the
same type. Discrete Mathematics
Goals : To solve linear recurrence relations with constant coefficients.
Advantages:
Simplicity of code
Easy to understand
Disadvantages:
Memory
Speed
Possibly redundant work
Tail recursion offers a solution to the memory problem, but really, do we need recursion?
Specifically, we study how to define & solve recurrence relations.
Definition:
A recurrence relation for a sequence { } is an equation that expresses an in terms of one
or more of the previous terms in the sequence, , , . . . , for all integers ≥ where
is a nonnegative integer. A sequence is called a solution of a recurrence relation if its
terms satisfy the recurrence relation.
Example:
Consider the recurrence relation an = 2an-1 – an-2 for = 2, 3, 4, …
-Is the sequence {an} with = 3 a solution of this recurrence relation?
let us see for n 2 we see that
2an-1 – an-2 = 2(3(n – 1)) – 3(n – 2) = 3n = an.
Therefore, {an} with an=3n is a solution of the recurrence relation.
-Is the sequence {an} with an=5 a solution of the same recurrence relation?
For n 2 we see that
2an-1 – an-2 = 25 - 5 = 5 = an.
Therefore, {an} with an=5 is also a solution of the recurrence relation.
Solution: We let a n denote the number of bacteria at the end of n hours. Hence a n 3a n 1 ,
where n is a positive integer. This equation, called the recurrence relation, together with
the initial condition a 0 10 , uniquely determines the sequence a n , for all nonnegative
integers n. The sequence of a recurrence relation is called a solution of the recurrence
relation.
Example 2:
Someone deposits $10,000 in a savings account at a bank yielding 5% per year with
interest compounded annually. How much money will be in the account after 30 years?
Solution:
Let Pn denote the amount in the account after n years. How can we determine Pn on the
basis of Pn-1? We can derive the following recurrence relation:
Pn = Pn-1 + 0.05Pn-1 = 1.05Pn-1.
The initial condition is P0 = 10,000.
Then we have:
= .
= . = ( . )
= . = ( . )
…..
= . = ( . )
Example 4:
a) Find a recurrence relation for the number of ways to climb stairs if the person
climbing the stairs can take one stair or two stairs at a time.
b) What are the initial conditions?
c) In how many ways can this person climb a flight of eight stairs?
Solution:
Let denote the number of ways of climbing the stairs.
a) Let ≥ 3. The last step either was a single step, for which there are possibilities,
or a double step, for which there are possibilities.
The recurrence is = + ≥ 3.
b) We have = 1 = 2. You can take two stairs either directly or by taking stair
at a time.
c) The recurrence gives the Fibonacci sequence 1, 2, 3, 5, 8, 13, 21, 34, 55, …
Hence there are = ways to climb a flight of eight stairs
Example 5:
The Fibonacci numbers are defined by the recurrence,
= + where = 1 , =1
how do we find its solution? We will back to this later.
Example 6:
The game of Hanoi Tower is to play with a set of disks of graduated size with holes in their
centers and a playing board having three spokes for holding the disks.
The object of the game is to transfer all the disks from spoke A to spoke C by moving one
disk at a time without placing a larger disk on top of a smaller one. What is the minimal
number of moves required when there are n disks?
Solution:
Let be the minimum number of moves to transfer n disks from one spoke to another. In
order to move n disks from spoke A to spoke C, one must move the first − 1 disks from
spoke A to spoke B by moves, then move the last (also the largest) disk from spoke A
to spoke C by one move, and then remove the − 1 disks again from spoke B to spoke C by
moves. Thus the total number of moves should be
an an1 1 an1 2an1 1
This means that the sequence { | ≥ 1} satisfies the recurrence relation
an 2a n1 1 with a1 1
We will see later in the non-homogeneous recurrence relation how to find solutions of
recurrence relation of the above type.
Given a recurrence relation for a sequence with initial conditions. Solving the recurrence
relation means to find a formula to express the general term of the sequence.
= + +··· +
The recurrence relation in the definition is linear since the right-hand side is a sum of
multiples of the previous terms of the sequence.
• The recurrence relation is homogeneous since no terms occur that are not multiples of
the ′ .
• The coefficients of the terms of the sequence are all constants, rather than functions that
depend on n.
• The order is k because is expressed in terms of the previous k terms of the sequence.
Example:
The recurrence relation = 1.11 is a linear homogeneous recurrence relation of
order one.
The basic approach for solving LHRR is to look for solutions of the form = , where r
is a constant. Note that = is a solution of the recurrence relation
= + +··· +
if and only if
= + +··· +
When both sides of late equation are divided by and the right-hand side is subtracted
from the left, we obtain the equivalent equation
− − −··· − =0
which is called the characteristic equation of the recurrence relation. The solutions of this
equation are called the characteristic roots of the recurrence relation. We will first develop
results that deal with LHRR with constant coefficients of degree two. Then corresponding
general results when the degree may be greater than two will be stated.
Theorem:
Let be real numbers. Suppose that − − = 0
has two distinct roots . Then the sequence { a n } is a solution of the recurrence
relation = + if and only if = +
Solution: Recall that the sequence of Fibonacci numbers satisfies the recurrence relation
= + and also satisfies the initial conditions = 0 = 1.
The characteristic equation is − − 1 = 0, and the solutions are
= (1 + √5)⁄2 and = (1 − √5)⁄2
Therefore, from the above theorem it follows that the Fibonacci numbers are given by
= (1 + √5)⁄2 + (1 − √5)⁄2 for some constants
The initial conditions = 0 and = 1 can be used to find these constants. We have
= (1 + √5)⁄2 + (1 − √5)⁄2 = + =0
= (1 + √5)⁄2 + (1 − √5)⁄2 = (1 + √5)⁄2 + (1 − √5)⁄2 = 1
Solution:
The characteristic equation of the recurrence relation is r2 – r – 2 = 0.
Its roots are r = 2 and r = -1.
Hence, the sequence {an} is a solution to the recurrence relation if and only if:
an = 12n + 2(-1)n for some constants 1 and 2.
Given the equation an = 12n + 2(-1)n and the initial conditions a0 = 2 and a1 = 7, it follows
that
a0 = 2 = 1 + 2 and a1 = 7 = 12 + 2 (-1)
Solving these two equations gives us 1 = 3 and 2 = -1.
Therefore, the solution to the recurrence relation and initial conditions is the sequence {an}
with
an = 32n – (-1)n.
The above theorem does not apply when there is one characteristic root of multiplicity two.
This case can be handled using the following theorem.
Theorem :
Let and be real numbers with ≠ 0. Suppose that − − = 0 has only one
root . A sequence { } is a solution of the recurrence relation = +
if and only if
= +
Solving these equations yields 1 = 1 and 2 = 1. Consequently, the overall solution is given
by an = 3n + n3n.
And by putting = 50 = 3 + 50(3)
Exercise:
What is the solution to the recurrence relation = 8 − 16
with initial conditions = 1, = 7?
Assignment two:
1). Assume that the population of the world in 2010 is 6.2 billion and is growing at the
rate of 1.3% a year.
a) Set up a recurrence relation for the population of the world n years after 2002.
b) Find an explicit formula(solution) for the population of the world n years after 2002.
c) What will the population of the world be in 2018?
Summary
Our general technique for solving LHRR with constant coefficients are two-step process.
Step 1: Find the roots of the characteristic polynomial and use them to develop the
general solution.
How do I find roots of polynomials?
Step 2: Use the initial conditions to make and solve a system of linear equations that
determine the arbitrary constants in the general solution to get the particular
solution.
How do I solve systems of linear equations?
For recursive algorithms, cost functions are often not homogenous because there is usually
a non-recursive cost depending on the input size. Such a recurrence relation is called a
linear non-homogeneous recurrence relation. Such functions are of the form
= + +··· + + ( )
= + +··· +
which is the associated homogenous recurrence relation. Every solution of a linear non-
homogeneous recurrence relation is the sum of a particular solution and a solution to the
associated linear homogeneous recurrence relation.
Theorem :
( )
If { } is a particular solution of the non-homogeneous linear recurrence relation with
constant coefficients
= + +··· + + ( )
( ) ( ) ( )
then every solution is of the form{ + } where { } a solution of the associated
homogenous recurrence relation
= + +··· +
There is no general method for solving such relations. However, we can solve them for
special cases. In particular, if f(n) is a polynomial or exponential function (or more
precisely, when f(n) is the product of a polynomial and exponential function), then there is
a general solution. To solve the above non homogeneous recurrence relation it remains to
( ) ( )
find a particular solution . Let us one method to find the particular solution
The basic trial forms are given in the table below (c denotes a constant in the expression of
f(n)
and A (with or without subscripts) denotes a constant to be determined):
( ) ( ) ( ) ( )
Trial or gauss of Trial or gauss of
( ∈ )
+ ( ) +
+ + ( ) +
( )
Now, is supposed to satisfy the recurrence relation. As such, we have:
Solving the above system, we obtain and . This makes it clear that
( )
= + 4 + 3 and hence . By plugging the value of , we
finally obtain . Hence the final answer is
= −2 + +4 +3.
Exercise :