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.
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 . The key property of the difference equation is its ability to help easily find the transform, , 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:
Using the above formula, Equation 2, we can easily generalize the transfer function, , 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: .
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.
Below is a basic example showing the opposite of the steps above: given a transfer function one can easily calculate the systems difference equation.
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, , 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:
We begin by assuming that the input is zero, . Now we simply need to solve the homogeneous difference equation:
The particular solution, , will be any solution that will solve the general difference equation:
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, . Then by inverse transforming this and using partial-fraction expansion, we can arrive at the solution.
This can be interatively extended to an arbitrary order derivative as in Equation Equation 18.
Now, the Laplace transform of each side of the differential equation can be taken
which by linearity results in
and by differentiation properties in
Rearranging terms to isolate the Laplace transform of the output,
Thus, it is found that
In order to find the output, it only remains to find the Laplace transform 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
with the initial conditions and Using the method described above, the Z transform of the solution is given by
Performing a partial fraction decomposition, this also equals
Computing the inverse Laplace transform,
One can check that this satisfies that this satisfies both the differential equation and the initial conditions.