"Difference equation" redirects here.
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.
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
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 k has the form
The factorial is defined by the recurrence relation
and the initial condition
An example of a recurrence relation is the logistic map:
with a given constant r; given the initial term x0 each subsequent term is determined by this relation.
Solving a recurrence relation means obtaining a closed-form solution: a non-recursive function of n.
The Fibonacci sequence is defined using the recurrence
with initial conditions (seed values)
Explicitly, the recurrence yields the equations
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 = t + 1; the generating function of the sequence is the rational function
Relationship to difference equations narrowly defined
which can be simplified to
(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 k differences.
(A widely used broader definition treats "difference equation" as synonymous with "recurrence relation".
Actually, it is easily seen that,
Thus, a difference equation can be defined as an equation that involves an, an-1, an-2 etc. (or equivalently an, an+1, an+2 etc.)
Since difference equations are a very common form of recurrence, some authors use the two terms interchangeably.
For example, the difference equation
is equivalent to the recurrence relation
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.
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 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
The same coefficients yield the characteristic polynomial (also "auxiliary polynomial")
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 each solution to the recurrence takes the form
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 (x−r), with the same root r occurring three times, then the solution would take the form
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
has the solution an = r with a0 = 1 and the most general solution is an = kr 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 = r is a solution for the recurrence exactly when t = r is a root of the characteristic polynomial.
Consider, for example, a recurrence relation of the form
When does it have a solution of the same general form as an = r?
Substituting this guess (ansatz) in the recurrence relation, we find that
must be true for all n > 1.
Dividing through by r, we get that all these equations reduce to the same thing:
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
while if they are identical (when A + 4B = 0), we have
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.
can be rewritten as
Here E and F (or equivalently, G and δ) are real constants which depend on the initial conditions.
one may simplify the solution given above as
where a1 and a2 are the initial conditions and
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
with constant term K, this can be converted into homogeneous form as follows: The steady state is found by setting bn = bn−1 = bn−2 = b* to obtain
Then the non-homogeneous recurrence can be rewritten in homogeneous form as
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-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")
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−λ) divides p(t).
The following two properties hold:
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 an as a linear combination of all the roots (counting multiplicity as shown in the theorem above) with unknown coefficients bi.
- This is the general solution to the original recurrence relation. (q is the multiplicity of λ*)
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 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:
it can be seen that the coefficients of the series are given by the n 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:
and more generally
Example: The recurrence relationship for the Taylor series coefficients of the equation:
is given by
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
The conversion of the differential equation to a difference equation of the Taylor coefficients is
It is easy to see that the nth derivative of e evaluated at 0 is a
Solving via linear algebra
A linearly recursive sequence y of order n
is identical to
Solving for coefficients,
This description is really no different from general method above, however it is more succinct.
It also works nicely for situations like
where there are several linked recurrences.
Solving with 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:
This is a non-homogeneous recurrence.
If we substitute n ↦ n+1, we obtain the recurrence
Subtracting the original recurrence from this equation yields
This is a homogeneous recurrence, which can be solved by the methods explained above.
In general, if a linear recurrence has the form
is the generating function of the inhomogeneity, the generating function
of the non-homogeneous recurrence
with constant coefficients ci is derived from
Solving first-order non-homogeneous recurrence relations with variable coefficients
Moreover, for the general first-order non-homogeneous linear recurrence relation with variable coefficients:
there is also a nice method to solve it:
Solving general homogeneous linear recurrence relations
Many homogeneous linear recurrence relations may be solved by means of the generalized hypergeometric series.
For example, the solution to
is given by
the Bessel function, while
is solved by
Sequences which are the solutions of linear difference equations with polynomial coefficients are called P-recursive.
Solving first-order rational difference equations
Main article: Rational difference equation
Stability of linear higher-order recurrences
The linear recurrence of order d,
has the characteristic equation
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
Main article: Matrix difference equation
In the first-order matrix difference equation
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
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,
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:
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.
Relationship to differential equations
For example, when solving the initial value problem
with Euler's method and a step size h, one calculates the values
by the recurrence
Systems of linear first order differential equations can be discretized exactly analytically using the methods shown in the discretization article.
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.
In this context, coupled difference equations are often used to model the interaction of two or more populations.
with Nt representing the hosts, and Pt the parasites, at time t.
These and other difference equations are particularly suited to modeling univoltine populations.
Recurrence relations are also of fundamental importance in analysis of algorithms.
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
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.
For example, the equation for a "feedforward" IIR comb filter of delay T is:
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.
Credits to the contents of this page go to the authors of the corresponding Wikipedia page: en.wikipedia.org/wiki/Recurrence relation.