0% found this document useful (0 votes)
162 views30 pages

Lecture 13

This document discusses recurrence relations and generating functions. It begins by defining generating functions and providing examples of generating functions for different sequences. It then discusses how generating functions can be used to solve recurrence relations by translating the recurrence relation into an equation involving the generating function. The document provides two examples of solving recurrence relations using generating functions. It shows setting up and solving a recurrence relation for the generating function.

Uploaded by

Pradipto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
162 views30 pages

Lecture 13

This document discusses recurrence relations and generating functions. It begins by defining generating functions and providing examples of generating functions for different sequences. It then discusses how generating functions can be used to solve recurrence relations by translating the recurrence relation into an equation involving the generating function. The document provides two examples of solving recurrence relations using generating functions. It shows setting up and solving a recurrence relation for the generating function.

Uploaded by

Pradipto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

UNIT 2 : Recurrence Relations

Definition of Generating function and examples


Examples of Generating Function
Use of Generating function in solving Recurrence Relation
Quiz
Definition of Generating function

Generating functions are used to represent sequences efficiently by


coding the terms of a sequence as coefficients of powers of a
variable x in a formal power series.
Definition of Generating function

Generating functions are used to represent sequences efficiently by


coding the terms of a sequence as coefficients of powers of a
variable x in a formal power series.
The generating function for the sequence a0 , a1 , a3 , . . . , ak , . . . of
real numbers is the infinite series

X
2 k
G (x) = a0 + a1 x + a2 x + · · · + ak x + · · · = ak x k .
k=0
Examples of Generating function
The generating function for the sequence {ak }, with ak = 3 is

X
3x k .
k=0

The generating function for the sequence {ak }, with ak = k + 1 is



X
(k + 1)x k .
k=0

The generating function for the sequence {ak }, with ak = 2k is



X
2k x k .
k=0
About Generating functions

We can define generating functions for finite sequences of real numbers


by extending a finite sequence a0 , a1 , . . . , an into an infinite sequence by
setting an+1 = 0, an+2 = 0, and so on.
About Generating functions

We can define generating functions for finite sequences of real numbers


by extending a finite sequence a0 , a1 , . . . , an into an infinite sequence by
setting an+1 = 0, an+2 = 0, and so on.

The generating function G (x) of this infinite sequence {an } is a


polynomial of degree n because no terms of the form aj x j with j > n
occur, that is,

G (x) = a0 + a1 x + a2 x 2 + · · · + an x n .
Generating functions

What is the generating function for the sequence 1, 1, 1, 1, 1, 1?


Generating functions

What is the generating function for the sequence 1, 1, 1, 1, 1, 1?

Solution : The generating function of 1, 1, 1, 1, 1, 1 is

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 + · · ·

Thus, correct option is (D)


Quiz 1

What is the generating function of 1, 2, 3, 4, 5, . . .?

1
A.
1−x
1
B.
(1 − x)2
1
C.
1+x
1
D.
(1 + x)2
Quiz 1

What is the generating function of 1, 2, 3, 4, 5, . . .?

1
A.
1−x
1
B.
(1 − x)2
1
C.
1+x
1
D.
(1 + x)2
Answer : B
Quiz 2

What is the generating function of 1, 0, 1, 0, 1, 0, 1, 0 . . .?

1
A.
1 − x2
1
B.
(1 − x)2
1
C.
1 + x2
1
D.
(1 + x)2
Quiz 2

What is the generating function of 1, 0, 1, 0, 1, 0, 1, 0 . . .?

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

Generating functions are used in solving many types of counting


problems, such as the number of ways to select or distribute
objects of different kinds, subject to variety of constraints, and the
number of ways to make change for a dollar using coins of different
denominations.
Solving Recurrence relations using Generating functions

Generating functions are used in solving many types of counting


problems, such as the number of ways to select or distribute
objects of different kinds, subject to variety of constraints, and the
number of ways to make change for a dollar using coins of different
denominations.
Here, in this unit, we will see, how generating functions can be
used to solve recurrence relations by translating a recurrence
relation for the terms of a sequence into an equation involving a
generating function.
Examples of solving Recurrence relations using Generating
functions

Solve the recurrence relation ak = 3ak−1 , for k = 1, 2, 3, . . . and


initial condition a0 = 2.
Examples of solving Recurrence relations using Generating
functions

Solve the recurrence relation ak = 3ak−1 , for k = 1, 2, 3, . . . and


initial condition a0 = 2.

Solution : Let G (x) be the generating function for the sequence


{ak }, that is

X
G (x) = ak x k
k=0
cont . . .
We have

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

and the initial condition a1 = 9. Use generating function to find an


explicit formula for an .
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

and the initial condition a1 = 9. Use generating function to find an


explicit formula for an .

Solution : To make our work with generating function simpler, we


extend this sequence by setting a0 = 1 as

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

+ (100 x + 101 x 2 + 102 x 3 + · · · )


⇒ G (x) − a0 = 8x(a0 + a1 x + a2 x 2 + · · · )
+ x(1 + 10x + 102 x 2 + 103 x 3 + · · · )
x
⇒ G (x) − 1 = 8xG (x) +
1 − 10x
x
⇒ G (x)(1 − 8x) = +1
1 − 10x
1 − 9x
⇒ G (x)(1 − 8x) =
1 − 10x
cont . . .

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

What is the sequence depicted by the generating series


4 + 10x 2 + 15x 3 + 25x 5 + 16x 6 + · · · ?

A. 4, 10, 15, 25, 16, . . .


B. 4, 0, 10, 15, 0, 25, 16, . . .
C. 4, 15, 10, 16, 25, . . .
D. 4, 10, 15, 25, 0, 16, 0, . . .
Quiz 3

A. 4, 10, 15, 25, 16, . . .


B. 4, 0, 10, 15, 0, 25, 16, . . .
C. 4, 15, 10, 16, 25, . . .
D. 4, 10, 15, 25, 0, 16, 0, . . .
Answer : B

You might also like