Lecture 9 RECURRENCE RELATION
Lecture 9 RECURRENCE RELATION
RECURRENCE RELATION
OBJECTIVES
At the end of the lecture, the student must
be able to:
Solve problems involving recurrence
relations.
Understand Fibonacci recurrence
relations and second-order recurrence
relations
RECURRENCE RELATION
A recurrence relation is an infinite sequence
a1, a2, a3,…, an,…
in which the formula for the nth term an
depends on one or more preceding terms,
with a finite set of start-up values or initial
conditions.
RECURRENCE RELATION
Example:
Initial condition:
a0 = 1
Recursive formula:
a n = 1 + 2a n-1 for n>1
First few terms are:
1, 3, 7, 15, 31, 63, …
RECURRENCE RELATION
Example:
Initial conditions:
a0 = 1, a1 = 2
Recursive formula:
a n = 3(a n-1 + a )
n-2 for n > 2
First few terms are:
1, 2, 9, 33, 126, 477, 1809, 6858,…
RECURRENCE RELATION
Example: Fibonacci sequence
Initial conditions:
f1 = 1, f2 = 2
Recursive formula:
f n+1 = f n-1 + f n for n > 3
First few terms:
n 1 2 3 4 5 6 7 8 9 10 11
fn 1 2 3 5 8 13 21 34 55 89 144
RECURRENCE RELATION
Example: Fibonacci sequence application
The Fibonacci numbers occur in the sums
of "shallow" diagonals in Pascal's triangle
RECURRENCE RELATION
Example: Fibonacci sequence application
These numbers also give the solution to
certain enumerative problems.
The most common such problem is that
of counting the number of compositions
of 1s and 2s that sum to a given total n:
there are Fn+1 ways to do this.
For example F6 = 8 counts the eight
compositions:
RECURRENCE RELATION
Example: Fibonacci sequence application
The Fibonacci numbers can be found
among the set of binary strings
The number of binary strings of length n
without consecutive 1s is the Fibonacci
number Fn+2.
Out of the 16 binary strings of length 4,
there are F6 = 8 without consecutive 1s –
they are 0000, 0001, 0010, 0100, 0101, 1000,
1001 and 1010.
RECURRENCE RELATION
Example: Fibonacci sequence history
Medieval mathematician and businessman
Fibonacci (Leonardo Pisano) posed the
following problem:
How many pairs of rabbits will be
produced in a year, beginning with a
single pair, if in every month each pair
bears a new pair which becomes
productive from the second month on?
RECURRENCE RELATION
Example: Fibonacci sequence history
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, ...
This is an example of a recursive sequence,
obeying the simple rule that to calculate the
next term one simply sums the preceding two:
F(1) = 1
F(2) = 1
F(n) = F(n – 1) + F(n – 2)
RECURRENCE RELATION
Example: Fibonacci sequence geometrically
1.6180339887
RECURRENCE RELATION
Example: Catalan numbers
Eugene Catalan Belgian mathematician,
1814-1894
Catalan numbers are generated by the
formula:
Cn = C(2n,n) / (n+1) for n > 0
The first few Catalan numbers are:
n 0 1 2 3 4 5 6 7 8 9 10 11
1 1
2 1, 2, 1
3 1, 2, 1, 3, 1, 2, 1
4 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1
RECURRENCE RELATION
Example: Towers of Hanoi
Start with three pegs numbered 1, 2 and 3
mounted on a board, n disks of different sizes
with holes in their centers, placed in order of
increasing size from top to bottom.
Object of the game: find the minimum number
of moves needed to have all n disks stacked in
the same order in peg number 3.
RECURRENCE RELATION
Example: Towers of Hanoi
Start with all disks stacked in peg 1 with
the smallest at the top and the largest
at the bottom.
Use peg number 2 for intermediate
steps
Only a disk of smaller diameter can be
placed on top of another disk
RECURRENCE RELATION
Example: Towers of Hanoi
Game ends when all disks are stacked in
peg number 3 in the same order they
were stored at the start in peg number 1.
Is the minimum number of moves needed
the Catalan number C3 = 5?
RECURRENCE RELATION
Example: Recurrence Relation for the
Towers of Hanoi N No.Moves
Given: T(1) = 1
1 1
T(n) = 2 T( n-1 ) +1
2 3
3 7
4 15
5 31
RECURRENCE RELATION
Exercise: Recurrence Relation for the
Towers of Hanoi
Find the closed-form solution.
N Number of Moves
1 1
2 3
3 7
4 15
5 31
LINEAR RECURRENCE RELATIONS WITH
CONSTANT COEFFICIENTS
A recurrence relation of order k is a function of the form
Where , . . . , are constants with , and f (n) is a function of n.
The meanings of the names linear and constant coefficients
follow:
Trythis:
Consider the second-order homogeneous recurrence relation
with initial conditions , ,
(c) Find the unique solution with the given initial conditions.
SOLVING RECURRENCE RELATION
Solving Fibonacci
Consider the celebrated Fibonacci sequence:
SOLVING RECURRENCE RELATION
Solving Fibonacci
Consider the celebrated Fibonacci sequence:
Solution when Roots of the Characteristic
Polynomial are Equal
Solution when Roots of the Characteristic
Polynomial are Equal
L20 48
PREPARATION FOR THE COURSE