One of the most important concepts of DSP is to be able to properly represent the input/output relationship to a given LTI system. A linear constant-coefficient difference equation (LCCDE) serves as a way to express just this relationship in a discrete-time system. Writing the sequence of inputs and outputs, which represent the characteristics of the LTI system, as a difference equation help in understanding and manipulating a system.

Definition 1: difference equation

An equation that shows the relationship between
consecutive values of a sequence and the differences among
them. They are often rearranged as a recursive formula so
that a systems output can be computed from the input
signal and past outputs.

Example 1

$$y\left[n\right]+7y\left[n-1\right]+2y\left[n-2\right]=x\left[n\right]-4x\left[n-1\right]$$

1

As stated briefly in the definition above, a difference equation is a very useful tool in describing and calculating the output of the system described by the formula for a given sample $n$. The key property of the difference equation is its ability to help easily find the transform, $H\left(z\right)$, of a system. In the following two subsections, we will look at the general form of the difference equation and the general conversion to a z-transform directly from the difference equation.

The general form of a linear, constant-coefficient difference equation (LCCDE), is shown below:

$$\sum _{k=0}^{N}{a}_{k}y\left[n-k\right]=\sum _{k=0}^{M}{b}_{k}x\left[n-k\right]$$

2

$$y\left[n\right]=-\sum _{k=1}^{N}{a}_{k}y\left[n-k\right]+\sum _{k=0}^{M}{b}_{k}x\left[n-k\right]$$

3

Using the above formula, Equation 2, we can easily generalize the transfer function, $H\left(z\right)$, for any difference equation. Below are the steps taken to convert any difference equation into its transfer function, i.e. z-transform. The first step involves taking the Fourier Transform of all the terms in Equation 2. Then we use the linearity property to pull the transform inside the summation and the time-shifting property of the z-transform to change the time-shifting terms to exponentials. Once this is done, we arrive at the following equation: ${a}_{0}=1$.

$$Y\left(z\right)=-\sum _{k=1}^{N}{a}_{k}Y\left(z\right){z}^{-k}+\sum _{k=0}^{M}{b}_{k}X\left(z\right){z}^{-k}$$

4

$$\begin{array}{rcl}\hfill H\left(z\right)& \hfill =\hfill & \frac{Y\left(z\right)}{X\left(z\right)}\hfill \\ \hfill & \hfill =\hfill & \frac{\sum _{k=0}^{M}{b}_{k}{z}^{-k}}{1+\sum _{k=1}^{N}{a}_{k}{z}^{-k}}\hfill \end{array}$$

5

Once the z-transform has been calculated from the difference equation, we can go one step further to define the frequency response of the system, or filter, that is being represented by the difference equation.

Note:

Remember that the reason we are dealing with these
formulas is to be able to aid us in filter design. A LCCDE
is one of the easiest ways to represent FIR filters. By
being able to find the frequency response, we will be able to
look at the basic properties of any filter represented by a
simple LCCDE.
$$\begin{array}{rcl}\hfill H\left(w\right)& \hfill =\hfill & H\left(z\right){|}_{z,z={e}^{iw}}\hfill \\ \hfill & \hfill =\hfill & \frac{\sum _{k=0}^{M}{b}_{k}{e}^{-(iwk)}}{\sum _{k=0}^{N}{a}_{k}{e}^{-(iwk)}}\hfill \end{array}$$

6

Example 2: Finding Difference Equation

Below is a basic example showing the opposite of the steps above: given a transfer function one can easily calculate the systems difference equation.

$$H\left(z\right)=\frac{{\left(z+1\right)}^{2}}{(z-\frac{1}{2})(z+\frac{3}{4})}$$

7

$$\begin{array}{rcl}\hfill H\left(z\right)& \hfill =\hfill & \frac{(z+1)(z+1)}{(z-\frac{1}{2})(z+\frac{3}{4})}\hfill \\ \hfill & \hfill =\hfill & \frac{{z}^{2}+2z+1}{{z}^{2}+2z+1-\frac{3}{8}}\hfill \\ \hfill & \hfill =\hfill & \frac{1+2{z}^{-1}+{z}^{-2}}{1+\frac{1}{4}{z}^{-1}-\frac{3}{8}{z}^{-2}}\hfill \end{array}$$

8

$$x\left[n\right]+2x\left[n-1\right]+x\left[n-2\right]=y\left[n\right]+\frac{1}{4}y\left[n-1\right]-\frac{3}{8}y\left[n-2\right]$$

9

$$y\left[n\right]=x\left[n\right]+2x\left[n-1\right]+x\left[n-2\right]+\frac{-1}{4}y\left[n-1\right]+\frac{3}{8}y\left[n-2\right]$$

10

In order for a linear constant-coefficient difference equation to be useful in analyzing a LTI system, we must be able to find the systems output based upon a known input, $x\left(n\right)$, and a set of initial conditions. Two common methods exist for solving a LCCDE: the direct method and the indirect method, the later being based on the z-transform. Below we will briefly discuss the formulas for solving a LCCDE using each of these methods.

The final solution to the output based on the direct method is the sum of two parts, expressed in the following equation:

$$y\left(n\right)={y}_{h}\left(n\right)+{y}_{p}\left(n\right)$$

11

We begin by assuming that the input is zero, $x\left(n\right)=0$. Now we simply need to solve the homogeneous difference equation:

$$\sum _{k=0}^{N}{a}_{k}y\left[n-k\right]=0$$

12

$$\sum _{k=0}^{N}{a}_{k}{\lambda}^{n-k}=0$$

13

$${y}_{h}\left(n\right)={C}_{1}{\left({\lambda}_{1}\right)}^{n}+{C}_{2}{\left({\lambda}_{2}\right)}^{n}+\dots +{C}_{N}{\left({\lambda}_{N}\right)}^{n}$$

14

$${y}_{h}\left(n\right)={C}_{1}{\left({\lambda}_{1}\right)}^{n}+{C}_{1}n{\left({\lambda}_{1}\right)}^{n}+{C}_{1}{n}^{2}{\left({\lambda}_{1}\right)}^{n}+\dots +{C}_{1}{n}^{K-1}{\left({\lambda}_{1}\right)}^{n}+{C}_{2}{\left({\lambda}_{2}\right)}^{n}+\dots +{C}_{N}{\left({\lambda}_{N}\right)}^{n}$$

15

The particular solution, ${y}_{p}\left(n\right)$, will be any solution that will solve the general difference equation:

$$\sum _{k=0}^{N}{a}_{k}{y}_{p}\left(n-k\right)=\sum _{k=0}^{M}{b}_{k}x\left(n-k\right)$$

16

The indirect method utilizes the relationship between the difference equation and z-transform, discussed earlier, to find a solution. The basic idea is to convert the difference equation into a z-transform, as described above, to get the resulting output, $Y\left(z\right)$. Then by inverse transforming this and using partial-fraction expansion, we can arrive at the solution.

$$Z\left\{y\left(n+1\right)-y\left(n\right)\right\}=zY\left(z\right)-y\left(0\right)$$

17

This can be interatively extended to an arbitrary order derivative as in Equation Equation 18.

$$Z\left\{-\sum _{m=0}^{N-1}y\left(n-m\right)\right\}={z}^{n}Y\left(z\right)-\sum _{m=0}^{N-1}{z}^{n-m-1}{y}^{\left(m\right)}\left(0\right)$$

18

Now, the Laplace transform of each side of the differential equation can be taken

$$Z\left\{\sum _{k=0}^{N}{a}_{k}\left[y\left(n-m+1\right)-\sum _{m=0}^{N-1}y\left(n-m\right)y\left(n\right)\right]=Z\left\{x\left(n\right)\right\}\right\}$$

19

which by linearity results in

$$\sum _{k=0}^{N}{a}_{k}Z\left\{y\left(n-m+1\right)-\sum _{m=0}^{N-1}y\left(n-m\right)y\left(n\right)\right\}=Z\left\{x\left(n\right)\right\}$$

20

and by differentiation properties in

$$\sum _{k=0}^{N}{a}_{k}\left({z}^{k}Z\left\{y\left(n\right)\right\}-\sum _{m=0}^{N-1}{z}^{k-m-1}{y}^{\left(m\right)}\left(0\right)\right)=Z\left\{x\left(n\right)\right\}.$$

21

Rearranging terms to isolate the Laplace transform of the output,

$$Z\left\{y\left(n\right)\right\}=\frac{Z\left\{x\left(n\right)\right\}+{\sum}_{k=0}^{N}{\sum}_{m=0}^{k-1}{a}_{k}{z}^{k-m-1}{y}^{\left(m\right)}\left(0\right)}{{\sum}_{k=0}^{N}{a}_{k}{z}^{k}}.$$

22

Thus, it is found that

$$Y\left(z\right)=\frac{X\left(z\right)+{\sum}_{k=0}^{N}{\sum}_{m=0}^{k-1}{a}_{k}{z}^{k-m-1}{y}^{\left(m\right)}\left(0\right)}{{\sum}_{k=0}^{N}{a}_{k}{z}^{k}}.$$

23

In order to find the output, it only remains to find the Laplace transform $X\left(z\right)$ of the input, substitute the initial conditions, and compute the inverse Z-transform of the result. Partial fraction expansions are often required for this last step. This may sound daunting while looking at Equation 23, but it is often easy in practice, especially for low order difference equations. Equation 23 can also be used to determine the transfer function and frequency response.

As an example, consider the difference equation

$$y\left[n-2\right]+4y\left[n-1\right]+3y\left[n\right]=cos\left(n\right)$$

24

with the initial conditions ${y}^{\text{'}}\left(0\right)=1$ and $y\left(0\right)=0$ Using the method described above, the Z transform of the solution $y\left[n\right]$ is given by

$$Y\left[z\right]=\frac{z}{[{z}^{2}+1][z+1][z+3]}+\frac{1}{[z+1][z+3]}.$$

25

Performing a partial fraction decomposition, this also equals

$$Y\left[z\right]=.25\frac{1}{z+1}-.35\frac{1}{z+3}+.1\frac{z}{{z}^{2}+1}+.2\frac{1}{{z}^{2}+1}.$$

26

Computing the inverse Laplace transform,

$$y\left(n\right)=(.25{z}^{-n}-.35{z}^{-3n}+.1cos\left(n\right)+.2sin\left(n\right))u\left(n\right).$$

27

One can check that this satisfies that this satisfies both the differential equation and the initial conditions.