Recurrence Relations
Recurrence Relations
DISCRETE MATHEMATICS
S.E.(COMPUTER) SEM-IV
RECURRENCE RELATIONS
➢ GENERATING FUNCTIONS
• 1, 2, 3, 5, 8,…
• 1, 3, 9, 27, 81, …
▪ Sequences arise throughout mathematics, computer science, and in many
other disciplines, ranging from botany to music.
The notation 𝑎𝑛 is used to denote the image of the integer n. We can think 𝑎𝑛
as equivalent of 𝑓(𝑛) where f is a function from {0, 1, 2, 3, 4, …} to S.
INTRODUCTION
Definition: A recurrence relation for the sequence 𝑎𝑛 is an equation that expresses 𝑎𝑛
in terms of one or more of the previous terms of the sequence, namely, 𝑎0 , 𝑎1 , 𝑎2 ,…
𝑎𝑛−1 , for all integers n with 𝑛 ≥ 𝑛0 where 𝑛0 is a nonnegative integer.
• A sequence is called a solution of a recurrence relation if its terms satisfy the
recurrence relation.
• Finding a formula for the nth term of the sequence generated by a recurrence
relation is called solving the recurrence relation.
• The initial conditions for a sequence specify the terms that precede the first term
where the recurrence relation takes effect.
INTRODUCTION
• Example: Let 𝑎𝑛 be a sequence that satisfies the recurrence relation
𝑎𝑛 = 𝑎𝑛−1 + 3 for 𝑛 = 1,2,3,4, … and suppose that 𝑎0 = 2. What are
𝑎1 , 𝑎2 and 𝑎3 ?
Solution: 𝑎1 = 𝑎0 + 3 = 2 + 3 = 5
𝑎2 = 𝑎1 + 3 = 5 + 3 = 8
𝑎3 = 𝑎2 + 3 = 8 + 3 =11
• Example: Let 𝑎𝑛 be a sequence that satisfies the recurrence relation
𝑎𝑛 = 𝑎𝑛−1 + 𝑎𝑛−2 ; 𝑛 ≥ 2 and 𝑎0 = 0 and 𝑎1 = 1 (Fibonacci sequence)
Solution: 𝑎2 = 𝑎1 + 𝑎0 = 1 + 0 = 1
𝑎3 = 𝑎2 + 𝑎1 = 1 + 1 = 2
𝑎4 = 𝑎3 + 𝑎2 = 2 + 1 = 3
INTRODUCTION
• Example: Consider the recurrence relation
𝑎𝑛 = 𝑛𝑎𝑛−1 ; 𝑛 ≥ 1 𝑎𝑛𝑑 𝑎0 = 2.
The solution is 𝑎𝑛 = 𝑛!
• Example:
𝑎𝑛 = 2𝑎𝑛−1 + 1; 𝑛 ≥ 2 and 𝑎1 = 1
The solution is 𝑎𝑛 = 2𝑛 − 1
FORMULATION
Example 1: A person invest Rs. 10,000 in a savings account @ 12% interest compounded annually. Find
the recurrence relation for the amount 𝑎𝑛 at the end of n years. How much will be there at the end of 15
years?
Solution: Let 𝑎𝑛 be the amount at the end of n years.
The amount at the end of n years is equal to the amount at the end of n-1 years plus the interest on that
amount.
𝑎𝑛 = 𝑎𝑛−1 + 0 ⋅ 12 𝑎𝑛−1 ; 𝑛 ≥ 1, 𝑎0 = 10000
𝑎𝑛 = 1.12 𝑎𝑛−1 ; 𝑛 ≥ 1, 𝑎0 = 10000
𝑎𝑛 = 1.12 𝑎𝑛−1 = 1.12 1.12 𝑎𝑛−2 = 1.12 2 𝑎𝑛−2
= 1.12 3 𝑎𝑛−3
= 1.12 4 𝑎𝑛−4
⋮
= 1.12 𝑛 𝑎0
= 1.12 𝑛 ∙ 10000
The amount at the end of 15 years = 𝑎𝑛 = 1.12 15 ∙ 10000 = 𝑅𝑠. 54735.66
FORMULATION
Example 2: There are two kinds of particles 𝛼 and 𝛽 in a nuclear reactor. In every second, an 𝛼 particle
will split up into 3 𝛽 particles and a 𝛽 particle will split up into an 𝛼 particle and 2 𝛽 particles. If there is a
single 𝛼 particle in the reactor at time 𝑡 = 0, find the recurrence relation for the number of particles
altogether at the end of n seconds. How many particles are there altogether at 𝑡 = 100 seconds ?
Solution: Let 𝑎𝑛 be total number of particles at the end of n seconds.
Since each of 𝛼 and 𝛽 particles splits into 3 particles at the end of every second,
𝑎𝑛 = 3𝑎𝑛−1 , 𝑛 ≥ 1; 𝑎0 = 1
𝑎𝑛 = 3𝑎𝑛−1
= 32 𝑎𝑛−2
= 33 𝑎𝑛−3
⋮
= 3𝑛 𝑎0 = 3𝑛
𝑎100 = 3100 particles
FORMULATION
Example 3: Find the recurrence relation 𝑎𝑛 for the number of ways of arranging n
distinct objects in row.
The first object can be arranged in n ways and the remaining n-1 objects can be
𝐴 = 𝑥1 , 𝑥2 , 𝑥3 , ⋯ , 𝑥𝑛−1 ∪ 𝑥𝑛
.
FORMULATION
• The rules for moving the disks are as follows:
1. Only one disk can be moved at a time.
2. The removed disk must be placed on one of the pegs.
3. A larger disk cannot be placed on top of a smaller disk.
• The objective is to determine the minimum number of moves required to transfer the disks
from the first peg to the third peg.
• Find the recurrence relation 𝑎𝑛 for the minimum number of moves required to transfer n
disks from the first peg to the third peg.
Solution: Let 𝑎𝑛 for the minimum number of moves required to transfer n disks from one peg to
another peg.
n – 1 disks can be transferred from peg 1 to peg 2 in 𝑎𝑛−1 moves.
The largest disk can be transferred from peg 1 to peg 3 in one move.
The n – 1 disks from peg 2 can be transferred to peg 3 in 𝑎𝑛−1 moves.
Therefore, 𝑎𝑛 = 𝑎𝑛−1 + 1 + 𝑎𝑛−1
𝑎𝑛 = 2𝑎𝑛−1 + 1; 𝑛 ≥ 2, 𝑎1 = 1 is the required recurrence relation.
FORMULATION
Example 6: Find the recurrence relation 𝑎𝑛 and give initial conditions for the number of binary sequences(
bit strings) of length n that do not contain the pattern 11.
Solution: Let 𝑎𝑛 be the number of binary sequences( bit strings) of length n that do not contain the
pattern 11.
𝑎𝑛 = 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑏𝑖𝑡 𝑠𝑡𝑟𝑖𝑛𝑔𝑠 𝑠𝑡𝑎𝑟𝑡𝑖𝑛𝑔 𝑤𝑖𝑡ℎ 0 + 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑏𝑖𝑡 𝑠𝑡𝑟𝑖𝑛𝑔𝑠 𝑠𝑡𝑎𝑟𝑡𝑖𝑛𝑔 𝑤𝑖𝑡ℎ 1
If the binary string starts with 0, then we need to append a binary string of length n-1 that do not contain
the pattern 11. There are 𝑎𝑛−1 such bit strings.
If the binary string starts with 1, then the second bit has to be 0. We need to append a binary string of
length n-2 that do not contain the pattern 11. There are 𝑎𝑛−2 such bit strings.
∴ 𝑎𝑛 = 𝑎𝑛−1 + 𝑎𝑛−2 ; 𝑛 ≥ 3, 𝑎1 = 2, 𝑎2 = 3
FORMULATION
Example 7: Find the recurrence relation 𝑎𝑛 and give initial conditions for the number of binary sequences( bit
strings) of length n in which the pattern 11 appears for the first time at the end of the sequence.
Solution: Let 𝑎𝑛 be the number of binary sequences( bit strings) of length n in which the pattern 11 appears for
the first time at the end of the sequence.
𝑎𝑛 = 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑏𝑖𝑡 𝑠𝑡𝑟𝑖𝑛𝑔𝑠 𝑠𝑡𝑎𝑟𝑡𝑖𝑛𝑔 𝑤𝑖𝑡ℎ 0 + 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑏𝑖𝑡 𝑠𝑡𝑟𝑖𝑛𝑔𝑠 𝑠𝑡𝑎𝑟𝑡𝑖𝑛𝑔 𝑤𝑖𝑡ℎ 1
If the binary string starts with 0, then we need to append a binary string of length n-1 in which the pattern 11
appears for the first time at the end of the sequence. There are 𝑎𝑛−1 such bit strings.
If the binary string starts with 1, then the second bit has to be 0. We need to append a binary string of length
n-2 in which the pattern 11 appears for the first time at the end of the sequence. There are 𝑎𝑛−2 such bit
strings.
∴ 𝑎𝑛 = 𝑎𝑛−1 + 𝑎𝑛−2 ; 𝑛 ≥ 3, 𝑎1 = 0, 𝑎2 = 1
FORMULATION
Example 8: Find the recurrence relation 𝑎𝑛 and give initial conditions for the number of binary sequences( bit strings) of
length n that do not contain three consecutive zeros.
Solution: Let 𝑎𝑛 be the number of binary sequences( bit strings) of length n that do not contain three consecutive zeros.
𝑎𝑛 = 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑏𝑖𝑡 𝑠𝑡𝑟𝑖𝑛𝑔𝑠 𝑠𝑡𝑎𝑟𝑡𝑖𝑛𝑔 𝑤𝑖𝑡ℎ 0 + 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑏𝑖𝑡 𝑠𝑡𝑟𝑖𝑛𝑔𝑠 𝑠𝑡𝑎𝑟𝑡𝑖𝑛𝑔 𝑤𝑖𝑡ℎ 1
• If the binary string starts with 1, then we need to append a binary string of length n-1 that do not contain three
consecutive zeros. There are 𝑎𝑛−1 such bit strings.
• Consider the binary strings starting with 0.
If the second bit is 1, we need to append a binary string of length n-2 that do not contain three consecutive zeros.
There are 𝑎𝑛−2 such bit strings.
If the second bit is 0, then the third bit has to be 1. Hence we need to append a binary string of length n-3 that do not
contain three consecutive zeros. There are 𝑎𝑛−3 such bit strings.
∴ 𝑎𝑛 = 𝑎𝑛−1 + 𝑎𝑛−2 + 𝑎𝑛−3 ; 𝑛 ≥ 4, 𝑎1 = 2, 𝑎2 = 4, 𝑎3 = 7
FORMULATION
Example 9: Find the recurrence relation 𝑎𝑛 and give initial conditions for the number of ways of climbing n
stairs if a person climbing the stairs can climb one or two or three stairs at a time.
• If the person takes a single step in the beginning, then the remaining n-1 steps can be climbed in 𝑎𝑛−1
ways.
• If the person jumps over two steps in the beginning, then the remaining n-2 steps can be climbed in
𝑎𝑛−2 ways.
• If the person jumps over three steps in the beginning, then the remaining n-3 steps can be climbed in
𝑎𝑛−3 ways.
Definition: A linear homogeneous recurrence relation of degree ‘k’ with constant coefficients is
a recurrence relation of the form
𝑐0 𝑎𝑛 + 𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + ⋯ + 𝑐𝑘 𝑎𝑛−𝑘 = 𝑓(𝑛)
where 𝑐0 , 𝑐1 , 𝑐2 , …, 𝑐𝑘 are real constants and 𝑐𝑘 ≠ 0
• If 𝑓 𝑛 = 0, the recurrence relation is said to be homogenous otherwise non-homogenous
Examples:
1 𝑎𝑛 = (1.11) 𝑎𝑛−1 linear homogeneous recurrence relation of degree 1
2 𝑓𝑛 = 𝑓𝑛−1 + 𝑓𝑛−2 linear homogeneous recurrence relation of degree 2
3 𝑎𝑛 = 2𝑎𝑛−1 + 1 linear non-homogeneous recurrence relation of degree 1
2
4 𝑎𝑛 = 𝑎𝑛−1 + 𝑎𝑛−2 non linear homogeneous recurrence relation of degree 2
2
5 𝑎𝑛 = 𝑛𝑎𝑛−1 non linear , no constant coefficients,homogenous
METHODS OF SOLUTION OF RECURRENCE RELATIONS
1. Iteration Method: In this method, we apply the recurrence relation repeatedly to obtain the general
expression for 𝑎𝑛 in terms of n.
Examples:
1. Solve the recurrence relation 𝑎𝑛 = 𝑎𝑛−1 + 2, n ≥ 2 , 𝑎1 = 3
Solution: 𝑎𝑛 = 𝑎𝑛−1 + 2
= 𝑎𝑛−2 + 2 + 2 = 𝑎𝑛−2 + 2 ∙ 2
= 𝑎𝑛−3 + 2 + 2 ∙ 2 = 𝑎𝑛−3 + 3 ∙ 2
⋮
= 𝑎1 + (𝑛 − 1) ∙ 2
= 3 + 2(𝑛 − 1)
= 2𝑛 + 1
ITERATION METHOD
2. Solve the recurrence relation 𝑎𝑛 = 𝑎𝑛−1 + n, n ≥ 2 , 𝑎1 = 1
Solution: 𝑎𝑛 = 𝑎𝑛−1 + n
= 𝑎𝑛−2 + 𝑛 − 1 + n
𝑛(𝑛 + 1)
= 𝑎𝑛−3 + 𝑛 − 2 + 𝑛 − 1 + n 1 + 2 + 3 + ⋯+ 𝑛 =
2
= 𝑎𝑛−4 + 𝑛 − 3 + 𝑛 − 2 + 𝑛 − 1 + n
⋮
= 𝑎1 + 2 + 3 + ⋯ + 𝑛 − 1 + n
= 1 + 2 + 3 + ⋯+ 𝑛
𝑛(𝑛+1)
=
2
ITERATION METHOD
3. Solve the recurrence relation 𝑎𝑛 = 2𝑎𝑛−1 + 1, n ≥ 2 , 𝑎1 = 1
Solution: 𝑎𝑛 = 2𝑎𝑛−1 + 1
= 2 2𝑎𝑛−2 + 1 + 1 = 22 𝑎𝑛−2 + 2 + 1
= 22 2𝑎𝑛−3 + 1 + 2 + 1 = 23 𝑎𝑛−3 + 22 + 2 + 1
= 24 𝑎𝑛−4 + 23 + 22 + 2 + 1
⋮
= 2𝑛−1 𝑎1 + 2𝑛−2 + ⋯ + 22 + 2 + 1
= 2𝑛−1 + 2𝑛−2 + ⋯ + 22 + 2 + 1
2𝑛 −1
=
2−1
1 − 𝑥 𝑛+1
= 2𝑛 − 1 2 3
1+ 𝑥 + 𝑥 +𝑥 +⋯+ 𝑥 = 𝑛
1−𝑥
𝑖𝑓 |𝑥| < 1
𝑥 𝑛+1 − 1
= 𝑖𝑓 |𝑥| > 1
𝑥−1
METHOD OF CHARACTERISTIC ROOTS
• Used for solving linear recurrence relations with constant coefficients
• In this method the solution is obtained as the sum of two parts 𝑎𝑛 = 𝑎𝑛 (ℎ) + 𝑎𝑛 (𝑝) , the
homogeneous solution 𝑎𝑛 (ℎ) which satisfy the recurrence relation when the RHS = 0 and the
particular solution 𝑎𝑛 (𝑝) which satisfy the recurrence relation with 𝑓 𝑛 on RHS.
• Solving homogeneous recurrence relations
Consider 𝑐0 𝑎𝑛 + 𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + ⋯ + 𝑐𝑘 𝑎𝑛−𝑘 = 0 -----(1)
Let 𝑎𝑛 = 𝑟 𝑛 be a solution of (1)
∴ 𝑐0 𝑟 𝑛 + 𝑐1 𝑟 𝑛−1 + 𝑐2 𝑟 𝑛−2 + ⋯ + 𝑐𝑘 𝑟 𝑛−𝑘 = 0
Dividing by 𝑟 𝑛−𝑘
𝑐0 𝑟 𝑘 + 𝑐1 𝑟 𝑘−1 + 𝑐2 𝑟 𝑘−2 + ⋯ + 𝑐𝑘 = 0 -----(2)
(2) is called the characteristic equation which is a polynomial equation of degree ‘k’ in r.
A characteristic equation of degree ‘k’ has k characteristic roots 𝑟1 , 𝑟2 , 𝑟3 , ⋯ 𝑟𝑘 .
METHOD OF CHARACTERISTIC ROOTS
Case I (Distinct roots) : If the k characteristic roots are distinct, then the general form of the solution is
𝑎𝑛 (ℎ) = 𝑏1 𝑟1 𝑛 + 𝑏2 𝑟2 𝑛 + 𝑏3 𝑟3 𝑛 + ⋯ + 𝑏𝑘 𝑟𝑘 𝑛
where 𝑏1 , 𝑏2 , 𝑏3 , ⋯ 𝑏𝑘 are constants which satisfy the initial conditions.
Case ii (Multiple roots): If 𝑟1 is the root of multiplicity m and the remaining 𝑘 − 𝑚 roots of distinct, then
𝑎𝑛 (ℎ) = (𝑏1 +𝑛𝑏2 + 𝑛2 𝑏3 + ⋯ + 𝑛𝑚−1 𝑏𝑚 )𝑟1 𝑛 + 𝑏𝑚+1 𝑟2 𝑛 + 𝑏𝑚+2 𝑟3 𝑛 + ⋯
Examples:
1. If the roots of characteristic equation are 2, 3, -4 , then
𝑎𝑛 (ℎ) = 𝑏1 2𝑛 + 𝑏2 3𝑛 + 𝑏3 (−4)𝑛
2. If the roots of characteristic equation are 2, 2, 2, 3 ,4 then
𝑎𝑛 (ℎ) = (𝑏1 +𝑛𝑏2 + 𝑛2 𝑏3 )2𝑛 + 𝑏4 3𝑛 + 𝑏5 (4)𝑛
3. If the roots of characteristic equation are -1, -1, 3, 3 ,4 then
𝑎𝑛 (ℎ) = (𝑏1 +𝑛𝑏2 )(−1)𝑛 +(𝑏3 +𝑛𝑏4 )3𝑛 + 𝑏5 (4)𝑛
METHOD OF CHARACTERISTIC ROOTS
1. Solve the recurrence relation 𝑎𝑛 = 5𝑎𝑛−1 , n ≥ 1 , 𝑎0 = 1
Solution: 𝑎𝑛 − 5𝑎𝑛−1 = 0 -----(1)
Let 𝑎𝑛 = 𝑟 𝑛 be a solution of (1)
𝑟 𝑛 − 5𝑟 𝑛−1 = 0
Divide by 𝑟 𝑛−1
⟹r−5=0
⟹r= 5
∴ 𝑎𝑛 = 𝑏1 5𝑛
put n = 0, 𝑎0 = 𝑏1
⟹ 𝑏1 = 1
∴ 𝑎𝑛 = 5𝑛 is the required solution.
METHOD OF CHARACTERISTIC ROOTS
2. Solve the recurrence relation 𝑎𝑛 = 4(𝑎𝑛−1 − 𝑎𝑛−2 ), n ≥ 2 , 𝑎0 = 0, 𝑎1 = 2
Solution: 𝑎𝑛 − 4𝑎𝑛−1 + 4𝑎𝑛−2 = 0 -----(1)
Let 𝑎𝑛 = 𝑟 𝑛 be a solution of (1)
𝑟 𝑛 − 4𝑟 𝑛−1 + 4𝑟 𝑛−2 = 0
Divide by 𝑟 𝑛−2
⟹𝑟 2 − 4r + 4 = 0
⟹ r = 2, 2
∴ 𝑎𝑛 = (𝑏1 + 𝑛𝑏2 )2𝑛
put n = 0, 𝑎0 = 𝑏1 ⟹ 𝑏1 = 0
put n = 1 𝑎1 = 2𝑏1 + 2𝑏2
⟹ 2 = 2𝑏2
⟹ 𝑏2 = 1
∴ 𝑎𝑛 = 𝑛 ∙ 2𝑛 is the required solution.
METHOD OF CHARACTERISTIC ROOTS
3. Solve the recurrence relation of the Fibonacci sequence
𝑎𝑛 = 𝑎𝑛−1 + 𝑎𝑛−2 , n ≥ 2 , 𝑎0 = 0, 𝑎1 = 1
Solution: 𝑎𝑛 − 𝑎𝑛−1 − 𝑎𝑛−2 = 0 -----(1)
Let 𝑎𝑛 = 𝑟 𝑛 be a solution of (1)
𝑟 𝑛 − 𝑟 𝑛−1 − 𝑟 𝑛−2 = 0
Divide by 𝑟 𝑛−2
⟹𝑟 2 − r − 1 = 0
1+ 5 1− 5
⟹r = , 2
2
𝑛 𝑛
1+ 5 1− 5
∴ 𝑎𝑛 = 𝑏1 + 𝑏2
2 2
put n = 0, 0 = 𝑏1 + 𝑏2
1+ 5 1− 5
put n = 1 1 = 2
𝑏 1 + 2
𝑏2
1 1
⟹ 𝑏1 = and 𝑏2 = −
5 5
𝑛 𝑛
1 1+ 5 1 1− 5
∴ 𝑎𝑛 = 5 2 − 5 2 is the required solution.
METHOD OF CHARACTERISTIC ROOTS
Solving non homogeneous recurrence relations:
• Consider 𝑐0 𝑎𝑛 + 𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + ⋯ + 𝑐𝑘 𝑎𝑛−𝑘 = 𝑓(𝑛)
• Then 𝑎𝑛 = 𝑎𝑛 (ℎ) + 𝑎𝑛 (𝑝)
• 𝑎𝑛 (ℎ) is obtained by solving 𝑐0 𝑟 𝑛 + 𝑐1 𝑟 𝑛−1 + 𝑐2 𝑟 𝑛−2 + ⋯ + 𝑐𝑘 𝑟 𝑛−𝑘 = 0.
• There is no general method to find the particular solution 𝑎𝑛 (𝑝) .
• Depending upon the characteristic roots and 𝑓(𝑛), the following trial sequences are used
𝑛 2 2 2 2 3 2 𝑛
=3 1 + + + + ⋯+
3 3 3 3
2 𝑛+1
𝑛
1− 3
𝑛+1 2 𝑛+1
= 3 2 =3 1−
1−3 3
= 3𝑛+1 − 2𝑛+1
GENERATING FUNCTIONS
2. Shifting property:
If 𝐺(𝑥) = σ∞ 𝑎
𝑛=0 𝑛 𝑥 𝑛
generates the sequence 𝑎0 , 𝑎1 , 𝑎2 , 𝑎3 , ⋯, then
a. 𝑥 ∙ 𝐺(𝑥) generates 0, 𝑎0 , 𝑎1 , 𝑎2 , 𝑎3 , ⋯
b. 𝑥 2 ∙ 𝐺(𝑥) generates 0, 0, 𝑎0 , 𝑎1 , 𝑎2 , 𝑎3 , ⋯
c. In general , 𝑥 𝑘 ∙ 𝐺(𝑥) generates 0, 0, 0, ⋯ , 0 , 𝑎0 , 𝑎1 , 𝑎2 , 𝑎3 , ⋯
𝑘 𝑡𝑖𝑚𝑒𝑠
1
Examples: 𝐺(𝑥) = generates the sequence 1,1,1,1, ⋯ , then
1−𝑥
𝑥
a. 1−𝑥
generates 0,1,1,1,1, ⋯
𝑥2
b. 1−𝑥
generates 0, 0, 1,1,1,1, ⋯
GENERATING FUNCTIONS
3. If 𝐺(𝑥) = σ∞ 𝑛=0 𝑛 𝑎 𝑥 𝑛 generates the sequence 𝑎 , 𝑎 , 𝑎 , 𝑎 , ⋯, then
0 1 2 3
a. 𝐺 𝑥 − 𝑎0 = σ∞ 𝑛=1 𝑛𝑎 𝑥 𝑛 generates 0, 𝑎 ,𝑎 , 𝑎 , ⋯
1 2 3
b. 𝐺 𝑥 − 𝑎0 − 𝑎1 𝑥 = σ∞ 𝑎
𝑛=2 𝑛 𝑥 𝑛
generates 0, 0, 𝑎2 , 𝑎3 , ⋯
c. 𝐺 𝑥 − 𝑎0 − 𝑎1 𝑥 − 𝑎2 𝑥 2 − ⋯ − 𝑎𝑘−1 𝑥 𝑘−1 = σ∞ 𝑛=𝑘 𝑛 𝑎 𝑥 𝑛
generates
0, 0, 0, ⋯ , 0 , 𝑎𝑘 , 𝑎𝑘+1 , 𝑎𝑘+2 , 𝑎𝑘+3 , ⋯
𝑘 𝑡𝑖𝑚𝑒𝑠
4. If 𝐺(𝑥) = σ∞ 𝑎
𝑛=0 𝑛 𝑥 𝑛
generates the sequence 𝑎0 , 𝑎1 , 𝑎2 , 𝑎3 , ⋯, then
𝐺 𝑥 −𝑎0
a. = σ∞ 𝑎
𝑛=1 𝑛 𝑥 𝑛−1 generates 𝑎 ,𝑎 ,
1 2 𝑎3 , ⋯
𝑥
𝐺 𝑥 −𝑎0 −𝑎1 𝑥
b. 𝑥2
generates 𝑎2 , 𝑎3 , 𝑎4 , 𝑎5 ⋯
GENERATING FUNCTIONS
Example: Find the generating functions of the following sequence:
1. 0, 0,2,2,2,2, ⋯
2 2𝑥 2
Since generates 2,2,2,2,2, ⋯, G 𝑥 = generates 0, 0,2,2,2,2, ⋯
1−𝑥 1−𝑥
2. 1,1, 0, 1,1,1, 1 ⋯
1
G 𝑥 = − 𝑥2
1−𝑥
3. 3, −3, 3, −3, 3, −3 ⋯
3
G 𝑥 =
1+𝑥
4. 1, 0, −1, 0, 1, 0, −1 , 0, 1, 0, −1 , 0, ⋯
G 𝑥 = 1 + 0𝑥 − 𝑥 2 + 0𝑥 3 + 𝑥 4 + 0𝑥 5 − 𝑥 6 + 0𝑥 7 + 𝑥 8 − ⋯
= 1 − 𝑥2 + 𝑥4 − 𝑥6 + 𝑥8 − ⋯
= 1 − 𝑥 2 + (𝑥 2 )2 −(𝑥 2 )3 +(𝑥 2 )4 − ⋯
1
=
1+𝑥 2
GENERATING FUNCTIONS
Solution of Recurrence relations using Generating functions:
1. 𝑎𝑛 = 3𝑎𝑛−1 + 2 , n ≥ 1, 𝑎0 = 1 ----- (1)
Solution: Let 𝐺(𝑥) = σ∞ 𝑛
𝑛=0 𝑎𝑛 𝑥 be the generating function of sequence {𝑎𝑛 }
Multiply each term of (1) by 𝑥 𝑛 and take sum from 1 to ∞
σ∞ 𝑎
𝑛=1 𝑛 𝑥 𝑛
= 3 σ ∞
𝑎
𝑛=1 𝑛−1 𝑥 𝑛
+ 2 σ ∞
𝑛=1 𝑥 𝑛 ∞
1 𝑎𝑛 𝑥 𝑛 = 𝐺 𝑥 − 𝑎0
𝐺 𝑥 − 𝑎0 = 3𝑥𝐺 𝑥 + 2 −1 𝑛=1
1−𝑥
1−(1−𝑥)
𝐺 𝑥 − 1 = 3𝑥𝐺 𝑥 + 2 ∞
1−𝑥 𝑎𝑛−1 𝑥 𝑛 = 𝑥𝐺 𝑥
𝑥
𝐺 𝑥 − 3𝑥𝐺 𝑥 = 1 + 2 𝑛=1
1−𝑥
1+𝑥 ∞
𝐺 𝑥 (1 − 3𝑥) = 𝑥𝑛 =
1
1−𝑥
1−𝑥
1+𝑥 𝑛=0
𝐺 𝑥 =
1−𝑥 (1−3𝑥)
GENERATING FUNCTIONS
𝐴 𝐵
𝐺 𝑥 = + ∞
1−3𝑥 (1−𝑥) 1
2 1 = 𝑎𝑛 𝑥 𝑛
= − 1 − 𝑎𝑥
(1−3𝑥) 1−𝑥 𝑛=0
σ∞ 𝑛 ∞ 𝑛 𝑛
𝑛=0 𝑎𝑛 𝑥 = 2 σ𝑛=0 3 𝑥 − σ𝑛=0 𝑥
∞ 𝑛
= σ∞ 𝑛=0 (2 ∙ 3𝑛 −1) 𝑥 𝑛
∴𝑎𝑛 = 2 ∙ 3𝑛 − 1
σ∞ 𝑛 ∞ 𝑛 𝑛 ∞
𝑛=0 𝑎𝑛 𝑥 = 2 σ𝑛=0 2 𝑥 − σ𝑛=0 𝑥
𝑛
= σ∞
𝑛=0(2 ∙ 2 𝑛 −1) 𝑥 𝑛
∴𝑎𝑛 = 2 ∙ 2𝑛 − 1
= 2𝑛+1 − 1
GENERATING FUNCTIONS
3. 𝑎𝑛 − 9𝑎𝑛−1 + 20𝑎𝑛−2 = 0, n ≥ 2, 𝑎0 = −3, 𝑎1 = −10 ----- (1)
Solution: Let 𝐺(𝑥) = σ∞ 𝑛
𝑛=0 𝑎𝑛 𝑥 be the generating function of sequence {𝑎𝑛 }
𝐺 𝑥 − 𝑎0 − 𝑎1 𝑥 − 9𝑥 𝐺 𝑥 − 𝑎0 + 20𝑥 2 𝐺(𝑥) = 0 ∞
𝑎𝑛−1 𝑥 𝑛 = 𝑥(𝐺 𝑥 − 𝑎0 )
𝐺 𝑥 + 3 + 10𝑥 − 9𝑥𝐺 𝑥 − 27𝑥 + 20𝑥 2 𝐺(𝑥) = 0 𝑛=2
𝑎𝑛−2 𝑥 𝑛 = 𝑥 2 𝐺 𝑥
𝐺 𝑥 (1 − 9𝑥 + 20𝑥 2 ) = −3 + 17𝑥 𝑛=2
−3+17𝑥 −3+17𝑥
𝐺 𝑥 = =
(1−9𝑥+20𝑥 2 ) (1−5𝑥)(1−4𝑥)
GENERATING FUNCTIONS
𝐴 𝐵
𝐺 𝑥 = +
1−5𝑥 (1−4𝑥)
2 5
= −
(1−5𝑥) 1−4𝑥
σ∞ 𝑎
𝑛=0 𝑛 𝑥 𝑛
= 2 σ ∞
𝑛=0 5𝑛 𝑛
𝑥 − 5 σ ∞ 𝑛 𝑛
𝑛=0 4 𝑥
= σ∞ 𝑛 𝑛
𝑛=0(2 ∙ 5 −5 ∙ 4 ) 𝑥
𝑛
∴𝑎𝑛 = 2 ∙ 5𝑛 − 5 ∙ 4𝑛
𝑥 𝑥2 𝑥3 𝑥4
7) 1 + + + + + ⋯ ∞ = 𝑒 𝑥 , ∀𝑥
1! 2! 3! 4!
𝑥3 𝑥5 𝑥7
8) 𝑥 − 3!
+
5!
−
7!
+ ⋯ ∞ = sin 𝑥 , ∀ 𝑥
𝑥2 𝑥4 𝑥6
9) 1 − + − + ⋯ ∞ = cos 𝑥 , ∀𝑥
2! 4! 6!
THANK YOU!