Prerequisite – Solving Recurrences, Different types of recurrence relations and their solutions, Practice Set for Recurrence Relations

The sequence which is defined by indicating a relation connecting its general term a_{n} with a_{n-1}, a_{n-2}, etc is called a **recurrence relation** for the sequence.

### Types of recurrence relations

**First order Recurrence relation :-**A recurrence relation of the form :**a**for n>=1_{n}= ca_{n-1}+ f(n)

where c is a constant and f(n) is a known function is called linear recurrence relation of first order with constant coefficient. If f(n) = 0, the relation is homogeneous otherwise non-homogeneous.**Example :-**x_{n}= 2x_{n-1}– 1, a_{n}= na_{n-1}+ 1, etc.**Question :-**Solve the recurrence relation T(2^{k}) = 3T(2^{k-1}) + 1, T(1) = 1.

Let T(2^{k}) = a_{k}. Therefore, a_{k}= 3a_{k-1}+ 1

Multiplying by x^{k}and then taking sum,

Σa_{k}x^{k}= 3Σa_{k-1}x^{k}+ Σx^{k}——> (1)

Σa_{k-1}x^{k}= [a_{0}x + a_{1}x^{2}+ ……]

= x[a_{0}+ a_{1}x + ……] = x[G(x)]

(1) becomes

G(x) – 3xG(x) – x/(1-x) = 0

G(x)(1-3x) – x/(1-x) = 0

G(x) = x/[(1-x)(1-3x)] = A/(1-x) + B/(1-3x)

–> A = -1/2 and B = 3/2

G(x) = (3/2)Σ(3x)^{k}– (1/2)Σ(x)^{k}

Coefficient of x^{k}is, a_{k}= (3/2)3^{k}– (1/2)1^{k}

So, a_{k}= [3^{k+1}– 1]/2.**Second order linear homogeneous Recurrence relation :-**A recurrence relation of the form**c**——> (1)_{n}a_{n}+ c_{n-1}a_{n-1}+ c_{n-2}a_{n-2}= 0

for n>=2 where c_{n}, c_{n-1}and c_{n-2}are real constants with c_{n}!= 0 is called a second order linear homogeneous recurrence relation with constant coefficients.

Solution to this is in form a_{n}= ck^{n}where c, k!=0

Putting this in (1)

c_{n}ck^{n}+ c_{n-1}ck^{n-1}+ c_{n-2}ck^{n-2}= 0

c_{n}k^{2}+ c_{n-1}k + c_{n-2}= 0 —–> (2)

Thus, a_{n}= ck^{n}is solution of (1) if k satisfies quadratic equation (2). This equation is called characteristic equation for relation (1).

Now three cases arises,**Case 1 :**If the two roots k_{1}, k_{2}of equation are real and distinct then, we take**a**as general solution of (1) where A and B are arbitrary real constants._{n}= A(k_{1})^{n}+ B(k_{2})^{n}**Case 2 :**If the two roots k_{1}, k_{2}of equation are real and equal, with k as common value then, we take**a**as general solution of (1) where A and B are arbitrary real constants._{n}= (A + Bn)k^{n}**Case 3 :**If the two roots k_{1}and k_{2}of equation are complex then, k_{1}and k_{2}are complex conjugate of each other i.e k_{1}= p + iq and k_{2}= p – iq and we take**a**as general solution of (1) where A and B are arbitrary complex constants, r = |k_{n}= r^{n}(Acosnθ + Bsinnθ)_{1}| = |k_{2}| = √p^{2}+ q^{2}and θ = tan^{-1}(q/p).

**Question :- **Solve the recurrence relation a_{n} + a_{n-1} – 6a_{n-2} = 0 for n>=2 given that a_{0} = -1 and a_{1} = 8.

Here coefficients of a_{n}, a_{n-1} and a_{n-2} are c_{n} = 1, c_{n-1} = 1 and c_{n-2} = -6 respectively. Hence, characteristic equation is

k^{2} + k – 6 or (k + 3)(k – 2) = 0 ——> (1)

The roots of (1) are k_{1} = -3 and k_{2} = 2 which are real and distinct. Therefore, general solution is

a_{n} = A(-3)^{n} + B(2)^{n}

where A and B are arbitrary constants. From above we get, a_{0} = A + B and a_{1} = -3A + 2B

A + B = -1

-3A + 2B = 8

Solving these we get A = -2 and B = 1

Therefore, a_{n} = -2(-3)^{n} + (2)^{n}

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the **CS Theory Course** at a student-friendly price and become industry ready.