You are on page 1of 29

RECURSION

Recurrence Relation
Definition 1: A recurrence relation of
degree (order) k for a sequence an  is
a rule
an  f  n, an1 , an2 ,..., ank 
for finding an , where n=k+1,k+2,…,
and the terms a , a ,...a are known ■
1 2 k
Examples of Recurrence
Relations
1) Arithmetic progression:

an  an1  d , n  2,3,...; a1  a;
“d” is a difference, “a” is known.

2) Geometric progression:

an  q  an1 , n  2,3,...; a1  a;
“q” is a ratio, “a” is known.
Examples of Recurrence
Relations
3) Progression of the mixed type:

an  q  an 1  d , n  2,3,...; a1  a;
“q,d,a” are known.
4) Factorial:

an  n  an1 , n  1,2,...: a0  1.
5) The Tower of Hanoi:
H n  2 H n1  1, n  2,3,...; H1  1.
6) Fibonacci
numbers:

Fn  Fn1  Fn2 ,
n  3,4,...;
F1  F2  1.
Fibonacci numbers:

 Suppose there are two newborn rabbits, one


male and the other female.
 Each pair takes one month to become

mature.
 Each pair produces a mixed pair every month,

from the second month.


 No rabbits die.

Find the number of pairs of rabbits produced


after “n” months.
Linear Homogeneous
Recurrence Relation
Definition 2: A linear homogeneous
recurrence relation of degree k with constant
coefficients is a recurrence relation of the form
an  c1an1  c2 an2  ...  ck ank
where c1 , c2 ,..., ck are real numbers,
ck  0 and the terms a1 , a2 ,...ak are
known ■
Linear nonhomogeneous
Recurrence Relation
Definition 3: A linear nonhomogeneous
recurrence relation of degree k with constant
coefficients is a recurrence relation of the form
an  c1an1  c2 an2  ...  ck ank  F  n 
where c1 , c2 ,..., ck are real numbers,
ck  0 and the terms a1 , a2 ,...ak are

known ■
The First-Order Linear
Recurrence Relation
Theorem 4: The explicit solution of the
first-order linear homogeneous recurrence
relation
an  q  an1 , n  2,3,...; a1 is known;
is the sequence
n 1
an  a1  q , n  1,2,... ■
The First-Order Linear
Recurrence Relation
Definition 4: When a1 is considered as an
arbitrary real constant, the formula
n 1
an  a1  q , n  1,2,...
is also called the general solution to the
recursion
an  q  an1 ■
The First-Order Linear
Recurrence Relation
Theorem 5: The explicit solution of the
first-order linear nonhomogeneous recurrence
relation
an  q  an1  F  n  , n  2,3,...; a1 is known;
is the sequence
n2
an  a1  q n 1
  F  n  k  q , n  2,3,... ■
k

k 0
The Second-Order Linear
Recurrence Relation
Theorem 6: (Method of decomposition) Let an 
satisfy the relation:
an  c1  an1  c2  an2  F  n  , n  3,4,...; a1 , a2 are known;
Let x 2  c1 x  c2 - characteristic equation with
characteristic roots q1 and q2. Then
un  q1un 1  F  n  , n  3, 4,...; u2  a2  q2 a1 ;

 an  q2 an 1  un ; n  3, 4,...; a2  is known.
The Second-Order Linear
Recurrence Relation
Theorem 7: Let the homogeneous relation
an  c1  an 1  c2  an 2 , n  3,4,...; a1 , a2 are known;
has distinct real characteristic roots q1  q2

Then
a1q2  a2 n 1 a2  a1q1 n 1
an   q1   q2 , n  1, 2,...
q2  q1 q2  q1

Is the explicit solution of this relation ■


The Second-Order Linear
Recurrence Relation
Theorem 8: Let the homogeneous relation
an  c1  an 1  c2  an 2 , n  3,4,...; a1 , a2 are known;
has multiple characteristic root q1  q2  q
Then the explicit solution of this relation is

an  a1q n 1
  a2  qa1  n  1 q n2


The Second-Order Linear
Recurrence Relation
Example: The explicit solution of Fibonacci
Recurrence relation (distinct characteristic roots )

Fn  Fn1  Fn2 , n  3,4,...; F1  F2  1.


Is:

1   1 5 
n
 1 5   n

Fn        
5  2   2  
 
The Second-Order Linear
Recurrence Relation
Example: (multiple characteristic root )

an  4an 1  4an  2 , a1  1, a2  4;
x  4 x  4 , q1  q2  2;
2

n 1
an  n  2 .
The Second-Order Linear
Recurrence Relation
Theorem 9 Let the homogeneous relation

an  c1  an 1  c2  an 2 , n  3,4,...; a1 , a2 are known;


has complex characteristic roots q and q . Let
q  q  cos   i  sin   - goniometric form of the
root q. Then the explicit solution of this relation is
a2  a1 q cos 
cos  n  1  sin  n  1
n 1 n2
an  a1 q q
sin 
The Second-Order Linear
Recurrence Relation
Example: (complex characteristic roots ):
an   an  2 , n  3, 4,...; a1 , a2 are known;
x  1  0 , q  i, q  i; q  1,    2 ;
2

an  a1  cos
 n  1 
a  sin
 n  1 
2
2 2
Generating function

Definition 5: Let an n  0  a0 ,a1 ,...,an ,...


be a sequence of real numbers. Then the


function (formal power series)

g  x    an x n  a0  a1 x  a2 x 2  ...  an x n  ...
n 0
is the generating function for the
an n0

sequence ■
Generating function
Definition 6: 1) Two generating functions
 
f  x    an x n
and g  x    bn x n

n 0 n0

are equal if an  bn for every n0



2) f  x   g  x     an  bn  x n

n 0

c  f  x    can x , c  R
n

n 0
Using generating functions to
solve recurrence relations
1) Progression of the mixed type:
an  q  an1  d , n  2,3,...; a1 is known

 n n0    n

a  g x  a x n

n 0

an  qan 1  d n0  0    an  qan 1  d   x 
 n

n 0

d
 1  qx   g  x   q  a1  
1 x
Using generating functions to
solve recurrence relations
 qd  1 d 1
g  x    qa1     
 1  q  1  qx 1  q 1  x
 
n 1  d  d  n
   q  a1   x
n0   1 q  1 q 

n 1  d  d n 1  d  d
an  q  a1    q  a1  
 1 q  1 q  1 q  1 q
Using generating functions to
solve recurrence relations
2) Fibonacci numbers:
Fn  Fn1  Fn2 , n  3,4,...; F1  F2  1.

Fn n0  g  x    Fn x
 n

n 0

Fn  Fn1  Fn 2 n0  0    Fn  Fn 1  Fn  2   x n 

n0

  F2  1  x  F1   x  x  1  g  x  
2

  x   x 2  x  1  g  x 
Using generating functions to
solve recurrence relations
x 1  1 1 
g  x  2    
x  x  1 x2  x1  1  x x2 1  x x1 

1
  x2  x1   x 
n n n

n  0 x2  x1

1  1 5   1 5   n
 n n

      x
n0 5  2   2  
 
1  5
x1,2 
2
Using generating functions to
solve recurrence relations
3) Nonhomogeneous recursion:
an  8an 1  15an  2  2  3 , a1  27 , a2  110 , n  3, 4,...
n


an n0  g  x    an x n

n0

a
n  8an 1  15an  2  2  3 
n 
n 0
 0    an  8an 1  15a n  2  2  3 n  x n
n 0

2
 15a2  15 x  8  a1  1  8 x  15 x   g  x  
2

1  3x
g  x 
 8a1  15 xa1  15a2 1  3 x   2 1 88  563 x  627 x 2
  
1  5 x 1  3x  15 1  5 x 1  3 x 
2 2

 209 98 
a
 1  , a2   
 152 153 
1  3 40 45 
    2

15 1  5 x 1  3 x 1  3 x  
1    
n
 3 5 x   40 3 x   45  n  13 x   
n n

15  n 0 n 0 n 0 

  5n 1  8  3n 1   n  1  3n 1  
n0

 an  5n 1  8  3n 1   n  1  3n 1
The first-order linear
recursion with arbitrary coefficients

Theorem 10: The explicit solution of the


recurrence relation

an  q  n   an 1  F  n  , n  2 ,3,...; a1 is known
is the sequence

 n
F k   n
an   a1     Q  n  , where Q  n    q i 
 k 2 Q  k   i2
The first-order linear
recursion with arbitrary coefficients

Example:
n
an   an 1  2, a1  2, n  2,3,...
n 1
n  n  3
an 
n 1

You might also like