x[n]1DELAY 10×0.9DELAY 20×−0.81y[0]–y[1]–y[2]–y[3]–y[4]–y[5]–1from scipy import signal2b, a = [1], [1, -0.9, 0.81]3x = [1, 0, 0, 0, 0, 0]4y = signal.lfilter(b, a, x)5print(y.round(4))000000000000
0122436-2-1012n (sample number)h[n]IMPULSE RESPONSE h[n]period 6 · ×0.9 eachgrows ×1.05 per sampleFIR: 44 taps|h| < 0.01 after n = 43same as lfilter-2-1012-101real partimag. partz-PLANE260°× poles 0.9·e^(±jπ/3)× poles 1.05: outside the circle0π/32π/3π0246ω (rad per sample) · π = half the sample rate|H|GAIN |H(e^jω)|peak 6.08 at ω ≈ 0.332πsignal.freqz(b, a)
Coloured parts: what the current step is about; everything else rests in whiteBlocks: input x[n], the adder, output cells y[n], two delay boxes, two multipliers and a Python code cardPlots: impulse response h[n], the z-plane with the poles, and the gain |H| against frequencyValue tokens ride the wires one sample at a time; each delay box shows the number it remembersThe filter y[n] = x[n] + 0.9·y[n−1] − 0.81·y[n−2] runs from rest on an impulse: the output rings 1, 0.9, 0, −0.729, −0.6561, 0 … with poles at 0.9·e^(±jπ/3). scipy.signal.lfilter and most books put every output term on the left: y[n] − 0.9·y[n−1] + 0.81·y[n−2] = x[n]. That is why a = [1, −0.9, 0.81] holds −0.9 for a feedback weight of +0.9.

A filter with feedback

  1. 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

Poles and the peak

Stability and cost

In code

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.