---
title: Bode plots
heading: Straight lines that sketch any frequency response
eyebrow: C4 · Lesson 2 · Bode plots
xp: 50
---

::: hook
With log frequency across and gain in dB up, every pole and zero becomes a corner joining two straight lines. A pole bends the gain down by 20 dB per decade and pulls the phase down by 90°; a zero does the opposite. Because the dB of a product is a sum, you can sketch any response by adding the straight lines of its poles and zeros, which engineers do in seconds on paper, and which shows at a glance what a circuit does.

::: play
- The response has a gain K, two poles and a zero. Move the poles apart. Count the slope between and beyond them.
- Bring the zero down between the poles. What happens to the slope after it?
- Read the gain at each corner. How far is the true curve from where the straight lines meet?
:::
:::

```sim plot
view: bode
x: f = 1..10M Hz log
slider: K = 1..1000 = 100 log
slider: f1 = 10..100k = 100 Hz log
slider: f2 = 10..1M = 10k Hz log
slider: fz = 100..10M = 10M Hz log
H: K*(1 + j*f/fz)/((1 + j*f/f1)*(1 + j*f/f2))
marker: x = f1 | label: pole 1
marker: x = f2 | label: pole 2
marker: x = fz | label: zero
```

::: predict
## A response is flat at 40 dB, with poles at 100 Hz and 10 kHz. What does the straight-line sketch give at 100 kHz?

- [ ] 20 dB
- [ ] 0 dB
- [ ] −20 dB
- [x] −40 dB

::: reveal
−40 dB. From 100 Hz to 10 kHz is two decades at −20 dB per decade, which brings the gain from 40 dB down to 0 dB. Above 10 kHz both poles act, so the gain falls 40 dB per decade, reaching −40 dB at 100 kHz. Counting decades and adding slopes is all a Bode sketch takes.
:::
:::

::: nameit
## Sketching a Bode plot

**Why straight lines.** For one pole, $|H| = 1/\sqrt{1 + (f/f_p)^2}$:

- for $f \ll f_p$, $|H| \approx 1$: a flat line at 0 dB;
- for $f \gg f_p$, $|H| \approx f_p/f$: a line falling 20 dB for every decade (6 dB per octave);
- the two meet at $f_p$, where the true curve is 3 dB below.

**Phase of one pole:** 0° well below $f_p$, −45° at $f_p$, −90° well above. As a sketch: a straight ramp from 0° at $f_p/10$ to −90° at $10f_p$ (within about 6°).

**Zeros** do the same upside down: +20 dB per decade and +90°.

**The recipe:**

1. Write H as $K \times$ factors of the form $(1 + jf/f_z)$ over $(1 + jf/f_p)$.
2. Start at $20\log_{10}K$ dB on the left.
3. Going right, at each pole's corner the slope drops by 20 dB per decade; at each zero's it rises by 20.
4. Add 90° of phase lag per pole, spread over two decades around its corner; 90° of lead per zero.

**Repeated poles** (two at the same frequency) give −40 dB per decade at once, and 6 dB below the straight lines at the corner.

**Reading slopes.** A slope of −20n dB per decade at high frequencies means there are n more poles than zeros. The final phase is −90° per excess pole.
:::


::: example
## Sketch $H = 100\frac{1 + jf/1\text{ kHz}}{(1 + jf/100\text{ Hz})(1 + jf/10\text{ kHz})}$ and read it at 50 kHz.

::: solution
1. **Start at the DC gain.** The sketch starts at 40 dB.
2. **First pole.** From 100 Hz it falls 20 dB per decade, reaching 20 dB at 1 kHz.
3. **Zero.** The zero flattens it until 10 kHz.
4. **Second pole.** Then it falls 20 dB per decade again, so at 50 kHz
   $$\begin{aligned} |H| &= 20 - 20\log_{10}5 \\ &= 6.0\ \text{dB} \end{aligned}$$
5. **Check.** The exact value is 5.9 dB.

**Answer:** the sketch reads 6.0 dB at 50 kHz, and the exact value is 5.9 dB.
:::
:::

::: example
## A single pole sits at 1 kHz. Compare the straight-line phase sketch with the true phase at 300 Hz.

::: solution
1. **Straight-line sketch.** The sketch ramps 45° per decade from 0° at 100 Hz, so at 300 Hz it gives
   $$\begin{aligned} \phi &= -45 \times \log_{10}3 \\ &= -21.5° \end{aligned}$$
2. **True phase.**
   $$\begin{aligned} \phi &= -\arctan 0.3 \\ &= -16.7° \end{aligned}$$
3. **Compare.** The two agree within the 6° the sketch promises.

**Answer:** the sketch gives −21.5° at 300 Hz and the true phase is −16.7°.
:::
:::

::: example
## A lead network has $H = \frac{1 + jf/1\text{ kHz}}{1 + jf/10\text{ kHz}}$. At what frequency is its phase lead largest, and how large?

::: solution
1. **What adds phase and what takes it.** The zero adds phase from 100 Hz to 10 kHz, and the pole takes it away from 1 kHz to 100 kHz.
2. **Where the lead peaks.** Midway between them on a log scale:
   $$\begin{aligned} f &= \sqrt{1 \times 10}\ \text{kHz} \\ &= 3.16\ \text{kHz} \end{aligned}$$
3. **Peak lead.** There
   $$\begin{aligned} \phi &= \arctan\sqrt{10} - \arctan\frac{1}{\sqrt{10}} \\ &= 72.5° - 17.5° \\ &= 54.9° \end{aligned}$$
4. **Check.** It equals
   $$\arcsin\frac{10 - 1}{10 + 1}$$
5. **Where it's used.** Control engineers place exactly such networks so their peak lead falls at a loop's crossover, buying phase margin.

**Answer:** the lead is largest at 3.16 kHz, where it reaches 54.9°.
:::
:::

::: check
given: n = 3 | 4 | 5; m = 1 | 2
answer: -20*(n - m)
unit: dB/dec
tolerance: 0.5%

## A response has {n} poles and {m} zero(s). What is its slope far above all the corners?

::: right
Right. Each pole adds −20 dB per decade and each zero +20: {answer}.
:::

::: misses
- [-20*n] Each zero cancels a pole's slope.
- [-6*(n - m)] That's per octave. Per decade it's 20.
- [any] Not yet. $-20(n - m)$ dB per decade.
:::
:::

::: check
given: K = 20 | 40 | 60; f1 = 0.1 | 1; k = 1 | 2
answer: K - 20*k
unit: dB
tolerance: 0.5%

## A response starts flat at {K} dB with one pole at {f1} kHz. Using straight lines, what is the gain {k} decade(s) above the pole?

::: right
Right. −20 dB per decade for {k} decade(s): {answer}.
:::

::: misses
- [K - 3] That's at the corner itself.
- [K - 40*k] One pole gives −20 dB per decade.
- [any] Not yet. $K - 20k$ dB.
:::
:::

::: check
given: K = 20 | 40; f1 = 1 | 2
answer: K - 10*log10(2)
unit: dB
tolerance: 0.5%

## A response flat at {K} dB has a single pole at {f1} kHz (and nothing else nearby). What is the true gain at {f1} kHz?

::: right
Right. A pole's corner is 3.01 dB below the straight lines: {answer}.
:::

::: misses
- [K] The true curve sits below the corner of the straight lines.
- [K - 6] That's for a double pole.
- [any] Not yet. $|H| = 1/\sqrt2$ at the corner.
:::
:::

::: check
given: f1 = 1 | 2; f2 = 20 | 50; f = 4 | 6
answer: -(atan(f/f1) + atan(f/f2))*180/pi
unit: °
tolerance: 0.5%

## A response has poles at {f1} kHz and {f2} kHz. What is its phase at {f} kHz?

::: right
Right. Each pole contributes $-\arctan(f/f_p)$: {answer}.
:::

::: misses
- [-90] Each pole's lag depends on how far past its corner you are.
- [-(atan(f1/f) + atan(f2/f))*180/pi] It's f over the corner frequency.
- [any] Not yet. Add $-\arctan(f/f_p)$ for each pole.
:::
:::

::: check
given: K = 40 | 60; f1 = 0.1 | 1; d = 2 | 3
answer: K - 20*d
unit: dB
tolerance: 0.5%

## A response flat at {K} dB has a pole at {f1} kHz and a second pole exactly {d} decades higher. Using straight lines, what is the gain at the second pole's corner?

::: right
Right. {d} decades at −20 dB per decade: {answer}. Above it, the slope doubles.
:::

::: misses
- [K - 40*d] Only one pole acts below the second corner.
- [any] Not yet. Count decades at −20 dB each.
:::
:::

::: check
kind: parts
given: a = 0.1 | 1; r = 4 | 10 | 20

## A lead network has a zero at {a} kHz and a pole {r} times higher.

::: part
answer: a*sqrt(r)
unit: kHz
tolerance: 0.5%

### Where is its phase lead largest?

::: misses
- [a*(1 + r)/2] It peaks at the geometric mean, not the arithmetic one.
- [any] $\sqrt{f_zf_p}$.
:::
:::

::: part
answer: asin((r - 1)/(r + 1))*180/pi
unit: °
tolerance: 0.5%

### How large is that lead?

::: misses
- [any] $\arcsin\frac{r - 1}{r + 1}$.
:::
:::
:::

::: check
kind: derivation
vars: a = 1..10000, b = 10..100000, f = 1..100000

## A network with a zero at a and a pole at b (both Hz), at frequency f.

::: step
answer: atan(f/a) - atan(f/b)

### What's its phase, in radians?
:::

::: step
answer: sqrt(a*b)

### Where is the phase extreme?
:::

::: step
answer: asin((b - a)/(b + a))

### What's the phase there?
:::

::: right
Right. The farther apart the zero and pole, the more lead, up to 90°.
:::
:::

::: check
kind: python

## Write `bode_db(k, zeros, poles, f)` returning the exact gain in dB of $H = k\frac{\prod(1 + jf/z_i)}{\prod(1 + jf/p_i)}$, and `asymptote_db(k, zeros, poles, f)` returning the straight-line sketch: $20\log k$, plus 20 dB per decade above each zero, minus 20 dB per decade above each pole.

```python starter
import math

def bode_db(k, zeros, poles, f):
    return 20 * math.log10(k)

def asymptote_db(k, zeros, poles, f):
    return 20 * math.log10(k)

print(bode_db(100, [1000], [100, 1e4], 1000), asymptote_db(100, [1000], [100, 1e4], 1000))
```

```python solution
import math

def bode_db(k, zeros, poles, f):
    g = 20 * math.log10(k)
    g += sum(10 * math.log10(1 + (f / z) ** 2) for z in zeros)
    g -= sum(10 * math.log10(1 + (f / p) ** 2) for p in poles)
    return g

def asymptote_db(k, zeros, poles, f):
    g = 20 * math.log10(k)
    g += sum(20 * math.log10(f / z) for z in zeros if f > z)
    g -= sum(20 * math.log10(f / p) for p in poles if f > p)
    return g

print(bode_db(100, [1000], [100, 1e4], 1000), asymptote_db(100, [1000], [100, 1e4], 1000))
```

```python tests
assert abs(bode_db(1, [], [1000], 1000) + 3.0103) < 1e-4, "A single pole is 3.01 dB down at its corner."
assert abs(asymptote_db(1, [], [1000], 1000)) < 1e-12, "The sketch puts the corner at 0 dB."
assert abs(bode_db(100, [1000], [100, 1e4], 1000) - 22.9239) < 1e-3, f"Exact at 1 kHz: 22.92 dB; got {bode_db(100, [1000], [100, 1e4], 1000)}"
assert abs(asymptote_db(100, [1000], [100, 1e4], 1000) - 20) < 1e-9, "The sketch gives 20 dB at 1 kHz."
assert abs(asymptote_db(100, [1000], [100, 1e4], 50) - 40) < 1e-9, "Below every corner the sketch is flat at 40 dB."
```

::: right
Right. The sketch is off by about 3 dB at each isolated corner, and more where corners crowd together.
:::
:::

::: explain
## Why can a Bode plot be sketched by adding straight-line contributions from each pole and zero?

::: model
A transfer function is a product of factors, one for each pole and zero. On a log scale the magnitude of a product becomes the sum of the magnitudes of the factors, and the phase of a product is the sum of their phases. Each factor's magnitude in dB is almost exactly flat well below its corner and a straight line of ±20 dB per decade well above it, so the whole plot is a sum of straight lines, bending at each corner, with small corrections near the corners.
:::
:::

::: practice

::: check
given: n = 1 | 2 | 3
answer: -20*n
unit: dB/dec
tolerance: 0.5%

## {n} poles, no zeros. High-frequency slope?

::: misses
- [any] $-20n$ dB per decade.
:::
:::

::: check
given: n = 1 | 2 | 3
answer: -90*n
unit: °
tolerance: 0.5%

## {n} poles, no zeros. Phase at very high frequencies?

::: misses
- [-45*n] That's at the corners. Far above, each pole gives −90°.
- [any] $-90°$ per pole.
:::
:::

::: check
given: d = 1 | 2 | 3
answer: 20*d
unit: dB
tolerance: 0.5%

## A single zero, {d} decade(s) above its corner. How much has the gain risen (straight lines)?

::: misses
- [any] +20 dB per decade.
:::
:::
:::
