The plan
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.
From trapezoids to a map
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.
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.
What the map does
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.
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.
Design the filter
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.
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.
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.
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.
Check it
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.
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.
The working
# step 1/11 · goal 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
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). 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".