Recurrence Relations
Imagine you are trying to describe how something grows step by step: a population, an investment, the number of moves in a puzzle, or the running time of a computer program. Very often the cleanest way to describe the value at one step is not with a direct formula, but in terms of the values that came just before it. That self-referential description is a recurrence relation, and it is one of the most powerful bridges between simple rules and complex behavior in all of discrete mathematics.
A recurrence relation is essentially a rule that says "to get the next term, do this to the previous term(s)." What makes them fascinating is that a tiny, almost trivial-looking rule can generate sequences of astonishing richness — the Fibonacci numbers, the golden ratio, exponential explosions, and the exact cost of recursive algorithms all fall out of a single line of definition.
Learning Objectives
- Define a recurrence relation and distinguish the recurrence from its initial conditions
- Compute terms of a sequence given a recurrence and starting values
- Recognize and work with the Fibonacci recurrence and its origin
- Solve linear homogeneous recurrences using the characteristic equation
- Handle repeated roots and non-homogeneous recurrences at an introductory level
- Connect recurrences to the running time of recursive algorithms
Quick Answer
A recurrence relation defines each term of a sequence as a function of one or more earlier terms, together with initial conditions that anchor the sequence. For example, with generates the Fibonacci numbers. "Solving" a recurrence means finding a closed-form formula for that needs no previous terms. Linear homogeneous recurrences with constant coefficients are solved with the characteristic equation: turn the recurrence into a polynomial, find its roots, and combine exponential terms . Recurrences also describe how much work a recursive algorithm does, making them a core tool in computer science.
Where It Came From
The story most people know starts in 1202, when the Italian mathematician Leonardo of Pisa — later nicknamed Fibonacci ("son of Bonacci") — published Liber Abaci ("The Book of Calculation"). His broader mission was urgent and practical: he had learned the Hindu-Arabic decimal system while traveling in North Africa, and he wanted to convince European merchants to abandon clumsy Roman numerals. To make his arithmetic lessons engaging, he posed puzzles. One became immortal.
Fibonacci's rabbit problem asks: suppose you start with one newly-born pair of rabbits. Each pair takes one month to mature, and every mature pair produces a new pair every month thereafter. Rabbits never die. How many pairs are there after months? Counting carefully, the number of pairs each month is — each new count is the sum of the previous two, because every pair alive last month survives, and every pair that was mature (alive two months ago) produces a new pair. That single observation, "the total need is last month's total plus the newborns," is the first famous recurrence relation in Western mathematics.
The deeper motivation, though, is universal and predates Fibonacci: whenever a system's next state depends on its recent history, a recurrence is the natural language to describe it. Ancient Indian scholars such as Pingala (c. 200 BCE) and later Virahanka and Hemachandra had already encountered the same numbers while counting rhythmic patterns in Sanskrit poetry — how many ways to fill a line of a given length with short and long syllables. The systematic solving of recurrences came much later, developed by mathematicians like Abraham de Moivre and Leonhard Euler in the 1700s, who introduced the characteristic-equation method that turns a recurrence into ordinary algebra. In the 20th century, recurrences became indispensable in computer science for measuring how long recursive programs take to run.
Sequences Defined by Their Own Past
A recurrence relation has two essential ingredients, and forgetting either one leads to confusion:
- The recurrence itself — the rule linking a term to earlier terms.
- The initial conditions — enough starting values to get the rule going.
Consider . This rule alone does not determine a unique sequence; you must also say where it starts. If :
giving . But if instead , the same rule produces . A recurrence that refers back terms needs initial conditions.
The order of a recurrence is how many previous terms it uses. is first-order; the Fibonacci rule is second-order and therefore needs two starting values.
The Fibonacci Recurrence
The Fibonacci sequence is defined by
Let us generate terms explicitly:
so the sequence is .
A remarkable fact: the ratio of consecutive Fibonacci numbers approaches the golden ratio . For instance and . This is not a coincidence — it emerges directly from solving the recurrence, which we do next.
Solving Linear Recurrences: The Characteristic Equation
A linear homogeneous recurrence with constant coefficients has the form
where the are constants. "Homogeneous" means there is no extra term that does not involve the sequence (nothing like the from earlier). "Solving" it means finding a closed formula for .
The key insight, due to de Moivre and Euler, is to guess that solutions look like for some number . Substituting into the recurrence and dividing by the lowest power gives a polynomial called the characteristic equation. Its roots tell you the building blocks of every solution.
Worked example: a second-order recurrence
Solve with .
Step 1 — characteristic equation. Substitute :
Divide by :
Step 2 — find the roots. Factor: , so or .
Step 3 — general solution. With two distinct roots, the general solution is
for constants and determined by the initial conditions.
Step 4 — use the initial conditions.
From the first equation . Substituting: , so .
Closed form:
Check: . Directly from the recurrence, . It matches.
Applying it to Fibonacci
For the characteristic equation is , whose roots are . Call them and . Fitting yields Binet's formula:
Because , the term shrinks to zero, so for large we have — this is exactly why consecutive ratios tend to .
Repeated roots and non-homogeneous cases
Two situations need adjustment:
- Repeated root. If the characteristic equation has a double root (e.g. gives twice), the general solution is — you multiply the second copy by . This mirrors the trick used in differential equations.
- Non-homogeneous. For a rule like , solve the homogeneous part (, giving ) and add any particular solution to the full equation. Here a constant guess gives , so the general solution is . With : , so . Check: . Correct.
Recurrences and Algorithm Analysis
Every time a program calls itself, it creates a recurrence for its running time. Understanding these is how computer scientists predict whether an algorithm is fast or hopelessly slow.
Example — binary search. To search a sorted list of items, you check the middle and then search one half. The cost satisfies
with . Unrolling: after steps the list has size ; it hits size 1 when . So , which is why binary search is — searching a million items takes only about 20 comparisons.
Example — naive recursive Fibonacci. Computing by literally recursing on and costs
which grows like — exponential! This is the classic cautionary tale: the same recurrence that defines the numbers also exposes why the obvious recursive program is catastrophically slow, and why storing computed values (dynamic programming) reduces the cost to linear.
Real-World Applications
- Population and biology: modeling animal populations, cell division, and (as Fibonacci intended) reproduction dynamics.
- Finance: compound interest is the simplest recurrence, ; loan-amortization schedules are non-homogeneous recurrences.
- Computer science: analyzing recursive algorithms (mergesort, quicksort, tree traversals) and designing dynamic-programming solutions.
- Signal processing: digital filters compute each output from previous outputs and inputs — literally a recurrence.
- Combinatorics: counting tilings, binary strings without consecutive 1s, and the Tower of Hanoi (, giving moves).
Common Mistakes
-
Forgetting initial conditions. Misconception: the recurrence alone defines the sequence. Why wrong: the same rule produces infinitely many sequences depending on where it starts. Correction: always state as many initial values as the order of the recurrence.
-
Wrong number of initial conditions. Misconception: one starting value is always enough. Why wrong: a second-order recurrence like Fibonacci reaches back two steps, so one value leaves undefined. Correction: an order- recurrence requires exactly initial conditions.
-
Mishandling repeated roots. Misconception: a double root gives solution . Why wrong: is really one constant, so you cannot match two initial conditions. Correction: use for a repeated root.
Comparison and Connections
Recurrences are close cousins of several other tools. A recurrence relation is the discrete analogue of a differential equation: both express change in terms of current state, one in whole-number steps and one continuously — and both use the characteristic-equation method. A closed-form formula is the "solved" opposite of a recurrence: fast to evaluate but often hard to find.
| Idea | Defines term by | Needs starting values? | Evaluate |
|---|---|---|---|
| Recurrence relation | previous term(s) | yes | compute all prior terms |
| Closed form | position directly | no | plug in |
| Differential equation | rate of change | yes (initial value) | continuous analogue |
| Explicit sequence formula | a rule in | no | direct substitution |
Practice Questions
Recall
State the Fibonacci recurrence together with its standard initial conditions. Answer: with and .
Understanding
Explain why a second-order recurrence needs two initial conditions but a first-order one needs only one. Guidance: the rule for reaches back to and ; to compute the first term the rule applies to, both predecessors must already be known, so two anchors are required. A first-order rule reaches back only one term.
Application
Solve with . Answer: Characteristic equation , roots . General solution . From and : subtracting twice the first from the second gives , so . Thus . Check: , and . Correct.
Analysis
The naive recursive Fibonacci algorithm satisfies . Explain what this reveals about its efficiency and how to fix it. Guidance: the recurrence grows exponentially (like ) because the same subproblems are recomputed many times. Storing already-computed values (memoization / dynamic programming) makes each computed once, reducing the cost to linear, .
FAQ
Is a recurrence relation the same as a recursive function in programming? They are deeply related: a recursive function often implements a recurrence directly. But a recurrence is a mathematical statement about a sequence, while a recursive function is code — and the naive code can be far slower than the math suggests is necessary.
Why bother solving for a closed form if I can just compute term by term? A closed form lets you jump straight to without computing everything before it, reveals the growth rate (linear? exponential?), and often exposes hidden structure like the golden ratio in Fibonacci.
What does "linear" mean in "linear recurrence"? Each previous term appears only to the first power and is multiplied by a constant — no squares, products of terms, or other functions of the sequence. is not linear.
Why does the characteristic-equation trick work? Exponential functions are the natural solutions because plugging into a linear recurrence turns every shifted term into a power of , so the whole thing collapses to a polynomial in . It is the same reason solves linear differential equations.
Do all recurrences have nice closed-form solutions? No. The clean characteristic-equation method applies to linear recurrences with constant coefficients. Nonlinear recurrences (like the logistic map ) can be chaotic and have no simple formula at all.
Quick Revision
- A recurrence defines each term from earlier terms; initial conditions anchor it. Order needs starting values.
- Fibonacci: , ; ratios approach .
- Characteristic equation: substitute , solve the polynomial. Distinct roots .
- Repeated root : .
- Non-homogeneous: general = homogeneous solution + particular solution.
- Binet: .
- Algorithms: binary search ; naive Fibonacci is exponential — use dynamic programming.
Related Topics
Prerequisites
- Discrete Mathematics overview
- Sequences and series (algebraic foundations)
- Solving quadratic equations (needed for characteristic equations)
Related Topics
- Mathematical induction (used to prove closed-form solutions correct)
- Combinatorics and counting
- Differential equations (the continuous analogue) — see Differential Equations
Next Topics
- Generating functions (a powerful alternative method for solving recurrences)
- Algorithm analysis and Big-O notation
- Dynamic programming