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:

x_{n+1} = r x_n (1  x_n),
with a given constant r; given the initial term x_{0} 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 closedform solution: a nonrecursive 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

F_n = F_{n1}+F_{n2}
with seed values:

F_0 = 0

F_1 = 1
Explicitly, recurrence yields the equations:

F_2 = F_1 + F_0

F_3 = F_2 + F_1

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 closedform expression, which involves powers of the two roots of the characteristic polynomial t^{2} = t + 1; the generating function of the sequence is the rational function

\frac{t}{1tt^2}.
Binomial coefficients
A simple example of a multidimensional recurrence relation is given by the binomial coefficients \tbinom{n}{k}, which count the number of ways of selecting k out of a set of n elements. They can be computed by the recurrence relation

\binom{n}{k}=\binom{n1}{k1}+\binom{n1}{k},
with the base cases \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: \binom{n}{k}=\frac{n!}{k!(nk)!}.
Structure
Linear homogeneous recurrence relations with constant coefficients
An order d linear homogeneous recurrence relation with constant coefficients is an equation of the form

a_n = c_1a_{n1} + c_2a_{n2}+\cdots+c_da_{nd},
where the d coefficients c_{i} (for all i) are constants.
More precisely, this is an infinite list of simultaneous linear equations, one for each n>d−1. A sequence that 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 a_0,\dots,a_{d1} 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")

p(t)= t^d  c_1t^{d1}  c_2t^{d2}\cdotsc_{d}
whose d roots play a crucial role in finding and understanding the sequences satisfying the recurrence. If the roots r_{1}, r_{2}, ... are all distinct, then the solution to the recurrence takes the form

a_n = k_1 r_1^n + k_2 r_2^n + \cdots + k_d r_d^n,
where the coefficients k_{i} 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 (x−r)^{3}, with the same root r occurring three times, then the solution would take the form

a_n = k_1 r^n + k_2 n r^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, a_n = a_{nd}, n\geq d, which have sequence a_0,a_1,\dots,a_{d1},a_0,\dots and generating function a sum of geometric series:

\begin{align}\frac{a_0 + a_1 x^1 + \cdots + a_{d1}x^{d1}}{1x^d} =& \left(a_0 + a_1 x^1 + \cdots + a_{d1}x^{d1}\right) + \left(a_0 + a_1 x^1 + \cdots + a_{d1}x^{d1}\right)x^d + \\& \left(a_0 + a_1 x^1 + \cdots + a_{d1}x^{d1}\right)x^{2d} + \cdots.\end{align}
More generally, given the recurrence relation:

a_n = c_1a_{n1} + c_2a_{n2}+\cdots+c_da_{nd}
with generating function

a_0 + a_1x^1 + a_2 x^2 + \cdots,
the series is annihilated at a_{d} and above by the polynomial:

1 c_1x^1  c_2 x^2  \cdots  c_dx^d.
That is, multiplying the generating function by the polynomial yields

b_n = a_n  c_1 a_{n1}  c_2 a_{n2}  \cdots  c_d a_{nd}
as the coefficient on x^n, which vanishes (by the recurrence relation) for n ≥ d. Thus

\left (a_0 + a_1x^1 + a_2 x^2 + \cdots \right ) \left (1 c_1x^1  c_2 x^2  \cdots  c_dx^d \right) = \left (b_0 + b_1x^1 + b_2 x^2 + \cdots + b_{d1} x^{d1} \right )
so dividing yields

a_0 + a_1x^1 + a_2 x^2 + \cdots =\frac{b_0 + b_1x^1 + b_2 x^2 + \cdots + b_{d1} x^{d1}}{1 c_1x^1  c_2 x^2  \cdots  c_dx^d},
expressing the generating function as a rational function.
The denominator is 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 b_0 = a_0.
Relationship to difference equations narrowly defined
Given an ordered sequence \left\{a_n\right\}_{n=1}^\infty of real numbers: the first difference \Delta(a_n) is defined as

\Delta(a_n) = a_{n+1}  a_n\,.
The second difference \Delta^2(a_n) is defined as

\Delta^2(a_n) = \Delta(a_{n+1})  \Delta(a_n),
which can be simplified to

\Delta^2(a_n) = a_{n+2}  2a_{n+1} + a_n.
More generally: the k^{th} difference of the sequence a_{n} is written as \Delta^k(a_n) is defined recursively as

\Delta^k(a_n) = \Delta^{k1}(a_{n+1})  \Delta^{k1}(a_n)=\sum_{t=0}^k \binom{k}{t} (1)^t a_{n+kt}.
(The sequence and its differences are related by a binomial transform.) The more restrictive definition of difference equation is an equation composed of a_{n} and its k^{th} 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 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 a_{n}, a_{n1}, a_{n2} etc. (or equivalenty a_{n}, a_{n+1}, a_{n+2} etc.)
Since difference equations are a very common form of recurrence, some authors use the two terms interchangeably. For example, the difference equation

3\Delta^2(a_n) + 2\Delta(a_n) + 7a_n = 0
is equivalent to the recurrence relation

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
Singlevariable or onedimensional recurrence relations are about sequences (i.e. functions defined on onedimensional grids). Multivariable or ndimensional recurrence relations are about ndimensional grids. Functions defined on ngrids can also be studied with partial difference equations.^{[2]}
Solving
General methods
For order 1, the recurrence

a_{n}=r a_{n1}
has the solution a_{n} = r^{n} with a_{0} = 1 and the most general solution is a_{n} = kr^{n} with a_{0} = 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 a_{n} = r^{n} 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

a_{n}=Aa_{n1}+Ba_{n2}.
When does it have a solution of the same general form as a_{n} = r^{n}? Substituting this guess (ansatz) in the recurrence relation, we find that

r^{n}=Ar^{n1}+Br^{n2}
must be true for all n > 1.
Dividing through by r^{n−2}, we get that all these equations reduce to the same thing:

r^2=Ar+B,

r^2ArB=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

a_n = C\lambda_1^n+D\lambda_2^n
while if they are identical (when A^{2} + 4B = 0), we have

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 a_{0} and a_{1} 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 \lambda_1, \lambda_2 = \alpha \pm \beta i. Then it can be shown that

a_n = C\lambda_1^n+D\lambda_2^n
can be rewritten as^{[3]}^{:576–585}

a_n = 2 M^n \left( E \cos(\theta n) + F \sin(\theta n)\right) = 2 G M^n \cos(\theta n  \delta),
where

\begin{array}{lcl} M = \sqrt{\alpha^2+\beta^2} & \cos (\theta) =\tfrac{\alpha}{M} & \sin( \theta) = \tfrac{\beta}{M} \\ C,D = E \mp F i & & \\ 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

\lambda_1+\lambda_2=2 \alpha = A,

\lambda_1 \cdot \lambda_2=\alpha^2+\beta^2=B,
one may simplify the solution given above as

a_n = (B)^{\frac{n}{2}} \left( E \cos(\theta n) + F \sin(\theta n)\right),
where a_{1} and a_{2} are the initial conditions and

\begin{align} E &=\frac{A a_1 + a_2}{B} \\ F &=i \frac{A^2 a_1  A a_2 +2 a_1 B}{B \sqrt{A^2+4B}} \\ \theta &=\arccos \left (\frac{A}{2 \sqrt{B}} \right ) \end{align}
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 secondorder 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 nonhomogeneous recurrence

b_{n}=Ab_{n1}+Bb_{n2}+K
with constant term K, this can be converted into homogeneous form as follows: The steady state is found by setting b_{n} = b_{n−1} = b_{n−2} = b* to obtain

b^{*} = \frac{K}{1AB}.
Then the nonhomogeneous recurrence can be rewritten in homogeneous form as

[b_n  b^*]=A[b_{n1}b^*]+B[b_{n2}b^*],
which can be solved as above.
The stability condition stated above in terms of eigenvalues for the secondorder case remains valid for the general n^{th}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

y_{n+k}  c_{n1}y_{n1+k}  c_{n2}y_{n2+k} + \cdots  c_{0}y_{k} = 0
is identical to

y_{n} = c_{n1}y_{n1} + c_{n2}y_{n2} + \cdots +c_{0}y_{0}.
Expanded with n1 identities of kind y_{nk} = y_{nk}, this nth order equation is translated into a system of n first order linear equations,

\vec y_{n} = \begin{bmatrix}y_n\\y_{n1}\\ \vdots \\ \vdots \\ y_1 \end{bmatrix} = \begin{bmatrix} c_{n1} & c_{n2} & \cdots & \cdots & c_{0} \\ 1 & 0 & \cdots & \cdots & 0 \\ 0 & \ddots & \ddots & &\vdots \\ \vdots & \ddots & \ddots & \ddots &\vdots \\ 0 & \cdots & 0 & 1 & 0 \end{bmatrix} \begin{bmatrix}y_{n1} \\y_{n2} \\ \vdots \\ \vdots \\ y_0 \end{bmatrix} = C\ \vec y_{n1} = C^n \vec y_0.
Observe that the vector \vec y_n can be computed by n applications of the companion matrix, C, to the initial state vector, y_0. Thereby, nth entry of the sought sequence y, is the top component of \vec y_n, y_n = \vec y_n[n].
Eigendecomposition, \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, \lambda_1, \lambda_2, \ldots, \lambda_n, and eigenvectors, \vec e_1, \vec e_2, \ldots, \vec e_n, is used to compute \vec y_n. Thanks to the crucial fact that system C timeshifts every eigenvector, e, by simply scaling its components λ times,

C\,\vec e_i = \lambda_i \vec e_i = C \begin{bmatrix}e_{i,n} \\e_{i,n1} \\ \vdots \\ e_{i,1}\end{bmatrix} = \begin{bmatrix}\lambda_i\,e_{i,n} \\ \lambda_i\,e_{i,n1} \\ \vdots \\ \lambda_i\,e_{i,1}\end{bmatrix}
that is, timeshifted version of eigenvector,e, has components λ times larger, the eigenvector components are powers of λ, \vec e_i = \begin{bmatrix}\lambda_i^{n1} & \cdots & \lambda_i^2 & \lambda_i & 1\end{bmatrix}^T, and, thus, recurrent linear homogeneous equation solution is a combination of exponential functions, \vec y_n = \sum_1^n {c_i\,\lambda_i^n\,\vec e_i}. The components c_i can be determined out of initial conditions:

\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,

\begin{bmatrix}c_1 \\ c_2 \\ \cdots \\ c_n\end{bmatrix} = E^{1} \vec y_0 = \begin{bmatrix}\lambda_1^{n1} & \lambda_2^{n1} & \cdots & \lambda_n^{n1} \\ \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 \underbrace{y_a, y_b, \ldots}_\text{n}, not necessary the initial ones,

\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^{n1}} \\ \sum_{i=1}^n {c_i\,\lambda_i^b\,\lambda_i^{n1}} \\ \vdots\end{bmatrix} =

= \begin{bmatrix}\sum {c_i\,\lambda_i^{a+n1}} \\ \sum {c_i\,\lambda_i^{b+n1}} \\ \vdots\end{bmatrix} = \begin{bmatrix}\lambda_1^{a+n1} & \lambda_2^{a+n1} & \cdots & \lambda_n^{a+n1} \\ \lambda_1^{b+n1} & \lambda_2^{b+n1} & \cdots & \lambda_n^{b+n1} \\ \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

\begin{cases} a_n =a_{n1}b_{n1}\\ b_n =2a_{n1}+b_{n1}. \end{cases}
where there are several linked recurrences.^{[5]}
Solving with ztransforms
Certain difference equations  in particular, linear constant coefficient difference equations  can be solved using ztransforms. The ztransforms 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")

t^d  c_1t^{d1}  c_2t^{d2}\cdotsc_{d} = 0 \,
such that each c_{i} corresponds to each c_{i} 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:

Each of the r sequences \lambda^n, n\lambda^n, n^2\lambda^n,\dots,n^{r1}\lambda^n satisfies the recurrence relation.

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:

Find the characteristic polynomial p(t).

Find the roots of p(t) counting multiplicity.

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_1\lambda_1^n + b_2n\lambda_1^n + b_3n^2\lambda_1^n+\cdots+b_r n^{r1}\lambda_1^n \right )+\cdots+ \left (b_{dq+1}\lambda_{*}^n + \cdots + b_{d}n^{q1}\lambda_{*}^n \right )

This is the general solution to the original recurrence relation. (q is the multiplicity of λ_{*})

4. Equate each 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 a_0, a_1, \dots,a_d from the original recurrence relation. However, the values a_{n} 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 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, \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,\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:

\sum_{n=0}^\infin \frac{f^{(n)}(a)}{n!} (xa)^n
it can be seen 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 nonzero at zero) is that:

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

x^m*y^ \to n(n1)(nm+1)f[n+km]
Example: The recurrence relationship for the Taylor series coefficients of the equation:

(x^2 + 3x 4)y^ (3x+1)y^ + 2y = 0
is given by

n(n1)f[n+1] + 3nf[n+2] 4f[n+3] 3nf[n+1] f[n+2]+ 2f[n] = 0
or

4f[n+3] +2nf[n+2] + n(n4)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

ay'' + by' +cy = 0
has solution

y=e^{ax}.
The conversion of the differential equation to a difference equation of the Taylor coefficients is

af[n + 2] + bf[n + 1] + cf[n] = 0.
It is easy to see that the nth derivative of e^{ax} evaluated at 0 is a^{n}
Solving nonhomogeneous 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_{n+1} = a_{n} + 1
This is an inhomogeneous recurrence. If we substitute n ↦ n+1, we obtain the recurrence

a_{n+2} = a_{n+1} + 1
Subtracting the original recurrence from this equation yields

a_{n+2}  a_{n+1} = a_{n+1}  a_n
or equivalently

a_{n+2} = 2 a_{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

a_{n+k} = \lambda_{k1} a_{n+k1} + \lambda_{k2} a_{n+k2} + \cdots + \lambda_1 a_{n+1} + \lambda_0 a_{n} + p(n)
where \lambda_0, \lambda_1, \dots, \lambda_{k1} 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

P(x) = \sum_{n=0}^\infty p_n x^n
is the generating function of the inhomogeneity, the generating function

A(x) = \sum_{n=0}^\infty a(n) x^n
of the inhomogeneous recurrence

a_n = \sum_{i=1}^s c_i a_{ni}+p_n,\quad n\ge n_r,
with constant coefficients c_{i} is derived from

\left (1\sum_{i=1}^sc_ix^i \right )A(x)=P(x)+\sum_{n=0}^{n_r1}[a_np_n]x^n\sum_{i=1}^s c_ix^i\sum_{n=0}^{n_ri1}a_nx^n.
If P(x) is a rational generating function, A(x) is also one. The case discussed above, where p_{n} = K is a constant, emerges as one example of this formula, with P(x) = K/(1−x). Another example, the recurrence a_n=10 a_{n1}+n with linear inhomogeneity, arises in the definition of the schizophrenic numbers. The solution of homogeneous recurrences is incorporated as p = P = 0.
Solving nonhomogeneous recurrence relations with variable coefficients
Moreover, for the general firstorder linear inhomogeneous recurrence relation with variable coefficients:

a_{n+1} = f_n a_n + g_n, \qquad f_n \neq 0,
there is also a nice method to solve it:^{[6]}

a_{n+1}  f_n a_n = g_n

\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}

\frac{a_{n+1}}{\prod_{k=0}^n f_k}  \frac{a_n}{\prod_{k=0}^{n1} f_k} = \frac{g_n}{\prod_{k=0}^n f_k}
Let

A_n = \frac{a_n}{\prod_{k=0}^{n1} f_k},
Then

A_{n+1}  A_n = \frac{g_n}{\prod_{k=0}^n f_k}

\sum_{m=0}^{n1}(A_{m+1}  A_m) = A_n  A_0 = \sum_{m=0}^{n1}\frac{g_m}{\prod_{k=0}^m f_k}

\frac{a_n}{\prod_{k=0}^{n1} f_k} = A_0 + \sum_{m=0}^{n1}\frac{g_m}{\prod_{k=0}^m f_k}

a_n = \left(\prod_{k=0}^{n1} f_k \right) \left(A_0 + \sum_{m=0}^{n1}\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

J_{n+1}=\frac{2n}{z}J_nJ_{n1}
is given by

J_n=J_n(z), \,
the Bessel function, while

(bn)M_{n1} +(2nbz)M_n  nM_{n+1}=0 \,
is solved by

M_n=M(n,b;z) \,
the confluent hypergeometric series.
Solving a first order rational difference equation
A first order rational difference equation has the form w_{t+1} = \tfrac{aw_t+b}{cw_t+d}. Such an equation can be solved by writing w_t as a nonlinear transformation of another variable x_t which itself evolves linearly. Then standard methods can be used to solve the linear difference equation in x_t.
Stability
Stability of linear higherorder recurrences
The linear recurrence of order d,

a_n = c_1a_{n1} + c_2a_{n2}+\dots+c_da_{nd}, \,
has the characteristic equation

\lambda^d  c_1 \lambda^{d1}  c_2 \lambda^{d2}  \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 firstorder matrix recurrences
In the firstorder matrix difference equation

[x_t  x^*] = A[x_{t1}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 firstorder recurrences
Consider the nonlinear firstorder recurrence

x_n=f(x_{n1}).
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,

 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

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:

 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

y'(t) = f(t,y(t)), \ \ y(t_0)=y_0,
with Euler's method and a step size h, one calculates the values

y_0=y(t_0), \ \ y_1=y(t_0+h), \ \ y_2=y(t_0+2h), \ \dots
by the recurrence

\, 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 bestknown 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 NicholsonBailey model for a hostparasite interaction is given by

N_{t+1} = \lambda N_t e^{aP_t} \,

P_{t+1} = N_t(1e^{aP_t}), \,
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.
Computer science
Recurrence relations are also of fundamental importance in analysis of algorithms.^{[7]}^{[8]} 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 find an element in an ordered vector with 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 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

c_1=1

c_n=1+c_{n/2}
which will be close to \log_2(n).
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:

y_t = (1  \alpha) x_t + \alpha y_{t  T}
Where x_t is the input at time t, 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

y_t = (1  \alpha) x_t + \alpha ((1\alpha) x_{tT} + \alpha y_{t  2T})

y_t = (1  \alpha) x_t + (\alpha\alpha^2) x_{tT} + \alpha^2 y_{t  2T})
etc.
Economics
Recurrence relations, especially linear recurrence relations, are used extensively in both theoretical and empirical economics.^{[9]} 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.
See also
Notes

^ .

^ Partial difference equations, Sui Sun Cheng, CRC Press, 2003, ISBN 9780415298841

^ Chiang, Alpha C., Fundamental Methods of Mathematical Economics, third edition, McGrawHill, 1984.

^ Papanicolaou, Vassilis, "On the asymptotic stability of a class of linear difference equations," Mathematics Magazine 69(1), February 1996, 34–43.

^ .

^ http://faculty.pccu.edu.tw/%7Emeng/Math15.pdf

^ Cormen, T. et al, Introduction to Algorithms, MIT Press, 2009

^ R. Sedgewick, F. Flajolet, An Introduction to the Analysis of Algorithms, AddisonWesley, 2013

^ Sargent, Thomas J., Dynamic Macroeconomic Theory, Harvard University Press, 1987.
References
External links


Weisstein, Eric W., "Recurrence Equation", MathWorld.


Introductory Discrete Mathematics

OEIS index to a few thousand examples of linear recurrences, sorted by order (number of terms) and signature (vector of values of the constant coefficients)
This article was sourced from Creative Commons AttributionShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, EGovernment Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a nonprofit organization.