# Recurrence relation

Template:Redirect-distinguish In mathematics, a recurrence relation is an equation that recursively defines a sequence or multidimensional array of values, once one or more initial terms are given: each further term of the sequence or array is defined as a function of the preceding terms.

The term difference equation sometimes (and for the purposes of this article) refers to a specific type of recurrence relation. However, "difference equation" is frequently used to refer to any recurrence relation.

## Examples

### Logistic map

An example of a recurrence relation is the logistic map:

${\displaystyle x_{n+1}=rx_{n}(1-x_{n}),}$

with a given constant r; given the initial term x0 each subsequent term is determined by this relation.

Some simply defined recurrence relations can have very complex (chaotic) behaviours, and they are a part of the field of mathematics known as nonlinear analysis.

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

### Fibonacci numbers

The Fibonacci numbers are the archetype of a linear, homogeneous recurrence relation with constant coefficients (see below). They are defined using the linear recurrence relation

${\displaystyle F_{n}=F_{n-1}+F_{n-2}}$

with seed values:

${\displaystyle F_{0}=0}$
${\displaystyle F_{1}=1}$

Explicitly, recurrence yields the equations:

${\displaystyle F_{2}=F_{1}+F_{0}}$
${\displaystyle F_{3}=F_{2}+F_{1}}$
${\displaystyle F_{4}=F_{3}+F_{2}}$

etc.

We obtain the sequence of Fibonacci numbers which begins:

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

It can be solved by methods described below yielding the closed-form expression which involve powers of the two roots of the characteristic polynomial t2 = t + 1; the generating function of the sequence is the rational function

${\displaystyle {\frac {t}{1-t-t^{2}}}.}$

### Binomial coefficients

A simple example of a multidimensional recurrence relation is given by the binomial coefficients ${\displaystyle {\tbinom {n}{i}}}$, which count the number of ways of selecting i out of a set of n elements. They can be computed by the recurrence relation

${\displaystyle {\binom {n}{i}}={\binom {n-1}{i-1}}+{\binom {n-1}{i}},}$

with the base cases ${\displaystyle {\tbinom {n}{0}}={\tbinom {n}{n}}=1}$. Using this formula to compute the values of all binomial coefficients generates an infinite array called Pascal's triangle. The same values can also be computed directly by a different formula that is not a recurrence, but that requires multiplication and not just addition to compute: ${\displaystyle {\binom {n}{i}}={\frac {n!}{i!(n-i)!}}.}$

## Structure

### Linear homogeneous recurrence relations with constant coefficients

An order d linear homogeneous recurrence relation with constant coefficients is an equation of the form

${\displaystyle a_{n}=c_{1}a_{n-1}+c_{2}a_{n-2}+\cdots +c_{d}a_{n-d},}$

where the d coefficients ci (for all i) are constants.

More precisely, this is an infinite list of simultaneous linear equations, one for each n>d−1. A sequence which satisfies a relation of this form is called a linear recurrence sequence or LRS. There are d degrees of freedom for LRS, i.e., the initial values ${\displaystyle a_{0},\dots ,a_{d-1}}$ can be taken to be any values but then the linear recurrence determines the sequence uniquely.

The same coefficients yield the characteristic polynomial (also "auxiliary polynomial")

${\displaystyle p(t)=t^{d}-c_{1}t^{d-1}-c_{2}t^{d-2}-\cdots -c_{d}}$

whose d roots play a crucial role in finding and understanding the sequences satisfying the recurrence. If the roots r1, r2, ... are all distinct, then the solution to the recurrence takes the form

${\displaystyle a_{n}=k_{1}r_{1}^{n}+k_{2}r_{2}^{n}+\cdots +k_{d}r_{d}^{n},}$

where the coefficients ki are determined in order to fit the initial conditions of the recurrence. When the same roots occur multiple times, the terms in this formula corresponding to the second and later occurrences of the same root are multiplied by increasing powers of n. For instance, if the characteristic polynomial can be factored as (xr)3, with the same root r occurring three times, then the solution would take the form

${\displaystyle a_{n}=k_{1}r^{n}+k_{2}nr^{n}+k_{3}n^{2}r^{n}.}$[1]

As well as the Fibonacci numbers, other sequences generated by linear homogeneous recurrences include the Lucas numbers and Lucas sequences, the Jacobsthal numbers, the Pell numbers and more generally the solutions to Pell's equation.

### Rational generating function

Linear recursive sequences are precisely the sequences whose generating function is a rational function: the denominator is the polynomial obtained from the auxiliary polynomial by reversing the order of the coefficients, and the numerator is determined by the initial values of the sequence.

The simplest cases are periodic sequences, ${\displaystyle a_{n}=a_{n-d},n\geq d}$, which have sequence ${\displaystyle a_{0},a_{1},\dots ,a_{d-1},a_{0},\dots }$ and generating function a sum of geometric series:

{\displaystyle {\begin{aligned}{\frac {a_{0}+a_{1}x^{1}+\cdots +a_{d-1}x^{d-1}}{1-x^{d}}}=&\left(a_{0}+a_{1}x^{1}+\cdots +a_{d-1}x^{d-1}\right)+\left(a_{0}+a_{1}x^{1}+\cdots +a_{d-1}x^{d-1}\right)x^{d}+\\&\left(a_{0}+a_{1}x^{1}+\cdots +a_{d-1}x^{d-1}\right)x^{2d}+\cdots .\end{aligned}}}

More generally, given the recurrence relation:

${\displaystyle a_{n}=c_{1}a_{n-1}+c_{2}a_{n-2}+\cdots +c_{d}a_{n-d}}$

with generating function

${\displaystyle a_{0}+a_{1}x^{1}+a_{2}x^{2}+\cdots ,}$

the series is annihilated at ad and above by the polynomial:

${\displaystyle 1-c_{1}x^{1}-c_{2}x^{2}-\cdots -c_{d}x^{d}.}$

That is, multiplying the generating function by the polynomial yields

${\displaystyle b_{n}=a_{n}-c_{1}a_{n-1}-c_{2}a_{n-2}-\cdots -c_{d}a_{n-d}}$

as the coefficient on ${\displaystyle x^{n}}$, which vanishes (by the recurrence relation) for nd. Thus

${\displaystyle \left(a_{0}+a_{1}x^{1}+a_{2}x^{2}+\cdots \right)\left(1-c_{1}x^{1}-c_{2}x^{2}-\cdots -c_{d}x^{d}\right)=\left(b_{0}+b_{1}x^{1}+b_{2}x^{2}+\cdots +b_{d-1}x^{d-1}\right)}$

so dividing yields

${\displaystyle a_{0}+a_{1}x^{1}+a_{2}x^{2}+\cdots ={\frac {b_{0}+b_{1}x^{1}+b_{2}x^{2}+\cdots +b_{d-1}x^{d-1}}{1-c_{1}x^{1}-c_{2}x^{2}-\cdots -c_{d}x^{d}}},}$

expressing the generating function as a rational function.

The denominator is ${\displaystyle x^{d}p\left(x^{-1}\right),}$ a transform of the auxiliary polynomial (equivalently, reversing the order of coefficients); one could also use any multiple of this, but this normalization is chosen both because of the simple relation to the auxiliary polynomial, and so that ${\displaystyle b_{0}=a_{0}}$.

### Relationship to difference equations narrowly defined

Given an ordered sequence ${\displaystyle \left\{a_{n}\right\}_{n=1}^{\infty }}$ of real numbers: the first difference ${\displaystyle \Delta (a_{n})}$ is defined as

${\displaystyle \Delta (a_{n})=a_{n+1}-a_{n}\,}$.

The second difference ${\displaystyle \Delta ^{2}(a_{n})}$ is defined as

${\displaystyle \Delta ^{2}(a_{n})=\Delta (a_{n+1})-\Delta (a_{n})}$,

which can be simplified to

${\displaystyle \Delta ^{2}(a_{n})=a_{n+2}-2a_{n+1}+a_{n}}$.

More generally: the kth difference of the sequence an is written as ${\displaystyle \Delta ^{k}(a_{n})}$ is defined recursively as

${\displaystyle \Delta ^{k}(a_{n})=\Delta ^{k-1}(a_{n+1})-\Delta ^{k-1}(a_{n})=\sum _{t=0}^{k}{\binom {k}{t}}(-1)^{t}a_{n+k-t}}$.

(The sequence and its differences are related by a binomial transform.) The more restrictive definition of difference equation is an equation composed of an and its kth differences. (A widely used broader definition treats "difference equation" as synonymous with "recurrence relation". See for example rational difference equation and matrix difference equation.)

Actually, it is easily seen that ${\displaystyle a_{n+k}={n \choose 0}a_{n}+{n \choose 1}\Delta (a_{n})+\cdots +{n \choose k}\Delta ^{k}(a_{n}).}$ Thus, a difference equation can be defined as an equation that involves an, an-1, an-2 etc. (or equivalenty an, an+1, an+2 etc.)

Since difference equations are a very common form of recurrence, some authors use the two terms interchangeably. For example, the difference equation

${\displaystyle 3\Delta ^{2}(a_{n})+2\Delta (a_{n})+7a_{n}=0}$

is equivalent to the recurrence relation

${\displaystyle 3a_{n+2}=4a_{n+1}-8a_{n}}$

Thus one can solve many recurrence relations by rephrasing them as difference equations, and then solving the difference equation, analogously to how one solves ordinary differential equations. However, the Ackermann numbers are an example of a recurrence relation that do not map to a difference equation, much less points on the solution to a differential equation.

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

Summation equations relate to difference equations as integral equations relate to differential equations.

#### From sequences to grids

Single-variable or one-dimensional recurrence relations are about sequences (i.e. functions defined on one-dimensional grids). Multi-variable or n-dimensional recurrence relations are about n-dimensional grids. Functions defined on n-grids can also be studied with partial difference equations.[2]

## Solving

### General methods

For order 1, the recurrence

${\displaystyle a_{n}=ra_{n-1}}$

has the solution an = rn with a0 = 1 and the most general solution is an = krn with a0 = k. The characteristic polynomial equated to zero (the characteristic equation) is simply t − r = 0.

Solutions to such recurrence relations of higher order are found by systematic means, often using the fact that an = rn is a solution for the recurrence exactly when t = r is a root of the characteristic polynomial. This can be approached directly or using generating functions (formal power series) or matrices.

Consider, for example, a recurrence relation of the form

${\displaystyle a_{n}=Aa_{n-1}+Ba_{n-2}.}$

When does it have a solution of the same general form as an = rn? Substituting this guess (ansatz) in the recurrence relation, we find that

${\displaystyle r^{n}=Ar^{n-1}+Br^{n-2}}$

must be true for all n > 1.

Dividing through by rn−2, we get that all these equations reduce to the same thing:

${\displaystyle r^{2}=Ar+B,}$
${\displaystyle r^{2}-Ar-B=0,}$

which is the characteristic equation of the recurrence relation. Solve for r to obtain the two roots λ1, λ2: these roots are known as the characteristic roots or eigenvalues of the characteristic equation. Different solutions are obtained depending on the nature of the roots: If these roots are distinct, we have the general solution

${\displaystyle a_{n}=C\lambda _{1}^{n}+D\lambda _{2}^{n}}$

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

${\displaystyle a_{n}=C\lambda ^{n}+Dn\lambda ^{n}}$

This is the most general solution; the two constants C and D can be chosen based on two given initial conditions a0 and a1 to produce a specific solution.

In the case of complex eigenvalues (which also gives rise to complex values for the solution parameters C and D), the use of complex numbers can be eliminated by rewriting the solution in trigonometric form. In this case we can write the eigenvalues as ${\displaystyle \lambda _{1},\lambda _{2}=\alpha \pm \beta i.}$ Then it can be shown that

${\displaystyle a_{n}=C\lambda _{1}^{n}+D\lambda _{2}^{n}}$

can be rewritten as[3]:576–585

${\displaystyle a_{n}=2M^{n}\left(E\cos(\theta n)+F\sin(\theta n)\right)=2GM^{n}\cos(\theta n-\delta ),}$

where

${\displaystyle {\begin{array}{lcl}M={\sqrt {\alpha ^{2}+\beta ^{2}}}&\cos(\theta )={\tfrac {\alpha }{M}}&\sin(\theta )={\tfrac {\beta }{M}}\\C,D=E\mp Fi&&\\G={\sqrt {E^{2}+F^{2}}}&\cos(\delta )={\tfrac {E}{G}}&\sin(\delta )={\tfrac {F}{G}}\end{array}}}$

Here E and F (or equivalently, G and δ) are real constants which depend on the initial conditions. Using

${\displaystyle \lambda _{1}+\lambda _{2}=2\alpha =A,}$
${\displaystyle \lambda _{1}\cdot \lambda _{2}=\alpha ^{2}+\beta ^{2}=-B,}$

one may simplify the solution given above as

${\displaystyle a_{n}=(-B)^{\frac {n}{2}}\left(E\cos(\theta n)+F\sin(\theta n)\right),}$

where a1 and a2 are the initial conditions and

{\displaystyle {\begin{aligned}E&={\frac {-Aa_{1}+a_{2}}{B}}\\F&=-i{\frac {A^{2}a_{1}-Aa_{2}+2a_{1}B}{B{\sqrt {A^{2}+4B}}}}\\\theta &=a\cos \left({\frac {A}{2{\sqrt {-B}}}}\right)\end{aligned}}}

In this way there is no need to solve for λ1 and λ2.

In all cases—real distinct eigenvalues, real duplicated eigenvalues, and complex conjugate eigenvalues—the equation is stable (that is, the variable a converges to a fixed value (specifically, zero)); if and only if both eigenvalues are smaller than one in absolute value. In this second-order case, this condition on the eigenvalues can be shown[4] to be equivalent to |A| < 1 − B < 2, which is equivalent to |B| < 1 and |A| < 1 − B.

The equation in the above example was homogeneous, in that there was no constant term. If one starts with the non-homogeneous recurrence

${\displaystyle b_{n}=Ab_{n-1}+Bb_{n-2}+K}$

with constant term K, this can be converted into homogeneous form as follows: The steady state is found by setting bnbn−1bn−2b* to obtain

${\displaystyle b^{*}={\frac {K}{1-A-B}}.}$

Then the non-homogeneous recurrence can be rewritten in homogeneous form as

${\displaystyle [b_{n}-b^{*}]=A[b_{n-1}-b^{*}]+B[b_{n-2}-b^{*}],}$

which can be solved as above.

The stability condition stated above in terms of eigenvalues for the second-order case remains valid for the general nth-order case: the equation is stable if and only if all eigenvalues of the characteristic equation are less than one in absolute value.

### Solving via linear algebra

A linearly recursive sequence y of order n

${\displaystyle y_{n+k}-c_{n-1}y_{n-1+k}-c_{n-2}y_{n-2+k}+\cdots -c_{0}y_{k}=0}$

is identical to

${\displaystyle y_{n}=c_{n-1}y_{n-1}+c_{n-2}y_{n-2}+\cdots +c_{0}y_{0}.}$

Expanded with n-1 identities of kind ${\displaystyle y_{n-k}=y_{n-k},}$ this n-th order equation is translated into a system of n first order linear equations,

${\displaystyle {\vec {y}}_{n}={\begin{bmatrix}y_{n}\\y_{n-1}\\\vdots \\y_{1}\end{bmatrix}}={\begin{bmatrix}-c_{n-1}&-c_{n-2}&\cdots &-c_{0}\\1&0&\cdots &0\\\vdots &\vdots &\ddots &\vdots \\0&0&\cdots &0\end{bmatrix}}{\begin{bmatrix}y_{n-1}\\y_{n-2}\\\vdots \\y_{0}\end{bmatrix}}=C\ {\vec {y}}_{n-1}=C^{n}{\vec {y}}_{0}.}$

Observe that the vector ${\displaystyle {\vec {y}}_{n}}$ can be computed by n applications of the companion matrix, C, to the initial state vector, ${\displaystyle y_{0}}$. Thereby, n-th entry of the sought sequence y, is the top component of ${\displaystyle {\vec {y}}_{n},y_{n}={\vec {y}}_{n}[n]}$.

Eigendecomposition, ${\displaystyle {\vec {y}}_{n}={\vec {C}}^{n}\,{\vec {y}}_{0}=c_{1}\,\lambda _{1}^{n}\,{\vec {e}}_{1}+c_{2}\,\lambda _{2}^{n}\,{\vec {e}}_{2}+\cdots +c_{n}\,\lambda _{n}^{n}\,{\vec {e}}_{n}}$ into eigenvalues, ${\displaystyle \lambda _{1},\lambda _{2},\ldots ,\lambda _{n}}$, and eigenvectors, ${\displaystyle {\vec {e}}_{1},{\vec {e}}_{2},\ldots ,{\vec {e}}_{n}}$, is used to compute ${\displaystyle {\vec {y}}_{n}.}$ Thanks to the crucial fact that system C time-shifts every eigenvector, e, by simply scaling its components λ times,

${\displaystyle C\,{\vec {e}}_{i}=\lambda _{i}{\vec {e}}_{i}=C{\begin{bmatrix}e_{i,n}\\e_{i,n-1}\\\vdots \\e_{i,1}\end{bmatrix}}={\begin{bmatrix}\lambda _{i}\,e_{i,n}\\\lambda _{i}\,e_{i,n-1}\\\vdots \\\lambda _{i}\,e_{i,1}\end{bmatrix}}}$

that is, time-shifted version of eigenvector,e, has components λ times larger, the eighenvector components are powers of λ, ${\displaystyle {\vec {e}}_{i}={\begin{bmatrix}\lambda _{i}^{n-1}&\cdots &\lambda _{i}^{2}&\lambda _{i}&1\end{bmatrix}}^{T},}$ and, thus, recurrent linear homogeneous equation solution is a combination of exponential functions, ${\displaystyle {\vec {y}}_{n}=\sum _{1}^{n}{c_{i}\,\lambda _{i}^{n}\,{\vec {e}}_{i}}}$. The components ${\displaystyle c_{i}}$ can be determined out of initial conditions:

${\displaystyle {\vec {y}}_{0}={\begin{bmatrix}y_{0}\\y_{-1}\\\vdots \\y_{-n+1}\end{bmatrix}}=\sum _{i=1}^{n}{c_{i}\,\lambda _{i}^{0}\,{\vec {e}}_{i}}={\begin{bmatrix}{\vec {e}}_{1}&{\vec {e}}_{2}&\cdots &{\vec {e}}_{n}\end{bmatrix}}\,{\begin{bmatrix}c_{1}\\c_{2}\\\cdots \\c_{n}\end{bmatrix}}=E\,{\begin{bmatrix}c_{1}\\c_{2}\\\cdots \\c_{n}\end{bmatrix}}}$

Solving for coefficients,

${\displaystyle {\begin{bmatrix}c_{1}\\c_{2}\\\cdots \\c_{n}\end{bmatrix}}=E^{-1}{\vec {y}}_{0}={\begin{bmatrix}\lambda _{1}^{n-1}&\lambda _{2}^{n-1}&\cdots &\lambda _{n}^{n-1}\\\vdots &\vdots &\ddots &\vdots \\\lambda _{1}&\lambda _{2}&\cdots &\lambda _{n}\\1&1&\cdots &1\end{bmatrix}}^{-1}\,{\begin{bmatrix}y_{0}\\y_{-1}\\\vdots \\y_{-n+1}\end{bmatrix}}.}$

This also works with arbitrary boundary conditions ${\displaystyle \underbrace {y_{a},y_{b},\ldots } _{\text{n}}}$, not necessary the initial ones,

${\displaystyle {\begin{bmatrix}y_{a}\\y_{b}\\\vdots \end{bmatrix}}={\begin{bmatrix}{\vec {y}}_{a}[n]\\{\vec {y}}_{b}[n]\\\vdots \end{bmatrix}}={\begin{bmatrix}\sum _{i=1}^{n}{c_{i}\,\lambda _{i}^{a}\,{\vec {e}}_{i}[n]}\\\sum _{i=1}^{n}{c_{i}\,\lambda _{i}^{b}\,{\vec {e}}_{i}[n]}\\\vdots \end{bmatrix}}={\begin{bmatrix}\sum _{i=1}^{n}{c_{i}\,\lambda _{i}^{a}\,\lambda _{i}^{n-1}}\\\sum _{i=1}^{n}{c_{i}\,\lambda _{i}^{b}\,\lambda _{i}^{n-1}}\\\vdots \end{bmatrix}}=}$
${\displaystyle ={\begin{bmatrix}\sum {c_{i}\,\lambda _{i}^{a+n-1}}\\\sum {c_{i}\,\lambda _{i}^{b+n-1}}\\\vdots \end{bmatrix}}={\begin{bmatrix}\lambda _{1}^{a+n-1}&\lambda _{2}^{a+n-1}&\cdots &\lambda _{n}^{a+n-1}\\\lambda _{1}^{b+n-1}&\lambda _{2}^{b+n-1}&\cdots &\lambda _{n}^{b+n-1}\\\vdots &\vdots &\ddots &\vdots \end{bmatrix}}\,{\begin{bmatrix}c_{1}\\c_{2}\\\vdots \\c_{n}\end{bmatrix}}.}$

This description is really no different from general method above, however it is more succinct. It also works nicely for situations like

${\displaystyle {\begin{cases}a_{n}=a_{n-1}-b_{n-1}\\b_{n}=2a_{n-1}+b_{n-1}.\end{cases}}}$

where there are several linked recurrences.[5]

### 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(t) be the characteristic polynomial (also "auxiliary polynomial")

${\displaystyle t^{d}-c_{1}t^{d-1}-c_{2}t^{d-2}-\cdots -c_{d}=0\,}$

such that each ci corresponds to each ci in the original recurrence relation (see the general form above). Suppose λ is a root of p(t) having multiplicity r. This is to say that (t−λ)r divides p(t). The following two properties hold:

1. Each of the r sequences ${\displaystyle \lambda ^{n},n\lambda ^{n},n^{2}\lambda ^{n},\dots ,n^{r-1}\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 λ varies over all distinct roots of p(t).

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(t).
2. Find the roots of p(t) counting multiplicity.
3. Write an as a linear combination of all the roots (counting multiplicity as shown in the theorem above) with unknown coefficients bi.
${\displaystyle a_{n}=\left(b_{1}\lambda _{1}^{n}+b_{2}n\lambda _{1}^{n}+b_{3}n^{2}\lambda _{1}^{n}+\cdots +b_{r}n^{r-1}\lambda _{1}^{n}\right)+\cdots +\left(b_{d-q+1}\lambda _{*}^{n}+\cdots +b_{d}n^{q-1}\lambda _{*}^{n}\right)}$
This is the general solution to the original recurrence relation. (q is the multiplicity of λ*)
4. Equate each ${\displaystyle a_{0},a_{1},\dots ,a_{d}}$ from part 3 (plugging in n = 0, ..., d into the general solution of the recurrence relation) with the known values ${\displaystyle a_{0},a_{1},\dots ,a_{d}}$ from the original recurrence relation. However, the values an from the original recurrence relation used do not usually have to be contiguous: excluding exceptional cases, just d of them are needed (i.e., for an original linear homogeneous recurrence relation of order 3 one could use the values a0, a1, a4). This process will produce a linear system of d equations with d unknowns. Solving these equations for the unknown coefficients ${\displaystyle b_{1},b_{2},\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 ${\displaystyle a_{0},a_{1},a_{2},\dots }$ of the original recurrence relation).

The method for solving linear differential equations is similar to the method above—the "intelligent guess" (ansatz) for linear differential equations with constant coefficients is eλx where λ is a complex number that is determined by substituting the guess into the differential equation.

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

${\displaystyle \sum _{n=0}^{\infty }{\frac {f^{(n)}(a)}{n!}}(x-a)^{n}}$

it can be seen that the coefficients of the series are given by the nth 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:

${\displaystyle y^{[k]}\to f[n+k]}$

and more generally

${\displaystyle 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:

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

is given by

${\displaystyle n(n-1)f[n+1]+3nf[n+2]-4f[n+3]-3nf[n+1]-f[n+2]+2f[n]=0}$

or

${\displaystyle -4f[n+3]+2nf[n+2]+n(n-4)f[n+1]+2f[n]=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

${\displaystyle ay''+by'+cy=0}$

has solution

${\displaystyle y=e^{ax}.}$

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

${\displaystyle af[n+2]+bf[n+1]+cf[n]=0.}$

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

### 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:

${\displaystyle a_{n+1}=a_{n}+1}$

This is an inhomogeneous recurrence. If we substitute nn+1, we obtain the recurrence

${\displaystyle a_{n+2}=a_{n+1}+1}$

Subtracting the original recurrence from this equation yields

${\displaystyle a_{n+2}-a_{n+1}=a_{n+1}-a_{n}}$

or equivalently

${\displaystyle a_{n+2}=2a_{n+1}-a_{n}}$

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

${\displaystyle a_{n+k}=\lambda _{k-1}a_{n+k-1}+\lambda _{k-2}a_{n+k-2}+\cdots +\lambda _{1}a_{n+1}+\lambda _{0}a_{n}+p(n)}$

where ${\displaystyle \lambda _{0},\lambda _{1},\dots ,\lambda _{k-1}}$ are constant coefficients and p(n) is the inhomogeneity, then if p(n) is a polynomial with degree r, then this inhomogeneous recurrence can be reduced to a homogeneous recurrence by applying the method of symbolic differencing r times.

If

${\displaystyle P(x)=\sum _{n=0}^{\infty }p_{n}x^{n}}$

is the generating function of the inhomogeneity, the generating function

${\displaystyle A(x)=\sum _{n=0}^{\infty }a(n)x^{n}}$

of the inhomogeneous recurrence

${\displaystyle a_{n}=\sum _{i=1}^{s}c_{i}a_{n-i}+p_{n},\quad n\geq n_{r},}$

with constant coefficients ci is derived from

${\displaystyle \left(1-\sum _{i=1}^{s}c_{i}x^{i}\right)A(x)=P(x)+\sum _{n=0}^{n_{r}-1}[a_{n}-p_{n}]x^{n}-\sum _{i=1}^{s}c_{i}x^{i}\sum _{n=0}^{n_{r}-i-1}a_{n}x^{n}.}$

If P(x) is a rational generating function, A(x) is also one. The case discussed above, where pn = K is a constant, emerges as one example of this formula, with P(x) = K/(1−x). Another example, the recurrence ${\displaystyle a_{n}=10a_{n-1}+n}$ with linear inhomogeneity, arises in the definition of the schizophrenic numbers. The solution of homogeneous recurrences is incorporated as p = P = 0.

Moreover, for the general first-order linear inhomogeneous recurrence relation with variable coefficient(s)

${\displaystyle a_{n+1}=f_{n}a_{n}+g_{n},\qquad f_{n}\neq 0,}$

there is also a nice method to solve it:[6]

${\displaystyle a_{n+1}-f_{n}a_{n}=g_{n}}$
${\displaystyle {\frac {a_{n+1}}{\prod _{k=0}^{n}f_{k}}}-{\frac {f_{n}a_{n}}{\prod _{k=0}^{n}f_{k}}}={\frac {g_{n}}{\prod _{k=0}^{n}f_{k}}}}$
${\displaystyle {\frac {a_{n+1}}{\prod _{k=0}^{n}f_{k}}}-{\frac {a_{n}}{\prod _{k=0}^{n-1}f_{k}}}={\frac {g_{n}}{\prod _{k=0}^{n}f_{k}}}}$

Let

${\displaystyle A_{n}={\frac {a_{n}}{\prod _{k=0}^{n-1}f_{k}}},}$

Then

${\displaystyle A_{n+1}-A_{n}={\frac {g_{n}}{\prod _{k=0}^{n}f_{k}}}}$
${\displaystyle \sum _{m=0}^{n-1}(A_{m+1}-A_{m})=A_{n}-A_{0}=\sum _{m=0}^{n-1}{\frac {g_{m}}{\prod _{k=0}^{m}f_{k}}}}$
${\displaystyle {\frac {a_{n}}{\prod _{k=0}^{n-1}f_{k}}}=A_{0}+\sum _{m=0}^{n-1}{\frac {g_{m}}{\prod _{k=0}^{m}f_{k}}}}$
${\displaystyle a_{n}=\left(\prod _{k=0}^{n-1}f_{k}\right)\left(A_{0}+\sum _{m=0}^{n-1}{\frac {g_{m}}{\prod _{k=0}^{m}f_{k}}}\right)}$

### General linear homogeneous recurrence relations

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

${\displaystyle J_{n+1}={\frac {2n}{z}}J_{n}-J_{n-1}}$

is given by

${\displaystyle J_{n}=J_{n}(z),\,}$

the Bessel function, while

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

is solved by

${\displaystyle M_{n}=M(n,b;z)\,}$

### Solving a first order rational difference equation

{{#invoke:main|main}}

A first order rational difference equation has the form ${\displaystyle w_{t+1}={\tfrac {aw_{t}+b}{cw_{t}+d}}}$. Such an equation can be solved by writing ${\displaystyle w_{t}}$ as a nonlinear transformation of another variable ${\displaystyle x_{t}}$ which itself evolves linearly. Then standard methods can be used to solve the linear difference equation in ${\displaystyle x_{t}}$.

## Stability

### Stability of linear higher-order recurrences

The linear recurrence of order d,

${\displaystyle a_{n}=c_{1}a_{n-1}+c_{2}a_{n-2}+\dots +c_{d}a_{n-d},\,}$

has the characteristic equation

${\displaystyle \lambda ^{d}-c_{1}\lambda ^{d-1}-c_{2}\lambda ^{d-2}-\dots -c_{d}\lambda ^{0}=0.\,}$

The recurrence is stable, meaning that the iterates converge asymptotically to a fixed value, if and only if the eigenvalues (i.e., the roots of the characteristic equation), whether real or complex, are all less than unity in absolute value.

### Stability of linear first-order matrix recurrences

{{#invoke:main|main}}

In the first-order matrix difference equation

${\displaystyle [x_{t}-x^{*}]=A[x_{t-1}-x^{*}]\,}$

with state vector x and transition matrix A, x converges asymptotically to the steady state vector x* if and only if all eigenvalues of the transition matrix A (whether real or complex) have an absolute value which is less than 1.

### Stability of nonlinear first-order recurrences

Consider the nonlinear first-order recurrence

${\displaystyle x_{n}=f(x_{n-1}).}$

This recurrence is locally stable, meaning that it converges to a fixed point x* from points sufficiently close to x*, if the slope of f in the neighborhood of x* is smaller than unity in absolute value: that is,

${\displaystyle |f'(x^{*})|<1.\,}$

A nonlinear recurrence could have multiple fixed points, in which case some fixed points may be locally stable and others locally unstable; for continuous f two adjacent fixed points cannot both be locally stable.

A nonlinear recurrence relation could also have a cycle of period k for k > 1. Such a cycle is stable, meaning that it attracts a set of initial conditions of positive measure, if the composite function

${\displaystyle g(x):=f\circ f\circ \cdot \cdot \cdot \circ f(x)}$

with f appearing k times is locally stable according to the same criterion:

${\displaystyle |g'(x^{*})|<1,}$

where x* is any point on the cycle.

In a chaotic recurrence relation, the variable x stays in a bounded region but never converges to a fixed point or an attracting cycle; any fixed points or cycles of the equation are unstable. See also logistic map, dyadic transformation, and tent map.

## 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

${\displaystyle y'(t)=f(t,y(t)),\ \ y(t_{0})=y_{0},}$

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

${\displaystyle y_{0}=y(t_{0}),\ \ y_{1}=y(t_{0}+h),\ \ y_{2}=y(t_{0}+2h),\ \dots }$

by the recurrence

${\displaystyle \,y_{n+1}=y_{n}+hf(t_{n},y_{n}).}$

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

## Applications

### 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

${\displaystyle N_{t+1}=\lambda N_{t}e^{-aP_{t}}\,}$
${\displaystyle P_{t+1}=N_{t}(1-e^{-aP_{t}}),\,}$

with Nt representing the hosts, and Pt 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.

### Digital signal processing

In digital signal processing, recurrence relations can model feedback in a system, where outputs at one time become inputs for future time. They thus arise in infinite impulse response (IIR) digital filters.

For example, the equation for a "feedforward" IIR comb filter of delay T is:

${\displaystyle y_{t}=(1-\alpha )x_{t}+\alpha y_{t-T}}$

Where ${\displaystyle x_{t}}$ is the input at time t, ${\displaystyle y_{t}}$ is the output at time t, and α controls how much of the delayed signal is fed back into the output. From this we can see that

${\displaystyle y_{t}=(1-\alpha )x_{t}+\alpha ((1-\alpha )x_{t-T}+\alpha y_{t-2T})}$
${\displaystyle y_{t}=(1-\alpha )x_{t}+(\alpha -\alpha ^{2})x_{t-T}+\alpha ^{2}y_{t-2T})}$

etc.

### Economics

Recurrence relations, especially linear recurrence relations, are used extensively in both theoretical and empirical economics.[7] In particular, in macroeconomics one might develop a model of various broad sectors of the economy (the financial sector, the goods sector, the labor market, etc.) in which some agents' actions depend on lagged variables. The model would then be solved for current values of key variables (interest rate, real GDP, etc.) in terms of exogenous variables and lagged endogenous variables. See also time series analysis.

### Computer science

Recurrence relations are also of fundamental importance in analysis of algorithms.[8][9] If an algorithm is designed so that it will break a problem into smaller subproblems (divide and conquer), its running time is described by a recurrence relation.

A simple example is the time an algorithm takes to search an element in an ordered vector with ${\displaystyle n}$ elements, in the worst case.

A naive algorithm will search from left to right, one element at a time. The worst possible scenario is when the required element is the last, so the number of comparisons is ${\displaystyle n}$.

A better algorithm is called binary search. However, it requires a sorted vector. It will first check if the element is at the middle of the vector. If not, then it will check if the middle element is greater or lesser than the sought element. At this point, half of the vector can be discarded, and the algorithm can be run again on the other half. The number of comparisons will be given by

${\displaystyle c_{1}=1}$
${\displaystyle c_{n}=1+c_{n/2}}$

which will be close to ${\displaystyle \log _{2}(n)}$.

## References

1. {{#invoke:citation/CS1|citation |CitationClass=citation }}.
2. Partial difference equations, Sui Sun Cheng, CRC Press, 2003, ISBN 978-0-415-29884-1
3. Chiang, Alpha C., Fundamental Methods of Mathematical Economics, third edition, McGraw-Hill, 1984.
4. Papanicolaou, Vassilis, "On the asymptotic stability of a class of linear difference equations," Mathematics Magazine 69(1), February 1996, 34–43.
5. {{#invoke:citation/CS1|citation |CitationClass=citation }}.
6. http://faculty.pccu.edu.tw/%7Emeng/Math15.pdf
7. Sargent, Thomas J., Dynamic Macroeconomic Theory, Harvard University Press, 1987.
8. Cormen, T. et al, Introduction to Algorithms, MIT Press, 2009
9. R. Sedgewick, F. Flajolet, An Introduction to the Analysis of Algorithms, Addison-Wesley, 2013
• {{#invoke:citation/CS1|citation

|CitationClass=book }}

• {{#invoke:citation/CS1|citation

|CitationClass=book }}

|CitationClass=book }}

|CitationClass=book }}

• {{#invoke:citation/CS1|citation

|CitationClass=book }}

• {{#invoke:citation/CS1|citation

|CitationClass=book }} chapter 7.

• {{#invoke:citation/CS1|citation

|CitationClass=book }} Chapter 9.1: Difference Equations.