Beruflich Dokumente
Kultur Dokumente
Adamchik 1
Recursions
Victor Adamchik
Fall of 2005
Plan
1. Recurrence relations
2. Solving First Order Linear Recurrences
Recurrence relations
Definition. If n-th term of a sequence can be expressed as a function of previous terms
xn f xn k , xn k 1, ..., xn 1 , n k
then this equation is called a recurrence relation. The values x1 , x2 , ..., xk must be explic-
itely given. They are called initial conditions. The function f in the definition above may
depend upon all or some previous terms.
In this lecture we will we will outline some methods of solving recurrence relation. By
solving we mean to find an explicit form of xn as a function of n that is free of previous
terms except ones given in initial conditions.. For example, the Towers of Hanoi recur-
rence relation
xn 2 xn 1 1
x1 1
xn 2n 1
Recurrences are classified by the way in which terms are combined. Here is a list of some
of the recurrences
First Order
Linear an 2 an 1 1
1
Non-Linear an 1 an 1
V. Adamchik 21-127: Concepts of Mathematics
Second Order
Linear an an 1 an 2
Non-Linear an an 1 an 2
Higher Order
an an 1 an 2 an 3
an a0 an 1 a1 an 2 ... an 1 a0
Merge Sort an a n
2
a n
2
n
an n an 1
an an 1 n
an n an 1 n
The first two equations are called homogeneous. The last two equations are called
inhomogeneous.
an an 1
an 2 an 1
an 1 2 an 2
an 2 2 an 3
V. Adamchik 3
...
a2 2 a1
Performing back-substitution, we obtain
an 2 an 1 22 an 2 23 an 3 . .. 2n 1 a1
Hence,
an 2n 1
an n an 1
a1 1
an an 1 n
As an example of the inhomogeneous type, we consider
an an 1 n
a1 1
Applying the recurrence to itself
an an 1 n
an 1 an 2 n 1
an 2 an 3 n 2
V. Adamchik 21-127: Concepts of Mathematics
...
a2 a1 2
and performing back-substitution
an an 1 n an 2 n n 1 an 3 n n 1 n 2 . ..
we obtain
an n n 1 ... 2 1
n n 1
an
2
Theorem 3. The recurrence
an an 1 n, n 1
an a1. n n 1 ... 2 2
n
an a1 k
k 2
an an 1 n
The Towers of Hanoi recurrence relation
an 2 an 1 1
a1 1
We proceed in the same way as above. First we use iteration
an 2 an 1 1
an 1 2 an 2 1
an 2 2 an 3 1
...
a2 2 a1 1
and then back-substitution
an 2 an 1 1 22 an 2 2 1 23 an 3 22 2 1 ...
The solution is
an 2n 1
a1 2n 2
2n 1
... 2 1
or (since a1 1)
an 2n 1 2n 2 2n 1 ... 2 1 2n 1
V. Adamchik 5
a0 1
an n an 1 n
The explicit solution in this case is left as an exercise to the reader.
a1 1
Note. Solving recurrence equations by iteration is not a method of proof. Therefore, to be
formally correct we need to combine iteration with induction.