A recurrence relation for the sequence a0 , a1 , is an equation that relates an to certain of its predecessors a0,a1, …, an-1 .
e.g. Fibonacci sequence :
fn = fn-1 + fn-2 for n ³ 3
with initial condition : f1 = 1 , f2 = 2
Example 1 : Tower of Hanoi :
The Tower of Hanoi is a puzzle consisting of three pegs mounted on a board and n disks of various sizes with holes in their centers. It is assumed that if a disk is on a peg, only a disk of smaller diameter can be placed on top of the first disk. Given all the disks stacked on one peg , the problem is to transfer the disks to another peg by moving one disk at a time.
Let Cn be the number of disk movements needed to solve the n-disk Tower of Hanoi problem, then
Cn = 2 C n-1 + 1 for n > 1 with initial condition : C1 = 1
Example 2: Ackermann's Function :
A(m,0) = A(m-1,1) m = 1,2,…….
A(m,n) = A(m-1 , A(m,n-1) ) m = 1,2,……. and n = 1,2,……
With the initial conditions :
A(0,n ) = n + 1 , n = 0, 1, …….
Ackermann's function is a fast growing function.
Solving Recurrence relations
To solve a recurrence relation involving a0 , a1 …. by iteration , one uses the recurrence relation to replace the nth an in terms of certain of its
predecessors a n-1, … a0. Then successively use the recurrence relation to replace each of a n-1, … by certain of their predecessors. Continue in this fashion until an explicit formula is obtained.
Solve an = a n-1 + 3 subject to the initial condition a1 = 2.
an = a n-1 + 3 = a n-2 + 3 + 3 = an = a n-3 + 3 + 3 + 3 = a n-3 + 3*3
= a n-(n-1) + 3*(n-1) = 2 + 3*(n-1) = 3*n -1
Example 5.2.4 :
Solvecn = 2 c n-1 + 1 with initial condition c1 = 1 .
cn = 2 c n-1 + 1 = 2 *(2 c n-2 + 1) + 1 = 2 2 c n-2 + 2 + 1
= 2 2 (2 c n-3 + 1) + 2 + 1 = 2 3 c n-3 + 2 2 + 2 + 1
= ……. = 2 k c n-k + 2 k-1 + ….. + 2 + 1
= 2 n-1c n-(n-1) + 2 n-2 + …. + 2 + 1
= 2 n-1 + 2 n-2 + …. + 2 + 1 = 2 n - 1
A linear homogeneous recurrence relation of order k with constant coefficients is a recurrence relation of the form :
an = c1a n-1 + c2 a n-2 + …. + ck a n-k with ck ¹ 0 --- eq.1
A linear homogeneous recurrence relation of order k with constant coefficients, together with the k initial conditions
a0 = C0 , a1 = C1, ….., a k-1 = C k-1
uniquely defines a sequence a0, a1, …….
To solve :
1. substitute each ak by tk into the recurrence relation :
an = c1a n-1 + c2 a n-2 + …. + ck a n-k
tn = c1t n-1 + c2 t n-2 + …. + ck t n-k
(tk - c1t k-1 - c2 t k-2 -…. - ck )t n-k= 0 eq. 2
r1 , r2 , ….. , rk are the k distinct non-trivial roots
an = b1(r1)n + b2(r 2)n + … + bk(rk)n
where bj can be determined by solving the k linear equations derived from the k initial conditions:
a0 = C0 è C0 = b1(r1)0 + b2(r2)0 + … + bk(rk)0 = b1 + b2+ … + b k
a1 = C1 è C1 = b1(r1)1 + b2(r2) 1 + … + bk(rk)1 = b1r1+ b2 r2 + … + bkrk
… … … ….
a k-1 = C k-1 è Ck-1 = b1(r1)k-1 + b2(r2 )k-1 + … + bk(rk)k-1
Special cases : when k = 2 , eq.2 reduces to a quadratic equation :
t2 - c1t - c2 = 0
and always can be solved using the quadratic formula :
r = ( c1 ± ( (c1)2 - 4 c2) 1/2 )/2
an = A(r1)n + B(r2)n if r1 ¹ r2
and an = A(r)n + Bn(r)n if r1 = r2 = r