Discrete Mathematics and Combinatorics
Recurrence Relations and How to Solve the Linear Ones
Turn a rule that defines each term from earlier ones into a direct formula, using characteristic roots and particular solutions.
Key takeaways
- A recurrence needs starting values: as many as the number of steps it reaches back.
- For aₙ = c₁aₙ₋₁ + c₂aₙ₋₂, solve the characteristic equation r² = c₁r + c₂ and combine powers of its roots.
- A repeated root r contributes both rⁿ and n·rⁿ.
- With an extra non-recursive term, the answer is one particular solution plus the general solution of the version without it.
A recurrence relation defines each term of a sequence using earlier terms, such as aₙ = 5aₙ₋₁ − 6aₙ₋₂. To solve a linear one with constant coefficients, try aₙ = rⁿ, find the values of r that work, combine those solutions, and use the starting values to fix the constants.
"Linear" means the earlier terms appear only to the first power, never squared or multiplied together. "Solving" means finding a formula that gives aₙ directly, without computing all the terms before it.
Where recurrences come from
Say you climb a staircase of n steps, taking 1 or 2 steps at a time. Call the number of ways aₙ. Your first move is either 1 step, leaving aₙ₋₁ ways, or 2 steps, leaving aₙ₋₂ ways. So aₙ = aₙ₋₁ + aₙ₋₂, with a₀ = 1 and a₁ = 1.
The sequence runs 1, 1, 2, 3, 5, 8, 13: the Fibonacci numbers, shifted by one place.
Other sources include money that grows by a fixed percentage and receives regular deposits, the running time of programs that call themselves, and counts such as derangements. The method is to ask how a case of size n is built from smaller cases.
Building a recurrence
Setting up the rule is often the hardest part. A reliable method is to classify the objects of size n by what happens first, or last.
Count strings of length n made from the digits 0, 1 and 2 that never contain two zeros in a row. If a valid string ends in 1 or 2, the first n − 1 characters can be any valid string: 2aₙ₋₁ options. If it ends in 0, the character before must be 1 or 2, and before that comes any valid string of length n − 2: 2aₙ₋₂ options.
aₙ = 2aₙ₋₁ + 2aₙ₋₂, a₀ = 1, a₁ = 3
a₂ = 2×3 + 2×1 = 8 (all 9 strings except 00)
a₃ = 2×8 + 2×3 = 22 Checking a₂ against a list you can write out is a quick test that both the rule and the starting values are right.
First-order recurrences
The simplest type is aₙ = r·aₙ₋₁, a geometric sequence with solution aₙ = a₀·rⁿ. Add a constant and you get aₙ = r·aₙ₋₁ + d.
When r ≠ 1, look for a fixed point, a value c that the rule leaves unchanged: c = rc + d. Subtracting this from the recurrence shows that aₙ − c is purely geometric.
aₙ = 3aₙ₋₁ + 2, a₀ = 1
fixed point: c = 3c + 2, so c = −1
shifted: aₙ + 1 = 3(aₙ₋₁ + 1)
solution: aₙ = 2 × 3ⁿ − 1
check: a₁ = 5 = 3×1 + 2, a₂ = 17 = 3×5 + 2 When r = 1 the sequence is arithmetic: aₙ = a₀ + nd.
A savings example
Suppose a hypothetical account starts with 1,000, earns 2 percent each period and then receives a deposit of 100. The balance obeys Bₙ = 1.02·Bₙ₋₁ + 100.
fixed point: c = 1.02c + 100, so c = −5,000
solution: Bₙ = 6,000 × 1.02ⁿ − 5,000
B₁ = 6,000 × 1.02 − 5,000 = 1,120
B₂ = 6,000 × 1.0404 − 5,000 = 1,242.40 The formula answers questions the step-by-step rule handles slowly, such as the balance after 200 periods, or how many periods it takes to pass a target, which you solve with logarithms. This illustrates the mathematics only and is not financial advice. Real accounts have fees, taxes, rounding and changing rates.
The characteristic equation
For second order, aₙ = c₁aₙ₋₁ + c₂aₙ₋₂ with c₂ ≠ 0, guess aₙ = rⁿ with r ≠ 0. Substituting and dividing by rⁿ⁻² gives r² = c₁r + c₂, the characteristic equation.
Linearity means that if two sequences satisfy the rule, so does any sum of multiples of them. With two distinct roots r and s, the general solution is aₙ = A·rⁿ + B·sⁿ.
aₙ = 5aₙ₋₁ − 6aₙ₋₂, a₀ = 2, a₁ = 5
r² − 5r + 6 = 0 roots 2 and 3
aₙ = A·2ⁿ + B·3ⁿ
n = 0: A + B = 2
n = 1: 2A + 3B = 5 so A = 1, B = 1
aₙ = 2ⁿ + 3ⁿ
check: a₂ = 5×5 − 6×2 = 13 = 4 + 9 Why is this every solution? The two starting values determine the whole sequence, and the two constants can always be chosen to match them when r ≠ s.
Repeated roots
If the characteristic equation has a double root r, then A·rⁿ alone has only one free constant, which is not enough. A second solution is n·rⁿ.
aₙ = 4aₙ₋₁ − 4aₙ₋₂, a₀ = 1, a₁ = 6
r² − 4r + 4 = (r − 2)² = 0
aₙ = (A + Bn)·2ⁿ
n = 0: A = 1
n = 1: (1 + B)·2 = 6, so B = 2
aₙ = (1 + 2n)·2ⁿ
check: a₂ = 4×6 − 4×1 = 20 = 5 × 4 For higher orders the pattern continues. A root repeated three times contributes rⁿ, n·rⁿ and n²·rⁿ.
Three steps back
Higher orders work the same way, with a polynomial of higher degree.
aₙ = 6aₙ₋₁ − 11aₙ₋₂ + 6aₙ₋₃, a₀ = 3, a₁ = 6, a₂ = 14
r³ − 6r² + 11r − 6 = (r − 1)(r − 2)(r − 3) = 0
aₙ = A + B·2ⁿ + C·3ⁿ
A + B + C = 3
A + 2B + 3C = 6
A + 4B + 9C = 14 solution A = B = C = 1
aₙ = 1 + 2ⁿ + 3ⁿ
check: a₃ = 6×14 − 11×6 + 6×3 = 36 = 1 + 8 + 27 The difficulty shifts to finding the roots. For degrees beyond four there is no general formula in radicals, so in practice roots may have to be approximated numerically.
Fibonacci and the golden ratio
For Fₙ = Fₙ₋₁ + Fₙ₋₂ with F₀ = 0 and F₁ = 1, the equation r² = r + 1 has roots φ = (1 + √5)/2 and ψ = (1 − √5)/2. Fitting the starting values gives Binet's formula:
Fₙ = (φⁿ − ψⁿ) / √5 Here φ is about 1.618, the golden ratio, and ψ is about −0.618. Since |ψ| < 1, its powers fade away, and Fₙ is the whole number nearest φⁿ/√5. For n = 10, φ¹⁰/√5 is about 55.004, and F₁₀ = 55.
This shows a general fact: unless its constant is zero, the root of largest absolute value dominates the long-run growth.
Complex roots
The roots may be complex numbers even when every term is a whole number. Take aₙ = 2aₙ₋₁ − 2aₙ₋₂ with a₀ = 0 and a₁ = 1. The roots of r² − 2r + 2 = 0 are 1 + i and 1 − i, where i² = −1.
Each root has size √2 and angle π/4 or −π/4, and the solution can be written without any i:
aₙ = (√2)ⁿ × sin(nπ/4)
terms: 0, 1, 2, 2, 0, −4, −8, −8, 0, 16 Complex roots signal oscillation. Their size controls whether the swings grow or shrink, and their angle controls the rhythm. For more on this link, see why complex numbers connect rotation and waves.
Adding an extra term
A recurrence such as aₙ = 2aₙ₋₁ + n is called nonhomogeneous, because of the term n that does not involve the sequence. Find any one solution of the full rule, called a particular solution, and add the general solution of aₙ = 2aₙ₋₁.
Guess a particular solution shaped like the extra term. Here try pn + q:
pn + q = 2(p(n − 1) + q) + n
n terms: p = 2p + 1, so p = −1
constants: q = 2q − 2p, so q = −2
aₙ = C·2ⁿ − n − 2
with a₀ = 1: C = 3
check: a₁ = 3 = 2×1 + 1, a₂ = 8 = 2×3 + 2 If the extra term already solves the version without it, multiply the guess by n. For aₙ = 2aₙ₋₁ + 2ⁿ with a₀ = 0, trying c·2ⁿ fails, while aₙ = n·2ⁿ works exactly.
A familiar sum is a case of this. Let Sₙ = Sₙ₋₁ + n with S₀ = 0. The characteristic root is 1, so a constant already solves the version without n, and a guess of the form pn + q must be multiplied by n. Trying Sₙ = pn² + qn gives p = q = 1/2, which is the formula n(n + 1)/2.
Kinship with differential equations
If you have studied differential equations, the recipe will look familiar. There you try an exponential, solve a characteristic equation, treat repeated roots with an extra factor of the variable and add a particular solution. A recurrence is the discrete counterpart, with rⁿ playing the role of the exponential.
Long-run behavior differs in one respect worth remembering. A solution of a recurrence dies away when every root has absolute value below 1. It stays bounded or grows depending on the roots of largest size, and a repeated root of size 1 produces growth.
Beyond this method
The recipe covers linear rules with constant coefficients. Several other situations need different tools.
- Rules with coefficients that depend on n, such as aₙ = n·aₙ₋₁, are often solved by unrolling the product: here aₙ = a₀·n!.
- Rules in which the size is divided, such as T(n) = 2T(n/2) + n, are the territory of the master theorem.
- Rules that combine all earlier terms often yield to generating functions.
- Nonlinear rules may have no closed formula at all, and some behave chaotically.
One to try yourself
Solve aₙ = aₙ₋₁ + 6aₙ₋₂ with a₀ = 1 and a₁ = 8. The characteristic equation r² − r − 6 = 0 has roots 3 and −2, so aₙ = A·3ⁿ + B·(−2)ⁿ. The starting values give A + B = 1 and 3A − 2B = 8, hence A = 2 and B = −1.
The answer is aₙ = 2·3ⁿ − (−2)ⁿ. Test it at n = 2: the formula gives 18 − 4 = 14, and the recurrence gives 8 + 6 = 14. Notice that the negative root makes a term that alternates in sign, while the larger root 3 still controls the overall growth.
Common mistakes
Fitting the constants before adding the particular solution gives wrong values, so fit them last. Using too few starting values leaves the sequence undetermined. Sign errors in the characteristic equation are frequent: aₙ = 5aₙ₋₁ − 6aₙ₋₂ gives r² − 5r + 6 = 0, with the signs of the coefficients reversed when moved across.
Finally, always test a term you did not use in the fit. One extra line of arithmetic catches most errors, and a proof by induction confirms the formula for every n.