Transfer functions H(z)
About this lesson
A transfer function H(z) is one formula that captures a whole digital system. Take the filter y[n] = 0.5·y[n−1] + 0.25·x[n] + 0.25·x[n−1], watch its impulse response come out as 1/4, 3/8, 3/16, 3/32 ..., then turn every delay into z⁻¹ and solve for H(z) = Y(z)/X(z) = 0.25(z + 1)/(z − 0.5). You will find its zero and pole, see that H(z) is the Z-transform of h[n], and walk a point around the unit circle to get the frequency response of a low-pass filter. It builds on "The Z-transform and its region of convergence" and "The inverse Z-transform with partial fractions"; the continuous-time version is in the Circuits lessons on the Laplace transform and on transfer functions and Bode plots.
A filter drawn as blocks
Our filter follows y[n] = 0.5·y[n−1] + 0.25·x[n] + 0.25·x[n−1]. Two delay boxes remember the last input and the last output. Three weights scale the values, and the adder sums them into the new output.
y[n] = 0.5·y[n−1] + 0.25·x[n] + 0.25·x[n−1]
x[n] input, sample number n
y[n] output, sample number n
x[n−1] the input one sample ago (input delay)
y[n−1] the output one sample ago (output delay)
weights: 0.25 and 0.25 on the inputs
0.5 on the old output (feedback)
start at rest: both delays hold 0Read the lesson step by step
A filter drawn as blocks
Our filter follows y[n] = 0.5·y[n−1] + 0.25·x[n] + 0.25·x[n−1]. Two delay boxes remember the last input and the last output. Three weights scale the values, and the adder sums them into the new output.
y[n] = 0.5·y[n−1] + 0.25·x[n] + 0.25·x[n−1] x[n] input, sample number n y[n] output, sample number n x[n−1] the input one sample ago (input delay) y[n−1] the output one sample ago (output delay) weights: 0.25 and 0.25 on the inputs 0.5 on the old output (feedback) start at rest: both delays hold 0Feed in one impulse
Send in a single 1, then zeros: the impulse δ[n]. Out come 1/4, 3/8, 3/16, 3/32 ... This list is the impulse response h[n]. It describes the system completely, but it never ends.
input δ[n] = 1, 0, 0, 0 ... n 0.25·x[n] 0.25·x[n−1] 0.5·y[n−1] y[n] 0 1/4 0 0 1/4 1 0 1/4 1/8 3/8 2 0 0 3/16 3/16 3 0 0 3/32 3/32 as decimals: 0.25, 0.375, 0.1875, 0.09375 ... so h[n] = 0.25, 0.375, 0.1875, 0.09375 ...A delay is a multiply by z⁻¹
The Z-transform turns a list x[n] into a function X(z). Its shift rule says x[n−1] becomes z⁻¹X(z). So each delay box is simply "multiply by z⁻¹". That is why books label delays z⁻¹.
Z-transform: X(z) = Σ x[n]·z⁻ⁿ shift rule (one sample later): x[n−1] <-> z⁻¹·X(z) y[n−1] <-> z⁻¹·Y(z) z is a complex number; z⁻¹ = 1/z a delay in time = multiply by z⁻¹ (the Z-transform itself: lesson "The Z-transform and its region of convergence")Transform every term
Apply the Z-transform to both sides. Each list becomes a function of z, each delay becomes z⁻¹, and the weights stay as they are: Y = 0.5z⁻¹Y + 0.25X + 0.25z⁻¹X. No more sample-by-sample loop.
time: y[n] = 0.5·y[n−1] + 0.25·x[n] + 0.25·x[n−1] z: Y(z) = 0.5·z⁻¹Y(z) + 0.25·X(z) + 0.25·z⁻¹X(z) the transform is linear: weights pass straight through sums stay sums each delay -> one factor z⁻¹Divide: H(z) = Y(z)/X(z)
Move the Y terms left and factor: (1 − 0.5z⁻¹)Y = 0.25(1 + z⁻¹)X. Divide output by input. The ratio H(z) = 0.25(1 + z⁻¹)/(1 − 0.5z⁻¹) is the transfer function. It no longer depends on the input.
Y − 0.5z⁻¹Y = 0.25X + 0.25z⁻¹X (1 − 0.5z⁻¹)·Y = 0.25(1 + z⁻¹)·X Y(z) 0.25 + 0.25z⁻¹ H(z) = ------ = -------------- X(z) 1 − 0.5z⁻¹ top: the input weights b = [0.25, 0.25] bottom: 1, then minus the feedback a = [1, −0.5] for ANY input: Y(z) = H(z)·X(z)H(z) is the transform of h[n]
For the impulse, X(z) = 1, so Y(z) = H(z): the transfer function is the Z-transform of h[n]. Partial fractions give back h[0] = 1/4 and h[n] = 0.75·0.5ⁿ: 3/8, 3/16, 3/32, as the cells show.
δ[n] <-> 1, so Y(z) = H(z)·1 = H(z) partial fractions (previous lesson): H(z) = 0.25(1 + z⁻¹)/(1 − 0.5z⁻¹) = −0.5 + 0.75/(1 − 0.5z⁻¹) h[n] = −0.5·δ[n] + 0.75·0.5ⁿ·u[n] h[0] = −0.5 + 0.75 = 0.25 h[1] = 0.375 h[2] = 0.1875 h[3] = 0.09375 convolution y = h * x becomes Y = H·XOne zero, one pole
Multiply top and bottom by z: H(z) = 0.25(z + 1)/(z − 0.5). The top is 0 at z = −1: a zero. The bottom is 0 at z = 0.5: a pole, where H grows without limit. Plot them on the z-plane.
H(z) = 0.25(1 + z⁻¹)/(1 − 0.5z⁻¹) × z/z = 0.25(z + 1)/(z − 0.5) zero: z + 1 = 0 -> z = −1 (drawn o) pole: z − 0.5 = 0 -> z = 0.5 (drawn ×) gain: 0.25 z-plane: real part across, imaginary part up dashed circle: |z| = 1, the unit circleThe pole is the feedback
The pole 0.5 is the feedback weight. After n = 1 each output is 0.5 times the last: 3/8, 3/16, 3/32. The pole sits inside the unit circle (|0.5| < 1), so the response dies away: the filter is stable.
h[n] = 0.75·0.5ⁿ for n ≥ 1 ratio of neighbours: h[2]/h[1] = 0.1875/0.375 = 0.5 h[3]/h[2] = 0.09375/0.1875 = 0.5 = the pole |pole| < 1 -> h[n] shrinks -> stable |pole| > 1 -> h[n] grows -> unstable (more in "Stability and the unit circle")Walk around the unit circle
Put z = e^jω, a point on the unit circle at angle ω. Then H(e^jω) is the frequency response. Its size is 0.25 × (distance to the zero) ÷ (distance to the pole). From ω = 0 to π it falls from 1 to 0.
z = e^jω = cos ω + j·sin ω, |z| = 1 ω in radians per sample, 0 .. π |H(e^jω)| = 0.25 · |e^jω + 1| / |e^jω − 0.5| = 0.25 · (to the zero) / (to the pole) ω = 0: 0.25 × 2 / 0.5 = 1.000 ω = π: 0.25 × 0 / 1.5 = 0 allowed because the ROC |z| > 0.5 contains the unit circleLow frequencies pass
At ω = π/2 the distances are 1.414 and 1.118, so |H| = 0.25 × 1.414 ÷ 1.118 = 0.316. Near the pole the gain is high; at the zero it is 0. Slow wiggles pass, fast ones are blocked: a low-pass filter.
ω = π/2: z = j to the zero: |j + 1| = √2 = 1.414 to the pole: |j − 0.5| = √1.25 = 1.118 |H| = 0.25 × 1.414 / 1.118 = 0.316 = -10.0 dB half power (|H|² = 1/2): cos ω = 0.8, ω = 0.644 rad/sample same idea as H(s) and Bode plots in Circuits, "Transfer functions and Bode plots"In Python: tf2zpk and freqz
In Python 3 with scipy, b and a are the top and bottom of H(z). signal.tf2zpk finds the zero −1 and pole 0.5, signal.freqz computes H(e^jω), and signal.lfilter runs the filter, giving h[n] again.
from scipy import signal b, a = [0.25, 0.25], [1, -0.5] z, p, k = signal.tf2zpk(b, a) w, H = signal.freqz(b, a) h = signal.lfilter(b,a,[1,0,0,0]) >>> z, p, k (array([-1.]), array([0.5]), np.float64(0.25)) >>> len(w), abs(H[0]), abs(H[256]).round(3) (512, 1.0, 0.316) # w[256] = π/2 >>> h array([0.25 , 0.375 , 0.1875 , 0.09375]) freqz: 512 points on [0, π) by default
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01A system runs y[n] = 0.8·y[n−1] + x[n]. What is its transfer function H(z)?
Transform both sides: Y = 0.8z⁻¹Y + X. Then (1 − 0.8z⁻¹)Y = X, so H(z) = Y/X = 1/(1 − 0.8z⁻¹).
02Why does a delay box become a factor z⁻¹ in H(z)?
The Z-transform of a list delayed by one sample is z⁻¹ times the transform of the original list. So 'delay by one sample' and 'multiply by z⁻¹' are the same operation.
03H(z) = 0.25(z + 1)/(z − 0.5). Where are its zero and pole?
The numerator z + 1 is 0 at z = −1 (the zero). The denominator z − 0.5 is 0 at z = 0.5 (the pole).
04For our filter, what is |H(e^jω)| at ω = 0, the lowest frequency?
At ω = 0, z = 1. The distance to the zero at −1 is 2, to the pole at 0.5 it is 0.5, so |H| = 0.25 × 2 / 0.5 = 1. A constant input comes out unchanged.
05If the input to a system is the impulse δ[n], what is Y(z)?
The Z-transform of δ[n] is 1, so Y(z) = H(z)·1 = H(z). That is why H(z) is the Z-transform of the impulse response h[n].
Glossary
- Transfer function H(z)
- The ratio Y(z)/X(z) of the output and input Z-transforms of a linear time-invariant system. It is also the Z-transform of the impulse response. Also called the system function.
- z⁻¹
- A one-sample delay written in the z-domain: x[n−1] has Z-transform z⁻¹X(z).
- Zero
- A value of z where H(z) is 0 (the numerator is 0). Drawn as o on the z-plane.
- Pole
- A value of z where the denominator of H(z) is 0, so H(z) grows without limit. Drawn as × on the z-plane.
- z-plane
- A flat map of complex numbers z: real part across, imaginary part up. Poles and zeros are drawn on it.
- Unit circle
- The circle |z| = 1 on the z-plane. Its points are z = e^jω, one for each frequency ω.
- Frequency response
- H(e^jω): the transfer function on the unit circle. Its size says how much a sine wave at frequency ω is scaled.
Notes and sources
- The weights 0.25, 0.25 and 0.5 are chosen so every impulse-response value is a short exact fraction and the gain at ω = 0 is exactly 1. Every number in the figure is computed from this model; the Python output was checked with scipy 1.18.
- H(z) here is causal with region of convergence |z| > 0.5. Because that region contains the unit circle, the frequency response is H(z) evaluated at z = e^jω (Oppenheim and Schafer, ch. 5).
- H(z) is the discrete-time twin of H(s): the Circuits lessons "Circuit analysis with the Laplace transform" and "Transfer functions and Bode plots" do the same for circuits, with the jω axis playing the part of the unit circle.
- A. V. Oppenheim, A. S. Willsky, S. H. Nawab, Signals and Systems, 2nd ed., Pearson (ch. 10: the Z-transform, LTI systems and the system function, block diagrams)
- A. V. Oppenheim, R. W. Schafer, J. R. Buck, Discrete-Time Signal Processing, 2nd ed., chs. 3 and 5 (course text listed on MIT OCW 6.341 readings)
- MIT OpenCourseWare 6.003 Signals and Systems (Fall 2011), lecture notes: feedback and poles, Z transform, frequency response
- SciPy documentation: scipy.signal.lfilter (the difference equation and its rational transfer function in z)
- SciPy documentation: scipy.signal.tf2zpk (zeros, poles and gain from b and a)
- SciPy documentation: scipy.signal.freqz (frequency response, 512 points on [0, π) by default)
- Z-transform (Wikipedia): time-shift property, transfer function of a difference equation, poles inside the unit circle
- Pole–zero plot (Wikipedia): poles drawn ×, zeros drawn o, frequencies on the unit circle
Quiz Unlocks after the last step.