A filter with feedback
An IIR filter feeds its own past outputs back in. Ours: y[n] = x[n] + 0.9·y[n−1] − 0.81·y[n−2]. Two delay boxes remember the last two outputs; two multipliers weight them; the adder sums everything.
An impulse goes round the loop
Feed in an impulse: a single 1, then zeros. Both delays start at 0 (initial rest), so the feedback adds nothing yet. y[0] = 1 + 0 − 0 = 1. Then the delays shift: delay 1 now holds 1.
Now x[1] = 0, but delay 1 returns y[0] = 1, and 0.9 × 1 = 0.9. Delay 2 still holds 0. So y[1] = 0 + 0.9 − 0 = 0.9. No input, yet output: the feedback carries it.
Delay 1 gives 0.9 and delay 2 gives the old 1. y[2] = 0.9 × 0.9 − 0.81 × 1 = 0.81 − 0.81 = 0. The push from one path and the pull from the other cancel exactly.
Keep ticking: −0.729, −0.6561, 0, then 0.5314, 0.4783, 0. The output swings down and up again every 6 samples, and the swing shrinks by a factor of 0.9 every sample. It never quite stops.
Poles and the peak
The feedback weights fix the poles. H(z) = 1 / (1 − 0.9z⁻¹ + 0.81z⁻²), and the bottom is zero at z = 0.9·e^(±jπ/3). Radius 0.9 is the shrink per sample; angle π/3 (60°) gives one swing every 6 samples.
A filter that rings at a frequency passes that frequency best. The gain peaks at 6.08 near ω = π/3, a sixth of the sample rate. It is only 1.1 at ω = 0 and 0.37 at ω = π.
Stability and cost
Push the poles out to radius 1.05: weights 1.05 and −1.1025. Now the response grows 1.05 times every sample: 1, 1.05, 0, −1.158, −1.216 … and it grows forever. Poles outside the unit circle make a feedback filter unstable.
An FIR copy of this response needs 44 taps before every dropped sample is under 1% of the first. The IIR does it with 2 multiplies and 2 stored numbers. The price: its delay depends on frequency, so its phase is not linear.
In code
In Python 3 with scipy, lfilter(b, a, x) runs this loop. a = [1, −0.9, 0.81] holds the feedback weights with their signs flipped, because scipy writes every y term on the left. It prints 1, 0.9, 0, −0.729, −0.6561, 0.
The working
# step 1/10 · loop
y[n] = x[n] + 0.9·y[n−1] − 0.81·y[n−2]
x[n] the input, sample n
y[n−1] the output one sample ago (delay 1)
y[n−2] the output two samples ago (delay 2)
per sample: 2 multiplies, 2 adds,
2 stored numbers
IIR = infinite impulse response:
the feedback keeps old outputs alive
The pole radius 0.9 and angle 60° are chosen so the feedback weights are short exact numbers (0.9 and 0.81) and the ring repeats every 6 samples. Every value in the figure is computed from this model and was checked against scipy 1.13. numpy prints "-0." for y[2] and y[5] because 0.9 × 0.9 is not exactly 0.81 in binary floating point; the leftover is about 1e-17. In fixed-point hardware such leftovers can circulate in the loop, a topic for the fixed-point lesson.