# Linear difference equation

In mathematics and in particular dynamical systems, a linear difference equation[1]:ch. 17[2]:ch. 10 or linear recurrence relation equates to a polynomial that is linear in the various iterates of a variable—that is, in the values of the elements of a sequence. The polynomial's linearity means that each of its terms has degree 0 or 1. Usually the context is the evolution of some variable over time, with the current time period or discrete moment in time denoted as t, one period earlier denoted as t–1, one period later as t+1, etc.

An n-th order linear difference equation is one that can be written in terms of parameters ai and b as

${\displaystyle y_{t}=a_{1}y_{t-1}+\cdots +a_{n}y_{t-n}+b}$

or equivalently as

${\displaystyle y_{t+n}=a_{1}y_{t+n-1}+\cdots +a_{n}y_{t}+b.}$

The equation is called homogeneous if ${\displaystyle b=0}$ and inhomogeneous if ${\displaystyle b\neq 0}$. Since the longest time lag between iterates appearing in the equation is n, this is an n-th order equation, where n could be any positive integer. When the longest lag is specified numerically so n does not appear notationally as the longest time lag, n is occasionally used instead of t to index iterates.

In the most general case the coefficients ai and b could themselves be functions of time; however, this article treats the most common case, that of constant coefficients.

The solution of such an equation is a function of time, and not of any iterate values, giving the value of the iterate at any time. To find the solution it is necessary to know the specific values (known as initial conditions) of n of the iterates, and normally these are the n iterates that are oldest. The equation or its variable is said to be stable if from any set of initial conditions the variable's limit as time goes to infinity exists; this limit is called the steady state.

Difference equations are used in a variety of contexts, such as in economics to model the evolution through time of variables such as gross domestic product, the inflation rate, the exchange rate, etc. They are used in modeling such time series because values of these variables are only measured at discrete intervals. In econometric applications, linear difference equations are modeled with stochastic terms in the form of autoregressive (AR) models and in models such as vector autoregression (VAR) and autoregressive moving average (ARMA) models that combine AR with other features.

## Solution of homogeneous case

### Characteristic equation and roots

Solving the homogeneous equation ${\displaystyle x_{t}=a_{1}x_{t-1}+\cdots +a_{n}x_{t-n}}$ involves first solving its characteristic equation

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

for its characteristic roots ${\displaystyle \lambda _{i},}$ i = 1, ..., n. These roots can be solved for algebraically if n ≤ 4, but not necessarily otherwise. If the solution is to be used numerically, all the roots of this characteristic equation can be found by numerical methods. However, for use in a theoretical context it may be that the only information required about the roots is whether any of them are greater than or equal to 1 in absolute value.

It may be that all the roots are real or instead there may be some that are complex numbers. In the latter case, all the complex roots come in complex conjugate pairs.

### Solution with distinct characteristic roots

If no characteristic roots share the same value, the solution of the homogeneous linear difference equation ${\displaystyle x_{t}=a_{1}x_{t-1}+\cdots +a_{n}x_{t-n}}$ can be written in terms of the characteristic roots as

${\displaystyle x_{t}=c_{1}\lambda _{1}^{t}+\cdots +c_{n}\lambda _{n}^{t},}$

where the coefficients ci can be found by invoking the initial conditions. Specifically, for each time period for which an iterate value is known, this value and its corresponding value of t can be substituted into the solution equation to obtain a linear equation in the n as-yet-unknown parameters; n such equations, one for each initial condition, can be solved simultaneously for the n parameter values. If all characteristic roots are real, then all the coefficient values ci will also be real; but with non-real complex roots, in general some of these coefficients will also be non-real.

#### Converting complex solution to trigonometric form

If there are complex roots, they come in pairs and so do the complex terms in the solution equation. If two of these complex terms are ${\displaystyle c_{j}\lambda _{j}^{t}}$ and ${\displaystyle c_{j+1}\lambda _{j+1}^{t},}$ the roots ${\displaystyle \lambda _{i}}$ can be written as

${\displaystyle \lambda _{j},\lambda _{j+1}=\alpha \pm \beta i=M\left({\frac {\alpha }{M}}\pm {\frac {\beta }{M}}i\right),}$

where the non-subscript i is the imaginary unit and M is the modulus of the roots: ${\displaystyle M={\sqrt {\alpha ^{2}+\beta ^{2}}}.}$ Then the two complex terms in the solution equation can be written as

{\displaystyle {\begin{aligned}c_{j}\lambda _{j}^{t}+c_{j+1}\lambda _{j+1}^{t}&=M^{t}\left(c_{j}\left({\frac {\alpha }{M}}+{\frac {\beta }{M}}i\right)^{t}+c_{j+1}\left({\frac {\alpha }{M}}-{\frac {\beta }{M}}i\right)^{t}\right)\\[6pt]&=M^{t}[c_{j}(\cos \theta +i\sin \theta )^{t}+c_{j+1}(\cos \theta -i\sin \theta )^{t}]\\[6pt]&=M^{t}[c_{j}(\cos(\theta t)+i\sin(\theta t))+c_{j+1}(\cos(\theta t)-i\sin(\theta t))],\end{aligned}}}

where ${\displaystyle \theta }$ is the angle whose cosine is ${\displaystyle {\tfrac {\alpha }{M}}}$ and whose sine is ${\displaystyle {\tfrac {\beta }{M}};}$ the last equality here made use of de Moivre's formula.

Now the process of finding the coefficients ${\displaystyle c_{j}}$ and ${\displaystyle c_{j+1}}$ guarantees that they are also complex conjugates, which can be written as ${\displaystyle \gamma \pm \delta i.}$ Using this in the last equation gives this expression for the two complex terms in the solution equation:

${\displaystyle 2M^{t}\left(\gamma \cos(\theta t)-\delta \sin(\theta t)\right),}$

which can also be written as

${\displaystyle 2{\sqrt {\gamma ^{2}+\delta ^{2}}}M^{t}\cos(\theta t+\psi )}$

where ${\displaystyle \psi }$ is the angle whose cosine is ${\displaystyle {\tfrac {\gamma }{\sqrt {\gamma ^{2}+\delta ^{2}}}}}$ and whose sine is ${\displaystyle {\tfrac {\delta }{\sqrt {\gamma ^{2}+\delta ^{2}}}}.}$

#### Cyclicality

Depending on the initial conditions, even with all roots real the iterates can experience a transitory tendency to go above and below the steady state value. But true cyclicality involves a permanent tendency to fluctuate, and this occurs if there is at least one pair of complex conjugate characteristic roots. This can be seen in the trigonometric form of their contribution to the solution equation, involving ${\displaystyle \cos(\theta t)}$ and ${\displaystyle \sin(\theta t).}$

### Solution with duplicate characteristic roots

In the second-order case, if the two roots are identical (${\displaystyle \lambda _{1}=\lambda _{2}}$), they can both be denoted as ${\displaystyle \lambda }$ and a solution may be of the form

${\displaystyle x_{t}=c_{1}\lambda ^{t}+c_{2}t\lambda ^{t}.}$

### Conversion to homogeneous form

If b ≠ 0, the equation

${\displaystyle y_{t}=a_{1}y_{t-1}+\cdots +a_{n}y_{t-n}+b}$

is said to be non-homogeneous. To solve this equation it is convenient to convert it to homogeneous form, with no constant term. This is done by first finding the equation's steady state value—a value y * such that, if n successive iterates all had this value, so would all future values. This value is found by setting all values of y equal to y * in the difference equation, and solving, thus obtaining

${\displaystyle y^{*}={\frac {b}{1-a_{1}-\cdots -a_{n}}},}$

assuming the denominator is not 0. If it is zero, the steady state does not exist.

Given the steady state, the difference equation can be rewritten in terms of deviations of the iterates from the steady state, as

${\displaystyle (y_{t}-y^{*})=a_{1}(y_{t-1}-y^{*})+\cdots +a_{n}(y_{t-n}-y^{*}),}$

which has no constant term, and which can be written more succinctly as

${\displaystyle x_{t}=a_{1}x_{t-1}+\cdots +a_{n}x_{t-n}}$

where x equals yy *. This is the homogeneous form.

If there is no steady state, the difference equation

${\displaystyle y_{t}=a_{1}y_{t-1}+\cdots +a_{n}y_{t-n}+b}$

can be combined with its equivalent form

${\displaystyle y_{t-1}=a_{1}y_{t-2}+\cdots +a_{n}y_{t-(n+1)}+b}$

to obtain (by solving both for b)

${\displaystyle y_{t}-a_{1}y_{t-1}-\cdots -a_{n}y_{t-n}=y_{t-1}-a_{1}y_{t-2}-\cdots -a_{n}y_{t-(n+1)},}$

in which like terms can be combined to give a homogeneous equation of one order higher than the original.