You are on page 1of 4

GENERATING FUNCTIONS

MIGUEL A. LERMA
(Last updated: October 29, 2003)
1. Generating Functions
1. Denition. Given a sequence a
0
, a
1
, a
2
, . . . , the function
f(x) = a
0
+ a
1
x + a
2
x
2
+ =

n=0
a
n
x
n
is called the generating function for the given sequence.
Examples:
(1) (1 + x)
m
=

m
n=0
_
m
n
_
x
n
is the generating function for
_
m
0
_
,
_
m
1
_
,
_
m
2
_
, . . . ,
_
m
m
_
, 0, 0, 0, . . . .
(2) 1/(1 x) = 1 +x +x
2
+x
3
+ is the generating function for
the constant sequence a
n
= 1.
(3) The generating function of a geometric sequence a
n
= Ar
n
is
A
1 r x
= A + Ar x + Ar
2
x
2
+ Ar
3
x
3
+ . . .
(4) If f(x) = a
0
+a
1
x+a
2
x
2
+a
3
x
3
+ is the generating function
for a
0
, a
1
, a
2
, . . . , then the following is the generating function
for the sequence of partial sums

n
k=0
a
k
:
f(x)
1 x
= f(x)(1 + x + x
2
+ x
3
+ )
= (a
0
+ a
1
x + a
2
x
2
+ )(1 + x + x
2
+ x
3
+ )
= a
0
+ (a
0
+ a
1
) x + (a
0
+ a
1
+ a
2
) x
2
+
(5) Partitions of Integers. Let p
M
(n) be the number of ways the
positive integer n can be written as a sum of positive integers
1
2 MIGUEL A. LERMA
not exceeding M. For instance p
3
(5) = 5 because 5 = 3 + 2 =
3 +1 +1 = 2 +2 +1 = 2 +1 +1 +1 = 1 +1 +1 +1 +1. Then
M

k=1
1
1 x
k
=

n=0
p
M
(n) x
k
.
Example: Use generating functions to nd the sum of the terms of a
geometric sequence: s
n
= 1 + r + r
2
+ + r
n
(r = 1). Answer: We
have
1
1 rx
=

n=0
r
n
x
n
,
hence
1
(1 x)(1 rx)
=

n=0
s
n
x
n
.
Next, we expand the left hand side into partial fractions:
1
(1 x)(1 rx)
=
1
1 r
_
1
1 x

r
1 rx
_
=
1
r 1
_

n=0
r
n+1
x
n

n=0
x
n
_
=

n=0
r
n+1
1
r 1
x
n
,
hence
s
n
=
r
n+1
1
r 1
.
2. Generating Function of a Linear Homogeneous Recurrence.
Given a kth-order linear homogeneous recurrence relation:
x
n
+ c
1
x
n1
+ c
2
x
n2
+ + c
k
x
nk
= 0
(note that the leading coecient is 1), its characteristic polynomial is
Q(r) = r
k
+ c
1
r
n1
+ c
2
r
n2
+ + c
k
.
Let q(x) = x
k
Q(x
1
) be the polynomial
1
q(x) = x
k
Q(x
1
) = 1 + c
1
x + c
2
x
2
+ c
k
x
k
.
1
The polynomial q(x) is called reciprocal of Q(x).
GENERATING FUNCTIONS 3
Then the solution of the recurrence has the following generating func-
tion:
f(x) =
p(x)
q(x)
,
where p(x) is some polynomial of degree less than r which depends on
the initial conditions for the recurrence.
Example: We use the method of generating functions to obtain the
close-form formula for the Fibonacci sequence. The Fibonacci sequence
F
n
has the following characteristic polynomial:
P(x) = r
2
r 1 ,
so q(x) = 1 x x
2
. Hence,
a + b x
1 x x
2
= F
0
+ F
1
x + F
2
x
2
+ .
We determine the numerator of the generating function by writing
a + b x = (1 x x
2
) (F
0
+ F
1
x + F
2
x
2
+ )
= F
0
+ {F
1
F
0
} x + {F
2
F
1
F
0
} x
2
+ . . . ,
so that a = F
0
= 0, b = F
1
F
0
= 1, hence:
x
1 x x
2
= F
0
+ F
1
x + F
2
x
2
+ .
We can factor the denominator like this
1 x x
2
= (1 x) (1 +
1
x) ,
where
=
1 +

5
2
;
1
=
1

5
2
.
The generating function can be expressed as a sum of partial fractions
in the following way:
x
1 x x
2
=
1

5
_
1
1 x

1
1 +
1
x
_
.
Since in general 1/(1 a x) is the generating function for the sequence
a
n
, we get that
x
1 x x
2
=
1

5
_

n=0

n
x
n

n=0
(
1
)
n
x
n
_
=
1

n=0
_

n
()
n
_
x
n
.
4 MIGUEL A. LERMA
That must be equal to
x
1 x x
2
=

n=0
F
n
x
n
,
so we get:
F
n
=
1

5
_

n
()
n
_
.

You might also like