Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

a definition of a sequence where later elements are expressed as a function of earlier elements.

A recurrence relation is a way to define a sequence in which later elements are computed from earlier elements. Note that a sequence can but need not consist of numbers; sequences of words, trees and all kinds of other things are equally possible.


  • $x_0 = 0, x_{n+1} = 2 x_n$ is a recurrence relation that defines the sequence $0,2,4,6,\dots$ or $(2k)_{k\in\mathbb{N}}$.
  • $F_0=0,F_1=1,F_{n+2}=F_{n+1}+F_n$ is the recurrence of the famous Fibonacci sequence.
  • $y_0=0, y_n = \sum_{k=0}^{n-1} (y_k + k)$ is a recurrence that uses a full history.
  • $\mathrm{reverse}([]) = [], \mathrm{reverse}(x::t) = \mathrm{reverse}(t) + [x]$ is a recurrence defines the function that reverses a list.
  • $f_0=g_0=1, f_{n+1}=f_n +g_n, g_{n+1}=f_n \cdot g_n$ is a mutual recurrence that defines two sequences simultaneously.
  • $\mathrm{Tree} = \mathrm{Leaf} \mid \mathrm{Node}(\mathrm{Tree},\mathrm{Tree})$ is a recursive type definition for full binary trees. It implies the montone recurrence $f_0 = \{\mathrm{Leaf}\}, f_{n+1}=f_n \cup \{\mathrm{Node}(l,r) \mid l,r \in f_n\}$ whose limit is the set of all such trees.

Solving a recurrence

To solve a recurrence means to find a closed form for it. This is not always possible as a closed form may not even exist.

When studying the complexity of algorithms (often ), recurrence relations over integers often arise, following the recursive structure of the algorithm. Some well-known methods for solving such recurrences include generating functions and (for asymptotic results) the Master Theorem.

With some experience it also often possible to guess the solution (for example by writing down the first few elements and their structure) and prove it correct by induction.