4.1 Why IIR
You want a sharp low-pass with cutoff at kHz and stopband attenuation 60 dB at kHz, sample rate 8 kHz. You can do it with an FIR (Section 5) of about 100 taps, or an IIR (Section 4) of order 8 (about 8 multiplies per output for a cascade of biquads). The IIR is roughly less computation.
That is the IIR's selling point: same magnitude response, much lower order. The price: nonlinear phase, potential stability concerns, and higher coefficient sensitivity. For applications where shape, not phase, matters (RF preselection, analog-style audio EQ, control-loop compensators), IIR wins. For applications where phase matters (audio crossovers, image processing, communications equalization), FIR is preferred.
4.2 The standard recipe: design analog, transform to digital
The classical IIR design path:
- Translate digital specs into equivalent analog specs (handling frequency warp, depending on transformation).
- Design an analog prototype filter of the desired type (Butterworth, Chebyshev, elliptic, Bessel) of the right order.
- Apply an analog-to-digital transformation (impulse invariance or bilinear) to map the analog into a digital .
- Verify that the digital meets the original specs; iterate if not.
- Choose a structure (cascade of biquads is almost always the right choice).
The analog-prototype shortcut works because the analog filter design problem has been beautifully solved for decades: closed-form formulas exist for the pole-zero locations of Butterworth, Chebyshev, and elliptic filters, all sitting in canonical forms. Don't reinvent that work; transform to digital.
4.3 Analog filter types: Butterworth, Chebyshev, elliptic, Bessel
Each analog prototype trades off ripple, transition steepness, and phase response.
Butterworth. Maximally flat magnitude response in the passband (every derivative of at is zero), monotone falloff in the stopband.
For order , the falloff is dB/decade above the cutoff. Pole locations: equally spaced on a circle of radius in the left half-plane. Smooth, well-behaved, the default for general-purpose use. Audio EQ, control compensators, and sensor anti-aliasing typically use Butterworths.
Chebyshev type I. Allows ripple of magnitude in the passband to get a sharper transition than Butterworth of the same order. Stopband is monotone. Sharper rolloff for given order, at the cost of in-band ripple. Used where stopband attenuation matters more than passband flatness.
Chebyshev type II (inverse Chebyshev). Ripple in the stopband, smooth passband. Sharper transition than Butterworth. Used where you want a flat passband but sharp transition.
Elliptic (Cauer) filter. Ripple in both passband and stopband. Achieves the sharpest possible transition for a given filter order. The formula involves Jacobi elliptic functions; not closed-form, but tabulated and built into every design tool. Used where you must squeeze every dB of transition steepness from minimum order, e.g., in CD-audio anti-imaging filters of yesteryear.
Bessel. Designed for maximally flat group delay (linear phase) in the passband. Magnitude rolloff is gentle (worst of the four), but the pulse response is the cleanest, with no overshoot and minimal ringing. Used in pulse-shaping for digital communications, oscilloscope analog front ends (you want the scope's filter to not distort pulse edges), and audio crossovers where transient response matters.
A summary picture of the trade-offs:
| Filter | Passband | Stopband | Phase | When to use |
|---|---|---|---|---|
| Butterworth | flat | monotone | bowed | general-purpose |
| Cheby I | ripple | monotone | bowed | sharp rolloff, ripple OK |
| Cheby II | flat | ripple | bowed | flat passband, sharp transition |
| Elliptic | ripple | ripple | bowed | sharpest possible transition |
| Bessel | flat | gentle | linear | preserve pulse shape |
4.4 The bilinear transform, derived
The bilinear transform is the standard analog-to-digital mapping. Given an analog , the digital filter is
i.e., substitute everywhere appears.
Where does this come from? Trapezoidal integration of . Recall that an integrator in the analog world has . In discrete time, the trapezoidal rule for integration of a sequence is
Take the Z-transform:
Compare to the analog integrator . So the trapezoidal-rule digital integrator approximates by , i.e., is approximated by . That is the bilinear transform, derived from the trapezoidal rule.
Properties of the bilinear transform:
- Maps the entire -axis (the analog frequency axis) to the unit circle (the digital frequency axis), one-to-one. So no aliasing: every analog frequency is uniquely represented in the digital filter, no overlap.
- Maps the left half-plane (stable analog) to the inside of the unit circle (stable digital). So a stable analog prototype always becomes a stable digital filter.
- Distorts the frequency axis: this is frequency warping. The relation between analog frequency and digital frequency is
For small (low frequencies), (linear). At (Nyquist), . The whole infinite analog axis squished into the finite digital range.
Rubber-band analogy. Imagine the infinite analog frequency axis as an infinitely long rubber band. The bilinear transform stretches and squishes it nonlinearly to fit on the finite unit circle: low frequencies are barely warped, high frequencies are bent more and more aggressively as they approach the digital Nyquist. Filter shape (e.g., the relative slope of the transition) is preserved if you account for the warping by prewarping your specs.
Prewarping means: if you want digital cutoff , design analog prototype with cutoff before the bilinear transform. Then the bilinear transform places the digital cutoff exactly where you wanted it.
4.5 Impulse invariance, the alternative
Rather than the bilinear transform, you can use impulse invariance: sample the analog impulse response.
This causes the digital filter's impulse response to be a sampled version of the analog's. It maps poles via (each analog pole at becomes a digital pole at ).
Drawback: aliasing. If the analog filter's frequency response extends above , those high-frequency tails fold back into the digital passband. Most useful for low-pass filters where the analog response decays well before . Used historically and in some specific applications (Bessel filter approximation, where bilinear-transform's frequency warping would distort the all-important phase response).
Bilinear transform is the default for almost everything. Impulse invariance is an option to remember exists.
4.6 Frequency transformations: lowpass to highpass / bandpass / bandstop
You designed a digital lowpass. To get other types:
- LP → HP. Substitute in . Equivalently, in the analog prototype before bilinear transform, substitute .
- LP → BP. Substitute where is band center and is bandwidth. This doubles the order.
- LP → BS (band-stop). Substitute . Also doubles order.
All available as one-line calls in scipy.signal.
4.7 IIR design in code
The fastest way to design an IIR is in scipy.signal:
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
fs = 8000 # sample rate, Hz
fc = 1500 # passband edge
fstop = 2000 # stopband edge
gpass = 1.0 # passband ripple, dB
gstop = 40.0 # stopband attenuation, dB
# Compute order and natural frequency for Chebyshev-I
N, Wn = signal.cheb1ord(fc/(fs/2), fstop/(fs/2), gpass, gstop)
print(f"Cheby-I order: {N}")
# Design as second-order sections (cascade of biquads)
sos = signal.cheby1(N, gpass, Wn, btype='low', output='sos')
# Plot magnitude response
w, h = signal.sosfreqz(sos, worN=2048, fs=fs)
plt.semilogx(w, 20*np.log10(np.abs(h)))
plt.xlabel('Frequency (Hz)'); plt.ylabel('Magnitude (dB)')
plt.grid(True, which='both'); plt.show()
# Filter a real signal
x = np.random.randn(10000)
y = signal.sosfilt(sos, x)sos is a array, one row per biquad (numerator coefficients, then denominator). sosfilt runs them in cascade with proper internal scaling. This is what production audio engines look like under the hood.
For Butterworth, replace cheb1ord and cheby1 with buttord and butter. For elliptic: ellipord, ellip. For Bessel (which doesn't have a fixed-order specification; you choose order to balance flatness against rolloff): bessel.