Lecture 13
Lecture 13
G (x) = a0 + a1 x + a2 x 2 + · · · + an x n .
Generating functions
1 + x + x 2 + x 3 + x 4 + x 5.
Also, we have
x6 − 1
= 1 + x + x2 + x3 + x4 + x5
x −1
x6 − 1
when x 6= 1. Consequently, is the generating function of the
x −1
sequence 1, 1, 1, 1, 1, 1.
Generating functions
Which of the following is a closed form for the generating function
of he sequence 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, . . .?
x x3 x x
A. B. C. D.
1 − x2 1−x 1−x 1 − x3
Generating functions
Which of the following is a closed form for the generating function
of he sequence 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, . . .?
x x3 x x
A. B. C. D.
1 − x2 1−x 1−x 1 − x3
Solution : We have
x
1 − x2
= x(1 − x 2 )−1
= x(1 + x 2 + x 4 + x 6 + x 8 + · · · )
= x + x3 + x5 + x7 + x9 + · · ·
= 0 + 1 × x + 0 × x2 + 1 × x3 + 0 × x4 + 1 × x5 + 0 × x6 + 1 × x7
+ 0 × x8 + 1 × x9 + · · ·
cont . . .
x3
1−x
= x 3 (1 − x)−1
= x 3 (1 + x + x 2 + x 3 + x 4 + · · · )
= x3 + x4 + x5 + x6 + x7 + · · ·
= 0 + 0 × x + 0 × x2 + 1 × x3 + 1 × x4 + 1 × x5 + 1 × x6 + · · ·
cont . . .
x
1−x
= x(1 − x)−1
= x(1 + x + x 2 + x 3 + x 4 + · · · )
= x + x2 + x3 + x4 + x5 + · · ·
= 0 + 1 × x + 1 × x2 + 1 × x3 + 1 × x4 + 1 × x5 + · · ·
cont . . .
x
1 − x3
= x(1 − x 3 )−1
= x(1 + x 3 + x 6 + x 9 + x 12 + · · · )
= x + x 4 + x 7 + x 10 + x 13 + · · ·
= 0 + 1 × x + 0 × x2 + 0 × x3 + 1 × x4 + 0 × x5 + 0 × x6 + 1 × x7
+ 0 × x 8 + 0 × x 9 + 1 × x 10 + · · ·
cont . . .
x
1 − x3
= x(1 − x 3 )−1
= x(1 + x 3 + x 6 + x 9 + x 12 + · · · )
= x + x 4 + x 7 + x 10 + x 13 + · · ·
= 0 + 1 × x + 0 × x2 + 0 × x3 + 1 × x4 + 0 × x5 + 0 × x6 + 1 × x7
+ 0 × x 8 + 0 × x 9 + 1 × x 10 + · · ·
1
A.
1−x
1
B.
(1 − x)2
1
C.
1+x
1
D.
(1 + x)2
Quiz 1
1
A.
1−x
1
B.
(1 − x)2
1
C.
1+x
1
D.
(1 + x)2
Answer : B
Quiz 2
1
A.
1 − x2
1
B.
(1 − x)2
1
C.
1 + x2
1
D.
(1 + x)2
Quiz 2
1
A.
1 − x2
1
B.
(1 − x)2
1
C.
1 + x2
1
D.
(1 + x)2
Answer : A
Solving Recurrence relations using Generating functions
ak = 3ak−1
∞
X ∞
X
⇒ ak x k = 3ak−1 x k
k=1 k=1
⇒ a1 x + a2 x + a3 x + · · · = 3(a0 x + a1 x 2 + a2 x 3 + · · · )
2 3
⇒ G (x) − a0 = 3x(a0 + a1 x + a2 x 2 + · · · )
⇒ G (x) − a0 = 3xG (x)
⇒ G (x)(1 − 3x) = a0
2
⇒ G (x) =
1 − 3x
∞
X ∞
X
⇒ ak x k = 2(3x)k
k=0 k=0
cont . . .
Thus,
ak = 2.3k
Examples of solving Recurrence relations using Generating
functions
Suppose that a valid codeword is an n-digit number in decimal notation
containing an even number of 0s. Let an denote the number of valid
codewords of length n, then {an } satisfies the recurrence relation
an = 8an−1 + 10n−1
an = 8an−1 + 10n−1
a1 = 8.a0 + 100 ⇒ 9 = 8 + 1
is satisfied.
cont . . .
P∞ n
Let G (x) = n=0 an x be the required generating function. Then,
an = 8an−1 + 10n−1
∞
X ∞
X ∞
X
⇒ an x n = 8 an−1 x n + 10n−1 x n
n=1 n=1 n=1
⇒ a1 x + a2 x + a3 x + · · · = 8(a0 x + a1 x + a2 x 3 + · · · )
2 3 2
1 − 9x
⇒ G (x) =
(1 − 8x)(1 − 10x)
1 1 1
⇒ G (x) = +
2 1 − 8x 1 − 10x
∞ ∞
!
1 X
n n
X
n n
⇒ G (x) = 8 x + 10 x
2 n=0 n=0
∞ ∞
X X 1
⇒ an x n = (8n + 10n )x n
n=0 n=0
2
Thus,
1 n
an = (8 + 10n ).
2
Quiz 3