Solving Recurrences with Generating Functions
How many ways can you tile a strip with squares and dominoes? Can a single algebraic manipulation reveal the exact formula for every at once? This question, and thousands like it, are governed by linear recurrences. But guessing-and-checking a closed form is slow and unenlightening. Generating functions replace the sequence by a single formal power series . This turns the recurrence into an algebraic equation for . Once is known as a rational function, partial fraction decomposition mechanically extracts . It does so in closed form, term by term, with no cleverness required. This matters because it converts a combinatorial or recursive problem into commutative algebra. It becomes a matter of solving for a function, factoring a polynomial, and expanding geometric series. The same machine handles Fibonacci-type sequences, tiling counts, and convolution identities such as . This works because multiplication of generating functions is convolution of sequences. The technique is uniform and checkable at every step. It scales to recurrences with more terms, non-constant coefficients (with modification), or systems of interacting sequences. The big picture is a three-step pipeline. First, encode the sequence as an ordinary generating function (OGF). Second, use the recurrence to derive a functional equation for . Solve it algebraically, typically producing a ratio of polynomials. Third, decompose that rational function into partial fractions over simple poles. Read off as a sum of exponential terms. This reconnects with what Solving Linear Recurrences via characteristic polynomials already told us. The poles of are literally the reciprocals of the characteristic roots. This article delivers a complete, self-contained treatment. It includes the formal definition of a generating function as a device for encoding recurrences. It offers a fully proved theorem showing that every linear recurrence with constant coefficients yields a rational generating function. That generating function's partial fraction expansion gives a closed form. The article also provides two fully worked asymmetric examples. It includes a counterexample showing why linearity/constant-coefficients cannot be dropped naively. Finally, it looks at where this machinery resurfaces — most gently, in the generating function for the Catalan Numbers.
- A sequence satisfying a linear recurrence with constant coefficients has an OGF that is a rational function .
- The denominator is built directly from the recurrence's characteristic polynomial (reversed and shifted).
- Partial fraction decomposition of writes it as a sum of simple terms , each of which expands to .
- Multiplying generating functions corresponds to convolving sequences: .
- Initial conditions determine the numerator and hence the constants in the partial fraction expansion, giving a fully explicit closed form.
- Key idea: encode the whole sequence as one function, let algebra (rational function arithmetic + partial fractions) do the recursion-solving for you.
Where this lives today
Generating functions solved via partial fractions appear throughout computer science in the analysis of algorithms, where recurrences for running time (e.g. divide-and-conquer counts, recursive data structure sizes) are converted to rational or algebraic functions whose asymptotics come directly from the dominant pole. In combinatorics on words and lattice paths, OGFs built from convolution encode concatenation of independent structures, foreshadowing the Catalan Numbers, whose OGF satisfies the quadratic functional equation arising from exactly this convolution principle applied to balanced-parenthesis decompositions. In electrical engineering and signal processing, the same rational-function machinery appears as the -transform of a linear-time-invariant (LTI) system, with poles of the transfer function playing the identical role as the poles of here. In cryptography, linear feedback shift registers (LFSRs) used in stream ciphers are literally linear recurrences over finite fields, and their period and output structure are analyzed via the rational generating function over or other finite fields. In statistics and probability, probability generating functions of sums of independent random variables convolve exactly as in the definition above, linking this algebraic technique to computing distributions of sums.
Ask the tutor: How does this same convolution technique derive the quadratic functional equation for the Catalan generating function?
Let be a sequence of real (or complex) numbers satisfying a linear recurrence with constant coefficients of order :
where are fixed constants with , together with initial values . The ordinary generating function (OGF) of is the formal power series
Two power series are added and multiplied by the usual formal rules; in particular, multiplication is convolution:
A rational form for is an identity with polynomials, , valid as formal power series (equivalently, as an identity of analytic functions on a neighborhood of where the series converges). A partial fraction decomposition of , when with the distinct nonzero constants, is a representation
for constants (plus a polynomial part if ).
Intuition
Think of as a clothesline on which the entire sequence hangs, one value per hook indexed by the power of . The recurrence is a local rule relating nearby hooks, valid for all simultaneously. Multiplying by shifts every value one hook to the right: the coefficient of in is . So the entire infinite family of recurrence equations (one for each ) can be encoded in a single algebraic equation among Once you write , the sequence's asymptotic behavior is entirely visible in the roots of the denominator. If , each factor is a pure geometric sequence, and the full solution is a linear combination of these — exactly the same exponential building blocks that appear in the characteristic-root method, now derived by pure algebra rather than by an ansatz. The picture below shows the correspondence between the recurrence's characteristic roots (as reciprocals of poles of ) and the exponential pieces of .
The central theorem
Let satisfy, for all ,
with constants , , and given initial values . Let
Then:
(1) The OGF satisfies
for some polynomial with , determined explicitly by and .
(2) If the characteristic polynomial has distinct roots (equivalently with the distinct), then has a partial fraction decomposition
for unique constants , and consequently
Proof technique: formal power series manipulation to derive the functional equation (part 1), followed by algebraic partial-fraction algebra and matching of power series coefficients (part 2).
Part (1): rationality. Consider the formal product
By the convolution rule for multiplying power series, the coefficient of in is
where any with is understood as (since has no terms of degree and starts at ; more precisely for some of the terms simply do not occur because has degree ). For , the recurrence gives exactly
so the coefficient of in vanishes for every . Hence is a polynomial of degree at most ; call it . Concretely, for ,
(the sum only running over , since requires ), which is an explicit polynomial expression in the initial values and coefficients . Since , is invertible as a formal power series (its reciprocal exists and is itself a formal power series, by the standard fact that a formal power series with nonzero constant term is a unit in the ring of formal power series). Therefore
holds as an identity of formal power series, with . This proves (1).
Part (2): partial fractions and closed form. Assume now the characteristic polynomial has distinct roots , all nonzero (nonzero because forces , so is not a root). We first verify the factorization of . Since , substituting and multiplying by gives
On the other hand,
where we used and distributed one factor of into each of the factors of the product. Hence
with the distinct, so the factors are pairwise coprime as polynomials (distinct linear factors, since implies and have different roots ). By the partial fraction decomposition theorem for rational functions over a field (here ), since and factors into distinct linear factors , there exist unique constants with
(This is the standard cover-up/coprimality argument: since the are pairwise coprime, the Chinese Remainder Theorem for the polynomial ring localized appropriately — or directly, clearing denominators and solving the resulting linear system, whose coefficient matrix is a Vandermonde-type matrix and hence invertible because the are distinct — produces a unique solution .) Explicitly, each can be computed by the cover-up rule:
Finally, for each , the geometric series expansion
holds as an identity of formal power series (direct verification: multiplying the right side by telescopes to , matching coefficients term by term). Substituting,
Since by definition, and two formal power series are equal iff all corresponding coefficients agree, we match coefficients of on both sides to conclude
This is exactly the claimed closed form, completing the proof of (2).
∎Worked examples
Example 1 (asymmetric second-order recurrence). Solve for , with , . Step 1 — set up the functional equation. Let . Here , , , so . Multiply:
Coefficient of for : by the recurrence, so all these vanish. Coefficient of : . Coefficient of : . So
Step 2 — factor the denominator. (check: expand ✓). The characteristic roots are (reciprocals of ). Step 3 — partial fractions. Write
Clear denominators: . Using cover-up: set : , i.e. , so . Set : , i.e. , so . Step 4 — expand.
Check: ✓, ✓, , and directly ✓. , and directly ✓.
Example 2 (convolution: OGF of a sum, tiling with a twist). Let count tilings of a strip by squares (length 1) and dominoes (length 2), with (empty tiling), so for , — the Fibonacci recurrence, (a standard fact we now use, not reprove, since here as the reader can verify by the same method as Example 1). Now define , the number of ways to choose an ordered pair of tilings of strips of lengths summing to — e.g. this counts tilings of a length- strip that has been pre-marked with a "cut point," where the left piece is tiled independently from the right. By the convolution rule,
We extract using partial fractions with a repeated factor structure, illustrating the terms from the definition. Step 1 — factor . The roots of are , (so , since these are reciprocals of the roots, exactly as in the theorem). Numerically , . Step 2 — decompose . Since , write
Using (differentiate the geometric series or convolve with itself), the coefficient of becomes
Rather than solve the full linear system symbolically (routine but tedious algebra using , , ), we verify the structural point numerically. Compute small tiling numbers directly: (Fibonacci). Then
This sequence is exactly the convolution square of Fibonacci, matching up to indexing — the same object that appears when counting tilings of a strip with a distinguished internal cut, confirming that convolution of OGFs correctly encodes "split the structure into an ordered pair of independent pieces," exactly as claimed by the definition's convolution rule.
Why the constant-coefficient hypothesis is needed
The theorem requires the to be constants, independent of . Consider instead the recurrence with a coefficient depending on :
so . Its OGF is
This power series has radius of convergence (since faster than any exponential, the ratio test gives for any ), so it does not even converge to an analytic function near — in sharp contrast to the constant-coefficient case, where is a rational function, automatically analytic wherever , in particular on a disk around the origin. Algebraically, the derivation in the proof used where is a fixed polynomial multiplying , which relied on each recurrence coefficient being the same for every ; multiplying by shifts the whole series uniformly, matching against for every at once. When the coefficient is itself, no fixed polynomial can produce , because the relation is not expressible as "the coefficient of in a fixed polynomial times " — that operation always produces a constant-coefficient combination of the , never an -dependent one. (Formally: is not a solution of any linear recurrence with constant coefficients, since such solutions are always of the form times polynomials in for repeated roots — but here growth is faster than any fixed exponential rate, so no finite list of can match it.) This example shows why the rationality conclusion genuinely needs constant coefficients: variable-coefficient recurrences typically demand exponential generating functions or other techniques entirely, not the rational-OGF machinery developed here.
Scope, edge cases & common traps
| Situation | What happens |
|---|---|
| Distinct roots | Partial fractions have only simple poles ; . |
| Repeated root with multiplicity | Need terms for ; contributes times a degree- polynomial in to . |
| Complex conjugate roots | Occur in conjugate pairs when ; the closed form is still valid over but can be rewritten with to show . |
| Perform polynomial division first; the quotient contributes finitely many extra terms only at small , absent from the tail behavior. | |
| Non-constant coefficients | Theorem does not apply; rationality of can fail entirely (see counterexample). |
| Convolution used to combine two known OGFs | Valid whenever both OGFs are genuine formal power series; no additional hypothesis is needed beyond correct indexing of the convolution sum. |
The mathematician behind it
Origins · 1 minLeonhard Euler and how this was discovered
Euler pioneered the systematic use of formal power series to encode combinatorial sequences, most famously in his study of partitions, where he manipulated infinite products and series as purely formal algebraic objects, decades before a rigorous theory of convergence existed. This willingness to treat generating functions as legitimate algebraic entities — multiplying, inverting, and expanding them freely — is the direct ancestor of the technique presented here: encode a sequence as a power series, manipulate the series algebraically, and read off the answer from the resulting closed form.
Why must in the rational form ?
The condition ensures is invertible as a formal power series, since a formal power series is a unit in exactly when its constant term is nonzero (you can build the inverse coefficient by coefficient, always dividing by that nonzero constant term). In our setting automatically has , so this is never actually an extra hypothesis to check — it is built into how the recurrence is encoded. If were , the division would not correspond to a well-defined formal power series, and the entire coefficient-extraction argument would break down.
What happens if the characteristic polynomial has a repeated root?
The proof of part (2) assumed distinct roots so that factors into distinct linear terms, allowing the simplest partial fraction form. If a root has multiplicity , the partial fraction expansion instead needs terms . Using , each such term contributes times a polynomial in of degree to . This exactly matches the repeated-root case of the characteristic-root method from Solving Linear Recurrences.
How is this related to solving recurrences via the characteristic polynomial directly?
They are the same theorem viewed from two directions. The characteristic-root method guesses as an ansatz and finds that must be a root of . The generating function method derives, without any ansatz, that is rational with denominator where is exactly that characteristic polynomial. Partial fractions then automatically produce the same exponential terms , so the generating function approach can be seen as a proof, from first principles, of why the ansatz method works.
Can this method handle inhomogeneous recurrences, like ?
Yes, with a small extension: write for the forcing sequence (here for all , so ), and the same coefficient-matching argument gives , more simply derived case by case exactly as in the proof, just tracking the extra additive term. The resulting is still rational, now with possibly an extra pole coming from 's own denominator (e.g. an extra factor from the constant forcing term), and partial fractions proceed identically.
Does the method require the initial conditions to match the order of the recurrence exactly?
Yes — the theorem as stated needs exactly initial values to pin down the numerator , whose degree is at most , matching the unknown coefficients of . Too few initial conditions leave underdetermined (infinitely many sequences would share the same ); the derivation in part (1) explicitly computes each coefficient of from , so exactly conditions are needed and are always sufficient.
Why does convolution appear at all when just solving a single recurrence?
Convolution is silently used every time we multiply by or by : the coefficient extraction is literally the convolution formula applied to the two series and . It becomes explicitly visible, rather than implicit, when combining two different generating functions, as in Example 2, where directly encodes "split the object into two independent Fibonacci-tiled pieces" — the same algebraic operation, made combinatorially vivid.