Professional Documents
Culture Documents
be able to:
Solve problems involving recurrence
relations.
Understand Fibonacci recurrence
relations and second-order recurrence
relations
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.
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, …
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,…
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
Example: Fibonacci sequence application
The Fibonacci numbers occur in the sums
of "shallow" diagonals in Pascal's triangle
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:
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.
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?
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)
Example: Fibonacci sequence geometrically
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
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.
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
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?
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
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
Two main methods:
Iteration
Method for linear homogeneous
recurrence relations with constant
coefficients
METHOD 1 Problem:
Given a recursive expression with initial
conditions a0, a1
try to express an without dependence on
previous terms.
Example:
an = 2an-1 for n > 1, with initial condition
a0 = 1
Solution: an = 2n
Example: Deer Population growth
Deer population dn at time n
Initial condition: d0 = 1000
Increase from time n-1 to time n is 10%.
Therefore the recursive function is
dn – dn-1 = 0.1dn-1
dn = 1.1dn-1
Solution: dn = 1000(1.1)n
Example: Compound interest
Given
P = initial amount (principal)
n = number of years
r = annual interest rate
A = amount of money at the end of n years
At the end of:
1 year: A = P + rP = P(1+r)
2 years: A = P + rP(1+r) = P(1+r)2
3 years: A = P + rP(1+r)2 = P(1+r)3
Obtain the formula A = P (1 + r) n
Method 2: Linear homogeneous recurrence
Theorem: Given the second order linear
homogeneous recurrence relation with
constant coefficients
an = c1an-1 + c2an-2
and initial conditions a0 = C0, a1 = C1
If r is a root of t2 – c1t – c2 = 0, then the
sequence {rn}, n = 0, 1, 2,… is also a
solution.
Case 1: Two different roots
If r1 and r2 (r1 r2) are solutions of the
quadratic equation t2 – c1t – c2 = 0, then
there exist constants b and d such that
an = br1n + dr2n
for n = 0, 1, 2, 3,…
Case 2: One root of multiplicity 2
If r is a root of multiplicity 2 satisfying the
equation
t2 – c1t – c2 = 0,
then there exist constants b and d such that
an = brn + dnrn
for n = 0, 1, 2, 3,…
EXAMPLE: Solving Fibonacci
Recipe solution has 3 basic steps:
Assume solution of the form an = r n
r 2 - 2r +1 = 0
Since r 2 - 2r +1 = (r -1)2 the root r = 1 repeats.
If we tried to solve by using general solution
an = Ar1n+Br2n = A1n+B1n = A+B
which forces an to be a constant function ().
SOLUTION: Multiply second solution by n so
L20
general solution looks like: 50
n n
Solve an = 2an-1-an-2, a0 = 1, a1 = 2
General solution: an = A1n+Bn1n = A+Bn
Plug into initial conditions
1 = a0 = A+B·0·10= A
2 = a0 = A·11+B·1·11= A+B
Plugging first equation A = 1 into second:
2 = 1+B implies B = 1.
Final answer: an = 1+n
(CHECK IT!)
L20 51