Definitions

# Recurrence relation

"Difference equation" redirects here. It should not be confused with a differential equation.

In mathematics, a recurrence relation is an equation that defines a sequence recursively: each term of the sequence is defined as a function of the preceding terms.

A difference equation is a specific type of recurrence relation.

An example of a recurrence relation is the logistic map:

$x_\left\{n+1\right\} = r x_n \left(1 - x_n\right). ,$

Some simply defined recurrence relations can have very complex (chaotic) behaviours and are sometimes studied by physicists and mathematicians in a field of mathematics known as nonlinear analysis.

Solving a recurrence relation means obtaining a closed-form solution: a non-recursive function of n.

## Linear homogeneous recurrence relations with constant coefficients

The term linear means that each term of the sequence is defined as a linear function of the preceding terms. The order of a linear recurrence relation is the number of preceding terms required by the definition—so the relation $a_n = a_\left\{n-2\right\},$ is of order two, because there must be at least two preceding terms (whether they are both used or not). The general form of a linear recurrence relation of order $d ,$ is as follows:

$a_n = c_1a_\left\{n-1\right\} + c_2a_\left\{n-2\right\}+cdots+c_da_\left\{n-d\right\} + c ,$

where $c ,$ and $c_i ,$ (for all $i ,$) are allowed to depend on $n ,$, but $a_i ,$ (for all $i ,$) is not. If $c_i ,$ is independent of $n,$ (for all $i ,$), then the recurrence relation is said to have constant coefficients. Additionally, if $c = 0 ,$ then the recurrence relation is homogeneous; such a sequence is also called a linear recursive sequence or LRS.

The linear recurrence, together with seed values (initial conditions) for $a_0,dots,a_\left\{d-1\right\}$, determines the sequence uniquely.

### Example: Fibonacci numbers

The Fibonacci numbers are defined using the linear recurrence relation

$F_\left\{n\right\} = F_\left\{n-1\right\}+F_\left\{n-2\right\} ,$
with seed values:
$F_1 = 1 ,$
$F_2 = 1. ,$

The sequence of Fibonacci numbers begins:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 ...

It can be solved via the matrix solution described below, yielding the closed form expression.

### Solving via linear algebra

Given an LRS, one can write down its companion matrix, then put it in Jordan normal form (which is diagonal if the eigenvalues are distinct). Expressing the seed in terms of the eigenbasis, say
$begin\left\{bmatrix\right\}a_0$
vdots a_{d-1}end{bmatrix} = b_1v_1 + cdots + b_dv_d yields
$begin\left\{bmatrix\right\}a_n$
vdots a_{n+(d-1)}end{bmatrix} = C^nbegin{bmatrix}a_0 vdots a_{d-1}end{bmatrix} = C^n(b_1v_1 + cdots + b_dv_d) = lambda_1^nb_1v_1 + cdots + lambda_d^n b_dv_d which is a closed form expression (expand on the first coordinate to obtain a closed form expression for $a_n,$).

If the companion matrix is not diagonalizable, then the resulting expression is more complicated, but conceptually the same.

### Solving generally

Solutions to recurrence relations are found by systematic means, often by using generating functions (formal power series) or by noticing the fact that rn is a solution for particular values of r.

Consider, for example, a recurrence relation of the form

$a_\left\{n\right\}=Aa_\left\{n-1\right\}+Ba_\left\{n-2\right\}. ,$

Suppose that it has a solution of the form an = rn. Substituting this guess in the recurrence relation, we find:

$r^\left\{n\right\}=Ar^\left\{n-1\right\}+Br^\left\{n-2\right\}. ,$

Dividing through by rn − 2, we get

$r^2=Ar+B, ,$

$r^2-Ar-B=0. ,$

This is known as the characteristic equation of the recurrence relation. Solve for r to obtain the two roots λ1, λ2, and if these roots are distinct, we have the solution

$a_n = Clambda_1^n+Dlambda_2^n ,$

while if they are identical (when A2 + 4B = 0), we have

$a_n = Clambda^n+Dnlambda^n ,$

where constants C and D can be found from the "side conditions" that are often given as a0 = a, a1 = b.

Different solutions are obtained depending on the nature of the roots of the characteristic equation.

### Solving with z-transforms

Certain difference equations, in particular Linear constant coefficient difference equations, can be solved using z-transforms. The z-transforms are a class of integral transforms that lead to more convenient algebraic manipulations and more straightforward solutions. There are cases in which obtaining a direct solution would be all but impossible, yet solving the problem via a thoughtfully chosen integral transform is straightforward.

### Theorem

Given a linear homogeneous recurrence relation with constant coefficients of order $d ,$, let $p\left(t\right) ,$ be the characteristic polynomial (also "auxiliary polynomial")

$t^d - c_1t^\left\{d-1\right\} - c_2t^\left\{d-2\right\}-cdots-c_\left\{d\right\} = 0 ,$

such that each $c_i ,$ corresponds to each $c_i ,$ in the original recurrence relation (see the general form above). Suppose $lambda ,$ is a root of $p\left(t\right) ,$ having multiplicity $r ,$. This is to say that $\left(t-lambda\right)^r ,$ divides $p\left(t\right) ,$. The following two properties hold:

1. Each of the $r ,$ sequences $lambda^n, nlambda^n, n^2lambda^n,dots,n^\left\{r-1\right\}lambda^n ,$ satisfies the recurrence relation.
2. Any sequence satisfying the recurrence relation can be written uniquely as a linear combination of solutions constructed in part 1 as $lambda,$ varies over all distinct roots of $p\left(t\right),$.

As a result of this theorem a linear homogeneous recurrence relation with constant coefficients can be solved in the following manner:

1. Find the characteristic polynomial $p\left(t\right) ,$.
2. Find the roots of $p\left(t\right) ,$ counting multiplicity.
3. Write $a_n ,$ as a linear combination of all the roots (counting multiplicity as shown in the theorem above) with unknown coefficients $b_i,$.

$a_n = \left(b_1lambda_1^n + b_2nlambda_1^n + b_3n^2lambda_1^n+cdots+b_\left\{r\right\}n^\left\{r-1\right\}lambda_1^n\right)+cdots+\left(b_\left\{d-q+1\right\}lambda_\left\{*\right\}^n + cdots + b_\left\{d\right\}n^\left\{q-1\right\}lambda_\left\{*\right\}^n\right) ,$

This is the general solution to the original recurrence relation.

(Note: $q ,$ is the multiplicity of $lambda_\left\{*\right\} ,$)

4. Equate each $a_0, a_1, a_2,dots,a_d ,$ from part 3 (plugging in $n = 0,dots,d ,$ into the general solution of the recurrence relation) with the known values $a_0, a_1, a_2,dots,a_d ,$ from the original recurrence relation. Note, however, that the values $a_n ,$ from the original recurrence relation used do not have to be contiguous, just $d ,$ of them are needed (i.e. for an original linear homogeneous recurrence relation of order 3 one could use the values $a_0, a_1, a_4 ,$). This process will produce a linear system of $d ,$ equations with $d,$ unknowns. Solving these equations for the unknown coefficients $b_1, b_2, b_3,dots,b_d ,$ of the general solution and plugging these values back into the general solution will produce the particular solution to the original recurrence relation that fits the original recurrence relation's initial conditions (as well as all subsequent values $a_0,a_1,a_2,a_3,dots ,$ of the original recurrence relation).

Interestingly, the method for solving linear differential equations is similar to the method above — the "intelligent guess" for linear differential equations with constant coefficients is $e^\left\{lambda x\right\},$ where $lambda ,$ is a complex number that is determined by substituting the guess into the differential equation.

This is not a coincidence. If you consider the Taylor series of the solution to a linear differential equation:


sum_{n=0}^{infin} frac{f^{(n)}(a)}{n!} (x-a)^{n}

you see that the coefficients of the series are given by the n-th derivative of f(x) evaluated at the point a. The differential equation provides a linear difference equation relating these coefficients.

This equivalence can be used to quickly solve for the recurrence relationship for the coefficients in the power series solution of a linear differential equation.

The rule of thumb (for equations in which the polynomial multiplying the first term is non-zero at zero) is that:


y^{[k]} to f[n+k] and more generally

x^m*y^{[k]} to n(n-1)(n-m+1)f[n+k-m]

Example: The recurrence relationship for the Taylor series coefficients of the equation:

$\left(x^2 + 3x -4\right)y^\left\{\left[3\right]\right\} -\left(3x+1\right)y^\left\{\left[2\right]\right\} + 2y = 0,$

is given by

$n\left(n-1\right)f\left[n+1\right] + 3nf\left[n+2\right] -4f\left[n+3\right] -3nf\left[n+1\right] -f\left[n+2\right]+ 2f\left[n\right] = 0,$

or

$-4f\left[n+3\right] +2nf\left[n+2\right] + n\left(n-4\right)f\left[n+1\right] +2f\left[n\right] = 0.,$

This example shows how problems generally solved using the power series solution method taught in normal differential equation classes can be solved in a much easier way.

Example: The differential equation

$ay\text{'}\text{'} + by\text{'} +cy = 0,$

has solution

$y=e^\left\{ax\right\}.,$

The conversion of the differential equation to a difference equation of the Taylor coefficients is

$af\left[n + 2\right] + bf\left[n + 1\right] + cf\left[n\right] = 0,$.

It is easy to see that the nth derivative of eax evaluated at 0 is an

## General linear homogeneous recurrence relations

Many linear homogeneous recurrence relations may be solved by means of the hypergeometric series. Special cases of these lead to recurrence relations for the orthogonal polynomials, and many special functions. For example, the solution to

$J_\left\{n+1\right\}=frac\left\{2n\right\}\left\{z\right\}J_n-J_\left\{n-1\right\}$

is given by

$J_n=J_n\left(z\right) ,$,

the Bessel function, while

$\left(b-n\right)M_\left\{n-1\right\} +\left(2n-b-z\right)M_n - nM_\left\{n+1\right\}=0 ,$

is solved by

$M_n=M\left(n,b;z\right) ,$

## Solving non-homogeneous recurrence relations

If the recurrence is inhomogeneous, a particular solution can be found by the method of undetermined coefficients and the solution is the sum of the solution of the homogeneous and the particular solutions. Another method to solve an inhomogeneous recurrence is the method of symbolic differentiation. For example, consider the following recurrence:

$a_\left\{n+1\right\} = a_\left\{n\right\} + 1,$

This is an inhomogeneous recurrence. If we substitute $n mapsto n + 1$, we obtain the recurrence

$a_\left\{n+2\right\} = a_\left\{n+1\right\} + 1,$

Subtracting the original recurrence from this equation yields

$a_\left\{n+2\right\} - a_\left\{n+1\right\} = a_\left\{n+1\right\} - a_\left\{n\right\},$

or equivalently

$a_\left\{n+2\right\} = 2 a_\left\{n+1\right\} - a_\left\{n\right\},$

This is a homogeneous recurrence which can be solved by the methods explained above. In general, if a linear recurrence has the form

$a_\left\{n+k\right\} = lambda_\left\{k-1\right\} a_\left\{n+k-1\right\} + lambda_\left\{k-2\right\} a_\left\{n+k-2\right\} + cdots + lambda_1 a_\left\{n+1\right\} + lambda_0 a_\left\{n\right\} + p\left(n\right)$

where $lambda_0, lambda_1, dots, lambda_\left\{k-1\right\}$ are constant coefficients and $p\left(n\right)$ is the inhomogeneity, then if $p\left(n\right)$ is a polynomial with degree $r$, then this inhomogeneous recurrence can be reduced to a homogeneous recurrence by applying the method of symbolic differentiation $r$ times.

### Example

Let's solve the following inhomogeneous recurrence relation using the method of undetermined coefficients:

$a_\left\{n+1\right\} = 2a_n + 3^n + 5n,$

The general solution for the analogous homogeneous relation

$b_\left\{n+1\right\} = 2b_n,$

is

$b_n = c_1 2^n,$

The inhomogeneous part ($3^n + 5n$) leads us to guess the particular solution

$a_n = c_2 3^n + c_3 n + c_4,$

(the guess for $a^x$ is $a^x$, and the guess for a degree-n polynomial is a degree-n polynomial)

Substituting back into the recurrence relation, we get:

$c_2 3^\left\{n+1\right\} + c_3 \left(n+1\right) + c_4 = 2\left(c_2 3^n + c_3 n + c_4\right) + 3^n + 5n,$

Looking only at the coefficients of $3^n$:

$3c_2 = 2c_2 + 1,$

$c_2 = 1,$

Looking only at the coefficients of $n$:

$c_3 = 2c_3 + 5,$

$c_3 = -5,$

Looking only at the coefficients of $1$ (constants):

$c_3 + c_4 = 2c_4,$

$c_4 = c_3 = -5,$

So the general solution is

$a_n = c_1 2^n + 3^n - 5n - 5,$

## Relationship to difference equations

Given a sequence $\left\{a_n\right\},$ of real numbers: the first difference $d\left(a_n\right),$ is defined as

$a_n - a_\left\{n-1\right\},$.

The second difference $d^2\left(a_n\right),$ is defined as

$d\left(a_n\right) - d\left(a_\left\{n-1\right\}\right),$,

which can be simplified to

$a_n - 2a_\left\{n-1\right\} + a_\left\{n-2\right\},$.

More generally: the kth difference $d^k,$ is defined as

$d^\left\{k-1\right\}\left(a_n\right) - d^\left\{k-1\right\}\left(a_\left\{n-1\right\}\right),$.

A difference equation is an equation composed of $a_n,$ and its kth differences.

Every recurrence relation can be formulated as a difference equation. Conversely, every difference equation can be formulated as a recurrence relation. Some authors thus use the two terms interchangeably. For example, the difference equation

$3d^2\left(a_n\right) + 2d\left(a_n\right) + 7a_n = 0,$

is equivalent to the recurrence relation

$12a_n = 8a_\left\{n-1\right\} - 3a_\left\{n-2\right\},$

See time scale calculus for a unification of the theory of difference equations with that of differential equations.

## Relationship to differential equations

When solving an ordinary differential equation numerically, one typically encounters a recurrence relation. For example, when solving the initial value problem

$y\text{'}\left(t\right) = f\left(t,y\left(t\right)\right), y\left(t_0\right)=y_0,$

with Euler's method and a step size h, one calculates the values

$y_0=y\left(t_0\right), y_1=y\left(t_0+h\right), y_2=y\left(t_0+2h\right), dots$

by the recurrence

$, y_\left\{n+1\right\} = y_n + hf\left(t_n,y_n\right).$

Systems of linear first order differential equations can be discretized exactly analytically using the methods shown in the discretization article.

## Application to biology

Some of the best-known difference equations have their origins in the attempt to model population dynamics. For example, the Fibonacci numbers were once used as a model for the growth of a rabbit population.

The logistic map is used either directly to model population growth, or as a starting point for more detailed models. In this context, coupled difference equations are often used to model the interaction of two or more populations. For example, the Nicholson-Bailey model for a host-parasite interaction is given by

$N_\left\{t+1\right\} = lambda N_t e^\left\{-aP_t\right\} ,$
$P_\left\{t+1\right\} = N_t\left(1-e^\left\{-aP_t\right\}\right) ,$,

with $N_t$ representing the hosts, and $P_t$ the parasites, at time $t$.

Integrodifference equations are a form of recurrence relation important to spatial ecology. These and other difference equations are particularly suited to modeling univoltine populations.