IIR filters, poles and zeros
Filters with feedback — sharper for the same cost, described by poles and zeros, and best understood as a landscape over the complex plane.
- Read a transfer function as poles and zeros, and judge stability from the poles
- Explain the frequency response as the height of |H(z)| along the unit circle
- Compare Butterworth, Chebyshev, elliptic and Bessel designs
An FIR filter computes each output from inputs only. An infinite impulse response (IIR) filter also feeds back its own past outputs:
\[y[n] = \sum_{k=0}^{M} b_k\, x[n-k] \;-\; \sum_{k=1}^{N} a_k\, y[n-k].\]The feedback lets a handful of coefficients produce a response that would take hundreds of FIR taps — at the price of a phase response that is no longer linear, and the possibility of instability.
Transfer functions, poles and zeros
Taking the z-transform turns the recursion into a ratio of polynomials,
\[H(z) = \frac{b_0 + b_1 z^{-1} + \cdots + b_M z^{-M}}{1 + a_1 z^{-1} + \cdots + a_N z^{-N}} = g\,\frac{\prod (z - z_i)}{\prod (z - p_i)}.\]The roots of the numerator are the zeros, where \(H\) vanishes; the roots of the denominator are the poles, where it blows up. The LTI System/ scripts build these objects in SciPy:
H1 = signal.TransferFunction([1, 3, 3], [1, 2, 1]) # (s² + 3s + 3) / (s + 1)²
simple_lti = signal.ZerosPolesGain([1, 2], [3, 4], 5) # zeros 1, 2; poles 3, 4; gain 5
s1 = signal.lti([], [1, 1, 1], [5]) # three arguments: zeros, poles, gain
The last line is easy to misread: with three arguments lti means zeros, poles and gain, so this is \(H(s) = 5/(s-1)^3\) — a triple pole at \(s = +1\). It is the example from SciPy’s freqresp documentation and it is unstable, as are the poles at 3 and 4 of simple_lti: a continuous-time system is stable only when every pole has a negative real part, a discrete-time one only when every pole lies inside the unit circle.
The landscape over the z-plane
Here is the picture that makes all of this click. Plot \(20\log_{10}\vert H(z)\vert\) as a height over the complex plane. Every pole is a spike, every zero a pit. Frequency lives on the unit circle, \(z = e^{i\omega}\): DC at \(z = 1\), Nyquist at \(z = -1\). The frequency response is the height of the landscape along that circle.
That explains the Butterworth design at a glance: poles clustered near the DC end hold the passband up, zeros at Nyquist pull the stopband down, and the closer the poles creep to the circle, the sharper the edge. For order 4 at a cutoff of 0.2 × Nyquist the largest pole radius is 0.795 and the response falls from −3 dB at the cutoff to −39 dB at 0.5 × Nyquist.
Four classic designs
The IIR/ scripts design the classic families — as analog prototypes (analog=True, plotted with freqs). Leaving out analog=True gives the digital version via the bilinear transform, which is what these curves show:
8_butterworth_impl.py puts one to work: a band-pass from 500 to 1250 Hz at \(f_s = 5\) kHz, applied with lfilter, for orders 3, 5, 6 and 9. One habit worth adopting: high-order filters are better kept as second-order sections, butter(..., output='sos') with sosfilt. The order-9 band-pass has 19 denominator coefficients; here the (b, a) form still agrees with the SOS form to \(5 \times 10^{-11}\), but at higher orders or narrower bands the polynomial coefficients lose precision and the filter can turn unstable.
Two small notes on the folder: IIR/1_freq_res.py designs an FIR filter (firwin with a Kaiser window), not an IIR one; and LTI System/6_lti_example.py labels the Bode plot’s axis “Frequency (Hz)”, but signal.bode returns rad/s.
Try it yourself. Design signal.butter(4, 0.2, output='zpk'), plot the poles and zeros with the unit circle, then move one pole to radius 1.01 and filter a step with lfilter. Watch the output grow without bound — the landscape’s spike has crossed onto the circle.