Introduction

A recurrence relation defines each term of a sequence from earlier terms: an=an−1+an−2a_n = a_{n-1} + a_{n-2}, T(n)=2T(n/2)+nT(n) = 2T(n/2) + n. Recurrences arise whenever a problem of size nn is reduced to smaller instances of itself: counting strings by their last symbol, counting moves in the Tower of Hanoi, or measuring the running time of a recursive algorithm.

The topics are modelling with recurrences and solving linear recurrences with constant coefficients exactly. Divide-and-conquer recurrences and the master theorem, which give asymptotic answers, are treated in Recurrences and the Master Theorem; Generating Functions give a second method for the recurrences here.

Prerequisites

  • Counting: sum and product rules, binomial coefficients.
  • Solving quadratic equations; geometric series ∑i=0n−1ri=(rn−1)/(r−1)\sum_{i=0}^{n-1} r^i = (r^n - 1)/(r - 1) for r≠1r \ne 1.

Core concepts

Terminology

  • A recurrence of order kk expresses ana_n using an−1,…,an−ka_{n-1}, \ldots, a_{n-k}. It determines the sequence uniquely once kk initial conditions (for example a0,…,ak−1a_0, \ldots, a_{k-1}) are given.
  • Linear with constant coefficients: an=c1an−1+c2an−2+⋯+ckan−k+f(n)a_n = c_1 a_{n-1} + c_2 a_{n-2} + \cdots + c_k a_{n-k} + f(n), with constants cic_i and ck≠0c_k \ne 0.
  • Homogeneous if f(n)=0f(n) = 0; otherwise non-homogeneous, and f(n)f(n) is the forcing term.
  • A closed form gives ana_n directly as a function of nn.

Modelling: three standard recurrences

  1. Tower of Hanoi. To move nn discs, move n−1n - 1 discs aside, move the largest, then move the n−1n - 1 discs back on top: Hn=2Hn−1+1H_n = 2H_{n-1} + 1, H1=1H_1 = 1. Closed form Hn=2n−1H_n = 2^n - 1.
  2. Binary strings of length nn with no two consecutive 0s. A valid string ends in 1 (preceded by any valid string of length n−1n - 1) or in 10 (preceded by any valid string of length n−2n - 2): an=an−1+an−2a_n = a_{n-1} + a_{n-2}, a1=2a_1 = 2, a2=3a_2 = 3. So an=Fn+2a_n = F_{n+2}, with Fibonacci numbers F1=F2=1F_1 = F_2 = 1.
  3. Regions formed by nn lines in general position (no two parallel, no three concurrent). The nn-th line crosses the other n−1n - 1 lines at distinct points and is cut into nn pieces, each splitting a region: Ln=Ln−1+nL_n = L_{n-1} + n, L0=1L_0 = 1, so Ln=1+n(n+1)/2L_n = 1 + n(n+1)/2.

Method 1: unrolling (iteration)

For first-order recurrences, substitute repeatedly and sum.

an=c an−1+d  ⇒  an=cna0+d (cn−1+⋯+c+1)=cna0+d cn−1c−1(c≠1),a_n = c\,a_{n-1} + d \;\Rightarrow\; a_n = c^n a_0 + d\,(c^{n-1} + \cdots + c + 1) = c^n a_0 + d\,\frac{c^n - 1}{c - 1} \quad (c \ne 1),

and an=a0+nda_n = a_0 + nd when c=1c = 1. Similarly, an=an−1+g(n)a_n = a_{n-1} + g(n) gives an=a0+∑i=1ng(i)a_n = a_0 + \sum_{i=1}^{n} g(i).

Unrolling a recurrence and the characteristic-root cases
Figure 1. Left: the Tower of Hanoi recurrence Hn=2Hn−1+1H_n = 2H_{n-1} + 1 unrolled level by level into 1+2+4+⋯+2n−1=2n−11 + 2 + 4 + \cdots + 2^{n-1} = 2^n - 1. Right: the three cases of characteristic roots and the general solution for each.

Method 2: characteristic equation (homogeneous case)

For an=c1an−1+⋯+ckan−ka_n = c_1 a_{n-1} + \cdots + c_k a_{n-k}, try an=rna_n = r^n. Dividing by rn−kr^{n-k} gives the characteristic equation

rk−c1rk−1−c2rk−2−⋯−ck=0.r^k - c_1 r^{k-1} - c_2 r^{k-2} - \cdots - c_k = 0 .
Roots of the characteristic equationGeneral solution
Distinct roots r1,…,rkr_1, \ldots, r_kan=α1r1n+⋯+αkrkna_n = \alpha_1 r_1^n + \cdots + \alpha_k r_k^n
Root rr of multiplicity mmcontributes (β0+β1n+⋯+βm−1nm−1) rn(\beta_0 + \beta_1 n + \cdots + \beta_{m-1} n^{m-1})\, r^n
Simple conjugate pair ρe±iθ\rho e^{\pm i\theta} (real coefficients)ρn(γ1cos⁡(nθ)+γ2sin⁡(nθ))\rho^n(\gamma_1\cos(n\theta)+\gamma_2\sin(n\theta)); multiplicity mm gives ρn[Pm−1(n)cos⁡(nθ)+Qm−1(n)sin⁡(nθ)]\rho^n[P_{m-1}(n)\cos(n\theta)+Q_{m-1}(n)\sin(n\theta)], with real polynomials of degree at most m−1m-1

The constants αi\alpha_i (or βj\beta_j) are fixed by the kk initial conditions, which give kk linear equations.

Second-order summary. For an=c1an−1+c2an−2a_n = c_1 a_{n-1} + c_2 a_{n-2} with characteristic equation r2−c1r−c2=0r^2 - c_1 r - c_2 = 0: distinct roots r1≠r2r_1 \ne r_2 give an=αr1n+βr2na_n = \alpha r_1^n + \beta r_2^n; a double root r0r_0 gives an=(α+βn)r0na_n = (\alpha + \beta n) r_0^n.

Fibonacci (Binet's formula). Fn=Fn−1+Fn−2F_n = F_{n-1} + F_{n-2}, F0=0F_0 = 0, F1=1F_1 = 1. Roots φ=(1+5)/2\varphi = (1 + \sqrt{5})/2 and ψ=(1−5)/2\psi = (1 - \sqrt{5})/2:

Fn=φn−ψn5.F_n = \frac{\varphi^n - \psi^n}{\sqrt{5}} .

Since ∣ψ∣<1|\psi| < 1, FnF_n is the integer nearest to φn/5\varphi^n/\sqrt{5}, so Fn=Θ(φn)F_n = \Theta(\varphi^n) with φ≈1.618\varphi \approx 1.618.

Method 3: non-homogeneous recurrences

For an=c1an−1+⋯+ckan−k+f(n)a_n = c_1 a_{n-1} + \cdots + c_k a_{n-k} + f(n):

an=an(h)+an(p),a_n = a_n^{(h)} + a_n^{(p)},

where an(h)a_n^{(h)} is the general solution of the homogeneous part and an(p)a_n^{(p)} is any one particular solution. Apply the initial conditions after adding the two parts.

Trial forms for the particular solution, where ss is the multiplicity of bb as a characteristic root (s=0s = 0 if bb is not a root):

Forcing term f(n)f(n)Try an(p)a_n^{(p)}
Constant ddA nsA\, n^{s} with b=1b = 1
Polynomial of degree ttns(Atnt+⋯+A0)n^{s}(A_t n^t + \cdots + A_0) with b=1b = 1
d bnd\, b^nA nsbnA\, n^{s} b^n
(polynomial of degree t) bn(\text{polynomial of degree } t)\, b^nns(Atnt+⋯+A0) bnn^{s}(A_t n^t + \cdots + A_0)\, b^n

The factor nsn^{s} handles resonance, when the forcing term already solves the homogeneous recurrence.

Worked examples

Example 1: distinct roots

Solve an=5an−1−6an−2a_n = 5a_{n-1} - 6a_{n-2}, a0=1a_0 = 1, a1=0a_1 = 0.

Characteristic equation r2−5r+6=0r^2 - 5r + 6 = 0, roots 2 and 3, so an=α2n+β3na_n = \alpha 2^n + \beta 3^n. Initial conditions: α+β=1\alpha + \beta = 1 and 2α+3β=02\alpha + 3\beta = 0, so β=−2\beta = -2, α=3\alpha = 3:

an=3⋅2n−2⋅3n.a_n = 3 \cdot 2^n - 2 \cdot 3^n .

Check: a2=5⋅0−6⋅1=−6a_2 = 5 \cdot 0 - 6 \cdot 1 = -6 and 3⋅4−2⋅9=−63 \cdot 4 - 2 \cdot 9 = -6.

Example 2: repeated root

Solve an=4an−1−4an−2a_n = 4a_{n-1} - 4a_{n-2}, a0=1a_0 = 1, a1=6a_1 = 6.

r2−4r+4=(r−2)2r^2 - 4r + 4 = (r - 2)^2, double root 2, so an=(α+βn)2na_n = (\alpha + \beta n) 2^n. a0=α=1a_0 = \alpha = 1; a1=2(1+β)=6a_1 = 2(1 + \beta) = 6, so β=2\beta = 2:

an=(1+2n) 2n.a_n = (1 + 2n)\, 2^n .

Check: a2=4⋅6−4⋅1=20=5⋅4a_2 = 4 \cdot 6 - 4 \cdot 1 = 20 = 5 \cdot 4.

Example 3: non-homogeneous, no resonance

Solve an=3an−1+2na_n = 3a_{n-1} + 2^n, a0=1a_0 = 1.

Homogeneous: A⋅3nA \cdot 3^n. Particular: try C 2nC\, 2^n: C2n=3C2n−1+2nC 2^n = 3C 2^{n-1} + 2^n, so C=32C+1C = \tfrac{3}{2}C + 1, C=−2C = -2. General: an=A 3n−2n+1a_n = A\,3^n - 2^{n+1}; a0=A−2=1a_0 = A - 2 = 1, A=3A = 3:

an=3n+1−2n+1.a_n = 3^{n+1} - 2^{n+1} .

Check: a1=3+2=5=9−4a_1 = 3 + 2 = 5 = 9 - 4.

Example 4: resonance

Solve an=2an−1+2na_n = 2a_{n-1} + 2^n, a0=1a_0 = 1.

2 is a root of r−2=0r - 2 = 0 with multiplicity 1, so try Cn2nC n 2^n: Cn2n=2C(n−1)2n−1+2nC n 2^n = 2C(n-1)2^{n-1} + 2^n, giving Cn=C(n−1)+1C n = C(n - 1) + 1, so C=1C = 1. General: an=A2n+n2na_n = A 2^n + n 2^n; a0=A=1a_0 = A = 1:

an=(n+1) 2n.a_n = (n + 1)\, 2^n .

Example 5: polynomial forcing

T(n)=T(n−1)+nT(n) = T(n-1) + n, T(0)=0T(0) = 0. Unrolling: T(n)=1+2+⋯+n=n(n+1)/2=Θ(n2)T(n) = 1 + 2 + \cdots + n = n(n+1)/2 = \Theta(n^2). Likewise T(n)=T(n−1)+1T(n) = T(n-1) + 1 gives Θ(n)\Theta(n), and T(n)=2T(n−1)+1T(n) = 2T(n-1) + 1 gives Θ(2n)\Theta(2^n).

Example 6: a three-term counting recurrence

Count the ternary strings (digits 0, 1, 2) of length nn that do not contain "00". Ending in 1 or 2: 2an−12a_{n-1}. Ending in 0: the previous symbol is 1 or 2, giving 2an−22a_{n-2}. So an=2an−1+2an−2a_n = 2a_{n-1} + 2a_{n-2}, a1=3a_1 = 3, a2=8a_2 = 8; then a3=22a_3 = 22, a4=60a_4 = 60. Roots 1±31 \pm \sqrt{3}.

Important properties and observations

  • The solution space of a homogeneous linear recurrence of order kk is a vector space of dimension kk; kk initial values pin down one solution.
  • For a homogeneous linear recurrence with constant coefficients, if one root rmax⁡r_{\max} has strictly the largest modulus (every other root is smaller in modulus), has multiplicity mm, and the coefficient of nm−1rmax⁡nn^{m-1} r_{\max}^n is nonzero, then ∣an∣=Θ(nm−1∣rmax⁡∣n)\lvert a_n \rvert = \Theta(n^{m-1} \lvert r_{\max} \rvert^n); for a simple root this is Θ(∣rmax⁡∣n)\Theta(\lvert r_{\max} \rvert^n). Example 2 gives Θ(n2n)\Theta(n 2^n). For a non-homogeneous recurrence, compare with the particular solution, which can dominate: Example 4 is Θ(n2n)\Theta(n 2^n) although its only root 2 is simple, and Example 5 is Θ(n2)\Theta(n^2) although its only root 1 is simple. Example 1 has an→−∞a_n \to -\infty like −2⋅3n-2 \cdot 3^n, so the bound is stated for ∣an∣\lvert a_n \rvert. With two roots of equal modulus, such as ±2\pm 2, terms can cancel: an=2n+(−2)na_n = 2^n + (-2)^n solves an=4an−2a_n = 4a_{n-2} with nonzero coefficients, but an=0a_n = 0 for every odd nn, so it is not Θ(2n)\Theta(2^n). Non-real roots of a real recurrence come in conjugate pairs of equal modulus, so a strictly dominant root is real. If the largest modulus belongs to a conjugate pair, the rule does not apply and the terms can oscillate: an=2an−1−2an−2a_n = 2a_{n-1} - 2a_{n-2}, a0=0a_0 = 0, a1=1a_1 = 1 (roots 1±i1 \pm i) gives 0, 1, 2, 2, 0, −4, −8, −8, 0.
  • Linear recurrences with constant coefficients solve exactly. Divide-and-conquer recurrences such as T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n) are usually solved asymptotically (master theorem, recursion tree); substituting n=bkn = b^k turns them into constant-coefficient recurrences in kk.
  • Always verify a closed form against two or three terms computed directly from the recurrence.

GATE examination perspective

  • Solve or evaluate. Find ana_n or a specific term; the characteristic equation is the standard route. Watch repeated roots.
  • Modelling questions. Count strings or tilings by conditioning on the last symbol or block. Get the initial conditions right; check them carefully.
  • Particular solutions. Use the trial table, multiplying by nsn^s under resonance.
  • Asymptotics. Assume c>0c>0 and a nonnegative fixed base cost: T(n)=T(n−1)+cT(n) = T(n-1) + c is linear, +n+n is quadratic, 2T(n−1)+c2T(n-1) + c is exponential.
  • Trap: applying initial conditions to the homogeneous part before adding the particular solution.

Summary

Sources

  1. K. H. Rosen, Discrete Mathematics and Its Applications, 7th ed., McGraw-Hill, 2012: Sections 8.1 (Applications of Recurrence Relations), 8.2 (Solving Linear Recurrence Relations) and 8.3 (Divide-and-Conquer Algorithms and Recurrence Relations).

Next steps