<<

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)... = x10 + 10x9 + 45x8 + 120x7 + 210x6 + 252x5 + 210x4 + 120x3 + 45x2 + 10x + 1 10 10! The coefficient of x6 is = = 210. 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)... = ... + 15x2y4 + 30xy4 + 15y4 + ... The sum of the coefficients of the terms with y4 is 15 + 30 + 15 = 60. X 6! X 6! Another way to put it is 1axbyc = xby4. a!b!c! a!b!4! a+b+c=6|c=4 a+b=2 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+...+ab2c+abc2 +ac3 +b2c2 +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 sand- wiches 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 ) A formal over a field F is an infinite α = a0, a1, a2, .... It is a from the set of natural numbers to F.

Definition 2 ( Ordinary Power Series Generating Function) Given a se- ∞ X n quence α = a0, a1, a2, ... the function f(x) = anx is called the ordinary n=0 power series generating function of α.

Definition 3 (Exponential Generating Function) Given a sequence α = ∞ X an a , a , a , ... the function g(x) = xn is called the exponential generating 0 1 2 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 Example 1 (Binomial Expansion) (1+x)m = xn is the generating n n=0 m m m m  function for α = , , , ..., , 0, 0, 0, ... . 0 1 2 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 () The generating function of a geometric se- ∞ n 2 2 3 3 X n n quence with an = Ar is A + Arx + Ar x + Ar x + ... = Ar x . 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, polyno- mials, 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 func- tion 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 .

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 n=0 x closed form of this generating function is . (1 − x)2

3 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 of length 2. We can find a closed form for fn using generating functions. Define the generating function of the Fibonacci sequence as ∞ X n f(x) = fnx n=0 ∞ X n = f0 + f1x + fnx n=2 ∞ X n = 0 + 1x + (fn−1 + fn−2)x n=2 ∞ ∞ X n X n = x + fn−1x + fn−2x n=2 n=2 We can rewrite this in terms of f(x) and solve for a closed form of the gen- eraing function of the Fibonacci sequence.

3 f(x) = x + xf(x) + x2f(x) f(x) − xf(x) − x2f(x) = x f(x)(1 − x − x2) = x x f(x) = 1 − x − x2 2 2 We want to factor 1−x−x into (1−α1x)(1−α2x) = 1+(−α1 −α2)x+(α1α2)x 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 2 α1 − α1 − 1 = 0

2 The equation x − x − 1 is the characteristic√ polynomial√ of the Fibonacci 1 + 5 1 − 5 recurrence. It’s solutions are α = and α = . Incidentally α 1 2 2 2 1 equals φ, the golden ratio.

x A1 A2 In partial fractions, f(x) = 2 = + 1 − x − x 1 − α1x 1 − α2x (A + A ) − (A α + A α )x = 1 2 1 2 2 1 (1 − α1x)(1 − α2x)

, 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 − α1x 1 − α2x generating functions. ∞ ∞ ! ∞ 1 X n n X n n 1 X n n n f(x) = √ α1 x − α2 x = √ (α1 − α2 )x . 5 n=0 n=0 5 n=0 ∞ X n Since the original definition of our generating function was f(x) = fnx we n=0 n n α1 − α2 have found a closed form for the Fibonacci numbers fn = √ . 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, Philadel- phia, USA, http : //www.math.upenn.edu/ ∼ wilf/gfologyLinked.pdf

Lerma, A.M., 2003, Generating functions, http : //www.math.northwestern.edu/ ∼ mlerma/problem solving/results/gen func.pdf

Day, Roger, 2003, Topics for K-8 Teachers: Generating Func- tions, http : //math.illinoisstate.edu/day/courses/old/305/contentgeneratingfunctions.html

5