# How to know the filter order

Could anyone explain to me how can I know the filter order based on algorithm?

For example:

• $y[n] = \frac12 x[n] – x[n–1] + \frac12 x[n–2]$ has order filter 2.

• $y[n] =2 x[n] – x[n–1] + y[n–1]$ has order filter 1.

• $y[n] =2 x[n] – x[n–1] + x[n–2]+ y[n–1] + y[n–2]$ has order filter 2.

Why?

If the discrete-time filter is described by the linear difference equation

$$y[n]=\sum_{k=1}^{K}a_ky[n-k]+\sum_{m=0}^{M}b_mx[n-m]$$

(with $a_K\neq 0$ and $b_M\neq 0$), the filter order is given by $\max\{K,M\}$, i.e., by the maximum delay necessary to implement the filter.

• what about pole/zero cancellation? Jan 17 '17 at 4:11

As a general rule, the order of a filter is its length minus one. The length can be found by checking how many input samples the filter extends over.

In your first example, the filter extends over 3 input samples ($x[n],x[n-1],x[n-2]$), so its length is 3. Thus, the filter order is 2. In the second one, the length is 2, so the order is 1. The last example has the same length (and, therefore, the same order) as the first one.

EDIT: As Matt stated in his answer, the length can be determined not only by how many input samples the filter extends over, but also by how many output samples are used (whichever is the greatest).

• Only the first example is a FIR filter, the others are IIR. Anyway, the order is always equal to the maximum delay, no matter if applied to the input or output signal. Jan 15 '17 at 16:39
• @MattL. So if the filter equation was $y[n] =2 x[n] – x[n–1] + y[n–1] + y[n–2] + y[n-3]$, would the order be 3? Jan 15 '17 at 17:09
• Yes, that's right. Jan 15 '17 at 17:20
• @MattL. I didn't know that, thanks :) Jan 15 '17 at 17:29
• Welcome :) ${}$ Jan 15 '17 at 17:31