Generating Functions 1 Motivation for Generating Functions Prachi Pendse

advertisement
Generating Functions
Prachi Pendse
January 29, 2013
1
Motivation for Generating Functions
Question 1 How many ways can you select 6 cards from a set of 10?
A: Study the polynomial:
(1 + x)10 = (1 + x)(1 + x)(1 + x)...
7
6
5
4
3
2
= x10 + 10x9 + 45x8 + 120x
+ 210x + 252x + 210x + 120x + 45x + 10x + 1
10
10!
=
= 210.
The coefficient of x6 is
6
6!4!
This is a binomial coefficient.
Question 2 How many ways can a voter vote ”yes” 4 times if there are 6 issues
to vote on in a ballot and a voter can vote ”yes”, vote ”no” or abstain on each
issue?
A: Study the polynomial:
(1 + x + y)6 = (1 + x + y)(1 + x + y)(1 + x + y)...
= ... + 15x2 y 4 + 30xy 4 + 15y 4 + ...
The sum of the coefficients of the terms with y 4 is 15 + 30 + 15 = 60.
X
X
6! a b c
6! b 4
Another way to put it is
1 x y =
x y .
a!b!c!
a!b!4!
a+b=2
a+b+c=6|c=4
This is a sum of multinomial coefficients.
Question 3 How many ways can you select a 4-letter combination from the set
{A, B, C} if A can be included at most once, B at most twice, and C at most
thrice?
A1: Study the polynomial:
(1 + a)(1 + b + b2 )(1 + c + c2 + c3 )
= 1 + a + b + c + ab + ac + bc + b2 + c2 + abc + ... + ab2 c + abc2 + ac3 + b2 c2 + bc3 + ...
The answer is the sum of the coefficients of the terms where the total degree of
the variables is 4.
But the question only asks how many ways there are, not what the ways are.
We do not need to differentiate between a’s, b’s, and c’s.
A2: Study the polynomial:
1
(1 + x)(x + x + x2 )(1 + x + x2 + x3 ) = x6 + 3x5 + 5x4 + 6x4 + 5x2 + 3x + 1
We can determine the ways to select an n-letter combination satisfying the given
conditions by looking at the coefficient of the xn term.
There are 5 ways to select a 4-letter combination.
Question 4 How many ways can you order a combination of soups and sandwiches for r dollars if soup costs $2 and sandwiches $3?
A: Study the polynomial:
(1 + x2 + x4 + x6 + ...)(1 + x3 + x6 + x9 + ...)
= 1 + x2 + x3 + x4 + x5 + 2x6 + 2x7 + 2x8 + 2x9 + 2x10 + 2x11 + 3x12 + ...
The coefficient of the xr term in this polynomial gives the number of ways to
spend r dollars.
2
Generating Functions
Definition 1 (Formal Power Series) A formal power series over a field F
is an infinite sequence α = a0 , a1 , a2 , .... It is a function from the set of natural
numbers to F.
Definition 2 ( Ordinary Power Series Generating Function) Given a se∞
X
an xn is called the ordinary
quence α = a0 , a1 , a2 , ... the function f (x) =
n=0
power series generating function of α.
Definition 3 (Exponential Generating Function) Given a sequence α =
∞
X
an n
x is called the exponential generating
a0 , a1 , a2 , ... the function g(x) =
n!
n=0
function of α.
The first type of series is useful when the sequence α grows linearly with n,
while the second is used when α grows exponentially with n.
m X
m n
x is the generating
Example 1 (Binomial Expansion) (1+x) =
n
n=0 m
m
m
m
function for α =
,
,
, ...,
, 0, 0, 0, ... .
0
1
2
m
m
Example 2 (Sequence of 1’s) When α = {1, 1, 1, ...}, f (x) = 1 + x + x2 +
∞
X
1
x3 + ... =
xn . This has the closed form
.
1
−
x
n=0
Example 3 (Geometric Series) The generating function of a geometric se∞
X
quence with an = Arn is A + Arx + Ar2 x2 + Ar3 x3 + ... =
Arn xn . This has
n=0
A
.
the closed form
1 − rx
2
It is possible to do many operations on generating functions, such as adding,
subtracting, multiplying, dividing, or raising to a power by constants, polynomials, or generating functions (excluding dividing by 0), multiplying by x, and
differentiating. These operations apply to generating functions in both series
form and closed form.
In an ordinary power series generating function (opsgf), adding and subtracting
is useful to shift indices of the summation, while multiplying and dividing by
x is useful to get the power of x at n = i to be xi . ”The effect of dividing an
opsgf by (1-x) is to replace the sequence that is generated by the sequence of
its partial sums.” [Wilf]
In an exponential generating function (egf), differentiation serves the same function as addition and subtraction of terms, both operations shift the indices of
the summation. Since they can be easier to construct, generating functions are
useful in finding relations between formal power series.
Question 5 Find the closed form of the generating function of the sequence of
integers α = {1, 2, 3, ...}.
A: We realize we get the coefficients 1, 2, 3, ... when we differentiate the
generating function for a sequence of 1’s.
∞
X
1
f (x) = 1 + x + x2 + x3 + ... =
xn =
1−x
n=0
∞
X
1
f 0 (x) = 1 + 2x + 3x2 + ... =
nxn−1 =
(1
−
x)2
n=0
∞
X
Multiplying by x results in a generating function of the form
nxn . The
closed form of this generating function is
3
x
.
(1 − x)2
n=0
Closed Form of the Fibonacci Numbers
The Fibonacci sequence is F = fn where f0 = 0, f1 = 1, and fn = fn−1 + fn−2
for n > 1. The fn terms are defined in the form of a recurrence relation of
length 2. We can find a closed form for fn using generating functions. Define
the generating function of the Fibonacci sequence as
∞
X
f (x) =
fn xn
n=0
= f0 + f1 x +
∞
X
fn xn
n=2
= 0 + 1x +
=x+
∞
X
n=2
∞
X
(fn−1 + fn−2 )xn
n=2
fn−1 xn +
∞
X
fn−2 xn
n=2
We can rewrite this in terms of f(x) and solve for a closed form of the generaing function of the Fibonacci sequence.
3
f (x) = x + xf (x) + x2 f (x)
f (x) − xf (x) − x2 f (x) = x
f (x)(1 − x − x2 ) = x
x
f (x) =
1 − x − x2
We want to factor 1−x−x2 into (1−α1 x)(1−α2 x) = 1+(−α1 −α2 )x+(α1 α2 )x2
where −α1 − α2 = −1 and α1 α2 = −1.
Solving: −α1 − α2 = −1
α1 + α2 = 1
α1 α2 = −1
−1
α2 =
α1
1
=1
α1 −
α1
2
α1 − 1 = α1
α12 − α1 − 1 = 0
The equation x2 − x − 1 is the characteristic
polynomial
√
√ of the Fibonacci
1+ 5
1− 5
recurrence. It’s solutions are α1 =
and α2 =
. Incidentally α1
2
2
equals φ, the golden ratio.
A1
A2
x
=
+
2
1−x−x
1 − α1 x 1 − α2 x
(A1 + A2 ) − (A1 α2 + A2 α1 )x
=
(1 − α1 x)(1 − α2 x)
In partial fractions, f (x) =
, where A1 + A2 = 0 and A1 α2 + A2 α1 = −1.
Solving: A1 + A2 = 0
A2 = −A1
A1 α2 + A2 α1 = −1
A1 α2 − A1 α1 = −1
A1 (α2 − α1 ) = −1
−1
1
1
A1 =
=
=√
α2 − α1
α1 − α2
5
−1
A2 = √
5
1
1
1
Thus f (x) = √
−
, easily rewritten as the sum of two
5 1 − α1 x 1 − α2 x
generating functions.
!
∞
∞
∞
X
X
1
1 X n
n n
n n
f (x) = √
α1 x −
α2 x
=√
(α1 − α2n )xn .
5 n=0
5
n=0
n=0
∞
X
Since the original definition of our generating function was f (x) =
fn xn we
n=0
αn − αn
have found a closed form for the Fibonacci numbers fn = 1 √ 2 .
5
Generating functions provide a method to solve recurrence relations of finite
length and provide closed forms for their terms.
4
4
References
H.S. Wilf, 1994, generatingfunctionology, University of Pennsylvania, Philadelphia, USA, http : //www.math.upenn.edu/ ∼ wilf /gf ologyLinked.pdf
Lerma, A.M., 2003, Generating functions,
http : //www.math.northwestern.edu/ ∼ mlerma/problem solving/results/gen f unc.pdf
Day, Roger, 2003, Combinatorics Topics for K-8 Teachers: Generating Functions, http : //math.illinoisstate.edu/day/courses/old/305/contentgeneratingf unctions.html
5
Download