notesonly.in

One notebook for every subject — open it anywhere.

Log in

Recurrence Relations: Complete Beginner's Guide Guide.

A recurrence relation defines each term of a sequence using earlier terms, like a set of dominoes where each piece's position depends on the ones before it. The classic example is the Fibonacci sequence: each number is the sum of the two before it, so 1, 1, 2, 3, 5, 8, 13, … continues by the rule F(n) = F(n−1) + F(n−2).

Recurrences matter because they are the natural language of processes that build on their own history. Computer scientists use them to analyse recursive algorithms, banks use them for compound interest, and biologists use them to model populations. Whenever a quantity this year depends on its value last year, a recurrence relation is hiding underneath.

Key Concepts

  • Recurrence relation: an equation like a(n) = 2 × a(n−1) + 1 that expresses term n through earlier terms.
  • Initial conditions: the starting values, such as a(1) = 1, that anchor the sequence. A recurrence without them has infinitely many solutions.
  • Order: how far back the relation reaches. F(n) = F(n−1) + F(n−2) is second order; a(n) = 3 × a(n−1) is first order.
  • Homogeneous: every term contains the sequence itself, with no stray constants. a(n) = 2 × a(n−1) is homogeneous; a(n) = 2 × a(n−1) + 1 is not.
  • Closed form: a direct formula for term n that needs no earlier terms, such as a(n) = 2^n − 1.
  • Characteristic equation: for a second-order linear homogeneous recurrence a(n) = c1 × a(n−1) + c2 × a(n−2), the equation r² = c1 × r + c2, whose roots reveal the closed form.

Formulas

  • Arithmetic-style: a(n) = a(n−1) + d gives the closed form a(n) = a(1) + (n−1) × d. Assumption: the difference d is constant.
  • Geometric-style: a(n) = r × a(n−1) gives a(n) = a(1) × r^(n−1). Assumption: the ratio r is constant and non-zero.
  • Tower of Hanoi: T(n) = 2 × T(n−1) + 1 with T(1) = 1 solves to T(n) = 2^n − 1. You can verify it by substitution: 2 × (2^(n−1) − 1) + 1 = 2^n − 1.
  • Compound interest: A(n) = A(n−1) × (1 + r) with A(0) = P gives A(n) = P × (1 + r)^n, where r is the interest rate per period.

Worked Example

The Tower of Hanoi puzzle with 4 disks: what is the minimum number of moves? Use T(n) = 2 × T(n−1) + 1 with T(1) = 1.

  1. T(1) = 1 by the initial condition: one disk needs one move.
  2. T(2) = 2 × T(1) + 1 = 2 × 1 + 1 = 3 moves.
  3. T(3) = 2 × T(2) + 1 = 2 × 3 + 1 = 7 moves.
  4. T(4) = 2 × T(3) + 1 = 2 × 7 + 1 = 15 moves.
  5. Check with the closed form: 2^4 − 1 = 16 − 1 = 15. Both methods agree, so the minimum is 15 moves.

Common Misconceptions

  • "The recurrence alone defines the sequence." It does not. The rule a(n) = 2 × a(n−1) with a(1) = 5 gives 5, 10, 20, …, but with a(1) = 1 it gives 1, 2, 4, …. Initial conditions pick the one true sequence out of infinitely many.
  • "Recursion and recurrence are unrelated." They are two sides of one idea: a recurrence is the mathematical description, and recursion is how you implement that description in code.
  • "Off-by-one in the base case does not matter." It shifts everything. Using T(0) = 0 instead of T(1) = 1 changes which formula for T(n) is correct, so always state and use the base case consistently.

Real-World Applications

  • Algorithm analysis: merge sort satisfies T(n) = 2 × T(n/2) + n, which solves to O(n log n) — the reason it scales so well.
  • Finance: loans, savings and investments all follow recurrences, which is how banks compute balances period by period.
  • Population models: rabbit populations, infections and cell growth are modelled with recurrences that feed each generation into the next.
  • Dynamic programming: optimisation algorithms build answers from smaller subproblems, which is recurrence thinking turned into code.

A recurrence relation plus its initial conditions is a complete recipe for a sequence. Learn to unroll one step by step, recognise the famous patterns like the Tower of Hanoi, and you will read recursive algorithms and growth models the way musicians read sheet music.