---
title: Notch and all-pass filters
heading: Removing one frequency, and changing phase without changing gain
eyebrow: C4 · Lesson 15 · Notch and all-pass filters
xp: 40
---

::: hook
A sensitive measurement picks up 50 or 60 Hz hum from the mains wiring. A low-pass or high-pass would remove the signal along with it; what's wanted is a filter that removes one narrow band and leaves everything else alone: a **notch**. At the other extreme sits a filter that passes every frequency at full strength and changes only their phase: an **all-pass**. It sounds useless, yet all-pass networks straighten out the group delay of other filters and build the phase shifters in radios and audio effects.
:::

::: play
- A second-order notch filter's gain against frequency (relative to the notch frequency, log scale), for quality factor Q.
- The notch is infinitely deep at $f_0$ in theory; its −3 dB width is $f_0/Q$. Raise Q for a narrower notch that leaves nearby frequencies alone.
- A notch made of real parts only reaches a finite depth, limited by how well they match.
:::
:::

```sim plot
view: graph
x: r = 0.1..10 log
y: A = -60..3 dB
slider: Q = 0.25..20 = 2 log
plot: 20*log(abs((1 - r^2)/(1 - r^2 + j*r/Q)) + 1e-6) | label: notch | samples: 1500
readout: −3 dB width, in units of f₀ = 1/Q | digits: 3
```

::: predict
## A first-order all-pass filter has τ = 1 ms. What is its gain at 159 Hz, and its phase?

- [ ] −3 dB and −45°
- [x] 0 dB and −90°
- [ ] 0 dB and 0°
- [ ] −6 dB and −90°

::: reveal
0 dB and −90°. An all-pass, $H = \frac{1 - s\tau}{1 + s\tau}$, has the same magnitude for every frequency, so its gain is always 0 dB. Its phase is $-2\tan^{-1}\omega\tau$, and 159 Hz is where $\omega\tau = 1$: −90°, twice the RC low-pass's −45° there.
:::
:::

::: nameit
## Notch filters

A second-order notch (band-stop) has

$$H(s) = \frac{s^2 + \omega_0^2}{s^2 + \frac{\omega_0}{Q}s + \omega_0^2}$$

Its zeros sit right on the $j\omega$ axis at $\pm j\omega_0$, so the gain there is zero. Its −3 dB band is $f_0/Q$ wide, the same Q as a band-pass. A notch is $1 - H_\text{BP}$: the input minus a band-pass's output.

The passive **twin-T** notch, two T-networks in parallel (one of R, R and 2C, the other of C, C and R/2), nulls at

$$f_0 = \frac{1}{2\pi RC}$$

but alone has a low Q of 1/4; feeding back part of its output with an op amp raises it. In practice the depth is set by how closely the parts match: 1% resistors typically leave a notch 30 to 40 dB deep.

## All-pass filters

A first-order all-pass,

$$H(s) = \frac{1 - s\tau}{1 + s\tau}$$

has $|H| = 1$ at every frequency and phase $-2\tan^{-1}\omega\tau$, sweeping from 0° to −180°. Its group delay is $\frac{2\tau}{1 + (\omega\tau)^2}$, twice an RC low-pass's. A second-order all-pass sweeps 0° to −360°, reaching −180° at its $\omega_0$.

Uses: **delay equalizers** that add delay where another filter has too little, flattening the total group delay (lesson 3); phase shifters for single-sideband radios and phasing audio effects; and fractional delays in digital signal processing.
:::

```sim plot
view: graph
x: f = 10..10000 Hz log
y: phi = -180..0 °
slider: tau = 0.1..10 = 1 ms log
plot: -2*atan(2*pi*f*tau/1000)*180/pi | label: all-pass phase | samples: 400
readout: group delay at low frequencies, ms = 2*tau | digits: 3
```

::: example
## A 50 Hz hum notch has Q = 10. How wide is the notch, and how much does it take off at 45 Hz?

::: solution
1. **Notch width.**
   $$\begin{aligned} B &= \frac{50}{10} \\ &= 5\ \text{Hz} \end{aligned}$$
2. **Gain at 45 Hz.** At $r = 0.9$:
   $$\begin{aligned} |H| &= \left|\frac{1 - 0.81}{0.19 + j0.09}\right| \\ &= 0.90 \end{aligned}$$
   or −0.9 dB.
3. **Compare.** A signal at 45 Hz is barely touched while 50 Hz is removed.

**Answer:** the notch is 5 Hz wide, and it takes 0.9 dB off at 45 Hz.
:::
:::

::: example
## What twin-T resistor gives a 50 Hz notch with C = 0.33 µF?

::: solution
1. **Resistor for 50 Hz.**
   $$\begin{aligned} R &= \frac{1}{2\pi f_0C} \\ &= \frac{1}{2\pi \times 50 \times 0.33 \times 10^{-6}} \\ &= 9.6\ \text{k}\Omega \end{aligned}$$
2. **With a standard 10 kΩ.** The notch would sit at 48 Hz, so precision parts or a trimmer are used.

**Answer:** 9.6 kΩ.
:::
:::

::: example
## A first-order all-pass has its 90° point at 1 kHz. What phase does it give at 3 kHz, and what's its group delay at DC?

::: solution
1. **Phase.**
   $$\phi = -2\arctan\frac{f}{f_0}$$
   which is −90° at 1 kHz.
2. **At 3 kHz.**
   $$\begin{aligned} \phi &= -2\arctan3 \\ &= -143° \end{aligned}$$
   heading for −180°.
3. **Group delay at DC.**
   $$\begin{aligned} \tau_g &= \frac{2}{\omega_0} \\ &= \frac{1}{\pi f_0} \\ &= 0.318\ \text{ms} \end{aligned}$$
4. **Where it's used.** Cascading a few such sections with spread-out corners builds a phase-shift network, used in single-sideband modulators to make two signals 90° apart over a whole audio band.

**Answer:** −143° at 3 kHz, and a group delay of 0.318 ms at DC.
:::
:::

::: check
given: R = 4.7 | 10 | 22; C = 0.1 | 0.33
answer: 1/(2*pi*R*1000*C*1e-6)
unit: Hz
tolerance: 0.5%

## A twin-T notch uses R = {R} kΩ and C = {C} µF. Where is its null?

::: right
Right. $\frac{1}{2\pi RC}$ = {answer}.
:::

::: misses
- [1/(R*1000*C*1e-6)] Include the $2\pi$.
- [any] Not yet. $f_0 = 1/(2\pi RC)$.
:::
:::

::: check
given: f0 = 50 | 60 | 1000; Q = 2 | 10 | 30
answer: f0/Q
unit: Hz
tolerance: 0.5%

## A notch at {f0} Hz has Q = {Q}. How wide is it between the −3 dB points?

::: right
Right. $f_0/Q$ = {answer}.
:::

::: misses
- [f0*Q] Higher Q, narrower notch.
- [any] Not yet. Width $= f_0/Q$.
:::
:::

::: check
given: Q = 1 | 5 | 20; r = 0.8 | 1.3
answer: 20*log(abs((1 - r^2)/(1 - r^2 + j*r/Q)))
unit: dB
tolerance: 0.5%

## A notch with Q = {Q} is driven at {r} times its center frequency. What is its gain?

::: right
Right. {answer}.
:::

::: misses
- [any] Not yet. $\left|\frac{1 - r^2}{1 - r^2 + jr/Q}\right|$ in dB.
:::
:::

::: check
given: tau = 0.1 | 1; f = 100 | 1000
answer: -2*atan(2*pi*f*tau/1000)*180/pi
unit: °
tolerance: 0.5%

## A first-order all-pass with τ = {tau} ms carries a {f} Hz sinusoid. What phase does it add?

::: right
Right. $-2\tan^{-1}\omega\tau$ = {answer}.
:::

::: misses
- [-atan(2*pi*f*tau/1000)*180/pi] That's an RC low-pass; the all-pass shifts twice as much.
- [any] Not yet. Numerator and denominator each contribute $\tan^{-1}\omega\tau$.
:::
:::

::: check
given: tau = 0.05 | 0.5 | 2
answer: 2*tau
unit: ms
tolerance: 0.5%

## What group delay does a first-order all-pass with τ = {tau} ms give at low frequencies?

::: right
Right. $2\tau$ = {answer}.
:::

::: misses
- [tau] Twice an RC low-pass's.
- [any] Not yet. $\tau_g(0) = 2\tau$.
:::
:::

::: check
given: f0 = 0.5 | 1 | 2 | 5 | 10 | 20
answer: -180
unit: °
tolerance: 0.5%

## A second-order all-pass is centered at {f0} kHz. What phase does it give there?

::: right
Right. Half of its 360° sweep: {answer}.
:::

::: misses
- [-90] That's the first-order all-pass's midpoint; the second-order one sweeps 360°.
- [any] Not yet. It sweeps from 0° to −360°.
:::
:::

::: check
kind: parts
given: f = 0.1 | 1 | 5; x = 0.5 | 3

## A first-order all-pass has its 90° point at {f} kHz.

::: part
answer: -2*atan(x)*180/pi
unit: °
tolerance: 0.5%

### What phase does it give at {x} times that?

::: misses
- [-atan(x)*180/pi] An all-pass shifts twice as much as a single pole.
- [any] $-2\arctan\frac{f}{f_0}$.
:::
:::

::: part
answer: 1/(pi*f*1e3)*1000
unit: ms
tolerance: 0.5%

### What's its group delay at DC?

::: misses
- [any] $\frac{1}{\pi f_0}$.
:::
:::
:::

::: check
kind: derivation
vars: f = 10..100000, g = 1..1000000

## A first-order all-pass with 90° at f, evaluated at g (both Hz).

::: step
answer: -2*atan(g/f)

### What's its phase?
:::

::: step
answer: 1/(pi*f)/(1 + (g/f)^2)

### What's its group delay?
:::

::: right
Right. Group delay is concentrated around the 90° frequency.
:::
:::

::: explain
## How can a filter that passes every frequency at the same strength be useful?

::: model
An all-pass filter leaves every amplitude alone but delays different frequencies by different amounts. That's exactly what's needed to correct another filter whose group delay varies across its band: adding an all-pass that delays the frequencies the first filter rushed through evens out the total delay, so pulses keep their shape. The same frequency-dependent phase shift is used to build phase shifters, for example to make two copies of an audio or radio signal 90° apart over a wide band.
:::
:::

::: practice

::: check
given: f0 = 50 | 60; R = 10 | 22
answer: 1/(2*pi*f0*R*1000)*1e9
unit: nF
tolerance: 0.5%

## What twin-T capacitor nulls {f0} Hz with R = {R} kΩ?

::: misses
- [any] $C = 1/(2\pi f_0R)$.
:::
:::

::: check
given: f0 = 1 | 5; bw = 0.1 | 0.5
answer: f0/bw
tolerance: 0.5%

## A notch at {f0} kHz is {bw} kHz wide. What is its Q?

::: misses
- [any] $Q = f_0/\Delta f$.
:::
:::

::: check
given: tau = 0.1 | 0.25 | 0.5 | 1 | 2 | 5 | 10
answer: 1/(2*pi*tau/1000)
unit: Hz
tolerance: 0.5%

## At what frequency does a first-order all-pass with τ = {tau} ms shift by −90°?

::: misses
- [any] Where $\omega\tau = 1$.
:::
:::
:::
