IIR design with the bilinear transform
About this lesson
Turn a proven analog filter into a digital one. Replacing each integrator by the trapezoid rule gives the bilinear map s = (2/T)(z − 1)/(z + 1). It sends the jΩ axis once around the unit circle and keeps stable filters stable, but it squeezes frequency: ω = 2·atan(ΩT/2). Follow one design end to end: a 2nd-order Butterworth lowpass, cutoff 1000 Hz at fs = 8000 Hz. Prewarp the cutoff to 6627.4 rad/s, substitute, and get b = [0.0976, 0.1953, 0.0976], a = [1, −0.9428, 0.3333], exactly what scipy.signal.butter returns.
The order: a digital lowpass
We want a digital lowpass filter: keep tones below 1000 Hz, cut those above, for audio sampled at 8000 Hz. Plan: borrow a proven analog design, a 2nd-order Butterworth, and translate it from s into z.
wanted lowpass, cutoff fc = 1000 Hz (−3 dB) sampled fs = 8000 Hz, T = 1/fs = 125 µs analog designs are solved and tabled: Butterworth order 2 (previous lesson) Ha(s) = Ωc² / (s² + √2·Ωc·s + Ωc²) IIR = infinite impulse response: the output feeds back, like the analog filter's capacitors remember
Read the lesson step by step
The order: a digital lowpass
We want a digital lowpass filter: keep tones below 1000 Hz, cut those above, for audio sampled at 8000 Hz. Plan: borrow a proven analog design, a 2nd-order Butterworth, and translate it from s into z.
wanted lowpass, cutoff fc = 1000 Hz (−3 dB) sampled fs = 8000 Hz, T = 1/fs = 125 µs analog designs are solved and tabled: Butterworth order 2 (previous lesson) Ha(s) = Ωc² / (s² + √2·Ωc·s + Ωc²) IIR = infinite impulse response: the output feeds back, like the analog filter's capacitors rememberIntegrate with trapezoids
An analog filter is built from integrators, 1/s. With only samples, a computer integrates by adding trapezoids: each step adds T/2 × (x[n] + x[n−1]). Eight trapezoids give 0.628; the true area is 0.637.
integrator: y(t) = ∫ x dt (transfer 1/s) trapezoid rule, one step of width T: y[n] = y[n−1] + (T/2)·(x[n] + x[n−1]) example x(t) = sin(π·t / 1 ms) volts T = 0.125 ms, 8 steps to 1 ms sum = 0.628 V·ms exact = 2/π = 0.637 V·msTrapezoids give the bilinear map
Take the z-transform of the trapezoid rule: 1/s becomes (T/2)(1 + z⁻¹)/(1 − z⁻¹). Flip it: s = (2/T)(z − 1)/(z + 1). Put this in for every s in H(s) and the filter order stays 2.
y[n] − y[n−1] = (T/2)(x[n] + x[n−1]) Y(z)(1 − z⁻¹) = (T/2) X(z)(1 + z⁻¹) Y/X = (T/2)·(1 + z⁻¹)/(1 − z⁻¹) ≈ 1/s so s = (2/T)·(z − 1)/(z + 1) 2/T = 2·fs = 16000 per second ratio of two first-order terms in z: "bilinear". A 2nd-order H(s) stays a 2nd-order H(z).The jΩ axis lands on the unit circle
Solve for z: z = (1 + sT/2)/(1 − sT/2). For s = jΩ, top and bottom have the same size, so |z| = 1. The left half-plane lands inside the circle: a stable analog filter stays stable.
z = (1 + sT/2) / (1 − sT/2) s = jΩ: |1 + jΩT/2| = |1 − jΩT/2| so |z| = 1 (on the unit circle) s = σ + jΩ with σ < 0 (left half): |1 + sT/2| < |1 − sT/2| so |z| < 1 (inside) stable in s -> stable in z the dot climbs jΩ; its image goes roundFrequency warping
The whole infinite jΩ axis must fit once around the circle, so frequencies get squeezed: ω = 2·atan(ΩT/2). Low ones barely move; 10 kHz analog lands at 3365 Hz. Infinity lands at 4000 Hz, z = −1.
on the circle z = e^(jω), and ω = 2·atan(ΩT/2) (rad per sample) Ω = (2/T)·tan(ω/2) analog digital 100 Hz -> 99.9 Hz 1000 Hz -> 952.9 Hz 10000 Hz -> 3365 Hz ∞ -> 4000 Hz (z = −1) no aliasing: each Ω lands oncePrewarp the cutoff
Warping would pull a 1000 Hz analog cutoff down to 952.9 Hz. So aim high on purpose: Ωc = (2/T)·tan(ωc/2) = 16000·tan(π/8) = 6627.4 rad/s, that is 1054.8 Hz. The map warps it to exactly 1000 Hz.
ωc = 2π·fc/fs = 2π·1000/8000 = π/4 Ωc = (2/T)·tan(ωc/2) = 16000 × tan(π/8) = 16000 × 0.41421 = 6627.4 rad/s (1054.8 Hz) not prewarped: Ωc = 2π·1000 = 6283.2 -> digital cutoff 952.9 Hz (too low)The analog prototype
Butterworth order 2 with Ωc = 6627.4 rad/s: Ha(s) = Ωc²/(s² + √2·Ωc·s + Ωc²). Its poles sit on a circle of radius Ωc at ±135°: s = −4686 ± j4686 per second, both in the left half.
Ha(s) = Ωc² / (s² + √2·Ωc·s + Ωc²) Ωc = 6627.4 rad/s poles: s = Ωc·e^(±j135°) = −4686 ± j4686 (1/s) |Ha| at Ωc = 1/√2 (−3 dB) flat pass band, no ripple (Butterworth: previous lesson)Substitute and collect
Put s = (2/T)(z − 1)/(z + 1) into Ha(s) and tidy into powers of z⁻¹. With K = tan(π/8) = 0.41421, five numbers come out: b = 0.0976, 0.1953, 0.0976 and a1 = −0.9428, a2 = 0.3333.
K = Ωc·T/2 = tan(π/8) = 0.41421 D = 1 + √2·K + K² = 1.7574 b0 = b2 = K²/D = 0.0976 b1 = 2K²/D = 0.1953 a1 = 2(K² − 1)/D = −0.9428 a2 = (1 − √2K + K²)/D = 0.3333 y[n] = 0.0976x[n] + 0.1953x[n−1] + 0.0976x[n−2] + 0.9428y[n−1] − 0.3333y[n−2]Poles and zeros move over
Each analog pole maps by z = (1 + sT/2)/(1 − sT/2) to 0.4714 ± j0.3333, radius 0.5774: inside the circle, stable. The two zeros at s = ∞ land on z = −1, so the gain is exactly 0 at 4000 Hz.
s = −4686 + j4686 sT/2 = −0.2929 + j0.2929 z = (0.7071 + j0.2929)/(1.2929 − j0.2929) = 0.4714 + j0.3333 |z| = 0.5774 < 1 stable zeros: Ha(s) -> 0 as s -> ∞ (twice) ∞ maps to z = −1 (double zero) numerator (1 + z⁻¹)² = 1 + 2z⁻¹ + z⁻² -> b is K²/D × [1, 2, 1]Check the response
Sweep the digital filter from 0 to 4000 Hz. At 1000 Hz the gain is 0.7071 (−3.01 dB), just as ordered. Near 4000 Hz it falls faster than the analog prototype, because warping squeezes its tail onto z = −1.
|H(e^jω)| at 1000 Hz = 0.7071 (−3.01 dB) |H(e^jω)| at 4000 Hz = 0 (z = −1) analog |Ha| at 4000 Hz = 0.0694 digital: 0, the tail is folded onto the zero at z = −1 pass band: the same Butterworth shape with the cutoff exactly at 1000 HzThe same in Python
SciPy does the substitution: signal.bilinear uses s = 2·fs·(z − 1)/(z + 1) but does no prewarping, so we prewarp W first. The result matches signal.butter(2, 1000, fs=8000) to every digit.
import numpy as np from scipy.signal import bilinear fs, fc = 8000, 1000 W = 2*fs*np.tan(np.pi*fc/fs) den = [1, np.sqrt(2)*W, W**2] b, a = bilinear([W**2], den, fs) >>> b.round(4), a.round(4) ([0.0976, 0.1953, 0.0976], [1., −0.9428, 0.3333]) >>> signal.butter(2, 1000, fs=8000) (the same b and a) (Python 3, numpy, scipy; checked with SciPy 1.18.1)
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01Which numerical rule turns the integrator 1/s into (T/2)(1 + z⁻¹)/(1 − z⁻¹), and so gives the bilinear transform?
The trapezoid rule adds (T/2)(x[n] + x[n−1]) each step: y[n] − y[n−1] = (T/2)(x[n] + x[n−1]). Its z-transform is (T/2)(1 + z⁻¹)/(1 − z⁻¹). Flipping that gives s = (2/T)(z − 1)/(z + 1).
02With fs = 8000 Hz, where does an analog frequency of 10 kHz land after the bilinear transform (no prewarping)?
fd = (fs/π)·atan(π·fa/fs) = (8000/π)·atan(3.927) ≈ 3365 Hz. The bilinear transform never aliases: it squeezes the whole analog axis into 0 to fs/2. Only an infinite analog frequency reaches 4000 Hz (z = −1).
03You want a digital cutoff of 1000 Hz at fs = 8000 Hz. Which analog cutoff should the prototype have?
Prewarp: Ωc = (2/T)·tan(ωc/2) with ωc = 2π·1000/8000 = π/4, so Ωc = 16000·tan(π/8) = 6627.4 rad/s (1054.8 Hz). Using 2π·1000 instead puts the digital cutoff at 952.9 Hz.
04An analog pole sits at s = −4686 + j4686 per second, T = 125 µs. Is the digital pole the bilinear transform gives stable?
z = (1 + sT/2)/(1 − sT/2) = (0.7071 + j0.2929)/(1.2929 − j0.2929) = 0.4714 + j0.3333. Every left-half-plane pole maps inside the unit circle, so a stable analog filter always gives a stable digital one.
05Why does the bilinear-transformed Butterworth lowpass have exactly zero gain at fs/2?
Ha(s) → 0 twice as s → ∞, so it has two zeros at infinity. The map sends s = ∞ to z = −1, which is e^(jπ), the frequency fs/2. The numerator becomes (1 + z⁻¹)², so b is proportional to [1, 2, 1].
Glossary
- IIR filter
- Infinite impulse response filter: its output feeds back (the a coefficients), so one impulse rings on forever, decaying. Analog filter designs translate naturally into IIR filters.
- Bilinear transform
- The substitution s = (2/T)(z − 1)/(z + 1), a ratio of two first-order terms in z. It turns an analog transfer function H(s) into a digital H(z) of the same order.
- Trapezoid rule
- Integrate by adding trapezoids: each step of width T adds (T/2) times the sum of the two end values. Also called Tustin's method in control.
- Frequency warping
- The bilinear transform's squeeze of the analog frequency axis onto 0 to fs/2: ω = 2·atan(ΩT/2). Nearly exact at low frequency, strong near fs/2.
- Prewarping
- Choosing the analog design frequency as Ω = (2/T)·tan(ω/2), so that after warping the digital filter hits the wanted frequency ω exactly.
- Analog prototype
- A standard analog filter (Butterworth, Chebyshev ...) whose shape we copy into the digital design.
- Unit circle
- The points |z| = 1 in the z-plane, z = e^(jω). The frequency response of a digital filter is H(z) on this circle; poles inside it mean a stable filter.
Notes and sources
- The order (cutoff 1000 Hz, fs = 8000 Hz, Butterworth order 2) is a chosen example. Every number in the figure is computed from this model and was checked against SciPy 1.18.1 (scipy.signal.bilinear and scipy.signal.butter).
- The moving dots trace real points of the map: the s-plane dot climbs the jΩ axis and its image is z = (1 + sT/2)/(1 − sT/2).
- Euler versus Tustin for controllers uses this same derivation (Control: "Discretising a controller: Euler versus Tustin"); z = e^(sT) for sampling is in "From the s-plane to the z-plane"; Bode plots are in Circuits, "Transfer functions and Bode plots".
- A. V. Oppenheim, R. W. Schafer, J. R. Buck, Discrete-Time Signal Processing, 2nd ed. (§7.1: IIR design by the bilinear transformation), the course text listed on MIT OCW 6.341 readings
- MIT OpenCourseWare 6.341 Discrete-Time Signal Processing (A. V. Oppenheim): design of recursive (IIR) and non-recursive (FIR) filters
- MIT OpenCourseWare 6.003 Signals and Systems (D. Freeman, Fall 2011)
- J. O. Smith III, Physical Audio Signal Processing, "Bilinear Transformation" (CCRMA, Stanford): left half-plane to inside the circle, jω axis mapped once round it, warping
- Bilinear transform (Wikipedia): trapezoidal rule, frequency warping and prewarping
- Trapezoidal rule (Wikipedia): the one-step trapezoid area ½(b − a)(f(a) + f(b))
- SciPy documentation: scipy.signal.bilinear (s = 2·fs·(z − 1)/(z + 1), no prewarping)
- SciPy documentation: scipy.signal.butter
- NumPy documentation: numpy.tan (angles in radians)
Quiz Unlocks after the last step.