GENERATING FUNCTIONS
Generating function
Partition of integers
Solution of recurrence relations using generating
functions
GENERATING FUNCTION
Definition
For the sequence of real numbers 𝑎0, 𝑎1, 𝑎2 … … the function
𝑮 𝒙 = 𝒂 𝟎 + 𝒂 𝟏 𝒙 + 𝒂 𝟐 𝒙 𝟐
+ ⋯ = 𝒂 𝒏 𝒙 𝒏∞
𝒏=𝟎 is called the
generating function.
Example
1. For the sequence {1, 2, 3, 4, ...} the generating function
𝐺 𝑥 = 1 + 2𝑥 + 3𝑥2
+ ⋯ =
1
(1 − 𝑥)2
2. Sequence: {𝑛 𝐶0
, 𝑛 𝐶1
, 𝑛 𝐶2
, … , 𝑛 𝐶 𝑛
, 0,0,0, … }
𝐺 𝑥 = 𝑛 𝐶0
+ 𝑛 𝐶1
𝑥 + 𝑛 𝐶2
𝑥2
+ 𝑛 𝐶3
𝑥3
+ ⋯ + 𝑛 𝐶 𝑛
+
0 + 0 + 0 …
= 1 + 𝑥 𝑛
+ 0 + 0 + ⋯
𝐺 𝑥 = 1 + 𝑥 𝑛
PARTITION OF INTEGERS
𝑃 𝑛 = Number of partitioning a positive integer ‘n’ into sum of positive
numbers
Example
1. n = 4
4, 3+1, 2+2, 2+1+1, 1+1+1+1
∴ 𝑃 4 = 5
2. n = 5
5, 4+1, 3+1+1, 2+1+1+1, 1+1+1+1+1, 2+2+1
∴ 𝑃 5 = 7
Alliter
Determine 𝑃 5
Solution
The coefficient of 𝑥5
in
𝑓 𝑥 = 1 + 𝑥 + 𝑥2
+ 𝑥3
+ ⋯ 1 + 𝑥2
+ 𝑥4
+ ⋯ 1 + 𝑥3
+ 𝑥6
+ 𝑥9
+ ⋯ 1 + 𝑥4
+ 𝑥8
+ ⋯ 1 + 𝑥5
+ 𝑥10
+ 𝑥15
+ ⋯
𝑓 𝑥 =
1
(1 − 𝑥)
1
(1 − 𝑥2)
1
(1 − 𝑥3)
1
(1 − 𝑥4)
1
(1 − 𝑥5)
=
1
(1 − 𝑥 𝑖)
5
𝑖=1
Therefore, P(5) = 7.
Definition 𝑷 𝒅(𝒏)
The number of partitions of a positive integers ‘n’ into distinct summands
Pd x = (1 + 𝑥)( 1 + 𝑥2
) (1 + 𝑥3
) +......
= (1 + 𝑥 𝑖
)
∞
𝑖=1
For each 𝑛 ∈ 𝑍+
, Pd n is the coefficient of 𝑥 𝑛
in 1 + 𝑥 ( 1 + 𝑥2
)+ ⋯ 1 + 𝑥 𝑛
with Pd 0 = 1.
Now Pd 6 = Coefficient 𝑥6
in
1 + 𝑥 ( 1 + 𝑥2
) 1 + 𝑥3
( 1 + 𝑥4
) 1 + 𝑥5
( 1 + 𝑥6
)
= 4.
Problem
Find all partitions of 7. Also find 𝑃 7 and Pd(7).
SOLUTION OF RECURRENCE RELATIONS USING GENERATING
FUNCTIONS
Definition- Generating Function
The generating function for the sequence ‘s’ with terms 𝑎0, 𝑎1, … , 𝑎 𝑛 of real
numbers is the infinite sum.
𝐺 𝑥 = 𝐺 𝑠, 𝑥 = 𝑎0 + 𝑎1 𝑥 + ⋯ + 𝑎 𝑛 𝑥 𝑛
+ ⋯
= 𝑎 𝑛 𝑥 𝑛
∞
𝑛=0
Example
The generating function for the sequence ‘s’ with the terms 1, 1, 1, 1, ........, is
given by
𝐺 𝑥 = 𝐺 𝑠, 𝑥 = 𝑥 𝑛
=
∞
𝑛=0
1
(1 − 𝑥)
Problems
Find the generating function for the following sequences
1) < 20
, 21
, 22
, 23
, … 2 𝑟
>
2) < 7, −4, 3, 0, 1 >
3) < 1, 2, 3, 4 >
Procedure for solving recurrence relation using generating function
Step 1: Rewrite the recurrence relation as an equation with 0 on RHS
Step2: Multiply the equation obtained in step 1 by 𝑥 𝑛
and summing it from 1 to ∞
(or 0 to ∞) or (2 to ∞)
Step 3: Put 𝐺 𝑥 = 𝐺 𝑠, 𝑥 = 𝑎 𝑛 𝑥 𝑛∞
𝑛=0 and write 𝐺 𝑥 as a function of 𝑥
Step 4: Decompose 𝐺 𝑥 into partial fraction
Step 5: Express 𝐺 𝑥 as a sum of familiar series
Step 6: Express 𝑎 𝑛 as the coefficient of 𝑥 𝑛
in 𝐺 𝑥
The following table represents some sequences and their
generating functions.
Sequence Generating Function
1 1 1
1 − 𝑧
2 (−1) 𝑛 1
1 + 𝑧
3 𝑎 𝑛 1
1 − 𝑎𝑧
4 (−𝑎) 𝑛 1
1 + 𝑎𝑧
5 𝑛 + 1 1
1 − (𝑧)2
6 𝑛 1
(1 − 𝑧)2
7 𝑛2 𝑧(1 + 2)
(1 − 𝑧)3
8 𝑛𝑎 𝑛 𝑎𝑧
(1 − 𝑎𝑧)2
Example
Using generating function, solve the recurrence relation 𝑎 𝑛 = 3𝑎 𝑛−1 for
𝑛 ≥ 1 with 𝑎0=2.
Solution:
Let
G(x) = 𝑎 𝑛 𝑥 𝑛
∞
𝑛=0
Be the generating function of the sequence 𝑎 𝑛
Given recurrence relation can be written as
𝑎 𝑛 -3a𝑎 𝑛−1 = 0
Multiplying the above equation by 𝑥 𝑛
and summing from 1 to ∞, we get
⟹ 𝑎 𝑛 𝑥 𝑛
∞
𝑛=1 – 3𝑎 𝑛−1
∞
𝑛=1 𝑥 𝑛
= 0
⟹ 𝑎 𝑛 𝑥 𝑛−3𝑥
∞
𝑛=1 𝑎 𝑛−1 𝑥 𝑛−1
∞
𝑛=1 =0
⟹ (G(x)-𝑎0)-3x G(x) =0
⟹ G(x) (1-3x) = 𝑎0
G(x) (1-3x) =2 [∴ Given 𝑎0=2]
G(x) ⟹
2
1−3𝑥
= 21 − 3𝑥−1
⟹2(1+3x+(3𝑥)2
+........)
G(x) ⟹2 3 𝑛∞
𝑛=0 𝑥 𝑛
Consequently, 𝑎 𝑛 = 2. 𝑐𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡 𝑜𝑓 𝑥 𝑛
in G(x)
𝑎 𝑛 = 2. 3 𝑛
Problems
1. Use method of generating function to solve the recurrence relation 𝑎 𝑛 = 3𝑎 𝑛−1+1;
𝑛 ≥1 given that 𝑎0 = 1.
2. Solve the recurrence relation 𝑎 𝑛−7𝑎 𝑛−1 + 10𝑎 𝑛−2 = 0 for n≥2 given that 𝑎0= 10,
𝑎1=41 using generating functions.
3. Using generating function solve the recurrence relation corresponding to the
Fibonacci sequence, 𝑎 𝑛=𝑎 𝑛−1 +𝑎 𝑛−2, n≥2 with 𝑎0=1,𝑎1=1.
4. Solve the recurrence relation S(n+1)-2S(n)=4 𝑛
, S(0)=1, 𝑛 ≥ 0.
5. Using generating functions, solve the recurrence relation
𝑎 𝑛+2 −8𝑎 𝑛+1 + 15𝑎 𝑛 = 0 given that 𝑎0 = 2, 𝑎1 = 8 .
6. Identify the sequence having the expression
5+2𝑥
1−4𝑥2 as a generating
function.
7. Find the sequence having the expression
3−5𝑥
1−2𝑥−3𝑥2 as a generating
function.
8. Find the sequence whose generating function is
32−22𝑥
2−3𝑥+𝑥2 using partial
fraction.
9. Find the sequence whose generating function is
6−29𝑥
30𝑥2−11𝑥+1
using
partial fraction.
10. Using generating function, solve: 𝑦 𝑛+2 − 5𝑦 𝑛+1 + 6𝑦𝑛 = 0, 𝑛 ≥ 0
with 𝑦0 = 1 and 𝑦1 = 1.
11. Solve the recurrence relation, 𝑆 𝑛 = 𝑆 𝑛 − 1 + 2𝑆 𝑛 − 2 , with
𝑆 0 = 3, 𝑆 1 = 1, by finding its generating function.
12. Use generating function to solve the recurrence relation 𝑎 𝑛 +
3𝑎 𝑛−1 − 4𝑎 𝑛−2 = 0, 𝑛 ≥ 2 with the initial condition 𝑎0 = 3, 𝑎1 = −2.
13. Solve the recurrence relation 𝑎 𝑛+1 − 𝑎 𝑛 = 3𝑥2
− 𝑛, 𝑛 ≥ 0, 𝑎0 = 3.

Generating function

  • 2.
    GENERATING FUNCTIONS Generating function Partitionof integers Solution of recurrence relations using generating functions GENERATING FUNCTION Definition For the sequence of real numbers 𝑎0, 𝑎1, 𝑎2 … … the function 𝑮 𝒙 = 𝒂 𝟎 + 𝒂 𝟏 𝒙 + 𝒂 𝟐 𝒙 𝟐 + ⋯ = 𝒂 𝒏 𝒙 𝒏∞ 𝒏=𝟎 is called the generating function.
  • 3.
    Example 1. For thesequence {1, 2, 3, 4, ...} the generating function 𝐺 𝑥 = 1 + 2𝑥 + 3𝑥2 + ⋯ = 1 (1 − 𝑥)2 2. Sequence: {𝑛 𝐶0 , 𝑛 𝐶1 , 𝑛 𝐶2 , … , 𝑛 𝐶 𝑛 , 0,0,0, … } 𝐺 𝑥 = 𝑛 𝐶0 + 𝑛 𝐶1 𝑥 + 𝑛 𝐶2 𝑥2 + 𝑛 𝐶3 𝑥3 + ⋯ + 𝑛 𝐶 𝑛 + 0 + 0 + 0 … = 1 + 𝑥 𝑛 + 0 + 0 + ⋯ 𝐺 𝑥 = 1 + 𝑥 𝑛
  • 4.
    PARTITION OF INTEGERS 𝑃𝑛 = Number of partitioning a positive integer ‘n’ into sum of positive numbers Example 1. n = 4 4, 3+1, 2+2, 2+1+1, 1+1+1+1 ∴ 𝑃 4 = 5 2. n = 5 5, 4+1, 3+1+1, 2+1+1+1, 1+1+1+1+1, 2+2+1 ∴ 𝑃 5 = 7
  • 5.
    Alliter Determine 𝑃 5 Solution Thecoefficient of 𝑥5 in 𝑓 𝑥 = 1 + 𝑥 + 𝑥2 + 𝑥3 + ⋯ 1 + 𝑥2 + 𝑥4 + ⋯ 1 + 𝑥3 + 𝑥6 + 𝑥9 + ⋯ 1 + 𝑥4 + 𝑥8 + ⋯ 1 + 𝑥5 + 𝑥10 + 𝑥15 + ⋯ 𝑓 𝑥 = 1 (1 − 𝑥) 1 (1 − 𝑥2) 1 (1 − 𝑥3) 1 (1 − 𝑥4) 1 (1 − 𝑥5) = 1 (1 − 𝑥 𝑖) 5 𝑖=1 Therefore, P(5) = 7.
  • 6.
    Definition 𝑷 𝒅(𝒏) Thenumber of partitions of a positive integers ‘n’ into distinct summands Pd x = (1 + 𝑥)( 1 + 𝑥2 ) (1 + 𝑥3 ) +...... = (1 + 𝑥 𝑖 ) ∞ 𝑖=1 For each 𝑛 ∈ 𝑍+ , Pd n is the coefficient of 𝑥 𝑛 in 1 + 𝑥 ( 1 + 𝑥2 )+ ⋯ 1 + 𝑥 𝑛 with Pd 0 = 1. Now Pd 6 = Coefficient 𝑥6 in 1 + 𝑥 ( 1 + 𝑥2 ) 1 + 𝑥3 ( 1 + 𝑥4 ) 1 + 𝑥5 ( 1 + 𝑥6 ) = 4. Problem Find all partitions of 7. Also find 𝑃 7 and Pd(7).
  • 7.
    SOLUTION OF RECURRENCERELATIONS USING GENERATING FUNCTIONS Definition- Generating Function The generating function for the sequence ‘s’ with terms 𝑎0, 𝑎1, … , 𝑎 𝑛 of real numbers is the infinite sum. 𝐺 𝑥 = 𝐺 𝑠, 𝑥 = 𝑎0 + 𝑎1 𝑥 + ⋯ + 𝑎 𝑛 𝑥 𝑛 + ⋯ = 𝑎 𝑛 𝑥 𝑛 ∞ 𝑛=0
  • 8.
    Example The generating functionfor the sequence ‘s’ with the terms 1, 1, 1, 1, ........, is given by 𝐺 𝑥 = 𝐺 𝑠, 𝑥 = 𝑥 𝑛 = ∞ 𝑛=0 1 (1 − 𝑥) Problems Find the generating function for the following sequences 1) < 20 , 21 , 22 , 23 , … 2 𝑟 > 2) < 7, −4, 3, 0, 1 > 3) < 1, 2, 3, 4 >
  • 9.
    Procedure for solvingrecurrence relation using generating function Step 1: Rewrite the recurrence relation as an equation with 0 on RHS Step2: Multiply the equation obtained in step 1 by 𝑥 𝑛 and summing it from 1 to ∞ (or 0 to ∞) or (2 to ∞) Step 3: Put 𝐺 𝑥 = 𝐺 𝑠, 𝑥 = 𝑎 𝑛 𝑥 𝑛∞ 𝑛=0 and write 𝐺 𝑥 as a function of 𝑥 Step 4: Decompose 𝐺 𝑥 into partial fraction Step 5: Express 𝐺 𝑥 as a sum of familiar series Step 6: Express 𝑎 𝑛 as the coefficient of 𝑥 𝑛 in 𝐺 𝑥
  • 10.
    The following tablerepresents some sequences and their generating functions. Sequence Generating Function 1 1 1 1 − 𝑧 2 (−1) 𝑛 1 1 + 𝑧 3 𝑎 𝑛 1 1 − 𝑎𝑧 4 (−𝑎) 𝑛 1 1 + 𝑎𝑧 5 𝑛 + 1 1 1 − (𝑧)2 6 𝑛 1 (1 − 𝑧)2 7 𝑛2 𝑧(1 + 2) (1 − 𝑧)3 8 𝑛𝑎 𝑛 𝑎𝑧 (1 − 𝑎𝑧)2
  • 11.
    Example Using generating function,solve the recurrence relation 𝑎 𝑛 = 3𝑎 𝑛−1 for 𝑛 ≥ 1 with 𝑎0=2. Solution: Let G(x) = 𝑎 𝑛 𝑥 𝑛 ∞ 𝑛=0 Be the generating function of the sequence 𝑎 𝑛 Given recurrence relation can be written as 𝑎 𝑛 -3a𝑎 𝑛−1 = 0 Multiplying the above equation by 𝑥 𝑛 and summing from 1 to ∞, we get ⟹ 𝑎 𝑛 𝑥 𝑛 ∞ 𝑛=1 – 3𝑎 𝑛−1 ∞ 𝑛=1 𝑥 𝑛 = 0
  • 12.
    ⟹ 𝑎 𝑛𝑥 𝑛−3𝑥 ∞ 𝑛=1 𝑎 𝑛−1 𝑥 𝑛−1 ∞ 𝑛=1 =0 ⟹ (G(x)-𝑎0)-3x G(x) =0 ⟹ G(x) (1-3x) = 𝑎0 G(x) (1-3x) =2 [∴ Given 𝑎0=2] G(x) ⟹ 2 1−3𝑥 = 21 − 3𝑥−1 ⟹2(1+3x+(3𝑥)2 +........) G(x) ⟹2 3 𝑛∞ 𝑛=0 𝑥 𝑛 Consequently, 𝑎 𝑛 = 2. 𝑐𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡 𝑜𝑓 𝑥 𝑛 in G(x) 𝑎 𝑛 = 2. 3 𝑛
  • 13.
    Problems 1. Use methodof generating function to solve the recurrence relation 𝑎 𝑛 = 3𝑎 𝑛−1+1; 𝑛 ≥1 given that 𝑎0 = 1. 2. Solve the recurrence relation 𝑎 𝑛−7𝑎 𝑛−1 + 10𝑎 𝑛−2 = 0 for n≥2 given that 𝑎0= 10, 𝑎1=41 using generating functions. 3. Using generating function solve the recurrence relation corresponding to the Fibonacci sequence, 𝑎 𝑛=𝑎 𝑛−1 +𝑎 𝑛−2, n≥2 with 𝑎0=1,𝑎1=1. 4. Solve the recurrence relation S(n+1)-2S(n)=4 𝑛 , S(0)=1, 𝑛 ≥ 0.
  • 14.
    5. Using generatingfunctions, solve the recurrence relation 𝑎 𝑛+2 −8𝑎 𝑛+1 + 15𝑎 𝑛 = 0 given that 𝑎0 = 2, 𝑎1 = 8 . 6. Identify the sequence having the expression 5+2𝑥 1−4𝑥2 as a generating function. 7. Find the sequence having the expression 3−5𝑥 1−2𝑥−3𝑥2 as a generating function. 8. Find the sequence whose generating function is 32−22𝑥 2−3𝑥+𝑥2 using partial fraction. 9. Find the sequence whose generating function is 6−29𝑥 30𝑥2−11𝑥+1 using partial fraction.
  • 15.
    10. Using generatingfunction, solve: 𝑦 𝑛+2 − 5𝑦 𝑛+1 + 6𝑦𝑛 = 0, 𝑛 ≥ 0 with 𝑦0 = 1 and 𝑦1 = 1. 11. Solve the recurrence relation, 𝑆 𝑛 = 𝑆 𝑛 − 1 + 2𝑆 𝑛 − 2 , with 𝑆 0 = 3, 𝑆 1 = 1, by finding its generating function. 12. Use generating function to solve the recurrence relation 𝑎 𝑛 + 3𝑎 𝑛−1 − 4𝑎 𝑛−2 = 0, 𝑛 ≥ 2 with the initial condition 𝑎0 = 3, 𝑎1 = −2. 13. Solve the recurrence relation 𝑎 𝑛+1 − 𝑎 𝑛 = 3𝑥2 − 𝑛, 𝑛 ≥ 0, 𝑎0 = 3.