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.

Definition

A ''recurrence relation'' is an equation that expresses each element of a sequence as a function of the preceding ones. More precisely, in the case where only the immediately preceding element is involved, a recurrence relation has the form :$u\_n=\backslash varphi(n,\; u\_)\backslash quad\backslash text\backslash quad\; n>0,$ where :$\backslash varphi:\backslash mathbb\; N\backslash times\; X\; \backslash to\; X$ is a function, where is a set to which the elements of a sequence must belong. For any $u\_0\backslash in\; X$, this defines a unique sequence with $u\_0$ as its first element, called the ''initial value''. It is easy to modify the definition for getting sequences starting from the term of index 1 or higher. This defines recurrence relation of ''first order''. A recurrence relation of ''order'' has the form :$u\_n=\backslash varphi(n,\; u\_,\; u\_,\; \backslash ldots,\; u\_)\backslash quad\backslash text\backslash quad\; n\backslash ge\; k,$ where $\backslash varphi:\; \backslash mathbb\; N\backslash times\; X^k\; \backslash to\; X$ is a function that involves consecutive elements of the sequence. In this case, initial values are needed for defining a sequence.

Examples

Factorial

The factorial is defined by the recurrence relation :$n!=n(n-1)!\backslash quad\backslash text\backslash quad\; n>0,$ and the initial condition :$0!=1.$

Logistic map

An example of a recurrence relation is the logistic map: :$x\_\; =\; 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.
Solving a recurrence relation means obtaining a closed-form solution: a non-recursive function of ''n''.

Fibonacci numbers

The recurrence of order two satisfied by the Fibonacci numbers is the archetype of a homogeneous linear recurrence relation with constant coefficients (see below). The Fibonacci sequence is defined using the recurrence :$F\_n\; =\; F\_+F\_$ with initial conditions (seed values) :$F\_0\; =\; 0$ :$F\_1\; =\; 1.$ Explicitly, the 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, ... The recurrence can be solved by methods described below yielding Binet's formula, 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
: $\backslash frac.$

Binomial coefficients

A simple example of a multidimensional recurrence relation is given by the binomial coefficients $\backslash tbinom$, which count the number of ways of selecting ''k'' elements out of a set of ''n'' elements. They can be computed by the recurrence relation :$\backslash binom=\backslash binom+\backslash binom,$ with the base cases $\backslash tbinom=\backslash tbinom=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: $\backslash binom=\backslash frac.$

** Relationship to difference equations narrowly defined **

Given an ordered sequence $\backslash left\backslash \_^\backslash infty$ of real numbers: the first difference $\backslash Delta(a\_n)$ is defined as
:$\backslash Delta(a\_n)\; =\; a\_\; -\; a\_n.$
The second difference $\backslash Delta^2(a\_n)$ is defined as
:$\backslash Delta^2(a\_n)\; =\; \backslash Delta(a\_)\; -\; \backslash Delta(a\_n),$
which can be simplified to
:$\backslash Delta^2(a\_n)\; =\; a\_\; -\; 2a\_\; +\; a\_n.$
More generally: the ''k''-th difference of the sequence ''a_{n}'' written as $\backslash Delta^k(a\_n)$ is defined recursively as
:$\backslash Delta^k(a\_n)\; =\; \backslash Delta^(a\_)\; -\; \backslash Delta^(a\_n)=\backslash sum\_^k\; \backslash binom\; (-1)^t\; a\_.$
(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\_\; =\; a\_n\; +\; \backslash Delta(a\_n)\; +\; \backslash cdots\; +\; \backslash Delta^k(a\_n).$
Thus, a difference equation can be defined as an equation that involves
''a''_{''n''}, ''a''_{''n''−1}, ''a''_{''n''−2} etc. (or equivalently
''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\backslash Delta^2(a\_n)\; +\; 2\backslash Delta(a\_n)\; +\; 7a\_n\; =\; 0$
is equivalent to the recurrence relation
:$3a\_\; =\; 4a\_\; -\; 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 **

** Solving homogeneous linear recurrence relations with constant coefficients **

Roots of the characteristic polynomial

An order-''d'' homogeneous linear recurrence with constant coefficients is an equation of the form :$a\_n\; =\; c\_1a\_\; +\; c\_2a\_+\backslash cdots+c\_da\_,$ where the ''d'' coefficients ''c_{i}'' (for all ''i'') are constants, and $c\_d\backslash ne0$.
A constant-recursive sequence is a sequence satisfying a recurrence of this form. There are ''d'' degrees of freedom for solutions to this recurrence, i.e., the initial values $a\_0,\backslash dots,a\_$ can be taken to be any values but then the recurrence determines the sequence uniquely.
The same coefficients yield the characteristic polynomial (also "auxiliary polynomial")
:$p(t)=\; t^d\; -\; c\_1t^\; -\; c\_2t^-\backslash cdots-c\_$
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 each solution to the recurrence takes the form
:$a\_n\; =\; k\_1\; r\_1^n\; +\; k\_2\; r\_2^n\; +\; \backslash 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.$
As well as the Fibonacci numbers, other constant-recursive sequences include the Lucas numbers and Lucas sequences, the Jacobsthal numbers, the Pell numbers and more generally the solutions to Pell's equation.
For order 1, the recurrence
:$a\_=r\; a\_$
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\_=Aa\_+Ba\_.$
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^=Ar^+Br^$
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^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\backslash lambda\_1^n+D\backslash lambda\_2^n$
while if they are identical (when ), we have
:$a\_n\; =\; C\backslash lambda^n+Dn\backslash 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 $\backslash lambda\_1,\; \backslash lambda\_2\; =\; \backslash alpha\; \backslash pm\; \backslash beta\; i.$ Then it can be shown that
:$a\_n\; =\; C\backslash lambda\_1^n+D\backslash lambda\_2^n$
can be rewritten as
:$a\_n\; =\; 2\; M^n\; \backslash left(\; E\; \backslash cos(\backslash theta\; n)\; +\; F\; \backslash sin(\backslash theta\; n)\backslash right)\; =\; 2\; G\; M^n\; \backslash cos(\backslash theta\; n\; -\; \backslash delta),$
where
:$\backslash begin\; M\; =\; \backslash sqrt\; \&\; \backslash cos\; (\backslash theta)\; =\backslash tfrac\; \&\; \backslash sin(\; \backslash theta)\; =\; \backslash tfrac\; \backslash \backslash \; C,D\; =\; E\; \backslash mp\; F\; i\; \&\; \&\; \backslash \backslash \; G\; =\; \backslash sqrt\; \&\; \backslash cos\; (\backslash delta\; )\; =\; \backslash tfrac\; \&\; \backslash sin\; (\backslash delta\; )=\; \backslash tfrac\; \backslash end$
Here ''E'' and ''F'' (or equivalently, ''G'' and δ) are real constants which depend on the initial conditions. Using
:$\backslash lambda\_1+\backslash lambda\_2=2\; \backslash alpha\; =\; A,$
:$\backslash lambda\_1\; \backslash cdot\; \backslash lambda\_2=\backslash alpha^2+\backslash beta^2=-B,$
one may simplify the solution given above as
:$a\_n\; =\; (-B)^\; \backslash left(\; E\; \backslash cos(\backslash theta\; n)\; +\; F\; \backslash sin(\backslash theta\; n)\backslash right),$
where ''a''_{1} and ''a''_{2} are the initial conditions and
:$\backslash begin\; E\; \&=\backslash frac\; \backslash \backslash \; F\; \&=-i\; \backslash frac\; \backslash \backslash \; \backslash theta\; \&=\backslash arccos\; \backslash left\; (\backslash frac\; \backslash right\; )\; \backslash end$
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 pecifically, 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\_=Ab\_+Bb\_+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^\; =\; \backslash frac.$
Then the non-homogeneous recurrence can be rewritten in homogeneous form as
:$\_n\; -\; b^*A\_-b^*B\_-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 ''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.
Given a homogeneous linear recurrence relation with constant coefficients of order ''d'', let ''p''(''t'') be the characteristic polynomial (also "auxiliary polynomial")
:$t^d\; -\; c\_1t^\; -\; c\_2t^\; -\; \backslash cdots\; -\; c\_\; =\; 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 $\backslash lambda^n,\; n\backslash lambda^n,\; n^2\backslash lambda^n,\backslash dots,n^\backslash 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 homogeneous linear 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\; =\; \backslash left\; (b\_1\backslash lambda\_1^n\; +\; b\_2n\backslash lambda\_1^n\; +\; b\_3n^2\backslash lambda\_1^n+\backslash cdots+b\_r\; n^\backslash lambda\_1^n\; \backslash right\; )+\backslash cdots+\; \backslash left\; (b\_\backslash lambda\_^n\; +\; \backslash cdots\; +\; b\_n^\backslash lambda\_^n\; \backslash right\; )$
#:This is the general solution to the original recurrence relation. (''q'' is the multiplicity of λ_{*})
# Equate each $a\_0,\; a\_1,\; \backslash 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,\; \backslash 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 homogeneous linear 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,\; \backslash 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,\backslash 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:
:$\backslash sum\_^\backslash infin\; \backslash frac\; (x-a)^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 non-zero at zero) is that:
:$y^\; \backslash to\; f+k/math>\; and\; more\; generally\; :$ x^m*y^\; \backslash to\; n(n-1)...(n-m+1)f+k-m/math>\; 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(n-1)f+1+\; 3nf+2-4f+3-3nf+1-f+22f=\; 0$or\; :$ -4f+3+2nf+2+\; n(n-4)f+1+2f=\; 0.$This\; example\; shows\; how\; problems\; generally\; solved\; using\; the\; power\; series\; solution\; method\; taught\; in\; normal\; differential\; equation\; classes\; can\; be\; solved\; in\; a\; much\; easier\; way.\; Example:\; The\; differential\; equation\; :$ ay\text{'}\text{'}\; +\; by\text{'}\; +cy\; =\; 0$has\; solution\; :$ y=e^.$The\; conversion\; of\; the\; differential\; equation\; to\; a\; difference\; equation\; of\; the\; Taylor\; coefficients\; is\; :$ af+\; 2+\; bf+\; 1+\; cf=\; 0.$It\; is\; easy\; to\; see\; that\; the\; \text{'}\text{'}n\text{'}\text{'}th\; derivative\; of\; \text{'}\text{'}e\text{'}\text{'}\text{'}\text{'}ax\text{'}\text{'}evaluated\; at\; 0\; is\; \text{'}\text{'}a\text{'}\text{'}\text{'}\text{'}n\text{'}\text{'}.$$

Solving via linear algebra

A linearly recursive sequence y of order n :$y\_\; -\; c\_y\_\; -\; c\_y\_\; +\; \backslash cdots\; -\; c\_0\; y\_k\; =\; 0$ is identical to :$y\_n\; =\; c\_y\_\; +\; c\_y\_\; +\; \backslash cdots\; +c\_0\; y\_0.$ Expanded with ''n''−1 identities of kind $y\_\; =\; y\_$, this ''n''-th order equation is translated into a matrix difference equation system of n first-order linear equations, :$\backslash mathbf\; y\_n\; =\; \backslash beginy\_n\; \backslash \backslash \; y\_\backslash \backslash \; \backslash vdots\; \backslash \backslash \; \backslash vdots\; \backslash \backslash \; y\_1\; \backslash end\; =\; \backslash begin\; c\_\; \&\; c\_\; \&\; \backslash cdots\; \&\; \backslash cdots\; \&\; c\_0\; \backslash \backslash \; 1\; \&\; 0\; \&\; \backslash cdots\; \&\; \backslash cdots\; \&\; 0\; \backslash \backslash \; 0\; \&\; \backslash ddots\; \&\; \backslash ddots\; \&\; \&\backslash vdots\; \backslash \backslash \; \backslash vdots\; \&\; \backslash ddots\; \&\; \backslash ddots\; \&\; \backslash ddots\; \&\backslash vdots\; \backslash \backslash \; 0\; \&\; \backslash cdots\; \&\; 0\; \&\; 1\; \&\; 0\; \backslash end\; \backslash beginy\_\; \backslash \backslash y\_\; \backslash \backslash \; \backslash vdots\; \backslash \backslash \; \backslash vdots\; \backslash \backslash \; y\_0\; \backslash end\; =\; C\; \backslash mathbf\; y\_\; =\; C^n\; \backslash mathbf\; y\_0.$ Observe that the vector $\backslash mathbf\; y\_n$ can be computed by ''n'' applications of the companion matrix, ''C'', to the initial state vector, $y\_0$. Thereby, ''n''-th entry of the sought sequence y, is the top component of

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.

Solving non-homogeneous linear recurrence relations with constant coefficients

If the recurrence is non-homogeneous, 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 a non-homogeneous recurrence is the method of ''symbolic differentiation''. For example, consider the following recurrence: :$a\_\; =\; a\_\; +\; 1$ This is a non-homogeneous recurrence. If we substitute ''n'' ↦ ''n''+1, we obtain the recurrence :$a\_\; =\; a\_\; +\; 1$ Subtracting the original recurrence from this equation yields :$a\_\; -\; a\_\; =\; a\_\; -\; a\_$ or equivalently :$a\_\; =\; 2\; a\_\; -\; 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\_\; =\; \backslash lambda\_\; a\_\; +\; \backslash lambda\_\; a\_\; +\; \backslash cdots\; +\; \backslash lambda\_1\; a\_\; +\; \backslash lambda\_0\; a\_\; +\; p(n)$ where $\backslash lambda\_0,\; \backslash lambda\_1,\; \backslash dots,\; \backslash lambda\_$ are constant coefficients and ''p''(''n'') is the inhomogeneity, then if ''p''(''n'') is a polynomial with degree ''r'', then this non-homogeneous recurrence can be reduced to a homogeneous recurrence by applying the method of symbolic differencing ''r'' times. If :$P(x)\; =\; \backslash sum\_^\backslash infty\; p\_n\; x^n$ is the generating function of the inhomogeneity, the generating function :$A(x)\; =\; \backslash sum\_^\backslash infty\; a(n)\; x^n$ of the non-homogeneous recurrence :$a\_n\; =\; \backslash sum\_^s\; c\_i\; a\_+p\_n,\backslash quad\; n\backslash ge\; n\_r,$ with constant coefficients is derived from :$\backslash left\; (1-\backslash sum\_^sc\_ix^i\; \backslash right\; )A(x)=P(x)+\backslash sum\_^\_n-p\_n^n-\backslash sum\_^s\; c\_ix^i\backslash sum\_^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\_+n$ with linear inhomogeneity, arises in the definition of the schizophrenic numbers. The solution of homogeneous recurrences is incorporated as ''p'' = ''P'' = 0.

Solving first-order non-homogeneous recurrence relations with variable coefficients

Moreover, for the general first-order non-homogeneous linear recurrence relation with variable coefficients: :$a\_\; =\; f\_n\; a\_n\; +\; g\_n,\; \backslash qquad\; f\_n\; \backslash neq\; 0,$ there is also a nice method to solve it: :$a\_\; -\; f\_n\; a\_n\; =\; g\_n$ :$\backslash frac\; -\; \backslash frac\; =\; \backslash frac$ :$\backslash frac\; -\; \backslash frac\; =\; \backslash frac$ Let :$A\_n\; =\; \backslash frac,$ Then :$A\_\; -\; A\_n\; =\; \backslash frac$ :$\backslash sum\_^(A\_\; -\; A\_m)\; =\; A\_n\; -\; A\_0\; =\; \backslash sum\_^\backslash frac$ :$\backslash frac\; =\; A\_0\; +\; \backslash sum\_^\backslash frac$ :$a\_n\; =\; \backslash left(\backslash prod\_^\; f\_k\; \backslash right)\; \backslash left(A\_0\; +\; \backslash sum\_^\backslash frac\backslash right)$ If we apply the formula to $a\_\; =\; (1\; +\; h\; f\_)\; a\_n\; +\; hg\_$ and take the limit h→0, we get the formula for first order linear differential equations with variable coefficients; the sum becomes an integral, and the product becomes the exponential function of an integral.

Solving general homogeneous linear recurrence relations

Many homogeneous linear 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\_=\backslash fracJ\_n-J\_$ is given by :$J\_n=J\_n(z),$ the Bessel function, while :$(b-n)M\_\; +(2n-b-z)M\_n\; -\; nM\_=0$ is solved by :$M\_n=M(n,b;z)$ the confluent hypergeometric series. Sequences which are the solutions of linear difference equations with polynomial coefficients are called P-recursive. For these specific recurrence equations algorithms are known which find polynomial, rational or hypergeometric solutions.

Solving first-order rational difference equations

A first order rational difference equation has the form $w\_\; =\; \backslash tfrac$. 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\_\; +\; c\_2a\_+\backslash cdots+c\_da\_,$ has the characteristic equation :$\backslash lambda^d\; -\; c\_1\; \backslash lambda^\; -\; c\_2\; \backslash lambda^\; -\; \backslash cdots\; -\; c\_d\; \backslash 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 :$\_t\; -\; x^*=\; A\_-x^*/math>\; with\; state\; vector\; \text{'}\text{'}x\text{'}\text{'}\; and\; transition\; matrix\; \text{'}\text{'}A\text{'}\text{'},\; \text{'}\text{'}x\text{'}\text{'}\; converges\; asymptotically\; to\; the\; steady\; state\; vector\; \text{'}\text{'}x\text{'}\text{'}*\; if\; and\; only\; if\; all\; eigenvalues\; of\; the\; transition\; matrix\; \text{'}\text{'}A\text{'}\text{'}\; (whether\; real\; or\; complex)\; have\; anabsolute\; valuewhich\; is\; less\; than1.$

Stability of nonlinear first-order recurrences

Consider the nonlinear first-order recurrence :$x\_n=f(x\_).$ 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{'}\; (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\; \backslash circ\; f\; \backslash circ\; \backslash cdots\; \backslash circ\; f(x)$ with ''f'' appearing ''k'' times is locally stable according to the same criterion: : $|\; g\text{'}\; (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\text{'}(t)\; =\; f(t,y(t)),\; \backslash \; \backslash \; y(t\_0)=y\_0,$
with Euler's method and a step size ''h'', one calculates the values
:$y\_0=y(t\_0),\; \backslash \; \backslash \; y\_1=y(t\_0+h),\; \backslash \; \backslash \; y\_2=y(t\_0+2h),\; \backslash \; \backslash dots$
by the recurrence
:$\backslash ,\; y\_\; =\; y\_n\; +\; hf(t\_n,y\_n),\; t\_n\; =\; t\_0\; +\; nh$
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 of population dynamics. 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\_\; =\; \backslash lambda\; N\_t\; e^$
:$P\_\; =\; N\_t(1-e^),$
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. 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\_$ the time complexity of which will be $O(\backslash 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\; -\; \backslash alpha)\; x\_t\; +\; \backslash alpha\; y\_,$
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\; -\; \backslash alpha)\; x\_t\; +\; \backslash alpha\; ((1-\backslash alpha)\; x\_\; +\; \backslash alpha\; y\_)$
:$y\_t\; =\; (1\; -\; \backslash alpha)\; x\_t\; +\; (\backslash alpha-\backslash alpha^2)\; x\_\; +\; \backslash alpha^2\; y\_$
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 past and current values of other variables.

See also

* Holonomic sequences * Iterated function * Orthogonal polynomials * Recursion * Recursion (computer science) * Lagged Fibonacci generator * Master theorem (analysis of algorithms) * Circle points segments proof * Continued fraction * Time scale calculus * Combinatorial principles * Infinite impulse response * Integration by reduction formulae * Mathematical induction

** References **

** Footnotes **

** Bibliography **

*
*
*
*
* Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. ''Introduction to Algorithms'', Second Edition. MIT Press and McGraw-Hill, 1990. . Chapter 4: Recurrences, pp. 62–90.
*
*
* chapter 7.
* Chapter 9.1: Difference Equations.
*
* at EqWorld - The World of Mathematical Equations.
* at EqWorld - The World of Mathematical Equations.
*

** External links **

*
*
* 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)
{{Authority control
Category:Algebra
Category:Combinatorics

Definition

A ''recurrence relation'' is an equation that expresses each element of a sequence as a function of the preceding ones. More precisely, in the case where only the immediately preceding element is involved, a recurrence relation has the form :$u\_n=\backslash varphi(n,\; u\_)\backslash quad\backslash text\backslash quad\; n>0,$ where :$\backslash varphi:\backslash mathbb\; N\backslash times\; X\; \backslash to\; X$ is a function, where is a set to which the elements of a sequence must belong. For any $u\_0\backslash in\; X$, this defines a unique sequence with $u\_0$ as its first element, called the ''initial value''. It is easy to modify the definition for getting sequences starting from the term of index 1 or higher. This defines recurrence relation of ''first order''. A recurrence relation of ''order'' has the form :$u\_n=\backslash varphi(n,\; u\_,\; u\_,\; \backslash ldots,\; u\_)\backslash quad\backslash text\backslash quad\; n\backslash ge\; k,$ where $\backslash varphi:\; \backslash mathbb\; N\backslash times\; X^k\; \backslash to\; X$ is a function that involves consecutive elements of the sequence. In this case, initial values are needed for defining a sequence.

Examples

Factorial

The factorial is defined by the recurrence relation :$n!=n(n-1)!\backslash quad\backslash text\backslash quad\; n>0,$ and the initial condition :$0!=1.$

Logistic map

An example of a recurrence relation is the logistic map: :$x\_\; =\; r\; x\_n\; (1\; -\; x\_n),$ with a given constant ''r''; given the initial term ''x''

Fibonacci numbers

The recurrence of order two satisfied by the Fibonacci numbers is the archetype of a homogeneous linear recurrence relation with constant coefficients (see below). The Fibonacci sequence is defined using the recurrence :$F\_n\; =\; F\_+F\_$ with initial conditions (seed values) :$F\_0\; =\; 0$ :$F\_1\; =\; 1.$ Explicitly, the 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, ... The recurrence can be solved by methods described below yielding Binet's formula, which involves powers of the two roots of the characteristic polynomial ''t''

Binomial coefficients

A simple example of a multidimensional recurrence relation is given by the binomial coefficients $\backslash tbinom$, which count the number of ways of selecting ''k'' elements out of a set of ''n'' elements. They can be computed by the recurrence relation :$\backslash binom=\backslash binom+\backslash binom,$ with the base cases $\backslash tbinom=\backslash tbinom=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: $\backslash binom=\backslash frac.$

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.

Roots of the characteristic polynomial

An order-''d'' homogeneous linear recurrence with constant coefficients is an equation of the form :$a\_n\; =\; c\_1a\_\; +\; c\_2a\_+\backslash cdots+c\_da\_,$ where the ''d'' coefficients ''c

Solving via linear algebra

A linearly recursive sequence y of order n :$y\_\; -\; c\_y\_\; -\; c\_y\_\; +\; \backslash cdots\; -\; c\_0\; y\_k\; =\; 0$ is identical to :$y\_n\; =\; c\_y\_\; +\; c\_y\_\; +\; \backslash cdots\; +c\_0\; y\_0.$ Expanded with ''n''−1 identities of kind $y\_\; =\; y\_$, this ''n''-th order equation is translated into a matrix difference equation system of n first-order linear equations, :$\backslash mathbf\; y\_n\; =\; \backslash beginy\_n\; \backslash \backslash \; y\_\backslash \backslash \; \backslash vdots\; \backslash \backslash \; \backslash vdots\; \backslash \backslash \; y\_1\; \backslash end\; =\; \backslash begin\; c\_\; \&\; c\_\; \&\; \backslash cdots\; \&\; \backslash cdots\; \&\; c\_0\; \backslash \backslash \; 1\; \&\; 0\; \&\; \backslash cdots\; \&\; \backslash cdots\; \&\; 0\; \backslash \backslash \; 0\; \&\; \backslash ddots\; \&\; \backslash ddots\; \&\; \&\backslash vdots\; \backslash \backslash \; \backslash vdots\; \&\; \backslash ddots\; \&\; \backslash ddots\; \&\; \backslash ddots\; \&\backslash vdots\; \backslash \backslash \; 0\; \&\; \backslash cdots\; \&\; 0\; \&\; 1\; \&\; 0\; \backslash end\; \backslash beginy\_\; \backslash \backslash y\_\; \backslash \backslash \; \backslash vdots\; \backslash \backslash \; \backslash vdots\; \backslash \backslash \; y\_0\; \backslash end\; =\; C\; \backslash mathbf\; y\_\; =\; C^n\; \backslash mathbf\; y\_0.$ Observe that the vector $\backslash mathbf\; y\_n$ can be computed by ''n'' applications of the companion matrix, ''C'', to the initial state vector, $y\_0$. Thereby, ''n''-th entry of the sought sequence y, is the top component of

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.

Solving non-homogeneous linear recurrence relations with constant coefficients

If the recurrence is non-homogeneous, 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 a non-homogeneous recurrence is the method of ''symbolic differentiation''. For example, consider the following recurrence: :$a\_\; =\; a\_\; +\; 1$ This is a non-homogeneous recurrence. If we substitute ''n'' ↦ ''n''+1, we obtain the recurrence :$a\_\; =\; a\_\; +\; 1$ Subtracting the original recurrence from this equation yields :$a\_\; -\; a\_\; =\; a\_\; -\; a\_$ or equivalently :$a\_\; =\; 2\; a\_\; -\; 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\_\; =\; \backslash lambda\_\; a\_\; +\; \backslash lambda\_\; a\_\; +\; \backslash cdots\; +\; \backslash lambda\_1\; a\_\; +\; \backslash lambda\_0\; a\_\; +\; p(n)$ where $\backslash lambda\_0,\; \backslash lambda\_1,\; \backslash dots,\; \backslash lambda\_$ are constant coefficients and ''p''(''n'') is the inhomogeneity, then if ''p''(''n'') is a polynomial with degree ''r'', then this non-homogeneous recurrence can be reduced to a homogeneous recurrence by applying the method of symbolic differencing ''r'' times. If :$P(x)\; =\; \backslash sum\_^\backslash infty\; p\_n\; x^n$ is the generating function of the inhomogeneity, the generating function :$A(x)\; =\; \backslash sum\_^\backslash infty\; a(n)\; x^n$ of the non-homogeneous recurrence :$a\_n\; =\; \backslash sum\_^s\; c\_i\; a\_+p\_n,\backslash quad\; n\backslash ge\; n\_r,$ with constant coefficients is derived from :$\backslash left\; (1-\backslash sum\_^sc\_ix^i\; \backslash right\; )A(x)=P(x)+\backslash sum\_^\_n-p\_n^n-\backslash sum\_^s\; c\_ix^i\backslash sum\_^a\_nx^n.$ If ''P''(''x'') is a rational generating function, ''A''(''x'') is also one. The case discussed above, where ''p

Solving first-order non-homogeneous recurrence relations with variable coefficients

Moreover, for the general first-order non-homogeneous linear recurrence relation with variable coefficients: :$a\_\; =\; f\_n\; a\_n\; +\; g\_n,\; \backslash qquad\; f\_n\; \backslash neq\; 0,$ there is also a nice method to solve it: :$a\_\; -\; f\_n\; a\_n\; =\; g\_n$ :$\backslash frac\; -\; \backslash frac\; =\; \backslash frac$ :$\backslash frac\; -\; \backslash frac\; =\; \backslash frac$ Let :$A\_n\; =\; \backslash frac,$ Then :$A\_\; -\; A\_n\; =\; \backslash frac$ :$\backslash sum\_^(A\_\; -\; A\_m)\; =\; A\_n\; -\; A\_0\; =\; \backslash sum\_^\backslash frac$ :$\backslash frac\; =\; A\_0\; +\; \backslash sum\_^\backslash frac$ :$a\_n\; =\; \backslash left(\backslash prod\_^\; f\_k\; \backslash right)\; \backslash left(A\_0\; +\; \backslash sum\_^\backslash frac\backslash right)$ If we apply the formula to $a\_\; =\; (1\; +\; h\; f\_)\; a\_n\; +\; hg\_$ and take the limit h→0, we get the formula for first order linear differential equations with variable coefficients; the sum becomes an integral, and the product becomes the exponential function of an integral.

Solving general homogeneous linear recurrence relations

Many homogeneous linear 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\_=\backslash fracJ\_n-J\_$ is given by :$J\_n=J\_n(z),$ the Bessel function, while :$(b-n)M\_\; +(2n-b-z)M\_n\; -\; nM\_=0$ is solved by :$M\_n=M(n,b;z)$ the confluent hypergeometric series. Sequences which are the solutions of linear difference equations with polynomial coefficients are called P-recursive. For these specific recurrence equations algorithms are known which find polynomial, rational or hypergeometric solutions.

Solving first-order rational difference equations

A first order rational difference equation has the form $w\_\; =\; \backslash tfrac$. 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\_\; +\; c\_2a\_+\backslash cdots+c\_da\_,$ has the characteristic equation :$\backslash lambda^d\; -\; c\_1\; \backslash lambda^\; -\; c\_2\; \backslash lambda^\; -\; \backslash cdots\; -\; c\_d\; \backslash 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 :$\_t\; -\; x^*=\; A\_-x^*/math>\; with\; state\; vector\; \text{'}\text{'}x\text{'}\text{'}\; and\; transition\; matrix\; \text{'}\text{'}A\text{'}\text{'},\; \text{'}\text{'}x\text{'}\text{'}\; converges\; asymptotically\; to\; the\; steady\; state\; vector\; \text{'}\text{'}x\text{'}\text{'}*\; if\; and\; only\; if\; all\; eigenvalues\; of\; the\; transition\; matrix\; \text{'}\text{'}A\text{'}\text{'}\; (whether\; real\; or\; complex)\; have\; anabsolute\; valuewhich\; is\; less\; than1.$

Stability of nonlinear first-order recurrences

Consider the nonlinear first-order recurrence :$x\_n=f(x\_).$ 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{'}\; (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\; \backslash circ\; f\; \backslash circ\; \backslash cdots\; \backslash circ\; f(x)$ with ''f'' appearing ''k'' times is locally stable according to the same criterion: : $|\; g\text{'}\; (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.

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 (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\_$ the time complexity of which will be $O(\backslash log\_2(n))$.

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 past and current values of other variables.

See also

* Holonomic sequences * Iterated function * Orthogonal polynomials * Recursion * Recursion (computer science) * Lagged Fibonacci generator * Master theorem (analysis of algorithms) * Circle points segments proof * Continued fraction * Time scale calculus * Combinatorial principles * Infinite impulse response * Integration by reduction formulae * Mathematical induction