 #jsDisabledContent { display:none; } My Account | Register | Help Flag as Inappropriate This article will be permanently flagged as inappropriate and made unaccessible to everyone. Are you certain this article is inappropriate?          Excessive Violence          Sexual Content          Political / Social Email this Article Email Address:

# Difference equations

Article Id: WHEBN0001337720
Reproduction Date:

 Title: Difference equations Author: World Heritage Encyclopedia Language: English Subject: Collection: Publisher: World Heritage Encyclopedia Publication Date:

### Difference equations

"Difference equation" redirects here. It is not to be confused with differential equation.

In mathematics, a recurrence relation is an equation that recursively defines a sequence, once one or more initial terms are given: each further term of the sequence 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.

An example of a recurrence relation is the logistic map:

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

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

$F_n = F_\left\{n-1\right\}+F_\left\{n-2\right\}$

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

$\frac\left\{t\right\}\left\{1-t-t^2\right\}.$

## 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_\left\{n-1\right\} + c_2a_\left\{n-2\right\}+\cdots+c_da_\left\{n-d\right\},$

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 $a_0,\dots,a_\left\{d-1\right\}$ 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\left(t\right)= t^d - c_1t^\left\{d-1\right\} - c_2t^\left\{d-2\right\}-\cdots-c_\left\{d\right\}$

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

$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

$a_n = k_1 r^n + k_2 n r^n + k_3 n^2 r^n.$

### 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_\left\{n-d\right\}, n\geq d$, which have sequence $a_0,a_1,\dots,a_\left\{d-1\right\},a_0,\dots$ and generating function a sum of geometric series:

$\frac\left\{a_0 + a_1 x^1 + \cdots + a_\left\{d-1\right\}x^\left\{d-1\right\}\right\}\left\{1-x^d\right\} = \left\left(a_0 + a_1 x^1 + \cdots + a_\left\{d-1\right\}x^\left\{d-1\right\}\right\right) + \left\left(a_0 + a_1 x^1 + \cdots + a_\left\{d-1\right\}x^\left\{d-1\right\}\right\right)x^d + \left\left(a_0 + a_1 x^1 + \cdots + a_\left\{d-1\right\}x^\left\{d-1\right\}\right\right)x^\left\{2d\right\} + \cdots.$

More generally, given the recurrence relation:

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

with generating function

$a_0 + a_1x^1 + a_2 x^2 + \cdots,$

the series is annihilated at ad 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_\left\{n-1\right\} - c_2 a_\left\{n-2\right\} - \cdots - c_d a_\left\{n-d\right\}$

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

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

so dividing yields

$a_0 + a_1x^1 + a_2 x^2 + \cdots =\frac\left\{b_0 + b_1x^1 + b_2 x^2 + \cdots + b_\left\{d-1\right\} x^\left\{d-1\right\}\right\}\left\{1- c_1x^1 - c_2 x^2 - \cdots - c_dx^d\right\},$

expressing the generating function as a rational function.

The denominator is $x^d p\left\left(x^\left\{-1\right\}\right\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\\left\{a_n\right\\right\}_\left\{n=1\right\}^\infty$ of real numbers: the first difference $\Delta\left(a_n\right)$ is defined as

$\Delta\left(a_n\right) = a_\left\{n+1\right\} - a_n\,$.

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

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

which can be simplified to

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

More generally: the kth difference of the sequence an is written as $\Delta^k\left(a_n\right)$ is defined recursively as

$\Delta^k\left(a_n\right) = \Delta^\left\{k-1\right\}\left(a_\left\{n+1\right\}\right) - \Delta^\left\{k-1\right\}\left(a_n\right)=\sum_\left\{t=0\right\}^k \binom\left\{k\right\}\left\{t\right\} \left(-1\right)^t a_\left\{n+k-t\right\}$.

(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.)

Linear recurrence relations are difference equations, and conversely; since this is a simple and common form of recurrence, some authors use the two terms interchangeably. For example, the difference equation

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

is equivalent to the recurrence relation

$3a_\left\{n+2\right\} = 4a_\left\{n+1\right\} - 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.

## Solving

### General methods

For order 1, the recurrence

$a_\left\{n\right\}=r a_\left\{n-1\right\}$

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

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

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

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

must be true for all n > 1.

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

$r^2=Ar+B,$
$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

$a_n = C\lambda_1^n+D\lambda_2^n$

while if they are identical (when A2 + 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 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 $\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:576–585

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

where

$\begin\left\{array\right\}\left\{lcl\right\}$
 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 = \left(-B\right)^\left\{\frac\left\{n\right\}\left\{2\right\}\right\} \left\left( E \cos\left(\theta n\right) + F \sin\left(\theta n\right)\right\right),$

where a1 and a2 are the initial conditions and

\begin\left\{align\right\}
 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 &=a\cos \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 second-order case, this condition on the eigenvalues can be shown 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

$b_\left\{n\right\}=Ab_\left\{n-1\right\}+Bb_\left\{n-2\right\}+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

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

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

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

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

Given a linearly recursive sequence, let C be the transpose of the companion matrix of its characteristic polynomial, that is

$C=\begin\left\{bmatrix\right\}$

0 & 1 & 0 & \cdots & 0\\ 0 & 0 & 1 & \cdots & 0\\ \vdots & \vdots & \vdots & \ddots & \vdots\\ 0 & 0 & 0 & \cdots & 1\\ -c_0 & -c_1 & -c_2 & \cdots & -c_{d-1} \end{bmatrix}

where

$T_n + c_\left\{d-1\right\}T_\left\{n-1\right\} + c_\left\{d-2\right\}T_\left\{n-2\right\} + \cdots + c_\left\{0\right\}T_\left\{n-d\right\} = 0.$

Observe that

$\begin\left\{bmatrix\right\}a_n\\$

\vdots\\ a_{n+(d-1)}\end{bmatrix} = C^n\begin{bmatrix}a_0\\ \vdots\\ a_{d-1}\end{bmatrix}

Determine an eigenbasis $v_1, \cdots, v_d$ corresponding to eigenvalues $\lambda_1, \cdots, \lambda_d$. Then express the seed (the initial conditions of the LRS) as a linear combination of the eigenbasis vectors:

$\begin\left\{bmatrix\right\}a_0\\ \vdots\\ a_\left\{d-1\right\}\end\left\{bmatrix\right\} = b_1v_1 + \cdots + b_dv_d$

Then it conveniently works out that:

$\begin\left\{bmatrix\right\}a_n\\$

\vdots\\ a_{n+(d-1)}\end{bmatrix} = C^n\begin{bmatrix}a_0\\ \vdots\\ a_{d-1}\end{bmatrix} = C^n \left (b_1v_1 + \cdots + b_dv_d \right ) = \lambda_1^nb_1v_1 + \cdots + \lambda_d^n b_dv_d

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

$a_n=a_\left\{n-1\right\}-b_\left\{n-1\right\}.$
$b_n=2a_\left\{n-1\right\}+b_\left\{n-1\right\}.$

Where there are several linked recurrences .

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

$t^d - c_1t^\left\{d-1\right\} - c_2t^\left\{d-2\right\}-\cdots-c_\left\{d\right\} = 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 $\lambda^n, n\lambda^n, n^2\lambda^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 λ 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.
$a_n = \left \left(b_1\lambda_1^n + b_2n\lambda_1^n + b_3n^2\lambda_1^n+\cdots+b_r n^\left\{r-1\right\}\lambda_1^n \right \right)+\cdots+ \left \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 \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 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 $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_\left\{n=0\right\}^\infin \frac\left\{f^\left\{\left(n\right)\right\}\left(a\right)\right\}\left\{n!\right\} \left(x-a\right)^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:

$y^ \to f\left[n+k\right]$

and more generally

$x^m*y^ \to n\left(n-1\right)\left(n-m+1\right)f\left[n+k-m\right]$

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

$\left(x^2 + 3x -4\right)y^ -\left(3x+1\right)y^ + 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$ + by' +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

### 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 nn+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_n$

or equivalently

$a_\left\{n+2\right\} = 2 a_\left\{n+1\right\} - 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_\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(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\left(x\right) = \sum_\left\{n=0\right\}^\infty p_n x^n$

is the generating function of the inhomogeneity, the generating function

$A\left(x\right) = \sum_\left\{n=0\right\}^\infty a\left(n\right) x^n$

of the inhomogeneous recurrence

$a_n = \sum_\left\{i=1\right\}^s c_i a_\left\{n-i\right\}+p_n,\quad n\ge n_r,$

with constant coefficients ci is derived from

$\left \left(1-\sum_\left\{i=1\right\}^sc_ix^i \right \right)A\left(x\right)=P\left(x\right)+\sum_\left\{n=0\right\}^\left\{n_r-1\right\}\left[a_n-p_n\right]x^n-\sum_\left\{i=1\right\}^s c_ix^i\sum_\left\{n=0\right\}^\left\{n_r-i-1\right\}a_nx^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). 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)

$a_\left\{n+1\right\} = f_n a_n + g_n, \qquad f_n \neq 0,$

there is also a nice method to solve it:

$a_\left\{n+1\right\} - f_n a_n = g_n$
$\frac\left\{a_\left\{n+1\right\}\right\}\left\{\prod_\left\{k=0\right\}^n f_k\right\} - \frac\left\{f_n a_n\right\}\left\{\prod_\left\{k=0\right\}^n f_k\right\} = \frac\left\{g_n\right\}\left\{\prod_\left\{k=0\right\}^n f_k\right\}$
$\frac\left\{a_\left\{n+1\right\}\right\}\left\{\prod_\left\{k=0\right\}^n f_k\right\} - \frac\left\{a_n\right\}\left\{\prod_\left\{k=0\right\}^\left\{n-1\right\} f_k\right\} = \frac\left\{g_n\right\}\left\{\prod_\left\{k=0\right\}^n f_k\right\}$

Let

$A_n = \frac\left\{a_n\right\}\left\{\prod_\left\{k=0\right\}^\left\{n-1\right\} f_k\right\},$

Then

$A_\left\{n+1\right\} - A_n = \frac\left\{g_n\right\}\left\{\prod_\left\{k=0\right\}^n f_k\right\}$
$\sum_\left\{m=0\right\}^\left\{n-1\right\}\left(A_\left\{m+1\right\} - A_m\right) = A_n - A_0 = \sum_\left\{m=0\right\}^\left\{n-1\right\}\frac\left\{g_m\right\}\left\{\prod_\left\{k=0\right\}^m f_k\right\}$
$\frac\left\{a_n\right\}\left\{\prod_\left\{k=0\right\}^\left\{n-1\right\} f_k\right\} = A_0 + \sum_\left\{m=0\right\}^\left\{n-1\right\}\frac\left\{g_m\right\}\left\{\prod_\left\{k=0\right\}^m f_k\right\}$
$a_n = \left\left(\prod_\left\{k=0\right\}^\left\{n-1\right\} f_k \right\right) \left\left(A_0 + \sum_\left\{m=0\right\}^\left\{n-1\right\}\frac\left\{g_m\right\}\left\{\prod_\left\{k=0\right\}^m f_k\right\}\right\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_\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 a first order rational difference equation

A first order rational difference equation has the form $w_\left\{t+1\right\} = \tfrac\left\{aw_t+b\right\}\left\{cw_t+d\right\}$. 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 higher-order recurrences

The linear recurrence of order d,

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

has the characteristic equation

$\lambda^d - c_1 \lambda^\left\{d-1\right\} - c_2 \lambda^\left\{d-2\right\} - \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

In the first-order matrix difference equation

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

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

$x_n=f\left(x_\left\{n-1\right\}\right).$

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\text{'} \left(x^*\right) | < 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

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

$| g\text{'} \left(x^*\right) | < 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\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.

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

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

$y_t = \left(1 - \alpha\right) x_t + \alpha y_\left\{t - T\right\}$

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 = \left(1 - \alpha\right) x_t + \alpha \left(\left(1-\alpha\right) x_\left\{t-T\right\} + \alpha y_\left\{t - 2T\right\}\right)$
$y_t = \left(1 - \alpha\right) x_t + \left(\alpha-\alpha^2\right) x_\left\{t-T\right\} + \alpha^2 y_\left\{t - 2T\right\}$

etc.

### Economics

Recurrence relations, especially linear recurrence relations, are used extensively in both theoretical and empirical economics. 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. If an algorithm is designed so that it will break a problem into smaller subproblems, 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 $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. It will first check is 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 seeked 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_\left\{n/2\right\}$

which will be close to $\log_2\left(n\right)$.