In the post Recurrence Relation (Part 1) we studied three examples of recurrence relations. In this post we will solve them. The recurrence relation (Tn = Tn-1 + Tn-2) of Fibonacci problem is linear and has order 2 and degree 1. It is also homogeneous. The recurrence relation (Tn = 2Tn-1 + 1) of Tower of Hanoi problem is also linear. It has order 1 and degree 1 but it is non homogeneous. Recurrence relations can exist in many forms as linear or non-linear.
A linear recurrence relation looks like this
Tn = f1(n)Tn-1 + f2(n)Tn-2 + f3(n)Tn-3 + ...+ fr(n)Tn-r+...+fn-1(n)T1 + f(n)
The order of the recurrence relation is r if fi(n) = 0 for i > r.
It is called homogeneous if f(n) = 0 and non-homogeneous if f(n) ≠ 0.
We will consider linear homogeneous and non-homogeneous recurrence relation with constant coefficients. A linear recurrence relation with constant coefficients is given by
Tn = C1Tn-1 + C2Tn-2 + C3Tn-3 + ...+ CrTn-r+...+Cn-1T1 + f(n) where Ci is a constant, 0 < i < n.
The order of the recurrence relation is r if Ci = 0 for i > r.
It is called homogeneous if f(n) = 0 and non-homogeneous if f(n) ≠ 0.
We will solve the linear homogeneous recurrence relation with constant coefficients first. The example of this type of equation which we are going to solve is Fibonacci Problem.
Tn = Tn−1 + Tn−2
Substitute the Terms with the r(the subscript)
We get,
rn = rn−1 + rn−2
Divide throughout by the lowest power term which is rn-2.
We get,
r2 = r + 1
r2 − r − 1 = 0
The above equation is called the characteristic polynomial of the recurrence relation and its roots are called characteristic roots.
The solution of the polynomial is r1 = (1 + √5)/2 and r2 = (1 − √5)/2
The solution of the recurrence relation can be written like this
Tn = A(r1)n + B(r2)n = A[(1 + √5)/2]n + B[(1 − √5)/2]n
T1 = 1 = A[(1 + √5)/2] + B[(1 − √5)/2] = (A + B)/2 + (√5)/2(A − B)
T2 = 1 = A[(1 + √5)/2]2 + B[(1 − √5)/2]2
= A [1 + 5 + 2√5]/4 + B [1 + 5 − 2√5]/4
= A [6 + 2√5]/4 + B[6 − 2√5]/4
We get two relations
(A + B) + (√5)(A − B) = 2 ----(i)
and
3(A + B) + (√5)(A − B) = 2 ----(ii)
Solving the equations simultaneously, we get
3(i) - (ii)
2√5(A − B) = 4
A − B = 2/√5 and substituting in (i) we get
A + B = 0
Again solving simultaneously,
2A = 2/√5
A = 1/√5
B = -1/√5
Hence the solution of the recurrence is
Tn = [1/√5][(1 + √5)/2]n - [1/√5][(1 − √5)/2]n
Next we will solve the recurrence relation Tn = 2Tn−1 + 1 which belongs to the tower of Hanoi problem.
Linear non homogeneous recurrences require us to solve for their homogeneous part then substitute a relation which satisfies the non homogeneous recurrence. There are many methods which are different from it and can be used to solve many recurrences. These methods are
In this method we substitute the earlier term in the recurrence and look at the pattern and solve the series.
Tn = 2Tn−1 + 1
Tn = 2(2Tn−2 + 1) + 1
Tn = 2(2(2Tn−3 + 1) + 1) + 1
As T1 = 1, so we get
Tn = 2n-1 + 1 + 2 + 22 +....+ 2n-2
Tn = 2n-1 + (2n-1 − 1) = 2n − 1
Now we will solve the recurrence Tn = Tn-1 + k. This problem is multiplication problem. This recurrence will be solved by inspection. In inspection we write down enough terms such that we can guess the solution.
T1 = k. Hence,
Tn = Tn−2 + k + k
Tn = Tn−3 + k + k + k
Tn = Tn−4 + k + k + k + k
We can guess the solution to be Tn = nk as the number of k's increases as we use the lower terms of the recurrence and it increases by a definite number..
A linear recurrence relation looks like this
The order of the recurrence relation is r if fi(n) = 0 for i > r.
It is called homogeneous if f(n) = 0 and non-homogeneous if f(n) ≠ 0.
We will consider linear homogeneous and non-homogeneous recurrence relation with constant coefficients. A linear recurrence relation with constant coefficients is given by
The order of the recurrence relation is r if Ci = 0 for i > r.
It is called homogeneous if f(n) = 0 and non-homogeneous if f(n) ≠ 0.
We will solve the linear homogeneous recurrence relation with constant coefficients first. The example of this type of equation which we are going to solve is Fibonacci Problem.
Substitute the Terms with the r(the subscript)
We get,
rn = rn−1 + rn−2
Divide throughout by the lowest power term which is rn-2.
We get,
r2 = r + 1
r2 − r − 1 = 0
The above equation is called the characteristic polynomial of the recurrence relation and its roots are called characteristic roots.
The solution of the polynomial is r1 = (1 + √5)/2 and r2 = (1 − √5)/2
The solution of the recurrence relation can be written like this
Tn = A(r1)n + B(r2)n = A[(1 + √5)/2]n + B[(1 − √5)/2]n
T1 = 1 = A[(1 + √5)/2] + B[(1 − √5)/2] = (A + B)/2 + (√5)/2(A − B)
T2 = 1 = A[(1 + √5)/2]2 + B[(1 − √5)/2]2
= A [1 + 5 + 2√5]/4 + B [1 + 5 − 2√5]/4
= A [6 + 2√5]/4 + B[6 − 2√5]/4
We get two relations
(A + B) + (√5)(A − B) = 2 ----(i)
and
3(A + B) + (√5)(A − B) = 2 ----(ii)
Solving the equations simultaneously, we get
3(i) - (ii)
2√5(A − B) = 4
A − B = 2/√5 and substituting in (i) we get
A + B = 0
Again solving simultaneously,
2A = 2/√5
A = 1/√5
B = -1/√5
Hence the solution of the recurrence is
Tn = [1/√5][(1 + √5)/2]n - [1/√5][(1 − √5)/2]n
Next we will solve the recurrence relation Tn = 2Tn−1 + 1 which belongs to the tower of Hanoi problem.
Linear non homogeneous recurrences require us to solve for their homogeneous part then substitute a relation which satisfies the non homogeneous recurrence. There are many methods which are different from it and can be used to solve many recurrences. These methods are
- Method of iteration
- Method of substitution
- Method of telescoping sums
- Method of inspection
In this method we substitute the earlier term in the recurrence and look at the pattern and solve the series.
Tn = 2Tn−1 + 1
Tn = 2(2Tn−2 + 1) + 1
Tn = 2(2(2Tn−3 + 1) + 1) + 1
As T1 = 1, so we get
Tn = 2n-1 + 1 + 2 + 22 +....+ 2n-2
Tn = 2n-1 + (2n-1 − 1) = 2n − 1
Now we will solve the recurrence Tn = Tn-1 + k. This problem is multiplication problem. This recurrence will be solved by inspection. In inspection we write down enough terms such that we can guess the solution.
T1 = k. Hence,
Tn = Tn−2 + k + k
Tn = Tn−3 + k + k + k
Tn = Tn−4 + k + k + k + k
We can guess the solution to be Tn = nk as the number of k's increases as we use the lower terms of the recurrence and it increases by a definite number..
No comments:
Post a Comment