Discrete Math • Recurrence Relations

Use generating functions conceptually (intro)

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

A connected graph with binary values and set braces for discrete mathematics
Inside this lesson 10 sections 5 questions 7 figures

SECTION 1

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.

SECTION 2

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.

SECTION 3

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 Generating Function PipelineSTEP 1: Recurrenceaₙ = 3aₙ₋₁ − 2aₙ₋₂a₀ = 1, a₁ = 1Sequence: 1, 1, 1, 1, …EncodeSTEP 2: AlgebraA(x) = Σ aₙxⁿSolve for A(x)→ rational functionExtractSTEP 3: SolutionPartial fractions[xⁿ] A(x) = aₙClosed-form formulaKey Correspondence TableSequence OperationGF OperationAlgebraic EffectShift right by 1Multiply by xx · A(x)Scale by constant cMultiply by cc · A(x)
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ⁿ.

SECTION 4

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)=Σn=0∞anxn=a0+a1x+a2x2+a3x3+⋯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)=Σn=0∞rnxn=1+rx+r2x2+r3x3+⋯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

IfB(x)=Σn=0∞an+1xn,thenB(x)=(A(x)−a0)/xIf 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.

SECTION 5

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.

Sequence ↔ Generating Function OperationsADDITION(aₙ) + (bₙ) = (aₙ + bₙ) → A(x) + B(x)SCALAR MULTIPLICATION(c·aₙ) → c · A(x)RIGHT SHIFT (delay by 1)(0, a₀, a₁, a₂, …) → x · A(x)LEFT SHIFT (advance by 1)(a₁, a₂, a₃, …) → (A(x)−a₀)/xCONVOLUTION (Cauchy product)cₙ = Σₖ aₖbₙ₋ₖ → A(x)·B(x)MULTIPLY SEQUENCE BY nⁿ(rⁿ·aₙ) → A(rx)Example: Solving aₙ − 3aₙ₋₁ + 2aₙ₋₂ = 0Multiply & SumΣ aₙxⁿ − 3Σ aₙ₋₁xⁿ+ 2Σ aₙ₋₂xⁿ = 0Recognize GFsA(x) − 3xA(x)+ 2x²A(x) = ···Factor & SolveA(x)(1−3x+2x²)= f(initial cond.)Extract [xⁿ]aₙ = α·1ⁿ + β·2ⁿThe denominator 1 − 3x + 2x² = (1 − x)(1 − 2x) reveals the characteristic roots r = 1, 2Partial fractions then yield the coefficients α, β from initial conditions
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.

SECTION 6

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. 1

    Step 1 — Define the Generating Function

    Let 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. 2

    Step 2 — Translate the Recurrence

    Summing 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. 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. 4

    Step 4 — Partial Fraction Decomposition

    Write (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. 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.

SECTION 7

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.

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

Comparison of three methods for solving recurrence relations

✦

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.

SECTION 8

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.

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

From introductory OGFs to advanced generating function 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.

SECTION 9

Practice Problems

Question 1: CONCEPTUAL

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?
Show answer
By treating x as a formal indeterminate, we sidestep all questions of convergence—we never need to worry about whether the series A(x) converges for particular values of x. This means every sequence, no matter how fast it grows, has a well-defined generating function. Two generating functions are equal if and only if their corresponding coefficients are equal, which is all we need for extracting sequence information. The formalism lets us manipulate infinite series purely algebraically (adding, multiplying, substituting) without analytical concerns, freeing us to focus on the combinatorial or recurrence structure of the problem.

Question 2: BASIC CALCULATION

Find the ordinary generating function A(x) for the constant sequence aₙ = 5 for all n ≥ 0. Express your answer in closed form.
Show answer
We have A(x) = Σₙ≥₀ 5xⁿ = 5 · Σₙ≥₀ xⁿ = 5 · 1/(1 − x) = 5/(1 − x). This follows directly from the scalar multiplication property: scaling a sequence by a constant c scales its generating function by c. The fundamental geometric series identity 1/(1 − x) = 1 + x + x² + ⋯ is the generating function for the all-ones sequence (1, 1, 1, …), so multiplying by 5 gives the generating function for (5, 5, 5, …).

Question 3: INTERMEDIATE

Use generating functions to find a closed-form solution for the recurrence aₙ = 4aₙ₋₁ − 3aₙ₋₂ for n ≥ 2, with a₀ = 0 and a₁ = 2.
Show answer
Define A(x) = Σ aₙxⁿ. Multiplying the recurrence by xⁿ and summing from n = 2 to ∞: A(x) − 0 − 2x = 4x(A(x) − 0) − 3x²A(x). So A(x) − 2x = 4xA(x) − 3x²A(x), giving A(x)(1 − 4x + 3x²) = 2x. The denominator factors as (1 − x)(1 − 3x), so A(x) = 2x/((1 − x)(1 − 3x)). Applying partial fractions: 2x/((1 − x)(1 − 3x)) = C₁/(1 − x) + C₂/(1 − 3x). Solving: set x = 1 to get C₁ = 2·1/(1 − 3) = −1; set x = 1/3 to get C₂ = 2·(1/3)/(1 − 1/3) = 1. So A(x) = −1/(1 − x) + 1/(1 − 3x), yielding aₙ = 3ⁿ − 1. Check: a₀ = 1 − 1 = 0 ✓, a₁ = 3 − 1 = 2 ✓.

Question 4: APPLIED

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.
Show answer
The recurrence is pₙ = 2pₙ₋₁ + 10 for n ≥ 1 with p₀ = 50. Let P(x) = Σₙ≥₀ pₙxⁿ. Multiply by xⁿ and sum from n = 1: P(x) − 50 = 2xP(x) + 10·x/(1 − x), where the last term accounts for Σₙ≥₁ 10xⁿ = 10x/(1 − x). Solving for P(x): P(x)(1 − 2x) = 50 + 10x/(1 − x) = (50 − 50x + 10x)/(1 − x) = (50 − 40x)/(1 − x). Therefore P(x) = (50 − 40x)/((1 − x)(1 − 2x)). This rational function can be decomposed via partial fractions to extract pₙ. Note how the non-homogeneous term '+ 10' is handled naturally through the generating function for the constant sequence, demonstrating the method's advantage over characteristic roots for non-homogeneous recurrences.

Question 5: CRITICAL 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.
Show answer
Multiplying Fₙ = Fₙ₋₁ + Fₙ₋₂ by xⁿ and summing for n ≥ 2: F(x) − 0 − x = xF(x) + x²F(x), so F(x)(1 − x − x²) = x, yielding F(x) = x/(1 − x − x²). The denominator 1 − x − x² factors as (1 − φx)(1 − ψx) where φ = (1+√5)/2 and ψ = (1−√5)/2 are the roots of t² = t + 1 (equivalently, 1 − t − t² = 0 when t is replaced by 1/x). The partial fraction decomposition would yield F(x) as a sum of terms of the form C/(1 − rx), and since 1/(1 − rx) = Σ rⁿxⁿ, the coefficient of xⁿ is a linear combination of φⁿ and ψⁿ. Because |ψ| < 1, the ψⁿ term vanishes for large n, so Fₙ ~ φⁿ/√5 asymptotically. The dominant singularity of F(x)—the zero of the denominator nearest to the origin, at x = 1/φ—directly controls the exponential growth rate of the Fibonacci numbers. This is a fundamental principle in analytic combinatorics: the growth rate of a sequence is governed by the singularity structure of its generating function.

SUMMARY

Lesson Summary

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)