26-08 — Generating Functions

Phase: Combinatorics | Subject: 26-08 Prerequisites: 26-07-recurrence-relations.md, 03-07-sequences-and-series.md Next subject: 26-09-graph-theory-basics.md


Learning Objectives

By the end of this subject, you will be able to:

  1. Define ordinary generating functions (OGFs) and exponential generating functions (EGFs)
  2. Derive generating functions for common sequences
  3. Solve recurrence relations using generating functions
  4. Extract coefficients from generating functions
  5. Apply generating functions to partition problems

Core Content

Ordinary Generating Functions (OGF)

The ordinary generating function of a sequence ${a_n}_{n=0}^{\infty}$ is:

$$A(x) = \sum_{n=0}^{\infty} a_n x^n$$

The coefficient $a_n = [x^n]A(x)$.

Key Idea: Operations on sequences correspond to algebraic operations on generating functions. This turns combinatorial problems into algebraic ones.

Common OGFs

Sequence ($a_n$) OGF $A(x)$ Radius of convergence
$a_n = 1$ $\frac{1}{1-x}$ $|x| < 1$
$a_n = n$ $\frac{x}{(1-x)^2}$ $|x| < 1$
$a_n = \binom{m}{n}$ $(1+x)^m$ all $x$
$a_n = \binom{m+n-1}{n}$ $\frac{1}{(1-x)^m}$ $|x| < 1$
$a_n = \frac{1}{n!}$ $e^x$ all $x$

Operations on OGFs

Let $A(x) = \sum a_n x^n$, $B(x) = \sum b_n x^n$.

Solving Recurrences with Generating Functions

Recipe: 1. Write the recurrence for all $n \geq$ something 2. Multiply both sides by $x^n$ and sum from $n$ to $\infty$ 3. Express sums in terms of $A(x)$ and known series 4. Solve for $A(x)$ as a rational function 5. Partial fraction decomposition + coefficient extraction

Example (Fibonacci): $F_{n+2} = F_{n+1} + F_n, F_0 = 0, F_1 = 1$. $\sum F_{n+2} x^n = \sum F_{n+1} x^n + \sum F_n x^n$ $(F(x) - x)/x^2 = (F(x))/x + F(x)$ $F(x) = \frac{x}{1 - x - x^2}$.

Exponential Generating Functions (EGF)

$$E(x) = \sum_{n=0}^{\infty} a_n \frac{x^n}{n!}$$

EGFs are useful when the recurrence involves binomial coefficients or when counting labeled structures (e.g., permutations, set partitions).

Example: Bell numbers $B_n$ (partitions of an $n$-element set) have EGF: $B(x) = e^{e^x - 1}$.

Integer Partitions

Let $p(n)$ = number of partitions of $n$ (ways to write $n$ as sum of positive integers, order irrelevant).

OGF: $P(x) = \prod_{k=1}^{\infty} \frac{1}{1 - x^k} = \frac{1}{(1-x)(1-x^2)(1-x^3)\cdots}$.


Key Terms

Worked Examples

Example 1: Solve $a_n = 2a_{n-1} + 1, a_0 = 0$ using OGF

Solution: $a_n = 2a_{n-1} + 1$ for $n \geq 1$, $a_0 = 0$. Multiply by $x^n$, sum $n \geq 1$: $\sum_{n \geq 1} a_n x^n = 2\sum_{n \geq 1} a_{n-1} x^n + \sum_{n \geq 1} x^n$ $A(x) - 0 = 2x A(x) + \frac{x}{1-x}$ $A(x)(1 - 2x) = \frac{x}{1-x}$ $A(x) = \frac{x}{(1-x)(1-2x)} = \frac{1}{1-2x} - \frac{1}{1-x}$ $a_n = 2^n - 1$.

Click for answer $a_n = 2^n - 1$. The generating function method directly yields the closed form.

Example 2: Coefficient Extraction

Find $[x^5]$ in $\frac{1}{(1-x)^3}$.

Solution: $\frac{1}{(1-x)^3} = \sum_{n=0}^{\infty} \binom{n+2}{2} x^n$. $[x^5] = \binom{7}{2} = 21$.

Click for answer $[x^5]\frac{1}{(1-x)^3} = \binom{5+2}{2} = 21$.

Example 3: Convolution

Find the generating function for partial sums: $b_n = \sum_{k=0}^n a_k$.

Solution: $b_n = \sum_{k=0}^n a_k \cdot 1$. This is convolution of ${a_n}$ with ${1}$. $B(x) = A(x) \cdot \frac{1}{1-x}$.

Click for answer $B(x) = \frac{A(x)}{1-x}$. The $1/(1-x)$ factor acts as a summation operator.


Quiz

Q1: What does the concept of Ordinary Generating Function (OGF) primarily refer to in this subject?

A) A computational error related to Ordinary Generating Function (OGF) B) A visual representation of Ordinary Generating Function (OGF) C) A historical anecdote about Ordinary Generating Function (OGF) D) The definition and application of Ordinary Generating Function (OGF)

Correct: D)

Q2: Which of the following is the key formula discussed in this subject?

A) \{a_n\}{n=0}^{\infty} B) The inverse operation of the formula in question C) A simplified version of \{a_n\}{n=0}^{\infty}... D) An unrelated formula from a different topic

Correct: A)

Q3: What is the primary purpose of Exponential Generating Function (EGF)?

A) It is primarily a historical notation system B) It is used only in advanced research contexts C) It is used to exponential generating function (egf) in mathematical analysis D) It replaces all other methods in this domain

Correct: C)

Q4: Which statement about Convolution is TRUE?

A) Convolution is a fundamental concept covered in this subject B) Convolution is mentioned only as a historical footnote C) Convolution is an advanced topic beyond this subject's scope D) Convolution is not related to this subject

Correct: A)

Q5: Based on the worked examples in this subject, what is the correct result?

A) A different result from a common mistake B) The inverse of the correct answer C) An unrelated numerical value D) Coefficient Extraction

Correct: D)

Q6: How are Convolution and Coefficient Extraction related?

A) Convolution is the inverse of Coefficient Extraction B) Convolution is a special case of Coefficient Extraction C) Convolution and Coefficient Extraction are closely related concepts D) Convolution and Coefficient Extraction are completely unrelated topics

Correct: C)

Q7: What is a common pitfall when working with Integer Partitions?

A) Integer Partitions is always computed the same way in all contexts B) Integer Partitions has no common misconceptions C) A common mistake is confusing Integer Partitions with a similar concept D) The main error with Integer Partitions is using it when it is not needed

Correct: C)

Q8: When should you apply Ordinary Generating Functions (Ogf)?

A) Ordinary Generating Functions (Ogf) is not practically useful B) Use Ordinary Generating Functions (Ogf) only in pure mathematics contexts C) Apply Ordinary Generating Functions (Ogf) to solve problems in this subject's domain D) Avoid Ordinary Generating Functions (Ogf) unless explicitly instructed

Correct: C)

Practice Problems

  1. Find the OGF of $a_n = 2^n$.

    Click for answer $\sum_{n=0}^{\infty} 2^n x^n = \frac{1}{1-2x}$, for $|x| < 1/2$.

  2. Find $[x^4]$ in $(1+x)^{10}$.

    Click for answer $\binom{10}{4} = 210$.

  3. Solve $a_n = 3a_{n-1}$ with $a_0 = 2$ using generating functions.

    Click for answer $A(x) = \frac{2}{1-3x}$. $a_n = 2 \cdot 3^n$.

  4. What is the EGF of $a_n = 1$ for all $n$?

    Click for answer $\sum_{n=0}^{\infty} 1 \cdot \frac{x^n}{n!} = e^x$.

  5. How many ways to partition the number 4? List them.

    Click for answer $p(4) = 5$: 4, 3+1, 2+2, 2+1+1, 1+1+1+1.


Summary

Key takeaways:


Pitfalls



Next Steps

Next up: 26-09-graph-theory-basics.md — vertices, edges, degrees, and fundamental graph concepts.