Quant Memo
Core

Recurrence Relations

Defining a sequence by how each term relates to the ones before it, rather than by a direct formula — the natural language for compounding, backtesting loops, and any process where today depends on yesterday.

Prerequisites: Sequences and Series Convergence

A portfolio's value at the end of each month depends only on its value at the end of last month, plus that month's return. There's no need to re-derive the value from scratch each time using the entire history — you just need last month's number and this month's rule. That's the essence of a recurrence relation: a sequence defined not by a direct formula for the nn-th term, but by a rule connecting each term to the ones just before it, plus a starting point. Recurrences are how compounding, backtests, and recursive algorithms are naturally described, and often the real work is converting a recurrence into a closed-form formula you can evaluate directly without looping through every prior step.

An analogy: a chain of dominoes

A recurrence relation is like a row of dominoes: knocking down domino nn depends entirely on domino n1n-1 having just fallen (and maybe n2n-2, if they're close enough to double-trigger). You don't need to know anything about domino 1 to predict domino 50's fate directly — you just need to know the rule connecting consecutive dominoes, plus where the row started. Compounding interest is the same: this month's balance is last month's balance times (1+r)(1+r), and that one local rule, applied repeatedly, determines the whole sequence.

The math, one piece at a time

A recurrence relation defines a sequence ana_n using earlier terms of the same sequence. The simplest useful kind quants meet is linear with constant coefficients, such as:

an=c1an1+c2an2++ckank+f(n),a_n = c_1 a_{n-1} + c_2 a_{n-2} + \cdots + c_k a_{n-k} + f(n),

where ana_n is the term you're solving for, c1,,ckc_1, \ldots, c_k are fixed numbers, an1,,anka_{n-1}, \ldots, a_{n-k} are the kk previous terms the new term depends on, and f(n)f(n) is an optional external "forcing" term that doesn't come from the sequence itself (like a fixed monthly deposit). In words: each new term is a weighted blend of a fixed number of the terms right before it, plus possibly some outside input. To actually compute values you also need initial conditions — enough starting terms (a0a_0, or a0a_0 and a1a_1, etc.) to seed the recursion; without them the relation alone has infinitely many possible sequences satisfying it.

Solving a recurrence means finding a closed form — a direct formula for ana_n in terms of nn alone, no recursion needed. For the simplest first-order case an=ran1a_n = r \cdot a_{n-1} with a0a_0 given, the closed form is an=a0rna_n = a_0 \, r^n: each step multiplies by rr again, so after nn steps you've multiplied by rr a total of nn times.

Worked example 1: compounding by hand, recurrence vs. closed form

A $10,000 account earns 5% per year, recurrence: an=1.05an1a_n = 1.05 \, a_{n-1}, a0=10,000a_0 = 10{,}000. Stepping through by hand: a1=10,500a_1 = 10{,}500, a2=11,025a_2 = 11{,}025, a3=11,576.25a_3 = 11{,}576.25. The closed form an=10,000×1.05na_n = 10{,}000 \times 1.05^n gives the same a3a_3 directly: 10,000×1.157625=11,576.2510{,}000 \times 1.157625 = 11{,}576.25 — matching, but computed in one step instead of three, which matters enormously when nn is 30 years, not 3.

Worked example 2: the Fibonacci-style deposit sequence

Suppose a fund's monthly inflow follows an=an1+an2a_n = a_{n-1} + a_{n-2} (this month tracks the sum of the last two, a crude momentum rule), starting from a0=100a_0 = 100 and a1=150a_1 = 150 (units: $thousands). By hand: a2=250a_2 = 250, a3=400a_3 = 400, a4=650a_4 = 650, a5=1,050a_5 = 1{,}050. This is the Fibonacci recurrence with different starting values — it grows geometrically, at a rate approaching the golden ratio ϕ1.618\phi \approx 1.618 per step, even though the rule only references the two immediately preceding terms.

a₀=100 a₁=150 a₂=250 a₃=400 a₄=650 a₅≈1050
Each term uses only the two terms right before it, yet the sequence's growth rate curves upward, approaching a fixed geometric ratio (the golden ratio) rather than staying linear.
step n a_n = a_(n-1) + c (linear) a_n = r·a_(n-1) (geometric)
A recurrence that adds a constant each step grows linearly; one that multiplies by a constant each step grows geometrically — the same local, one-step rule produces very different long-run shapes depending on whether the connection is additive or multiplicative.

What this means in practice

Recurrences are the natural way to describe anything that updates step by step: compounding returns, moving-average and EWMA filters (each new value blends the previous estimate with a new observation), backtest loops that carry state (inventory, cash, drawdown) forward one bar at a time, and dynamic-programming solutions to optimal-execution or option-pricing lattices. Recognizing a problem as a recurrence — "this value depends on the last one or two values plus a rule" — is often the first step to either writing a clean loop or, better, solving for a closed form that skips the loop entirely.

A recurrence relation defines each term of a sequence using a fixed rule applied to the terms just before it, plus initial conditions to seed it — solving a recurrence means finding a closed-form formula for the nn-th term that doesn't require stepping through every prior term.

The classic mistake is treating a recurrence as if it were already a closed form — assuming ana_n can be read off directly instead of realizing it requires computing (or deriving a formula for) every term up to nn. This matters practically: a loop implementing an=an1+an2a_n = a_{n-1} + a_{n-2} naively takes O(n)O(n) steps (or worse, O(ϕn)O(\phi^n) if written as naive recursion without memoization), while the closed form evaluates in O(1)O(1). Confusing "I have a rule connecting the terms" with "I have a formula for the term" leads to needlessly slow code and, in interviews, to missing the intended closed-form answer.

Related concepts

Practice in interviews

Further reading

  • Graham, Knuth & Patashnik, Concrete Mathematics, ch. 1-2
  • Cormen et al., Introduction to Algorithms, ch. 4
ShareTwitterLinkedIn