0% found this document useful (0 votes)
12 views

Discrete Chapter 2

Uploaded by

cherkos welday
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Discrete Chapter 2

Uploaded by

cherkos welday
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Discrete Mathematics and combinatory

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 = 25 - 5 = 5 = an.
Therefore, {an} with an=5 is also a solution of the recurrence relation.

Note : Initial conditions + recurrence relation uniquely determine the sequence.


Let us consider the following application examples
Example 1: The number of bacteria in a colony triples every hour. If a colony begins with
10 bacteria, how many will be present after n hours?.

Prepared By: Getachew.M Page 1/9


Discrete Mathematics and combinatory

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:
= .
= . = ( . )

= . = ( . )
…..

= . = ( . )

= . = , is the recurrence relation for the above question.


We now have a formula to calculate Pn for any natural number n and can avoid the
iteration.
Let us use this formula to find P30 under the initial condition P0 = 10,000:
P30 = (1.05)3010,000 = 43,219.42
After 30 years, the account contains $43,219.42

Example 3: (Rabbits and the Fibonacci numbers)


A pair of rabbits does not breed until they are 2 months old. After they are 2 months old,
each pair produces another pair each month. Starting with a pair of rabbits, find a
recurrence relation for the number of pairs of rabbits after n months, assuming that no
rabbit ever dies.
Solution:
At the end of the first month, the number of pairs of rabbits is a 1  1
At the end of the second month, the number of pairs of rabbits is a 2  1
To find the number of pairs at the end of n months, add the number in the previous month,
a n 1 , and the number of newborn pairs, a n2 , since each newborn comes from a pair at least
two months old. Hence,
a n  a n 1  a n 2 , n  3 , with a 1  1 and a 2  1
is the desired recurrence relation.

Prepared By: Getachew.M Page 2/9


Discrete Mathematics and combinatory

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  an1  1  an1  2an1  1
This means that the sequence { | ≥ 1} satisfies the recurrence relation
an  2a n1  1 with a1  1

Prepared By: Getachew.M Page 3/9


Discrete Mathematics and combinatory

Applying the recurrence relation again and again, we have

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.

Solving Linear Recurrence Relations

Definition: a linear homogeneous recurrent relation (LHRR) of order


k with constant coefficients is a recurrence relation of the form

= + +··· +

where , ,· · · , are real numbers, and ≠ 0.


Linear homogeneous recurrence relations are studied for two reasons:

 First, they often occur in modeling of problems.


 Second, they can be systematically solved.

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.

Prepared By: Getachew.M Page 4/9


Discrete Mathematics and combinatory

• The recurrence relation = + is a linear homogeneous recurrence relation


of order two.
• The recurrence relation = + is not linear.
• The recurrence relation = 2 + 1 is not homogeneous.
• The recurrence relation = does not have constant coefficients.

SOLVING LHRR WITH CONSTANT COEFFICIENTS

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

for = 0, 1, 2,· · ·, where and are constants.

Example 1: Find an explicit formula for the Fibonacci numbers.

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

Prepared By: Getachew.M Page 5/9


Discrete Mathematics and combinatory

The solution to these simultaneous equations is

= , = Consequently, the Fibonacci numbers are given by


√ √
1 −1
= (1 + √5)⁄2(1 − √5)⁄2
+
√5 √5
Remark: The Fibonacci sequence is an integer sequence, but it “looks like" a sequence of
irrational numbers from its general formula above.

Example 2: What is the solution of the recurrence relation

an = an-1 + 2an-2 with a0 = 2 and a1 = 7 ?

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 = 12 + 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 = 32n – (-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
= +

For = 0, 1, 2,· · ·, where and are constants.

Example 3: What is the solution of the recurrence relation


= 6 –9 with a0 = 1 and a1 = 6? And find
Solution: The only root of r2 – 6r + 9 = 0 is r0 = 3. Hence, the solution to the recurrence
relation is an = 13n + 2n3n for some constants 1 and 2.
To match the initial condition, we need
a0 = 1 = 1
a1 = 6 = 13 + 23

Prepared By: Getachew.M Page 6/9


Discrete Mathematics and combinatory

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?

2). Find the solution of the following recurrence relation


a) = + ℎ =0 =1
b) =4 −3 ℎ =5 =7 ?

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?

Linear Non-homogeneous Recurrences

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
= + +··· + + ( )

Here, ( ) represents a non-recursive cost. If we chop it off, we are left with

= + +··· +
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.

Prepared By: Getachew.M Page 7/9


Discrete Mathematics and combinatory

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 method of undetermined coefficients:

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
( ∈ )
+ ( ) +
+ + ( ) +

Example: Solve the recurrence relation given

The corresponding linear homogeneous recurrence relation of the above equation


is . It’s general solution is for some constant to be determined
( ) ( )
later. As such, = 2 . Right now, we need to determine which should be in the
form of since is a quadratic function.

( )
Now, is supposed to satisfy the recurrence relation. As such, we have:

By rearranging and comparing coefficients, we obtain the following system of equations:

Prepared By: Getachew.M Page 8/9


Discrete Mathematics and combinatory

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 :

What is the solution of the recurrence relation


= 2 − + 2 ≥ 2, with =1 =2

Prepared By: Getachew.M Page 9/9

You might also like