Sub topic 4
Decibels and Bode Plots
This chapter assumes you can write H(jω) for a voltage divider, take the magnitude and angle of a complex number, and use base-10 logarithms. You will learn what a decibel is, why frequency-response plots use a logarithmic frequency axis, and how to read and build a Bode plot. The chapter stops short of the cutoff frequency, phase detail and asymptote sketching. Later chapters cover those topics.
Why frequency response needs a different scale
A first-order filter changes the amplitude of a sinusoid by a factor that depends on frequency. Across a useful range, that factor can span several orders of magnitude. An RC low-pass filter with a cutoff near 1 kHz passes 99.5 % of the input at 100 Hz and about 0.1 % at 100 kHz. On a linear plot, the high-frequency end would sit flat against the axis and show nothing.
Two choices fix this:
- Plot the gain on a logarithmic scale, which is what the decibel provides.
- Plot frequency on a logarithmic axis, so each decade (a factor of 10) takes the same width.
A plot with both choices, plus a matching phase plot, is a Bode plot.
The decibel
The decibel (dB) expresses a ratio of two powers on a logarithmic scale:
gain_dB = 10 · log10(P_out / P_in)Power in a resistance R is P = V²/R. For the same R at input and output, the power ratio is the square of the voltage ratio:
10 · log10(Vout² / Vin²) = 20 · log10(Vout / Vin)So for voltage (or current) ratios, the factor is 20, not 10. For a transfer function H(jω), the magnitude in decibels is:
|H|_dB = 20 · log10(|H(jω)|)Only the magnitude goes into the logarithm. The logarithm of a complex number is not the quantity we want here, and the phase is plotted separately in degrees.
Values worth memorizing
| Voltage ratio | Gain in dB | Note |
|---|---|---|
| 1 | 0 dB | Output equals input |
| 2 | +6.02 dB | Doubling |
| 10 | +20 dB | One decade up |
| 100 | +40 dB | Two decades up |
| 0.7071 (1/√2) | −3.01 dB | Half power |
| 0.5 | −6.02 dB | Halving |
| 0.1 | −20 dB | One decade down |
| 0.01 | −40 dB | Two decades down |
The −3 dB row matters for filters. A voltage ratio of 1/√2 is a power ratio of 1/2, and 10·log10(0.5) = −3.01 dB. Both views give the same number because the factors of 10 and 20 are chosen to agree.
Decibels turn multiplication into addition
Gains in a chain multiply. The logarithm of a product is the sum of the logarithms, so gains in decibels add. If one stage has a voltage ratio of 0.5 and the next 0.1, the overall ratio is 0.05.
-6.02 dB + (-20 dB) = -26.02 dB and 20 · log10(0.05) = -26.02 dBThis property is why Bode plots are practical. Each factor in a transfer function contributes a separate curve, and the curves add on the plot.
Converting in code
The following script is complete and runs as shown. It converts both ways and checks the cascade example above.
import numpy as np
def voltage_to_db(ratio):
return 20 * np.log10(ratio)
def power_to_db(ratio):
return 10 * np.log10(ratio)
def db_to_voltage(db):
return 10 ** (db / 20)
for r in (2, 10, 0.5, 1 / np.sqrt(2), 0.1):
print(f"voltage ratio {r:7.4f} -> {voltage_to_db(r):7.2f} dB")
print(f"power ratio 2 -> {power_to_db(2):.2f} dB")
print(f"-3 dB -> voltage ratio {db_to_voltage(-3):.4f}")
stage1, stage2 = 0.5, 0.1
total_db = voltage_to_db(stage1) + voltage_to_db(stage2)
print(f"cascade: {total_db:.2f} dB, direct: {voltage_to_db(stage1 * stage2):.2f} dB")Note that -3 dB converts to a ratio of 0.7079, not exactly 0.7071. The exact half-power point is −3.0103 dB, and "−3 dB" is a rounded name for it.
Anatomy of a Bode plot
A Bode plot is a pair of graphs that share one horizontal axis:
- The top graph shows magnitude in dB against frequency.
- The bottom graph shows phase in degrees against frequency.
- The horizontal axis is logarithmic, in hertz or radians per second. State which one you use.
On a log axis, equal distances mean equal frequency ratios. The distance from 10 Hz to 100 Hz equals the distance from 1 kHz to 10 kHz. Zero frequency never appears, because log(0) is undefined. DC behavior is read from the left edge of the plot instead.
A worked example: RC low-pass at 1 kHz
For an RC low-pass filter with the output across the capacitor:
H(jω) = 1 / (1 + jωRC)
|H| = 1 / sqrt(1 + (ω/ωc)²), ωc = 1/(RC)Take fc = 1 kHz and evaluate at one point per decade, from a decade below the cutoff to a decade above:
| Frequency | f / fc | \ | H\ | Column | Gain (dB) | Phase |
|---|---|---|---|---|---|---|
| 100 Hz | 0.1 | 0.9950 | −0.04 dB | −5.71° | ||
| 1 kHz | 1 | 0.7071 | −3.01 dB | −45.00° | ||
| 10 kHz | 10 | 0.0995 | −20.04 dB | −84.29° | ||
| 100 kHz | 100 | 0.0100 | −40.00 dB | −89.43° |
Reading the table:
- Far below fc, the gain is close to 0 dB, so the filter passes the signal.
- At fc, the gain is −3.01 dB.
- Each decade above fc, the gain drops by about 20 dB. The drop from 10 kHz to 100 kHz is 19.96 dB, close to 20 dB. This slope is the roll-off, and a later chapter explains it in detail.
The next script reproduces the table with the transfer function directly. It uses a sweep with many points so the same code can drive a plot.
import numpy as np
fc = 1000.0
f = np.array([100, 1000, 10000, 100000], dtype=float)
H = 1 / (1 + 1j * f / fc) # same as 1/(1 + jωRC) with ωc = 2π·fc
mag = np.abs(H)
mag_db = 20 * np.log10(mag)
phase_deg = np.degrees(np.angle(H))
for fi, m, d, p in zip(f, mag, mag_db, phase_deg):
print(f"{fi:9.0f} Hz |H|={m:.4f} {d:7.2f} dB {p:7.2f} deg")Choosing the frequency axis
Bode plots use either hertz or radians per second. The two differ by a factor of 2π, and mixing them is a common source of error. A cutoff of ωc = 6283 rad/s is the same point as fc = 1000 Hz. The shape of the plot is identical. Only the labels on the axis change.
Frequency spacing matters when you compute points yourself. np.logspace(1, 5, 5) gives one point per decade, which suits a table. For a smooth curve, use 20 or more points per decade, as in the SPICE directive .ac dec 20 10 100k.
Common errors
- Using 10·log10 for a voltage ratio. This halves every result. A 10:1 voltage ratio is 20 dB, not 10 dB.
- Using the natural logarithm.
np.logis base e. Usenp.log10. - Taking the logarithm of a complex number. Apply
np.absfirst, then the logarithm. - Reading a log axis as linear. Halfway between 10 Hz and 1 kHz on the plot is 100 Hz, not 505 Hz.
- Comparing dB values across different impedances. The 20·log10 rule for voltage assumes that the same resistance appears at input and output, or that you only care about voltage ratios. For voltage transfer functions, the second case holds, so the convention is fine. Just do not describe it as a power gain unless the impedances match.
- Writing a bare "dB" for an absolute level. A decibel is a ratio. Absolute levels need a reference, such as dBV (relative to 1 V RMS) or dBm (relative to 1 mW).
Reading a plot in practice
Given a magnitude plot, you can recover the ratios quickly:
- Locate the flat region at low frequency and note its level, here 0 dB.
- Find where the curve is 3 dB below the flat level. That frequency is the cutoff.
- Measure the slope one or two decades beyond the cutoff. A drop of about 20 dB per decade indicates a first-order filter.
- Convert any dB reading to a ratio with 10^(dB/20) when you need the actual output amplitude.
For example, a 2 V peak input at a frequency where the plot reads −26 dB gives an output of 2 × 10^(−26/20) ≈ 2 × 0.0501 ≈ 0.100 V peak.
Exercise
A filter has a voltage gain of 0.025 at 50 kHz. (a) What is the gain in dB? (b) The filter is followed by an amplifier with +40 dB gain. What is the overall voltage ratio? Round dB to two decimals.
Show answer
(a) 20·log10(0.025) = 20 × (−1.602) = −32.04 dB. (b) The total is −32.04 + 40 = +7.96 dB, which is a voltage ratio of 10^(7.96/20) ≈ 2.5. This matches 0.025 × 100 = 2.5, since +40 dB is a factor of 100.
Exercise
An RC low-pass filter has fc = 2 kHz. Using |H| = 1/sqrt(1 + (f/fc)²), find the gain in dB at 20 kHz, and state the change in dB between 20 kHz and 200 kHz.
Show answer
At 20 kHz, f/fc = 10, so |H| = 1/sqrt(101) = 0.0995 and the gain is 20·log10(0.0995) = −20.04 dB. At 200 kHz, f/fc = 100, so |H| = 1/sqrt(10001) = 0.0100 and the gain is −40.00 dB. The change is about −19.96 dB, which is close to the −20 dB per decade roll-off of a first-order filter.