0% found this document useful (0 votes)
3 views42 pages

Chapter 3

The document discusses recurrence relations in discrete mathematics, providing definitions, examples, and applications in modeling various problems such as population growth and financial calculations. It outlines methods for solving recurrence relations, including iterative approaches and the use of initial conditions. Exercises are included to reinforce understanding of the concepts presented.

Uploaded by

sidraq
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)
3 views42 pages

Chapter 3

The document discusses recurrence relations in discrete mathematics, providing definitions, examples, and applications in modeling various problems such as population growth and financial calculations. It outlines methods for solving recurrence relations, including iterative approaches and the use of initial conditions. Exercises are included to reinforce understanding of the concepts presented.

Uploaded by

sidraq
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/ 42

Addis Ababa science & Technology University

Department of Mathematics

Discrete mathematics-I
CHAPTER-3: Recurrence relation
TALK OUTLINES
3.1 Definition and Examples of recurrence relation

3.2 Modeling using recurrence relation

3.3 Solving recurrence relation

2
INTRODUCTION

 Many counting problems cannot be solved


easily using the methods discussed in Chapter 1.
 One such problem is: How many bit strings of
length n do not contain two consecutive
zeros?
 The techniques studied in this chapter, together
with the basic techniques of Chapter 1, can
be used to solve many counting problems.
3
Motivation
The number of bacteria in a colony doubles every
hour. If the colony begins with 5 bacteria, how many
will be present in n hours?
Solution:

Let an : the number of bacteria at the end of n hours


Then;
an = 2an-1, a0=5 By using
recursive
Since bacteria double every hour Initial condition definition

What we are doing actually?


We find a formula/model for an (the relationship
between an and a0) – this is called recurrence
relations between the term of sequence.
3.1 RECURRENCE RELATION
3.1 Recurrence Relation
A recurrence relation for the sequence {an} is an equation that
expresses an in terms of one or more of the previous terms of the
sequence, namely, a0, a1,…, an-1, for all integers n with n ≥ n0, where n0
is a nonnegative integer.
A sequence is call solution of a recurrence relation if its term satisfy
the recurrence relation.

an = 2an-1 Recurrence relation


Recursive
definition
a0 = 5 Initial condition

• A recursive algorithm provides the solution of a problem of size n in term of


the solutions of one or more instances of the same problem in smaller size.

• The initial condition specify the terms that precede the first term where
the recurrence relation takes effect.
3.1 RECURRENCE RELATION
Example 3.1
Let {an} be a sequence that satisfies the recurrence relation
an = an-1 – an-2 for n = 2, 3,4, and suppose that a0 =3 and a1 = 5.

List the first four term.

a0 = 3
a1 = 5
a2 = a1 – a0 = ___________________
a3 = __________________________

What is a5?

a5 = __________________________
3.1 RECURRENCE RELATION
Example 3.2
Determine whether {an} where an = 3n for every nonnegative
integer n, is a solution of recurrence relation an = 2an-1 – an-2
for n = 2, 3, 4, …
Suppose that an = 3n for every nonnegative integer n,
Then for n ≥ 2;
2an-1 – an-2 = ___________________
Therefore,

Determine whether {an} where an = 5 for every nonnegative


integer n, is a solution of recurrence relation an = 2an-1 – an-2
for n = 2, 3, 4, …
2an-1 – an-2 = ___________________
3.1 RECURRENCE RELATION
EXERCISE 3.1
1. Let an denotes the nth term of a sequence satisfying the
given initial condition (s) and the recurrence relation.
Compute the first four terms of the sequence.

a1  2, an  3   an 1   2an 1 for n  2


2
A

1
B a0  128, an  an 1 for n  1
4
C b1  5, bn  7  2bn1 for n  2

D a1  1, a2  2, an  an1 3  an2 for n  3

E d1  1, d2  2, d3  3, dn  dn1  dn2  dn3 for n  4


3.1 RECURRENCE RELATION
EXERCISE 3.1
2. Is the sequence {an} a solution of the an  3  2an1  an2 if
an  2n  1

3. Is the sequence {an} a solution of the an  3an1  6an2 if


an   3
n

4. Show that the sequence {an} is a solution of the recurrence


relation an  2an 1  an  2  2 if a n  n 2
3
3.2 MODELING WITH RECURRENCE
3.2 Modeling with Recurrence Relation
• We can use recurrence relation to model a wide variety of
problems such as

– Finding a compound interest


– Counting a population of rabbits
– Determining the number of moves in the Tower of Hanoi
puzzle
– Counting bit strings
3.2 MODELING WITH RECURRENCE
Example 3.3: Compound interest
Suppose that a person deposits Birr10,000 in a savings account
at CBE yielding 11% per year with interest compounded
annually. Define recursively the compound amount in the
account at the end of n years.
Solution:

Let an : the amount in the account after n years


Then;
an = (compound amount at the end of (n -1)th years)
+ (interest for the nth years)
an = an-1 + 0.11an-1
= 1.11 an-1
With initial condition; a0 = 10,000
3.2 MODELING WITH RECURRENCE
Example 3.4: Population of rabbits
A young pair of rabbits (one of each sex) is placed on an island. A pair
of rabbits does not breed until they are 2 months old. After they are 2
months old, each pair of rabbits produces another pair each month.
Find a recurrence relation for the numbers of pairs of rabbits on the
island after n months if all the rabbits alive.
Solution:
Let fn : the numbers of pairs of rabbits on the island after n months
Then;
fn = (number of pairs of rabbits in (n -1)th months)
+ (number of newborn pairs of rabbits)
fn = fn-1 + fn-2
WHY???
With initial condition; f1 = 1 and f2 = 1 ; n ≥ 3
[Problem develop by Leonardo Pisano (Liber abaci, 13th century) – lead to Fibonacci number]
3.2 MODELING WITH RECURRENCE
Example 3.4: Population of rabbits
3.2 MODELING WITH RECURRENCE
Example 3.5: Tower of Hanoi
• Popular Puzzle invented by Edouard Lucas
(French Mathematician, late 19th century)

RULES OF PUZZLE:

– Suppose we have 3 pegs labeled A, B, C and a set of disks of


different sizes.
– These disks are arranged from the largest disk at the bottom
to the smallest disk at the top (1 to n disks) on peg A.
– The goal: to have all disks on peg C in order of size, with the
largest on the bottom.
– Only one disk is allow to move at a time from a peg to another.
– Each peg must always be arranged from the largest at the
bottom to the smallest at the top
3.2 MODELING WITH RECURRENCE
Example 3.5: Tower of Hanoi
ILLUSTRATION: SOLUTION

Let Hn :
n disks the numbers of
moves with n disks

A B C
Initial Position in the Tower of Hanoi

n-1 disks transfer the top of


n-1 disks to peg B

A B C Hn-1 moves
Intermediate Position in the Tower of Hanoi
3.2 MODELING WITH RECURRENCE
Example 3.5: Tower of Hanoi
ILLUSTRATION: SOLUTION

Moves the largest


disk to peg C
1 disks
1 move

A B C
Intermediate Position in the Tower of Hanoi

n disks
transfer the top of
n-1 disks to peg B

A B C Hn-1 moves
Last Position in the Tower of Hanoi
3.2 RECURRENCE RELATION
Example 3.5: Tower of Hanoi
Solution (continue):

Thus the number of moves is given by:

H n  2H n1  1 ; H1  1

Where:
transfer the top of Moves the largest transfer the top of
n-1 disks to peg B disk to peg C n-1 disks to peg C

Hn-1 moves + 1 move + Hn-1 moves


3.2 MODELING WITH RECURRENCE
Example 3.6: Bit Strings
Find a recurrence relation and give initial conditions for the number of
bit strings of length n that do not have two consecutive 0s. How many
bit strings are there of six length?
Solve yourself
Solution:
Let an : number of bit strings of length n that do not have two
consecutive 0s
Then;
an = (number of bit strings of length n-1 that do not have
two consecutive 0s)
+ (number of bit strings of length n-2 that do not have
two consecutive 0s)
an = an-1 + an-2 ; n≥3
With initial condition;
a1 = 2, both strings of length 1 do not have consecutive 0s ( 0 and 1)
a2 = 3, the valid strings only 01, 10 and 11
3.2 MODELING WITH RECURRENCE
Example 3.7: Codeword enumeration
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 an be the number of valid n-digit
codewords. Find a recurrence relation for an.
Solution:
Let an : the number of valid n-digit codewords
Then;
an = (number of valid n-digit codewords obtained by adding a
digit other than 0 at the end of a valid string of length n – 1)
+ (number of valid n-digit codewords obtained by adding a
digit 0 at the end of an invalid string of length n – 1)

an  9an 1  10n 1  an 1   8an 1  10n 1

With initial condition;


a1 = 9, there are 10 one-digit strings and only one the string 0 not valid
3.2 MODELING WITH RECURRENCE
Example 3.7: Codeword enumeration
A valid codeword of length n can be formed by:

A) Adding a digit other than 0 at the end of a valid string of length n – 1


- This can be done in nine ways. Hence, a valid string with n digits can
be formed in this manner in 9an1 ways.

B) Adding a digit 0 at the end of an invalid string of length n – 1


- This produces a string with an even number of 0 digits because the
invalid string of length n – 1 has an odd number of 0 digits. The number
of ways that this can be done equals the number of invalid (n – 1)-digit
strings. Because there are 10n1 strings of length n – 1, and an 1 are
valid, then there are 10n 1  an 1 invalid (n – 1)-digit strings.

Thus;

an  A  B  9an 1  10n 1  an 1   8an 1  10n 1 , a1  9, n  2


3.2 MODELING WITH RECURRENCE
EXERCISE 3.1
6. Define recursively : 1, 4, 7, 10, 13, …

7. Beti deposits BIRR 1500 in a local savings bank at an


annual interest rate of 8% compounded annually. Define
recursively the compound amount an she will have in her
account at the end of n years. How much will be in her
account after 3 years?

8. There are n students at a class. Each person shakes


hands with everybody else exactly one. Define
recursively the number of handshakes that occur.
3.2 MODELING WITH RECURRENCE
EXERCISE 3.1
9. Find a recurrence relation and initial condition for the
number of ways to climb n stairs if the person climbing the
stairs can take one, two or three stairs at a time. How
many ways can this person climb a building with eight
stairs?

10. Find a recurrence relation and initial condition for the


number of bit strings of length n that contain three
consecutive 0s. How many bit strings of length seven
contain three consecutive 0s?

11. Find a recurrence relation for the number of bit sequences


of length n with an even number of 0s?
3.3 SOLVING RECURRENCE RELATION

• Solve a recurrence relation using iterative


method
• Solve a linear homogeneous recurrence
relation with constant coefficients
• Solve a linear nonhomogeneous recurrence
relation with constant coefficients
Iterative Method
• Solving the recurrence relation for a function f means
finding an explicit formula for f (n). The iterative
method of solving it involves two steps:
– Apply the recurrence formula iteratively and look
for the pattern to predict an explicit formula
 Forward: start from a0 to an
 Backward : start from an to a0

– Use Induction to prove that the formula does


indeed hold for every possible value of the integer
n.
3.3 SOLVING RECURRENCE RELATION
Example 3.3.1 (a): Iterative Method
Using the iterative method, predict a solution for the following
recurrence relation with the given initial condition.

Sn  2Sn1 ; S0  1
Solution: (FORWARD) Solution: (BACKWARD)

S0  1 Sn  2 Sn 1
S1  2S0
 22 Sn  2
S2  2S1  2  2 S0   22 S0
 23 S n  3
S 3  2 S 2  2  2 2 S 0   23 S 0

 2n S0  2n
Sn  2Sn 1  2  2n 1 S0   2n S0  2n ; n 1
3.3 SOLVING RECURRENCE RELATION
Example 3.3.2: Compound interest
Suppose that a person deposits Birr10,000 in a savings account
at a CBE yielding 11% per year with interest compounded
annually. How much will be in the account after 30 years?

Solution:

Let an : the amount in the account after n years


Then;
an = (compound amount at the end of (n -1)th years)
+ (interest for the nth years)
an = an-1 + 0.11an-1
= 1.11 an-1 ,n≥1
With initial condition; a0 = 10,000
Example 3.3.2: Compound interest
Solution (continue):
By iterative approach: PROVE BY
INDUCTION !
a0  10000
a1  1.11 a0
a2  1.11 a1  1.11 a0
2

a3  1.11 a2  1.11 a0
3

an  1.11 an 1  1.11 a0  1.11 10000 


n n

Thus, after 30 years the amount in the account will be:

a30  1.11 10000   ___________


30

=Birr 228,923
Example 3.3: Tower of Hanoi
The number of moves is given by:
PROVE BY
H n  2H n1  1 ; H1  1 INDUCTION !

By iterative approach:
H n  2 H n 1  1
 2  2 H n  2  1  1  22 H n  2  2  1
 22  2 H n 3  1  2  1  23 H n 3  22  2  1

 2n 1 H1  2n  2  2n 3   2 1
 2n 1  2n  2  2n 3   2 1
 2n  1
3.3 SOLVING RECURRENCE RELATION
EXERCISE 3.3.1
1. Using iterative method, predict a solution to each of the
following recurrence relation. Verify the solutions using
induction

• an  an1  4n ; a0  0 ; n  1

• bn  bn 1  n 2 ; a1  1 ; n  2

2. There are n students at a class. Each person shakes hands


with everybody else exactly one. Define recursively the
number of handshakes that occur. Solve this recurrence
relation using iterative method and prove it using induction.

3. If a deposit of birr 100 is made on the first day of each


month into an account that pays 6% interest per year
compounded monthly, show that the amount in the account
after 18 years is birr 38929.
Linear Homogeneous Recurrence

3.3 SOLVING RECURRENCE RELATION


Relations with constant coefficients
A linear homogeneous recurrence relation of degree k with
constant coefficients is a recurrence relation of the form
an = c1an-1 + c2an-2 + … + ckan-k
Where c1, c2,…, ck are real numbers and ck ≠ 0

Linear : The RHS is the sum of previous terms of the sequence each
multiplied by a function of n.
Homogeneous : No terms occur that are not multiplies of the aj s.
Degree k : an is expressed in terms of the previous k terms of the sequence
Constant coefficients : c1, c2,…, ck
Recurrence relation : with k initial condition
a0 = C0, a1 = C1, … ak-1= Ck-1
3.3 SOLVING RECURRENCE RELATION
Example 3.3.4: Linear Homogeneous RR
Linear Homogeneous Recurrence Relation

Pn = (1.11) Pn-1 degree one 1. Often occur


in modeling of
problems
fn = fn-1 + fn-2 degree two
2. Can be
systematically
an = an-5 degree five solved

Not Linear Homogeneous Recurrence Relation

Hn = 2Hn-1 + 1

Bn = nBn-1

an = an-1 + a²n-2
3.3 SOLVING RECURRENCE RELATION
Solving Linear Homogeneous Recurrence
Relations with constant coefficients
• OUR AIM – look for the solutions of the form an  r n , where r
is constant.

• Note that, an  r is a solution of the recurrence relation


n

an = c1an-1 + c2an-2 + … + ckan-k iff r n  c1r n 1  c2 r n  2   ck r n  k .

• When both sides of this equation are divided by r nk and


the RHS is subtracted from the left, we obtain a characteristic
equation: r k  c r k 1  c r k  2   c r  c  0
1 2 k 1 k

• The solution of this equation are called the characteristics


roots.
Solving Linear Homogeneous Recurrence

3.3 SOLVING RECURRENCE RELATION


Relations with constant coefficients
Let c1, c2, …, ck be real numbers. Suppose that the
characteristics equation r k  c1r k 1  c2 r k  2   ck 1r  ck  0
has k distinct roots r1, r2, …, rk.

Then a sequence {an} is a solution of the recurrence relation


an = c1an-1 + c2an-2 + … + ckan-k iff an  1r1n   2 r2 n    k rk n for
n ≥ 0 and α1, α2, …, αk constant.

If the characteristic equation has several (m) repeated roots,


then the solution of the recurrence relation is given by:
an  1r1n   2 nr1n    m n m r1n    k rk n
3.3 SOLVING RECURRENCE RELATION
Example 3.3.5: Second-Order LHRRWCCs
Solve the recurrence relation an = 5an-1 - 6an-2 where a0 = 4 and
a1 = 7.
Solution:
1) Find the general solution of the recurrence relation
• the characteristic equation is given by r 2  5r  6  0
• the characteristic roots are 2 and 3
• thus, the general solution is an  A  2  B  3
n n

2) Find the constant values, A,B and C using the initial


conditions a0  A  B  4
• Solving the linear system: a  2 A  3B  7 : A = 5, B = -1
1

an  5to
3) Thus the solution  2nthe
 3recurrence
n
,n0 relation and initial
conditions is .
3.3 SOLVING RECURRENCE RELATION
Example 3.3.6: Higher-Order LHRRWCCs
Solve the recurrence relation an = 6an-1 - 11an-2 + 6an-3 where
a0 = 2, a1 =5, and a2 = 15.
Solution:
1) Find the general solution of the recurrence relation
• the characteristic equation is given by r 3  6r 2  11r  6  0
• the characteristic roots are 1, 2 and 3
• thus, the general solution is an  A 1  B  2  C  3
n n n

2) Find the constant values, A and B using the initial conditions


• Solving the linear system: (A = 1, B = -1, C = 2)
a0  A  B  C  2, a1  A  2B  3C  5, a2  A  4B  9C  15

3) Thus the unique solution to the recurrence relation and


initial conditions is an  1  2n  2  3n , n  0 .
3.3 SOLVING RECURRENCE RELATION
Example 3.3.7: LHRRWCCs with multiple roots
Suppose that the roots of the characteristic equation of a
linear homogenous recurrence relation are 2, 2, 2, 5, 5, and
9. What is the form of general solution?

Solution:

Thus the general solution to the recurrence relation is

an  A2n  Bn2n  Cn 2 2n  D5n  En5n  F  9n


  A  Bn  Cn 2  2n   D  En  5n  F  9n
3.3 SOLVING RECURRENCE RELATION
EXERCISE 3.3.2
1. What is the solution of the following recurrence relation

• an  an1  2an2 ; a0  2, a1  7

• an  6an1  9an2 ; a0  1, a1  3

• an  3an1  3an2  an3 ; a0  1, a1  2, a2  1

2. Find an explicit formula for Fibonacci numbers.


Fn  Fn1  Fn2 ; F1  1, F2  1
3.3 SOLVING RECURRENCE RELATION
Linear NonHomogenous Recurrence
Relations with constant coefficients
• A Linear Nonhomogenous recurrence relation with constant
coefficients (LNHRRWCCs), that is a recurrence relation of the
form an = c1an-1 + c2an-2 + … + ckan-k + F (n) .
• Where
– c1, c2, …, ck are real numbers
– F (n) is a function not identically zero depending only n
– c1an-1 + c2an-2 + … + ckan-k is called the associated
homogenous recurrence relation
• Example:
an  3an1  2n an  an 1  an  2  n 2  n  1 an  2an 1  n3n
3.3 SOLVING RECURRENCE RELATION
Solving Linear NonHomogenous Recurrence
Relations with constant coefficients

Let
an  h  be the general solution of c1an-1 + c2an-2 + … + ckan-k
And
an  p  be the particular solution of LNHRRWCCs,
an = c1an-1 + c2an-2 + … + ckan-k + F (n)

Then the general solution of LNHRRWCCs is given by

an  an  h   an  p 

There is no general method to find the particular solution.


3.3 SOLVING RECURRENCE RELATION
THEOREM
Suppose that {an} satisfy the linear nonhomogenous recurrence relation
an  c1an1  ck ank  ...  F (n) where c1 , c2,..., ck 
And
F (n)  (bt nt  bt 1nt 1  ...b1n  b0 ) s n where b0 , b1 ,..., bt , s 

(i)When s is not a root of the characteristic equation, there is a


particular solution of the form
( pt nt  pt 1nt 1  ... p1n  p0 ) s n

(ii) When s is a root of the characteristic equation , there is a


particular solution of the form
n m ( pt nt  pt 1nt 1  ... p1n  p0 ) s n
3.3 SOLVING RECURRENCE RELATION
Example 3.3.8: LNHRRWCCs
Find all the solutions of recurrence relation an = 3an-1 + 2n
Solution:
1) Find the general solution of the associated linear homogenous
(ALH) equation.
• the ALH equation is given by an = 3an-1
• thus, the general solution is an  h   A  3n
2) Find the particular solution
• Since F(n) = 2n is polynomial with degree 1, then the trial
solution linear function: pn = cn + d (c and d are constant)
• The equation an = 3an-1 + 2n then become cn  d  3  c  n  1  d   2n  0
• Solve for c and d will gives c = -1 and d = -3/2
• Thus, the particular solution is an  p   n  3 2

3) Thus the unique solution to the recurrence relation is an  A  3  n  2


n 3
3.3 SOLVING RECURRENCE RELATION
EXERCISE 3.3.3
1. What is the solution of the following recurrence relation

• an  5an 1  6an  2  8n 2 ; a0  4, a1  7

• an  5an 1  6an  2  7 n ; a0  4, a1  7

2. What form does a particular solution of linear


nonhomogeneous recurrence relation an  6an1  9an2  F  n 
when
F  n   3n , F  n   n3n , F  n   n 2 2n
F  n   4  n  1 3n , F  n    n 2  1 3n

You might also like