Recurrence Relation and Generating Functions Notes
Recurrence Relation and Generating Functions Notes
Introduction :
Recursion is an elegant and powerful problem solving technique, used extensively in
both discrete mathematics and computer science. Many programming languages, such
as ALGOL, FORTRAN 90, C++ and Java, support recursion.
In addition, there are three simple methods for solving recurrence relations : iterations,
characteristic equations and generating functions.
We also establish the validity of recursive algorithms using induction and analyze their
complexities using bigoh and bigtheta notations.
Definition :
An equation that expresses a n , the general term of the sequence {an} in terms of one or
more of the previous terms of the sequence, namely a 0 , a1 , ………, an1 for all integers n
with n n0 , where n0 is an called a recurrence relation for {an} or a difference equation.
If the terms of a sequence satisfy a recurrence relation, then the sequence is called a
solution of recurrence relation.
Type I
Non-Homogenous, Linear Recurrence Relation
1. Determine the sequence a n whose recurrence relation is an = an1 + 3 with initial
condition a1 = 2.
Soln. :
This is linear, nonhomogenous recurrence relation.
We use back tracking method
an = an1 + 3 with a1 = 2
an = an2 3 3
= an2 3 3
= an3 33 3
= an3 3 3 3
= ann1 3 3 3 ... to (n 1)
= a1 + 3(n 1)
= 3n 1
Sequence is 2, 5, 8, 11, …
2. Determine the sequence b n whose recurrence relation is bn = 2bn1 + 1 with initial
condition b1 = 7.
Soln. :
The recurrence relation is linear & nonhomogenous
We use back tracking method
b n = 2bn1 + 1, b1 = 7
bn = 2(2bn2 + 1) + 1
= 22 bn2 2 1
= 22 2b n3 12 1
= 23 bn3 22 2 1
…………………….
= 2n1b 2 n2 2n3 ... 2 1
n n1
n1 2 n2
=
2 b1 12 2 ... 2
= 2n1 7
12 n1
1
2 1
= 7 2 2 1
n1 n1
Type II
Homogenous, Linear Recurrence Relation
Note :
(a) If the characteristic equation ax2 + bx + c = 0 has two roots s 1 and s 2 , then
Case (i) If s 1 ≠ s 2 , then the formula for the sequence is given by a n = us 1n vs 2n
Case (ii) If it has equal roots each = s, then the formula for the sequence is given
n n
by an = us + vns , where u and v are constants depending on initial
conditions.
(b) If the characteristic equation ax3 + bx2 + cx + d = 0 has 3 roots S 1, S 2 and S3 then
Case (i) if, s 1 = s 2 = s 3 = s (say)
then the formula for the sequence is given by
a n = (u +v n + wn2) . sn
Case (ii) if s 1 = s 2 = s (say)
and s s 3
then the formula for the sequence is given by
an = (u vn).s n n
w s3
Case (iii) if s1 s2 s3
then the formula for the sequence is given by
an u s1n v s2n w s3n
where u, v, w are constants depending on initial conditions.
3. Determine the sequence whose recurrence relation is given by C n = 3Cn1 2Cn2
with initial conditions C 1 = 5, C 2 = 3.
[D-08]
Soln. :
The quadratic equation associated with this recurrence relation is x2 = 3x 2 with
every linear homogenous recurrence relation there is associated a quadratic
equation.
C n = 3Cn 1 2 C n 2
x2 = 3x 2
x 3x + 2 = 0
2
4. Determine the sequence whose recurrence relation is a n = 2an1 an2 with initial
conditions a1 = 1.5, a2 = 3. [M-09]
Soln. :
a n = 2an1 an2 & the associated quadratic equation is x = 2x 1
2
x2 2x + 1 = 0
(x 1)2 = 0
x = 1, 1
Formula for sequence is an u1 vn1
n n
an u vn
Put n = 1
a1 = u + v u + v = 1.5 …(1)
Put n = 2
a2 = u + 2v u + 2v = 3 …(2)
v = 1.5 & u = 0
a n = (1.5) n
The sequence is 1.5, 3, 4.5, 6, …
5. Determine the sequence whose recurrence relation is a n = 4an1 5an2 with a1 = 2
& a2 = 6.
Soln. :
x2 = 4x + 5 x2 4x 5 = 0
x 5x + x 5 = 0
2
Put n = 1
a1 = u + 5vu + 5v = 2 …(1)
Put n = 2
a2 = u + 25v u + 25v = 6 …(2)
30 v = 8
v = 4/15
u + 4/3 = 2
4 2
u = 2
3 3
2 n 4 n
1
5
an =
3 15
Fibonacci Sequence
1, 1, 2, 3, 5, 8, …
fn fn1 fn2
The recurrence relation is given by fn fn1 fn2 which is homogenous & linear. The
quadratic equation is x2 = x + 1, f 1 = f2 = 1
x2 x 1 = 0
114
x =
2
1 5
x =
2
x1 1 5 ; x 1 5
2 2 2
fn = us1 vs 2
n n
n n
1 5 1 5
fn = u
v
2 2
Put n = 1
1 5 v 15
f1 =
u
2 2
u1 5 v1 5
= 1 …(1)
2 2
Put n = 2
2 2
1 5 15
f 2 = u
v 2
2
2 5 2
u1 5 v1 =1 …(2)
2 2
1 1
Solving (1) & (2) simultaneous u & v
5 5
n n
1 1 5 1 1 5
fn =
5 2 5 2
Procedure to find particular solution :
For the certain functions F(n) such as polynomials in n and power of constants, the forms
of the corresponding particular solution.
When F(n) is linear combination of the terms is 1st column then an(p) is the linear
combination of corresponding terms in 2nd column.
Solved Examples :
1. Find the solution of recurrence relation.
a n = 5a n1 6a n2 + 7n
Soln.:
Given recurrence relation is
a n = 5a n1 6a n2 + 7n
a n 5a n1 6a n2 = 7n …(1)
For homogeneous solution
Put a n = x2, a n 1 = x and a n 2 = 1
the characteristic equation is given by
x2 5x + 6 = 0
(x 2) (x + 3) = 0
x = 2, 3
(h) n n
an = u(2) v(3) …(2)
For particular solution
(p) n
an = A(7)
Sub in (1)
A(7)n 5A(7)n1 6A(7)
5 6
n2
= 7n
1
A(7)n = 7n
7 49
Comparing
5both sides 49
6
A 1 = 1, A =
7 49 20
49 n
(p)
(7) …(3)
an =
20
Adding equations (2) and (3) w.r.t. t
n n 49 n
a = (h) (p)
u(2) v(3) (7)
an an =
20
2. (i) a 5a 6a 3r2 (ii) a 5a 6a 3 r2 2r 1
r r1 r2 r r1 r2
Soln.:
(i) a 5a 6a 3r2 …(1)
r r1 r2
This is a linear and nonhomogeneous recurrence relation.
Its solution is given by
(H) (p)
ar = ar ar
where a r(H) is homogeneous solution and apn is particular solution.
x2 5x 6 = 0
(x + 2) (x + 3)= 0
x = 2, x = 3 arH u(2)r v(3)r (u, v are constants)
For particular solution,
the particular solution of f(n) = 3r2 is given by A 2r2 A1r A 0 where A2,A1,A0
are constants.
apr = A 2r 2 A1r A0
2
ar1 = A2 (r 1) A1(r 1) A0
ar2 = A2 (r 2)2 A1(r 2) A0
2 2 2
[A2r A1r A0 ] 5[A 2 (r 1) A1(r 1) A0 ] 6[A2 (r 1) A1(r 1) A0 ] 3r
…(from (1))
Simplifying the above equation, we get
2 2
12 A2r (34A2 12A1)r (12A0 29 A2 17A1) 3r
Comparing coefficients, we get,
1
12 A2 = 3 A =
2
17 4
12A1 34A2 = 0 A1 =
24
115
29A2 17A1 12A0 = 0 A0 =
288
Particular solution is
1 2 17 115
anp = r
4 24 r 288
Soln.:
an = 3an1 3an2 an3
an 3an1 3an2 an3 = 0
It is a linear Homogeneous recurrence relation.
Its characteristic equation is
x3 3x2 3x 1 = 0
(x 1)3 = 0
x = 1, 1, 1
There are three equal roots, the homogeneous solution is given by
an(h) = (u vn wn2 )(1)n
where u, v, w are constants
a0 = 1
1 = (u v 0 w 0) (1)0
u = 1
a1 = 2
2 = (u 1v 1w)(1)
1 = v+w
and a2 = 1
1 = (u 2v 4w)(1)
2 = 2v + 4w
1 = v + 2w
2 = w
w = 2
v = 3
Solution is
an = (13n 2n2 )(1)n
Soln.:
Given recurrence relation is
an = 3a 3a a
n1 n2 n3
where a0 5, a1 9, a2 15
The characteristic equation is
x3 3x2 3x 1 = 0
(x 1) = 0
3
x = 1, 1, 1
The homogeneous solution is
(h) 2 n
an = (u vn wn ) (1) …(1)
Putting n = 0 in (1)
5 = (u + 0 + 0) 1
u = 5
Putting n = 1 in (1),
9 = (u + v + w) (1)
9 = 5+v+w
4 = v+w …(2)
Putting n = 2 in (1), we get,
15 = (u 2v 4w)(1)2
15 = 5 + 2v + 4w
5 = v + 2w …(3)
w = 1 (From (2), (3))
v = 3
Solution is
an = (5 3n n2 ) (1)n
5. Find the solution to the recurrence relation a n = 6 an1 11an2 + 6an3 with initial
condition
a0 = 2, a1 = 5 and a2 = 15.
Soln.:
an = 6 an1 11an2 + 6an3
where a0 = 2, a1 = 5, a 2 = 15
Recurrence relation is
Its characteristic equation is
x3 6x2 11x 6 = 0
x x (5x2 11x 6) =
3 2
0
x 2 (x 1) [(5x 6)(x 1)] = 0
(x 1) (x 5x 6) =
2
0
(x 1) (x 2) (x 3) = 0
x = 1, 2, 3
Putting n = 0
2 = u+v+w
Putting n = 1
5 = u + 2v + 3w
Putting n = 2
w = 2; v + 2w = 3 ; 2v + 3w = 5
15 = u + 4v + 9w
Solving the above system of linear equations, we get
u = 1
v = 1
w = 2
Solution of the recurrence relation is
n n
an = 1(2) 2 : (3)
Graded Questions :
Generating Functions
Definition :
Let a0 , a1 , a2 , a3 …. be a sequence of real numbers, then the function.
2 3 n
g(x) = a0 + a1 x + a2 x + a3 x + …. + a n x + ….
is the generating function for the sequence. {an}.
Generating functions for a finite sequence a 0 , a , …., a n can also be defined by letting
n1n
ai = 0 for i > n. Thus,, g (x) = a 0 + a1 x + …. + a n x is the generating function for the finite
sequence a0 , a1 , …., an
e.g. g(x) = 1 + 2x + 3x2 + …. + (n+1)xn + ….
is the generating function for positive integers.
Uses :
To solve Linear Homogenous Recurrence Relations With Constant Coefficient
(LHRRWCC).
To solve combinatorial problems.
Abraham De Moivre, their inventor, used them to solve the Fibonacci recurrence
relation.
Shifting Properties
Solved Examples :
Soln. :
Let G(x) = 1 + ax + a2x2 + a3x3 + ……
So, G(x) 1 = ax + a2x2 + a3x3 + ……
G x1
1ax a 2x2 ......
ax
G x 1
G x
ax
G x 1
1ax
1
required generating function is .
1ax
Soln.:
Let G(x) =
n0
a n xn where G(x) is general function for sequence {an}.
an xn 2 3n xn xn
n0 n0 n0
Soln. :
To find formula,
1 1 1 1 1 1 1 1 1 1
(a) , , , , = , , , ,
1 2 4 8 16
20 2 2 1 2
2 3
24
n
4
= 1
n0 2
(b) 1, 3, 5, 7, 9
This is arithmetic progression,
Here a = 1, d = 2
Now, tn = a + (n 1)d
= 1 + (n 1) 2 = 2n 1
5
tn 2n 1
n1
r0
4. Let G(x) be generating function for sequence {aK}. What is generating function for
following sequence ?
(i) 0, 0, 0, a 3 , a4 , a5 ,………. (ii) 0, 0, 0, 0, a 4 , a5 , a6 , ……….
(iii) a4 , a 5 , a6 , ………. (iv) 0, 0, 0, a0 , a1 , a2 ,……….
(v) 0, 0, 0, 0, a0 , a 1 , a2 , ……..
Soln.:
(i) G(x) =
n0
a n xn generates the sequence,
a0 , a 1 , a2 ,………...
G(x) a0 generates the sequence
0, a, a2 , a3 , …………
Similarly
G(x) a0 a1x a2x 2 generates the sequence,
0,0,0, a 3 , a4 , a5 ,…………
(ii) G(x) anxn generates the sequence a0,a1,a2,...........
n 0
Same as in (i) part
G(x) a 0 a 1x a 2x2 a 3x3 generates the sequence
0, 0, 0, 0, a 4 , a5 ,a6 ,…………..
(iii) G(x) anxn generates the sequence, a 0 , a1 , a2 , a3 ,……….
n 0
G(x) a0
generates the sequence,
x
a1,a2,a3,..............
G(x) a0 a1x
generates the sequence,
x2
a 2 ,a 3 ,a4 ,........
Similarly
G(x) a 0 a1x .......... a KxK
…(1)
xK1
gives the generating function,
G(x) a nK1xn
n 0
and it generates the sequence
aK1,aK2,aK3,.............
putting K = 3 in (1)
G(x) a 0 a1x a 2 x 2 a 3 x 3
generates the sequence
x4
a4,a5,a6,..........
(iv) G(x) anxn generates the sequence
n 0
a0,a1,a2,.............
x G(x) anxn1 generates the sequence,
n 0
0,a0,a1,a2,............
x2 G(x) anxn2 generates the sequence,
n 0
0,0,a0,a1,a2,...........
Similarly
xK G(x) anxnk generates the sequence,
n 0
0,0
,
...
...
....
.
.0,a 0 ,a1,a 2 ,............... …(1)
K times
putting K = 3 in (1)
x3 G(x) anxn3 generates the sequence
n 0
0,0,0,a0,a1,a2,...........
(v) G(x) anxn generates the sequence
n 0
a0,a1,a2,a3 ,............
x G(x) anxn1 generates the sequence
n 0
0,a0,a1,a2,...........
Similarly
xK G(x) anxnK generates the sequence,
n 0
0,0
,0
,
0,...
....
...
.
.0,a 0 ,a1,a 2 ,............... …(1)
K times
Putting K = 4 in (1)
x4 G(x) anxn4 generates the sequence
n 0
0,0,0,0,a0 ,a1,a2,...........
Graded Questions :
1. What are the generating functions for the following sequences ?
(i) 1, 1, 1, 1, 1, 1
(ii) 1, 1, 1, 1, . . . .
2. Conjecture a simple formula for a n if the first 10 terms of the sequence {a n} are
1, 7, 25, 79, 241, 727, 2185, 6559, 19687, 59047
3. Solve the recurrence relation a n + 2 5an + 1 + 6an = 2 with initial conditions a0 = 1,
a1 = 1. [D-09]
4. Find the generating function of the following sequences [D-09]
(i) 1, 0, 1, 0, 1, 01, 0, ........
(ii) 1, 1, 1, 1, 1, ........
5. Give the exponential generating functions for the sequences given below : [M-10]
(i) {1, 1, 1, …………….}
(ii) (0, 1, 0, 1, 0, 1, 0, 1, ………………}
6. Solve the recurrence relation a n = 4 (an 1 an 2 ) where a0 = 1, a1 = 1. [D-12]
7. Find the solution to the recurrence relation : [M-13]
a n = an 1 + 2 n 2
subject to initial condition a 1 = 3