---
title: Frequency response from poles and zeros
heading: Reading a digital filter's response off the z-plane
eyebrow: C9 · Lesson 39 · Frequency response from poles and zeros
xp: 40
---

::: hook
Walk around the unit circle from z = 1 (DC) to z = −1 (half the sample rate), and at each point measure the distances to a filter's zeros and poles. The gain there is the product of the zero distances divided by the product of the pole distances. That's the whole of digital filter intuition: put a zero on the circle and the response drops to nothing at that frequency; put a pole just inside the circle and the response peaks. A notch filter that removes 60 Hz hum and leaves everything else alone is two zeros and two poles placed this way.
:::

::: play
- A notch filter: zeros on the unit circle at angle $\pm\omega_0$, and poles just inside, at radius r on the same angles. The curve is its gain from ω = 0 to π.
- The zeros force the gain to exactly zero at $\omega_0$. Away from $\omega_0$, each pole is almost as far from the point as its zero, so the gain is close to 1.
- Push r toward 1: the notch narrows, about 2(1 − r) radians wide. Pull r down and the notch widens and the gain elsewhere sags.
:::
:::

```sim plot
view: graph
x: w = 0..3.1416 rad
y: H = 0..1.6
slider: w0 = 0.1..3 = 0.377 step 0.001
slider: r = 0.5..0.999 = 0.95 step 0.001
plot: abs(2*cos(w) - 2*cos(w0))/sqrt((1 - 2*r*cos(w - w0) + r^2)*(1 - 2*r*cos(w + w0) + r^2)) | samples: 3000 | label: |H|
marker: x = w0 | label: ω₀
readout: notch width, rad = 2*(1 - r) | digits: 3
readout: gain at DC = (2 - 2*cos(w0))/(1 - 2*r*cos(w0) + r^2) | digits: 4
```

```sim plot
view: zplane
range: 1.3
slider: w0 = 0.1..3 = 0.377 step 0.001
slider: r = 0.5..0.999 = 0.95 step 0.001
num: z^2 - 2*cos(w0)*z + 1
den: z^2 - 2*r*cos(w0)*z + r^2
```

::: predict
## A filter has a zero exactly on the unit circle at angle ω₀. What happens to a sinusoid at frequency ω₀?

- [ ] It's amplified
- [ ] It passes unchanged
- [x] It's removed completely
- [ ] It's delayed by half a cycle

::: reveal
It's removed: on the unit circle at $\omega_0$, the distance to that zero is 0, so the product of zero distances, and the gain, is 0. Zeros on the circle are how FIR and notch filters make exact nulls.
:::
:::

::: nameit
## The geometric picture

Factor $H(z) = b_0\dfrac{\prod_k (z - z_k)}{\prod_k (z - p_k)}$ (times a power of z, which only adds linear phase). At $z = e^{j\omega}$:

$$\lvert H(e^{j\omega})\rvert = \lvert b_0\rvert\frac{\prod_k \lvert e^{j\omega} - z_k\rvert}{\prod_k \lvert e^{j\omega} - p_k\rvert}$$

the product of distances from the point on the circle to the zeros over the product of distances to the poles. So:

- a **zero on the circle** makes an exact null at its angle;
- a **pole near the circle** makes a peak at its angle, sharper the closer it is;
- poles and zeros near the origin barely matter, since all points on the circle are about equally far from them.

## The notch filter

$$H(z) = \frac{1 - 2\cos\omega_0\,z^{-1} + z^{-2}}{1 - 2r\cos\omega_0\,z^{-1} + r^2z^{-2}}$$

with zeros at $e^{\pm j\omega_0}$ and poles at $re^{\pm j\omega_0}$. Its notch is about $2(1 - r)$ radians wide at the −3 dB points, which is $(1 - r)f_s/\pi$ in hertz.

## All-pass and minimum phase

A pole at a and a zero at $1/a^*$ have distances in a fixed ratio from every point on the circle, so $(z^{-1} - a^*)/(1 - az^{-1})$ has $\lvert H\rvert = 1$ everywhere: an **all-pass** filter, which only changes phase. Moving a zero from inside the circle to its mirror position outside leaves the magnitude's shape unchanged but adds phase lag; a filter with all its zeros inside is **minimum phase**, the one with the least delay for its magnitude.
:::

::: example
## Design a notch for 60 Hz hum at 1 kHz sampling, with r = 0.98.

::: solution
1. **Notch frequency.**
   $$\begin{aligned} \omega_0 &= 2\pi \cdot 60/1000 \\ &= 0.377\ \text{rad} \end{aligned}$$
   so $2\cos\omega_0 = 1.860$.
2. **Transfer function.**
   $$H(z) = \frac{1 - 1.860z^{-1} + z^{-2}}{1 - 1.822z^{-1} + 0.960z^{-2}}$$
3. **Width and DC gain.** The notch is about 2(0.02) = 0.04 rad, or 6.4 Hz, wide, and the gain at DC is 1.017.

**Answer:** $H(z) = (1 - 1.860z^{-1} + z^{-2})/(1 - 1.822z^{-1} + 0.960z^{-2})$, a notch about 6.4 Hz wide with a DC gain of 1.017.
:::
:::

::: example
## Show that $H(z) = (z^{-1} - 0.5)/(1 - 0.5z^{-1})$ is all-pass.

::: solution
1. **At z = 1.**
   $$0.5/0.5 = 1$$
2. **At z = −1.**
   $$-1.5/1.5 = -1$$
3. **In general.** The numerator's size is
   $$\lvert e^{-j\omega} - 0.5\rvert = \lvert 1 - 0.5e^{j\omega}\rvert$$
   which equals $\lvert 1 - 0.5e^{-j\omega}\rvert$ because the two are complex conjugates. So the ratio's magnitude is 1 at every ω.
4. **Phase, pole and zero.** Its phase runs from 0 at DC to −π at ω = π. The pole is at 0.5 and the zero at 1/0.5 = 2.

**Answer:** its magnitude is 1 at every ω, so it's all-pass.
:::
:::

::: example
## A filter has a zero at z = −1 and a pole at z = 0.9. Find its gain at ω = 0 and π, and the scale factor for unity DC gain.

::: solution
1. **Transfer function.**
   $$H(z) = \frac{1 + z^{-1}}{1 - 0.9z^{-1}}$$
2. **At ω = 0 (z = 1).**
   $$2/0.1 = 20$$
3. **At ω = π (z = −1).** The zero makes it 0.
4. **Scale for unity DC gain.** Multiplying by 1/20 = 0.05 gives a low-pass with unity DC gain and a perfect null at half the sample rate: the zero kills the highest frequency, and the pole near z = 1 boosts the lowest.

**Answer:** a gain of 20 at ω = 0 and 0 at π; a scale factor of 0.05 gives unity DC gain.
:::
:::

::: check
kind: parts
given: f0 = 50 | 60 | 400; fs = 1000 | 8000

## A notch filter removes {f0} Hz from data sampled at {fs} Hz.

::: part
answer: 2*pi*f0/fs
unit: rad
tolerance: 0.5%

### At what angle do its zeros sit?

::: misses
- [any] $\omega_0 = 2\pi f_0/f_s$.
:::
:::

::: part
answer: -2*cos(2*pi*f0/fs)
tolerance: 0.5%

### What is the $z^{-1}$ coefficient of its numerator?

::: misses
- [2*cos(2*pi*f0/fs)] The numerator is $1 - 2\cos\omega_0\,z^{-1} + z^{-2}$.
- [any] Not yet. $-2\cos\omega_0$.
:::
:::
:::

::: check
given: r = 0.9 | 0.98 | 0.995; fs = 1000 | 48000
answer: (1 - r)*fs/pi
unit: Hz
tolerance: 0.5%

## A notch filter has its poles at radius {r}, at a sample rate of {fs} Hz. About how wide is the notch, in hertz?

::: right
Right. $2(1 - r)$ rad, which is $(1 - r)f_s/\pi$ = {answer} Hz.
:::

::: misses
- [2*(1 - r)] That's in radians; convert with $f = \omega f_s/2\pi$.
- [any] Not yet. $2(1 - r)$ rad, converted to hertz.
:::
:::

::: check
given: w0 = 0.3 | 1 | 2; r = 0.9 | 0.97
answer: (2 - 2*cos(w0))/(1 - 2*r*cos(w0) + r^2)
tolerance: 0.5%

## A notch at ω₀ = {w0} rad has poles at radius {r}. What is its gain at DC?

::: right
Right. H(1) = {answer}.
:::

::: misses
- [1] Close to 1, but the poles aren't exactly as far from z = 1 as the zeros.
- [any] Not yet. Evaluate H at z = 1.
:::
:::

::: check
given: z0 = 0.5 | -0.8 | 2; p = 0.6 | -0.3
answer: sqrt(1 + z0^2)/sqrt(1 + p^2)
tolerance: 0.5%

## $H(z) = (z - \given{z0})/(z - \given{p})$. What is its gain at ω = π/2?

::: right
Right. $\lvert j - z_0\rvert/\lvert j - p\rvert$ = {answer}.
:::

::: misses
- [abs(z0)/abs(p)] Measure from the point on the circle, $e^{j\pi/2} = j$, not from the origin.
- [any] Not yet. Distances from j to the zero and the pole.
:::
:::

::: check
kind: parts
given: a = 0.5 | 0.8 | -0.4; w = 0.5 | 2

## $H(z) = (z^{-1} - \given{a})/(1 - \given{a}z^{-1})$.

::: part
answer: 1
tolerance: 0.5%

### What is its gain at ω = {w}?

::: misses
- [any] It's all-pass: the gain is the same at every frequency.
:::
:::

::: part
answer: 1/a
tolerance: 0.5%

### Where is its zero?

::: misses
- [a] The pole is at a; the zero mirrors it to 1/a.
- [any] Not yet. Solve $z^{-1} = a$.
:::
:::
:::

::: check
kind: parts
given: k = 1..8 int

## An FIR filter is $H(z) = 1 + z^{-\given{k}}$.

::: part
answer: 2
tolerance: 0.5%

### What is its gain at DC?

::: misses
- [any] H(1).
:::
:::

::: part
answer: pi/k
unit: rad
tolerance: 0.5%

### At what lowest positive ω does it have a null?

::: misses
- [any] $e^{-jk\omega} = -1$ first at $k\omega = \pi$.
:::
:::
:::

::: check
kind: choice

## Two FIR filters have the same magnitude response. One has all its zeros inside the unit circle; the other has some reflected outside. What's different?

- [ ] The one with zeros outside is unstable
- [x] The one with all zeros inside has the least phase lag (minimum phase)
- [ ] Their outputs are identical
- [ ] The one with zeros outside has a sharper cutoff

::: misses
- [1] FIR filters have no poles away from the origin, so they're always stable; zeros don't affect stability.
- [3] The magnitudes match, but the phases, and so the output waveforms, differ.
- [4] Reflecting zeros leaves the magnitude unchanged.
:::
:::

::: check
kind: parts
given: f0 = 50 | 60 | 120; fs = 500 | 1000 | 2000; r = 0.95 | 0.98

## A notch removes {f0} Hz at {fs} Hz, with poles at radius {r}.

::: part
answer: 2*cos(2*pi*f0/fs)
tolerance: 0.5%

### What is the numerator's middle coefficient (with a minus sign in front)?

::: misses
- [any] $2\cos\omega_0$.
:::
:::

::: part
answer: 2*r*cos(2*pi*f0/fs)
tolerance: 0.5%

### And the denominator's?

::: misses
- [any] $2r\cos\omega_0$.
:::
:::
:::

::: check
kind: parts
given: r = 0.8 | 0.9 | 0.99; fs = 1000 | 48000

## A one-pole low-pass has its pole at z = {r} and runs at {fs} Hz.

::: part
answer: 1/(1 - r)
tolerance: 0.5%

### What is its gain at ω = 0, unscaled?

::: misses
- [any] $1/(1 - r)$.
:::
:::

::: part
answer: (1 - r)*fs/(2*pi)
unit: Hz
tolerance: 0.5%

### About where is its −3 dB corner, using $\omega \approx 1 - r$?

::: misses
- [any] $(1 - r)f_s/2\pi$.
:::
:::
:::

::: explain
## Why does a pole just inside the unit circle make a sharp peak in the frequency response?

::: model
The gain at each frequency divides by the distance from the point $e^{j\omega}$ on the circle to each pole. When a pole sits very close to the circle, that distance becomes tiny as the point passes the pole's angle, so the gain there becomes large, and it falls off quickly as the point moves away and the distance grows. The closer the pole to the circle, the smaller the minimum distance and the faster it grows on either side: a taller, narrower peak. That's resonance: in the time domain the same pole gives a slowly decaying oscillation at that frequency.
:::
:::

::: practice

::: check
given: f0 = 50 | 120; fs = 500 | 2000
answer: 2*pi*f0/fs
unit: rad
tolerance: 0.5%

## Zero angle for a {f0} Hz notch at {fs} Hz?

::: misses
- [any] $2\pi f_0/f_s$.
:::
:::

::: check
given: r = 0.95 | 0.99; fs = 8000 | 44100
answer: (1 - r)*fs/pi
unit: Hz
tolerance: 0.5%

## Approximate notch width for r = {r} at {fs} Hz?

::: misses
- [any] $(1 - r)f_s/\pi$.
:::
:::

::: check
given: a = 0.2 | 0.25 | 0.3 | 0.4 | 0.5 | 0.7 | 0.8
answer: 1/a
tolerance: 0.5%

## Zero of the all-pass $(z^{-1} - \given{a})/(1 - \given{a}z^{-1})$?

::: misses
- [any] 1/a.
:::
:::
:::
