Discrete Mathematics
1
Module-4
Recurrence Relations
����In this chapter, we will discuss how recursive techniques can derive sequences and be used for�solving counting problems. ���The procedure for finding the terms of a sequence in a recursive manner is called recurrence relation.���
2
�The sequence which is defined by indicating a relation connecting its general term an with an-1, an-2, etc is called a recurrence relation for the sequence.���A recurrence relation is an equation that defines a sequence based on a rule that gives the next term as a function of the previous term(s). ��The simplest form of a recurrence relation is the case where the next term depends only on the immediately previous term.���
3
4
If we denote the nth term in the sequence by xn, such a recurrence relation is of the form
for some function f.
One such example is xn+1=2−xn/2.
A recurrence relation can also be higher order, where the term xn+1 could depend not only on the previous term xn
but also on earlier terms such as xn−1, xn−2, etc.
Recurrence relation is also called as "Linear recursive sequences".
5
Common examples of Recurrence Relations are
Example | Recurrence Relation |
Fibonacci Sequence | F(n) = F(n-1) + F(n-2) |
Factorial of a number n | F(n) = n * F(n-1) |
Merge Sort | T(n) = 2*T(n/2) + O(n) |
Tower of Hanoi | H(n) = 2*H(n-1) + 1 |
Example
Let {an} be a sequence that satisfies the recurrence relation an=an-1 – an-2 for n=2, 3, 4, … and suppose that a0=3 and a1=5, what are a2 and a3?
Using the recurrence relation,
a2=a1-a0=5-3=2
and
a3=a2-a1=2-5=-3
6
Example
Determine whether the sequence {an}, where an=3n for every nonnegative integer n, is a solution of the recurrence relation an=2an-1 – an-2 for n=2, 3, 4, …
Suppose an=3n for every nonnegative integer n. Then for n≥2, we have 2an-1-an-2=2(3(n-1))-3(n-2)=3n=an.
Thus, {an} where an=3n is a solution for the recurrence relation
7
8
Order of the Recurrence Relation:
The order of the recurrence relation or difference equation is defined to be the difference between the highest and lowest subscripts of f(x) or ar=yk.
Example1: The equation 13ar+20ar-1=0 is a first order recurrence relation.
Example2: The equation 8f (x) + 4f (x + 1) + 8f (x+2) = k (x)
9
Degree of the Difference Equation:
The degree of a difference equation is defined to be the highest power of f (x) or ar=yk
Example1: The equation y3k+3+2y2k+2+2yk+1=0 has the degree 3, as the highest power of yk is 3.
Example2: The equation a4r+3a3r-1+6a2r-2+4ar-3 =0 has the degree 4, as the highest power of ar is 4.
Example3: The equation yk+3 +2yk+2 +4yk+1+2yk= k(x) has the degree 1, because the highest power of yk is 1 and its order is 3.
Example4: The equation f (x+2h) - 4f(x+h) +2f(x) = 0 has the degree1 and its order is 2.
A Recurrence Relations is called linear if its degree is one.
The general form of linear recurrence relation with constant coefficient is
Where C0,C1,C2......Cn are constant and R(n) is same function of independent variable n.
A solution of a recurrence relation in any function which satisfies the given equation.
Linear Homogeneous Recurrence Relations with Constant Coefficients:
The equation is said to be linear homogeneous difference equation if and only if R (n) = 0 and it will be of order n.
The equation is said to be linear non-homogeneous difference equation if R (n) ≠ 0.
12
13
Solving Recurrence Relations
In general, we would prefer to have an explicit formula to compute the value of an rather than conducting n iterations.
For one class of recurrence relations, we can obtain such formulas in a systematic way.
Those are the recurrence relations that express the terms of a sequence as linear combinations of previous terms.
16
Solving Recurrence Relations
Definition: A linear homogeneous recurrence relation of degree k with constant coefficients is a recurrence relation of the form:
an = c1an-1 + c2an-2 + … + ckan-k,
Where c1, c2, …, ck are real numbers, and ck ≠ 0.
A sequence satisfying such a recurrence relation is uniquely determined by the recurrence relation and the k initial conditions
a0 = C0, a1 = C1, a2 = C2, …, ak-1 = Ck-1.
17
Solving Recurrence Relations
Basically, when solving such recurrence relations, we try to find solutions of the form an = rn, where r is a constant.
an = rn is a solution of the recurrence relation� an = c1an-1 + c2an-2 + … + ckan-k
if and only if rn = c1rn-1 + c2rn-2 + … + ckrn-k.
Divide this equation by rn-k and subtract the right-hand side from the left:
rk - c1rk-1 - c2rk-2 - … - ck-1r - ck = 0
This is called the characteristic equation of the recurrence relation.
18
Solving Recurrence Relations
The solutions of this equation are called the characteristic roots of the recurrence relation.
Let us consider linear homogeneous recurrence relations of degree two.
Theorem 1: Let c1 and c2 be real numbers. Suppose that
r2 – c1r – c2 = 0 has two distinct roots r1 and r2.
Then the sequence {an} is a solution of the recurrence relation
an = c1an-1 + c2an-2 if and only if
an = α1r1n + α2r2n for n = 0, 1, 2, …,
where α1 and α2 are constants.
19
Solving Recurrence Relations
Example: What is the solution of the recurrence relation
an = an-1 + 2an-2 with a0 = 2 and a1 = 7 ?
Solution: The characteristic equation of the recurrence relation is r2 – r – 2 = 0.
Its roots are r = 2 and r = -1.
Hence, the sequence {an} is a solution to the recurrence relation if and only if:
an = α12n + α2(-1)n for some constants α1 and α2.
20
Solving Recurrence Relations
Given the equation an = α12n + α2(-1)n and the initial conditions a0 = 2 and a1 = 7, it follows that
a0 = 2 = α1 + α2
a1 = 7 = α1⋅2 + α2 ⋅(-1)
Solving these two equations gives us�2=α1+α2(Equation 1)
7=2α1−α2(Equation 2)
First, we can add Equation 1 and Equation 2 to eliminate α2:
9=3α1 Therefore α1=3 & α2 = -1
These values satisfy both equations: For Equation 1: 2=3−1
For Equation 2: 7=2⋅3−(−1)=6+1
Therefore, α1=3 and α2=−1 are the correct solutions.
21
Solving Recurrence Relations
Therefore, the solution to the recurrence relation and initial conditions is the sequence {an} with
an = 3⋅2n – (-1)n.
22
Solving Recurrence Relations
But what happens if the characteristic equation has only one root?
How can we then match our equation with the initial conditions a0 and a1 ?
Theorem 2: Let c1 and c2 be real numbers with c2 ≠ 0. Suppose that r2 – c1r – c2 = 0 has only one root r0. �
A sequence {an} is a solution of the recurrence relation
an = c1an-1 + c2an-2 if and only if � an = α1r0n + α2nr0n, for n = 0, 1, 2, …,
where α1 and α2 are constants.
23
Solving Recurrence Relations
Example: What is the solution of the recurrence relation
an = 6an-1 – 9an-2 with a0 = 1 and a1 = 6?
Solution: The only root of r2 – 6r + 9 = 0 is r0 = 3.
�Hence, the solution to the recurrence relation is
an = α13n + α2n3n for some constants α1 and α2.
To match the initial condition, we need
a0 = 1 = α1� a1 = 6 = α1⋅3 + α2⋅3
Solving these equations yields α1 = 1 and α2 = 1.
Consequently, the overall solution is given by
an = 3n + n3n.
24
The closed-form solution is a n =Ar^ n , where A is the initial condition.
Solve the recurrence relation
Solution
The characteristic equation of the recurrence relation is − x2−5x+6=0,
Hence, the roots are − x1=3 and x2=2
Hence, there is single real root x1=5