Poles, Zeros and Stability in the z-Plane
The mains-rejecting average needed 20 taps and still dented a signal by . A second-order recursive filter can remove with five coefficients and leave everything a few hertz away untouched. You design it not by solving equations but by placing two zeros and two poles on the z-plane, because the magnitude response can be read off that picture with a ruler. This lesson teaches that geometric view, the stability rule it gives, and how pole radius relates to bandwidth and settling time. The mathematics is in Poles and Zeros; the s-plane version is in Circuit Theory.
Factored form and the geometric picture
Factor the numerator and denominator of :
As runs from (DC, ) to (, ), the point walks around the upper half of the unit circle. The gain at each frequency is the product of its distances to the zeros divided by the product of its distances to the poles.
Rules of thumb that follow directly:
- A zero on the unit circle at angle gives an exact null at .
- A pole near the unit circle gives a peak; the closer, the sharper. For a pole at radius close to 1, the width of the peak (or of a notch formed by a nearby zero) is about rad/sample, i.e. .
- Poles and zeros of a real filter come in conjugate pairs, so the plot is symmetric about the real axis.
- Stability (for a causal filter): every pole strictly inside the unit circle, . Zeros may be anywhere.
- A pole at radius contributes a mode that decays with a time constant of samples: sharp filters ring for a long time.
- A stable causal filter with all its zeros inside the circle too is minimum phase: it has the least group delay for its magnitude response, and its inverse is also stable (useful for equalisers).
Worked example: a 50 Hz notch at 1 kSa/s
Given: , hum at ; signals of interest below .
Find: a second-order notch with unity DC gain and a notch about wide; its coefficients, its gain at and its settling time.
Solve:
- . Zeros on the circle at : numerator .
- Poles at the same angle, radius : width , so gives . Denominator .
- DC gain before scaling: ; divide the numerator by it.
- Pole time constant samples : allow about 5 time constants, , for the notch to settle after switch-on or a hum change.
Check: SciPy's iirnotch(50, Q, fs=1000) designs the same structure; its quality factor should give nearly the same coefficients.
import numpy as np
from scipy.signal import freqz, iirnotch, tf2zpk
fs, f0, r = 1000.0, 50.0, 0.98
W0 = 2 * np.pi * f0 / fs
b = np.array([1.0, -2 * np.cos(W0), 1.0])
a = np.array([1.0, -2 * r * np.cos(W0), r**2])
b = b * a.sum() / b.sum() # unity gain at DC
print("b =", np.round(b, 5), " a =", np.round(a, 5))
z, p, _ = tf2zpk(b, a)
print(f"|zeros| = {np.abs(z).round(4)}, |poles| = {np.abs(p).round(4)}, pole angle = {np.degrees(np.angle(p[0])):.1f} deg")
f_test = [10.0, 40.0, 47.0, 50.0, 53.0, 60.0, 200.0]
_, H = freqz(b, a, worN=f_test, fs=fs)
print("gain (dB):", ", ".join(f"{f:.0f} Hz {20 * np.log10(max(abs(h), 1e-12)):.2f}" for f, h in zip(f_test, H)))
f, Hf = freqz(b, a, worN=20000, fs=fs)
band = f[np.abs(Hf) < 1 / np.sqrt(2)]
print(f"-3 dB notch from {band.min():.2f} to {band.max():.2f} Hz: width {band.max() - band.min():.2f} Hz")
bq, aq = iirnotch(f0, Q=f0 / ((1 - r) * fs / np.pi), fs=fs)
print("iirnotch b =", np.round(bq, 5), " a =", np.round(aq, 5))
print(f"pole time constant: {-1 / np.log(r):.1f} samples = {1e3 * -1 / np.log(r) / fs:.1f} ms")b = [ 0.98409 -1.87184 0.98409] a = [ 1. -1.86407 0.9604 ]
|zeros| = [1. 1.], |poles| = [0.98 0.98], pole angle = 18.0 deg
gain (dB): 10 Hz -0.00, 40 Hz -0.40, 47 Hz -3.29, 50 Hz -240.00, 53 Hz -3.29, 60 Hz -0.40, 200 Hz 0.03
-3 dB notch from 46.83 to 53.18 Hz: width 6.35 Hz
iirnotch b = [ 0.98039 -1.86481 0.98039] a = [ 1. -1.86481 0.96078]
pole time constant: 49.5 samples = 49.5 ms
The notch is wide, as predicted ( and sit near its edges), and the signal passes untouched (a gain of , against for the 20-tap average). iirnotch uses the same structure but computes the pole radius from the exact bandwidth formula () instead of the approximation, so its coefficients differ in the fourth digit.
Stability at a glance
Any recursive filter can be checked by finding the roots of a. The picture also shows how stable: poles at radius are stable on paper but ring for thousands of samples, and the coefficient rounding of fixed-point implementations can push them out.
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import freqz
filters = {"notch r = 0.98": ([0.98409, -1.87185, 0.98409], [1, -1.86407, 0.9604]),
"a = [1, -1.8, 0.9]": ([1.0], [1, -1.8, 0.9]),
"a = [1, -2.1, 1.1]": ([1.0], [1, -2.1, 1.1])}
for name, (b, a) in filters.items():
p = np.roots(a)
print(f"{name:20s} |poles| = {np.round(np.abs(p), 4)} -> {'stable' if np.all(np.abs(p) < 1) else 'UNSTABLE'}")
b, a = filters["notch r = 0.98"]
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 3.4))
th = np.linspace(0, 2 * np.pi, 400)
ax1.plot(np.cos(th), np.sin(th), "k:", lw=1)
ax1.plot(np.roots(b).real, np.roots(b).imag, "o", mfc="none", ms=9, label="zeros")
ax1.plot(np.roots(a).real, np.roots(a).imag, "x", ms=9, label="poles")
ax1.set_aspect("equal"); ax1.set_title("z-plane"); ax1.legend(loc="lower left", fontsize=8)
f, H = freqz(b, a, worN=4096, fs=1000.0)
ax2.plot(f, 20 * np.log10(np.maximum(np.abs(H), 1e-5)))
ax2.set(xlabel="frequency (Hz)", ylabel="gain (dB)", ylim=(-50, 3), title="magnitude")
ax2.grid(True, alpha=0.3)
plt.tight_layout(); plt.show()notch r = 0.98 |poles| = [0.98 0.98] -> stable
a = [1, -1.8, 0.9] |poles| = [0.9487 0.9487] -> stable
a = [1, -2.1, 1.1] |poles| = [1.1 1. ] -> UNSTABLE
The second filter's poles have radius (for a conjugate pair, is the last coefficient). The third has a pole at exactly 1 (an accumulator) and one outside.
Guided lab: a notch filter on a board
Hand calculation. The notch above: at , at , a null at , settling about .
Simulation. Change r to : the notch narrows to about and the time constant grows to 200 samples. A narrower notch removes less of the signal, but needs a more exact hum frequency and settles more slowly.
What you would measure. Implement the difference equation in floating point at (timer interrupt), feed and sines from a function generator ( amplitude on a offset) and log the output. Expect the amplitude unchanged within and the tone attenuated by to : the depth is limited by the generator's frequency accuracy relative to the board's clock, the ADC noise and, in fixed point, the rounding of the coefficients. Step the generator from to and watch the residual decay over about a quarter of a second.
Hazards and safe setup. Use the generator, never mains, as the hum source. USB power, input checked on a scope to stay within to , series resistor.
Pitfalls
- Putting the notch poles on the unit circle (an oscillator, not a filter) or, after rounding, outside it.
- Asking for a very narrow notch and forgetting that it takes samples to settle.
- Reading pole angles in radians per sample as hertz: .
- Judging stability from the numerator: only the poles matter.
Practice
- A resonator has poles at and . At what frequency does it peak, roughly how wide is the peak, and is it stable?
- Write the denominator coefficients for poles at .
- A filter has a zero at . What is its gain at ?
Answer
- ; width ; stable ().
- :
a = [1, 0, 0.81]. - Zero ( is ).
Test yourself
A causal digital filter is stable when
- all zeros are inside the unit circle
- all poles are inside the unit circle
- all poles have negative real parts
- the numerator is symmetric
To place an exact null at , put
- a pole on the unit circle at angle
- a zero on the unit circle at angle
- a zero at the origin
- a pole at
Moving a notch's poles from to makes the notch
- wider and faster
- narrower and slower to settle
- unstable
- deeper only
For a conjugate pole pair, the coefficient of equals