Recursive and non-recursive filters


For all the examples of digital filters discussed so far, the current output (yn) is calculated solely from the current and previous input values (xn, xn-1, xn-2, ...). This type of filter is said to be non-recursive.

recursive filter is one which in addition to input values also uses previous output values. These, like the previous input values, are stored in the processor's memory.
The word recursive literally means "running back", and refers to the fact that previously-calculated output values go back into the calculation of the latest output. The expression for a recursive filter therefore contains not only terms involving the input values (xn, xn-1, xn-2, ...) but also terms in yn-1, yn-2, ...
From this explanation, it might seem as though recursive filters require more calculations to be performed, since there are previous output terms in the filter expression as well as input terms. In fact, the reverse is usually the case. To achieve a given frequency response characteristic using a recursive filter generally requires a much lower order filter, and therefore fewer terms to be evaluated by the processor, than the equivalent non-recursive filter. This will be demonstrated later.

Note: FIR and IIR filters

Some people prefer an alternative terminology in which a non-recursive filter is known as an FIR (or Finite Impulse Response) filter, and a recursive filter as an IIR (or InfiniteImpulse Response) filter. These terms refer to the differing "impulse responses" of the two types of filter
The impulse response of a digital filter is the output sequence from the filter when a unit impulse is applied at its input. (A unit impulse is a very simple input sequence consisting of a single value of 1 at time t = 0, followed by zeros at all subsequent sampling instants). An FIR filter is one whose impulse response is of finite duration. An IIR filter is one whose impulse response (theoretically) continues for ever, because the recursive (previous output) terms feed back energy into the filter input and keep it going. The term IIR is not very accurate, because the actual impulse responses of nearly all IIR filters reduce virtually to zero in a finite time. Nevertheless, these two terms are widely used.

Example of a recursive filter

A simple example of a recursive digital filter is given by
yn = xn + yn-1
In other words, this filter determines the current output (yn) by adding the current input (xn) to the previous output (yn-1).
Thus:
y0 = x0 + y-1y1 = x1 + y0y2 = x2 + y1y3 = x3 + y2... etc
Note that y-1 (like x-1) is undefined, and is usually taken to be zero.
Let us consider the effect of this filter in more detail. If in each of the above expressions we substitute for yn-1 the value given by the previous expression, we get the following:
y0 = x0 + y-1 = x0y1 = x1 + y0 = x1 + x0y2 = x2 + y1 = x2 + x1 + x0y3 = x3 + y2 = x3 + x2 + x1 + x0... etc
Thus we can see that yn, the output at t = nh, is equal to the sum of the current input xn and all the previous inputs. This filter therefore sums or integrates the input values, and so has a similar effect to an analog integrator circuit.
This example demonstrates an important and useful feature of recursive filters: the economy with which the output values are calculated, as compared with the equivalent non-recursive filter. In this example, each output is determined simply by adding two numbers together.
For instance, to calculate the output at time t = 10h, the recursive filter uses the expression
y10 = x10 + y9
To achieve the same effect with a non-recursive filter (i.e. without using previous output values stored in memory) would entail using the expression
y10 = x10 + x9 + x8 + x7 + x6 + x5 + x4 + x3 + x2 + x1 + x0
This would necessitate many more addition operations, as well as the storage of many more values in memory.

Order of a recursive (IIR) digital filter

The order of a digital filter was defined earlier as the number of previous inputs which have to be stored in order to generate a given output. This definition is appropriate for non-recursive (FIR) filters, which use only the current and previous inputs to compute the current output. In the case of recursive filters, the definition can be extended as follows:
The order of a recursive filter is the largest number of previous input or output values required to compute the current output.
This definition can be regarded as being quite general: it applies both to FIR and IIR filters.
For example, the recursive filter discussed above, given by the expression
yn = xn + yn-1
is classed as being of first order, because it uses one previous output value (yn-1), even though no previous inputs are required.
In practice, recursive filters usually require the same number of previous inputs and outputs. Thus, a first-order recursive filter generally requires one previous input (xn-1) and one previous output (yn-1), while a second-order recursive filter makes use of two previous inputs (xn-1 and xn-2) and two previous outputs (yn-1 and yn-2); and so on, for higher orders.
Note that a recursive (IIR) filter must, by definition, be of at least first order; a zero-order recursive filter is an impossibility. (Why?)

Coefficients of recursive (IIR) digital filters

From the above discussion, we can see that a recursive filter is basically like a non-recursive filter, with the addition of extra terms involving previous outputs (yn-1, yn-2 etc.).
A first-order recursive filter can be written in the general form
yn = (a0xn + a1xn-1 - b1yn-1) / b0
Note the minus sign in front of the "recursive" term b1yn-1, and the factor (1/b0) applied to all the coefficients. The reason for expressing the filter in this way is that it allows us to rewrite the expression in the following symmetrical form:
b0yn + b1yn-1 = a0xn + a1xn-1
In the case of a second-order filter, the general form is
yn = (a0xn + a1xn-1 + a2xn-2 - b1yn-1 - b2yn-2) / b0
An alternative "symmetrical" form of this expression is
b0yn + b1yn-1 + b2yn-2 = a0xn + a1xn-1 + a2xn-2
Note the convention that the coefficients of the inputs (the x's) are denoted by a's, while the coefficients of the outputs (the y's) are denoted by b's.