DISCRETE MATH • RECURRENCE RELATIONS

Use generating functions conceptually (intro)

Encode entire sequences as single algebraic objects to solve recurrence relations elegantly.

Historical Context & Motivation

The idea of encoding a sequence of numbers into a single algebraic expression has roots stretching back to the eighteenth century, when mathematicians sought systematic methods for solving combinatorial and number-theoretic problems. A generating function takes an infinite sequence (a₀, a₁, a₂, …) and packages it as the coefficients of a formal power series, transforming questions about sequences into questions about algebra. This conceptual shift—treating a whole sequence as a single object—was revolutionary because it allowed mathematicians to apply the full machinery of calculus and algebra to discrete counting problems and recurrence relations.

1718
de Moivre's Recurrence Work
Abraham de Moivre introduces methods for solving linear recurrence relations, laying groundwork for the algebraic treatment of sequences.
1748
Euler's Introductio in Analysin Infinitorum
Leonhard Euler systematically uses formal power series to study partitions and combinatorial identities, effectively pioneering the generating function technique.
1812
Laplace's Théorie Analytique
Pierre-Simon Laplace employs generating functions in probability theory, coining the term 'fonction génératrice' and demonstrating their power for solving difference equations.
1990s–present
Modern Combinatorics & CS
Generating functions become a standard tool in combinatorics, algorithm analysis, and computer science, featured prominently in texts by Wilf, Stanley, and Knuth.

The central question that generating functions address is this: given a recurrence relation such as aₙ = 3aₙ₋₁ − 2aₙ₋₂, can we find a closed-form expression for the general term aₙ without iterating step by step? Generating functions provide a powerful and systematic framework for answering exactly this kind of question, converting the recursive structure into algebraic manipulations that can be solved with familiar techniques.

Core Principles & Definitions

Before diving into computation, it is essential to build a firm conceptual understanding of what generating functions are and why they work. The fundamental idea is deceptively simple: given a sequence (a₀, a₁, a₂, a₃, …), we associate to it the ordinary generating function (OGF) A(x) = a₀ + a₁x + a₂x² + a₃x³ + ⋯ = Σₙ≥₀ aₙxⁿ. We treat this as a formal power series, meaning we do not worry about convergence—x is simply a placeholder that keeps track of the index n. The coefficients are what matter.

1

Encoding

A generating function encodes an entire sequence into a single algebraic object. The coefficient of xⁿ in A(x) is exactly aₙ, the n-th term of the sequence.
2

Algebraic Manipulation

Operations on sequences—shifting, scaling, adding, convolving—correspond to simple algebraic operations on generating functions: multiplication by x, scalar multiplication, addition, and product of series.
3

Closed-Form Extraction

Once a generating function is expressed in closed form (e.g., as a rational function), we can use partial fractions and known series expansions to extract a formula for the n-th coefficient.
4

Formal Power Series

Convergence is irrelevant in the formal setting. The variable x serves as a bookkeeping device—equality of generating functions means equality of all coefficients.
KEY TAKEAWAY
Think of a generating function as a DNA sequence for a number sequence. Just as a strand of DNA compactly encodes enormous amounts of biological information, a generating function compactly encodes an infinite list of numbers in a single algebraic expression. You do not need to 'read' every base pair to understand the organism; similarly, you do not need to compute every term—you work with the compact algebraic form and extract whatever coefficient you need.

Visual Explanation: From Sequence to Generating Function

The following diagram illustrates the core conceptual pipeline of the generating function method. On the left, we begin with a recurrence relation that defines a sequence recursively. In the center, the encoding step transforms this recurrence into an algebraic equation involving the generating function A(x). On the right, solving this algebraic equation and extracting coefficients yields the desired closed-form solution for aₙ.

The three-stage pipeline: a recurrence relation (left, violet) is encoded into a generating function equation (center, cyan), which is then solved algebraically and its coefficients extracted (right, emerald). The correspondence table at the bottom shows how common sequence operations translate into simple algebraic operations on A(x).

The diagram above captures the essence of why generating functions are so powerful. Notice that the difficult step—solving the recurrence—is replaced by routine algebraic manipulation. The encoding step translates the recursive definition into a functional equation. The algebraic step solves for A(x) in closed form, typically yielding a rational function. The extraction step uses partial fraction decomposition and known series expansions—such as 1/(1 − rx) = Σ rⁿxⁿ—to read off the coefficient of xⁿ.

Mathematical Framework

We now formalize the key mathematical ideas. Given a sequence (aₙ)ₙ≥₀, its ordinary generating function is defined as a formal power series. The power of this definition lies in the fact that algebraic operations on A(x) correspond precisely to natural operations on the underlying sequence.

ORDINARY GENERATING FUNCTION
A(x) = Σₙ₌₀∞ aₙ xⁿ = a₀ + a₁x + a₂x² + a₃x³ + ⋯
Here aₙ is the n-th term of the sequence, x is a formal indeterminate, and [xⁿ]A(x) denotes the coefficient of xⁿ in A(x), i.e., [xⁿ]A(x) = aₙ.
GEOMETRIC SERIES (FUNDAMENTAL IDENTITY)
1 / (1 − rx) = Σₙ₌₀∞ rⁿ xⁿ = 1 + rx + r²x² + r³x³ + ⋯
This is the most important generating function identity. The sequence (1, r, r², r³, …) has generating function 1/(1 − rx). This is the building block for solving linear recurrences via partial fractions.
RIGHT-SHIFT PROPERTY
If B(x) = Σₙ₌₀∞ aₙ₊₁ xⁿ, then B(x) = (A(x) − a₀) / x
Shifting the sequence left by one position corresponds to subtracting the constant term and dividing by x. More generally, shifting left by k gives (A(x) − a₀ − a₁x − ⋯ − aₖ₋₁xᵏ⁻¹) / xᵏ. This property is what allows us to translate recurrence relations into algebraic equations.

These three identities form the foundation of the generating function method for solving recurrences. The strategy is always the same: multiply every term of the recurrence by xⁿ, sum over all valid n, recognize each sum as a generating function (possibly shifted), solve the resulting algebraic equation for A(x), and then decompose the closed-form expression to extract [xⁿ]A(x). The partial fraction decomposition is typically the key step in the extraction phase, since it breaks a rational function into a sum of terms of the form C/(1 − rx), each of which has a known power series expansion.

Operations on Generating Functions

A major reason generating functions are so useful is that natural operations on sequences translate into clean algebraic operations on the corresponding power series. Understanding this correspondence table is arguably more important at the introductory level than mastering any single computation. The diagram below summarizes the most common operations and their generating function counterparts, providing a visual reference that you can return to whenever you encounter a new recurrence.

Top: six fundamental sequence-to-GF operation correspondences. Bottom: a step-by-step visual trace of how the recurrence aₙ − 3aₙ₋₁ + 2aₙ₋₂ = 0 is solved using generating functions—multiply and sum, recognize shifted GFs, factor out A(x), then extract coefficients via partial fractions.

Notice how the right-shift property is the workhorse that converts the recurrence into an algebraic equation. Each occurrence of aₙ₋ₖ in the recurrence introduces a factor of xᵏ multiplied by A(x), after appropriate adjustment for initial conditions. Once A(x) is factored out, the denominator polynomial is precisely the characteristic polynomial of the recurrence (with x in place of 1/r). This deep connection between the generating function approach and the characteristic root method is not a coincidence—they are two perspectives on the same underlying algebraic structure.

Worked Example: Solving a Linear Recurrence

Let us apply the generating function method to solve the recurrence aₙ = 5aₙ₋₁ − 6aₙ₋₂ for n ≥ 2, with initial conditions a₀ = 1 and a₁ = 4. Our goal is to find a closed-form expression for aₙ.

Solving aₙ = 5aₙ₋₁ − 6aₙ₋₂ with a₀ = 1, a₁ = 4
1
Step 1 — Define the Generating FunctionLet A(x) = Σₙ≥₀ aₙxⁿ. Our aim is to find A(x) in closed form. We start by multiplying both sides of the recurrence aₙ = 5aₙ₋₁ − 6aₙ₋₂ by xⁿ and summing from n = 2 to ∞.
A(x) = Σₙ≥₀ aₙxⁿ (to be determined)
2
Step 2 — Translate the RecurrenceSumming aₙxⁿ from n = 2 to ∞ gives A(x) − a₀ − a₁x = A(x) − 1 − 4x. Summing 5aₙ₋₁xⁿ from n = 2 gives 5x(A(x) − a₀) = 5x(A(x) − 1) = 5xA(x) − 5x. Summing 6aₙ₋₂xⁿ from n = 2 gives 6x²A(x). Putting it together: A(x) − 1 − 4x = 5xA(x) − 5x − 6x²A(x).
A(x) − 1 − 4x = 5xA(x) − 5x − 6x²A(x)
3
Step 3 — Solve for A(x)Collecting all terms with A(x) on the left: A(x)(1 − 5x + 6x²) = 1 + 4x − 5x = 1 − x. Therefore A(x) = (1 − x) / (1 − 5x + 6x²). Factoring the denominator: 1 − 5x + 6x² = (1 − 2x)(1 − 3x).
A(x) = (1 − x) / ((1 − 2x)(1 − 3x))
4
Step 4 — Partial Fraction DecompositionWrite (1 − x)/((1 − 2x)(1 − 3x)) = C₁/(1 − 2x) + C₂/(1 − 3x). Multiplying both sides by (1 − 2x)(1 − 3x): 1 − x = C₁(1 − 3x) + C₂(1 − 2x). Setting x = 1/2: 1 − 1/2 = C₁(1 − 3/2), so 1/2 = C₁(−1/2), giving C₁ = −1. Setting x = 1/3: 1 − 1/3 = C₂(1 − 2/3), so 2/3 = C₂(1/3), giving C₂ = 2.
A(x) = −1/(1 − 2x) + 2/(1 − 3x)
5
Step 5 — Extract the Coefficient [xⁿ]Using the geometric series identity 1/(1 − rx) = Σ rⁿxⁿ, we have [xⁿ](−1/(1 − 2x)) = −2ⁿ and [xⁿ](2/(1 − 3x)) = 2 · 3ⁿ. Therefore the closed-form solution is aₙ = 2 · 3ⁿ − 2ⁿ.
aₙ = 2 · 3ⁿ − 2ⁿ
Verification
Check: a₀ = 2 · 1 − 1 = 1 ✓, a₁ = 2 · 3 − 2 = 4 ✓, a₂ = 2 · 9 − 4 = 14. From recurrence: a₂ = 5(4) − 6(1) = 14 ✓. The formula is confirmed.

Generating Functions vs. Other Methods

The generating function method is not the only way to solve recurrence relations. It is instructive to compare it with the characteristic root method and the method of iteration (unrolling). Each approach has its strengths and weaknesses, and understanding when to deploy each tool is part of mathematical maturity.

Comparison of three methods for solving recurrence relations
FeatureCharacteristic RootsGenerating FunctionsIteration / Unrolling
ScopeLinear, constant-coefficientBroader: handles non-constant coefficients, nonlinear in some casesAny recurrence (but may not yield closed form)
Non-homogeneous termsRequires separate particular solution guessHandles automatically via algebraCase-by-case
Initial conditionsApplied after general solution foundBuilt into the derivation from the startUsed at each unrolling step
Conceptual difficultyLow once masteredHigher setup; lower risk of error in complex casesLow, but tedious for large n
Connection to combinatoricsIndirectDirect: encodes counting problems naturallyIndirect
KEY TAKEAWAY
Think of the characteristic root method as a specialized surgical tool—fast and precise for the specific case of constant-coefficient linear recurrences. Generating functions, by contrast, are more like a Swiss Army knife: versatile enough to handle non-homogeneous terms, variable coefficients, and even combinatorial counting problems in a unified framework. For constant-coefficient linear recurrences, both methods yield the same answer—but the generating function approach scales to a wider class of problems.

Connections to Advanced Theory

The introductory treatment of generating functions presented here focuses on ordinary generating functions (OGFs) and linear recurrences with constant coefficients. However, the generating function framework extends far beyond this setting. Understanding where these extensions lead provides motivation for deeper study and reveals the true power of the method.

From introductory OGFs to advanced generating function theory
Concept (Intro Level)Advanced ExtensionApplication Domain
OGF: Σ aₙxⁿEGF: Σ aₙxⁿ/n!Labeled structures (permutations, Stirling numbers)
Single-variable GFMultivariate GFsMultidimensional recurrences, lattice paths
Rational A(x)Algebraic & D-finite GFsCatalan numbers, tree enumeration, holonomic sequences
Coefficient extractionAnalytic combinatorics (singularity analysis)Asymptotic growth of sequences (e.g., aₙ ~ C · rⁿ · nᵅ)
Formal power seriesZ-transform (discrete-time signals)Digital signal processing, control theory

The exponential generating function (EGF) Σ aₙxⁿ/n! is particularly natural when the sequence counts labeled structures, because the factorial denominator accounts for relabeling. Meanwhile, the Z-transform used in engineering is essentially the OGF evaluated at z⁻¹ instead of x, making the connection between discrete mathematics and signal processing remarkably direct. The field of analytic combinatorics, developed by Flajolet and Sedgewick, takes the generating function paradigm to its logical conclusion by analyzing the singularities of A(x) in the complex plane to derive asymptotic estimates for aₙ—a technique that underpins much of modern algorithm analysis.

Practice Problems

PROBLEM 1CONCEPTUAL
Explain in your own words why we treat the variable x in a generating function as a 'formal' indeterminate rather than a real number. What advantage does this give us?
PROBLEM 2BASIC CALCULATION
Find the ordinary generating function A(x) for the constant sequence aₙ = 5 for all n ≥ 0. Express your answer in closed form.
PROBLEM 3INTERMEDIATE
Use generating functions to find a closed-form solution for the recurrence aₙ = 4aₙ₋₁ − 3aₙ₋₂ for n ≥ 2, with a₀ = 0 and a₁ = 2.
PROBLEM 4APPLIED
A population of bacteria doubles every hour, and at each hour 10 new bacteria are also introduced from outside. If the initial population is p₀ = 50, set up the generating function equation for pₙ (the population at hour n) using the recurrence pₙ = 2pₙ₋₁ + 10, and find P(x) in closed form. You do not need to extract the coefficient.
PROBLEM 5CRITICAL THINKING
Consider the Fibonacci recurrence Fₙ = Fₙ₋₁ + Fₙ₋₂ with F₀ = 0, F₁ = 1. Derive the generating function F(x) = x/(1 − x − x²). Then explain conceptually (without performing the full partial fraction calculation) how the golden ratio φ = (1 + √5)/2 emerges from this generating function, and what it tells us about the asymptotic growth of Fibonacci numbers.

Lesson Summary

A generating function encodes an entire sequence (a₀, a₁, a₂, …) as a single formal power series A(x) = Σ aₙxⁿ, transforming recursive definitions into algebraic equations. The method follows a three-stage pipeline: encode the recurrence by multiplying by xⁿ and summing, solve algebraically for A(x) in closed form (typically a rational function), and extract coefficients using partial fraction decomposition and the geometric series identity 1/(1 − rx) = Σ rⁿxⁿ.

Key operations on sequences—shifting, scaling, addition, and convolution—have clean algebraic counterparts: multiplication by x, scalar multiplication, addition of series, and series product. Compared to the characteristic root method, generating functions offer greater versatility, handling non-homogeneous terms and variable coefficients in a unified framework. This introductory conceptual understanding sets the stage for advanced topics including exponential generating functions, analytic combinatorics, and connections to the Z-transform in signal processing.

Varsity Tutors • Discrete Math • Use generating functions conceptually (intro)