---
title: Frequency response lab
heading: Exact poles, exact corners and the time-constant estimates, in Python
eyebrow: C6 · Lesson 14 · Frequency response lab
xp: 50
---

::: hook
Lessons 10 to 13 estimated amplifier bandwidths with Miller's theorem and open-circuit time constants: quick, and usually good to ten percent. A two-capacitor stage is small enough to solve exactly, though, and doing it shows when the estimates hold and why. In this lab you'll write the common-source stage's exact transfer function, find its poles and its true −3 dB point, and compare them with the estimates, then do the same quick analysis for the cascode and the common-gate stage.

::: play
- The curves are a common-source stage's gain against frequency: the exact two-pole response with its right-half-plane zero, and the single-pole estimate from open-circuit time constants.
- They agree closely while the two poles are far apart. Add load capacitance: the second pole comes down, and the estimate starts to drift.
- Raise the source resistance: the dominant pole falls, and the time-constant estimate tracks it.
:::
:::

```sim plot
view: graph
x: f = 10k..10G Hz log
y: g = -40..30 dB
slider: Rs = 100..100k = 10k Ω log
slider: CL = 0..5 step 0.1 = 0 pF
slider: gm = 1..20 step 0.5 = 4 mS
plot: 20*log(gm*1e-3*5000*sqrt(1 + (2*pi*f*0.5e-12/(gm*1e-3))^2)/sqrt((1 - (2*pi*f)^2*Rs*5000*(2e-12*0.5e-12 + 2e-12*CL*1e-12 + 0.5e-12*CL*1e-12))^2 + (2*pi*f*(Rs*2e-12 + Rs*0.5e-12*(1 + gm*1e-3*5000) + 5000*(0.5e-12 + CL*1e-12)))^2)) | label: exact | samples: 500
plot: 20*log(gm*1e-3*5000/sqrt(1 + (2*pi*f*(Rs*2e-12 + Rs*0.5e-12*(1 + gm*1e-3*5000) + 5000*(0.5e-12 + CL*1e-12)))^2)) | color: ch2 | label: time-constant estimate | samples: 500
readout: estimated corner, MHz = 1/(2*pi*(Rs*2e-12 + Rs*0.5e-12*(1 + gm*1e-3*5000) + 5000*(0.5e-12 + CL*1e-12)))/1e6 | digits: 4
```

::: predict
## A CS stage ($g_m$ = 4 mS, $R_L$ = 5 kΩ, $C_{gs}$ = 2 pF, $C_{gd}$ = 0.5 pF, 10 kΩ source) has an open-circuit time-constant estimate of 1.248 MHz. How close is its exact −3 dB frequency?

- [x] Within 0.5%: 1.252 MHz
- [ ] About 10% higher
- [ ] About 10% lower
- [ ] Twice as high

::: reveal
1.252 MHz, 0.3% above the estimate. The sum of time constants is exactly the coefficient of s in the denominator, which equals the sum of the reciprocal poles. When the second pole is far above the first (here 405 MHz against 1.25 MHz), it barely contributes, and the estimate is almost the dominant pole itself.
:::
:::

::: nameit
## The common-source stage, exactly

With source resistance $R_s$, load $R_L$ and capacitances $C_{gs}$, $C_{gd}$ and $C_L$, nodal analysis at the gate and drain gives

$$\frac{v_o}{v_s} = -g_mR_L\frac{1 - sC_{gd}/g_m}{1 + as + bs^2},$$

$$a = R_sC_{gs} + R_sC_{gd}(1 + g_mR_L) + R_L(C_{gd} + C_L), \qquad b = R_sR_L(C_{gs}C_{gd} + C_{gs}C_L + C_{gd}C_L).$$

The poles are the roots of $1 + as + bs^2$. Their reciprocals add to a, so the **open-circuit time-constant** estimate $\frac{1}{2\pi a}$ is the dominant pole whenever the other is far away. The zero at $\frac{g_m}{2\pi C_{gd}}$ lies in the right half-plane: the signal fed forward through $C_{gd}$ arrives with the wrong sign.

## The exact corner

$|H(j\omega)|$ follows from the magnitudes of numerator and denominator; the −3 dB frequency is where it falls to $\frac{1}{\sqrt2}$ of its DC value. It decreases steadily with frequency, so bisection on a log scale finds it.

## Cascode and common gate

The cascode's time constants (lesson 13) sum to

$$C_{gs1}R_s + C_{gd1}\left[R_s\left(1 + \frac{g_{m1}}{g_{m2}}\right) + \frac{1}{g_{m2}}\right] + \frac{C_{gs2}}{g_{m2}} + (C_{gd2} + C_L)R_L.$$

A common-gate stage has an input pole at $\frac{1}{2\pi C_\text{in}(R_s \parallel 1/g_m)}$, usually very high, and an output pole at $\frac{1}{2\pi C_\text{out}R_L}$.
:::

::: example
## Find the exact poles, zero and −3 dB frequency of the predict's stage.

::: solution
1. **Coefficients.** The denominator $1 + as + bs^2$ has
   $$\begin{aligned} a &= 127.5\ \text{ns} \\ b &= 5.0 \times 10^{-17}\ \text{s}^2 \end{aligned}$$
2. **Poles.** Its roots give poles at 1.252 MHz and 405 MHz.
3. **Zero.**
   $$\frac{4\ \text{mS}}{2\pi \times 0.5\ \text{pF}} = 1.27\ \text{GHz}$$
4. **The −3 dB point.** Bisection on $|H|$ puts it at 1.252 MHz, the dominant pole itself.
5. **Compare the estimates.** Miller's estimate, which ignores $C_{gd}$'s effect at the output, gave 1.27 MHz; the time constants gave 1.248 MHz.

**Answer:** the poles are at 1.252 MHz and 405 MHz, the zero at 1.27 GHz, and the −3 dB frequency is 1.252 MHz.
:::
:::

::: example
## Add 1 pF of load capacitance. What happens to the poles and the estimate?

::: solution
1. **New coefficients.**
   $$\begin{aligned} a &= 132.5\ \text{ns} \\ b &= 1.75 \times 10^{-16}\ \text{s}^2 \end{aligned}$$
2. **Poles.** They move to 1.213 MHz and 119 MHz: the second has come down by more than three times, while the first barely moved.
3. **The −3 dB point and the estimate.** The exact point is 1.213 MHz, and the estimate is 1% low:
   $$\frac{1}{2\pi a} = 1.201\ \text{MHz}$$
4. **How the estimate behaves.** It's always conservative, and it degrades gracefully as the poles approach each other.

**Answer:** the poles move to 1.213 MHz and 119 MHz, and the estimate of 1.201 MHz is 1% below the exact 1.213 MHz.
:::
:::

::: example
## The same transistor as a cascode (two identical devices) and as a common-gate stage from the 10 kΩ source. Estimate their bandwidths.

::: solution
1. **Cascode time constants.**
   $$\begin{aligned} \tau &= 2\ \text{pF} \times 10\ \text{k} \\ &\quad + 0.5\ \text{pF} \times (20\ \text{k} + 250) \\ &\quad + 2\ \text{pF} \times 250 \\ &\quad + 0.5\ \text{pF} \times 5\ \text{k} \\ &= 33.1\ \text{ns} \end{aligned}$$
   so 4.80 MHz: almost four times the CS stage's, at the same gain.
2. **Common gate, input pole.** The input sees 10 kΩ ∥ 250 Ω = 244 Ω, which with 2 pF puts a pole at 326 MHz.
3. **Common gate, output pole.** 0.5 pF across 5 kΩ puts it at 63.7 MHz.
4. **Common gate, overall gain.** Its input resistance of 244 Ω takes most of the 10 kΩ source's signal, so its overall gain is only about 0.5: wide bandwidth, little gain.

**Answer:** the cascode reaches 4.80 MHz; the common-gate stage has poles at 326 MHz and 63.7 MHz but an overall gain of only about 0.5.
:::
:::

::: check
kind: python

## Step 1. Write `cs_coeffs(gm, RL, Rs, Cgs, Cgd, CL)` returning `(a, b)`, the coefficients of s and s² in the common-source stage's denominator.

```python starter
def cs_coeffs(gm, RL, Rs, Cgs, Cgd, CL):
    return Rs * (Cgs + Cgd * (1 + gm * RL)), 0.0

print(cs_coeffs(4e-3, 5e3, 10e3, 2e-12, 0.5e-12, 0))
```

```python solution
def cs_coeffs(gm, RL, Rs, Cgs, Cgd, CL):
    a = Rs * Cgs + Rs * Cgd * (1 + gm * RL) + RL * (Cgd + CL)
    b = Rs * RL * (Cgs * Cgd + Cgs * CL + Cgd * CL)
    return a, b

print(cs_coeffs(4e-3, 5e3, 10e3, 2e-12, 0.5e-12, 0))
```

```python tests
a, b = cs_coeffs(4e-3, 5e3, 10e3, 2e-12, 0.5e-12, 0)
assert abs(a - 127.5e-9) < 1e-15 and abs(b - 5e-17) < 1e-25, f"Expected 127.5 ns and 5e-17 s²; got {a}, {b}"
a2, b2 = cs_coeffs(4e-3, 5e3, 10e3, 2e-12, 0.5e-12, 1e-12)
assert abs(a2 - 132.5e-9) < 1e-15 and abs(b2 - 1.75e-16) < 1e-24, "With 1 pF of load: 132.5 ns and 1.75e-16 s²."
```

::: right
Right. The s coefficient is the sum of open-circuit time constants, term for term.
:::
:::

::: check
kind: python

## Step 2. Write `poles(a, b)` returning the two pole frequencies in Hz, smaller first, from the roots of $1 + as + bs^2$ (assume they're real).

```python starter
import math

def poles(a, b):
    return 1 / (2 * math.pi * a), 1 / (2 * math.pi * a)

print(poles(127.5e-9, 5e-17))
```

```python solution
import math

def poles(a, b):
    d = math.sqrt(a * a - 4 * b)
    s1 = (a - d) / (2 * b)
    s2 = (a + d) / (2 * b)
    return s1 / (2 * math.pi), s2 / (2 * math.pi)

print(poles(127.5e-9, 5e-17))
```

```python tests
import math
p1, p2 = poles(127.5e-9, 5e-17)
assert abs(p1 - 1252137.2) < 1 and abs(p2 - 404592968) < 100, f"Expected 1.252 MHz and 405 MHz; got {p1}, {p2}"
assert abs(1 / (2 * math.pi * p1) + 1 / (2 * math.pi * p2) - 127.5e-9) < 1e-15, "The reciprocal poles must add to a."
```

::: right
Right. A widely split pair of poles makes a nearly equal to the dominant one's time constant.
:::
:::

::: check
kind: python

## Step 3. Write `f3db(gm, RL, Rs, Cgs, Cgd, CL)` returning the exact −3 dB frequency, including the right-half-plane zero, by bisection on a log scale between 1 Hz and 1 THz. Your `cs_coeffs` is available.

```python starter
import math

def cs_coeffs(gm, RL, Rs, Cgs, Cgd, CL):
    a = Rs * Cgs + Rs * Cgd * (1 + gm * RL) + RL * (Cgd + CL)
    b = Rs * RL * (Cgs * Cgd + Cgs * CL + Cgd * CL)
    return a, b

def f3db(gm, RL, Rs, Cgs, Cgd, CL):
    a, b = cs_coeffs(gm, RL, Rs, Cgs, Cgd, CL)
    return 1 / (2 * math.pi * a)

print(f3db(4e-3, 5e3, 10e3, 2e-12, 0.5e-12, 0))
```

```python solution
import math

def cs_coeffs(gm, RL, Rs, Cgs, Cgd, CL):
    a = Rs * Cgs + Rs * Cgd * (1 + gm * RL) + RL * (Cgd + CL)
    b = Rs * RL * (Cgs * Cgd + Cgs * CL + Cgd * CL)
    return a, b

def f3db(gm, RL, Rs, Cgs, Cgd, CL):
    a, b = cs_coeffs(gm, RL, Rs, Cgs, Cgd, CL)
    def mag(f):
        w = 2 * math.pi * f
        return math.hypot(1, w * Cgd / gm) / math.hypot(1 - b * w * w, a * w)
    lo, hi = 1.0, 1e12
    for _ in range(200):
        m = math.sqrt(lo * hi)
        if mag(m) > 1 / math.sqrt(2):
            lo = m
        else:
            hi = m
    return lo

print(f3db(4e-3, 5e3, 10e3, 2e-12, 0.5e-12, 0))
```

```python tests
f1 = f3db(4e-3, 5e3, 10e3, 2e-12, 0.5e-12, 0)
f2 = f3db(4e-3, 5e3, 10e3, 2e-12, 0.5e-12, 1e-12)
assert abs(f1 - 1252126) < 5 and abs(f2 - 1213263) < 5, f"Expected 1.2521 and 1.2133 MHz; got {f1}, {f2}"
```

::: right
Right. The exact corner sits just above the time-constant estimate, as it always does.
:::
:::

::: check
kind: python

## Step 4. Write `cascode_tau(gm1, gm2, Rs, RL, Cgs1, Cgd1, Cgs2, Cgd2, CL)` returning the cascode's sum of open-circuit time constants.

```python starter
def cascode_tau(gm1, gm2, Rs, RL, Cgs1, Cgd1, Cgs2, Cgd2, CL):
    return Rs * (Cgs1 + Cgd1 * (1 + gm1 * RL))

print(cascode_tau(4e-3, 4e-3, 10e3, 5e3, 2e-12, 0.5e-12, 2e-12, 0.5e-12, 0))
```

```python solution
def cascode_tau(gm1, gm2, Rs, RL, Cgs1, Cgd1, Cgs2, Cgd2, CL):
    return (Cgs1 * Rs + Cgd1 * (Rs * (1 + gm1 / gm2) + 1 / gm2)
            + Cgs2 / gm2 + (Cgd2 + CL) * RL)

print(cascode_tau(4e-3, 4e-3, 10e3, 5e3, 2e-12, 0.5e-12, 2e-12, 0.5e-12, 0))
```

```python tests
import math
t = cascode_tau(4e-3, 4e-3, 10e3, 5e3, 2e-12, 0.5e-12, 2e-12, 0.5e-12, 0)
assert abs(t - 33.125e-9) < 1e-15, f"Expected 33.1 ns; got {t}"
assert abs(1 / (2 * math.pi * t) - 4804678) < 5, "That's 4.80 MHz."
```

::: right
Right. The cascode device's low input resistance, $1/g_{m2}$, is what kills the Miller multiplication.
:::
:::

::: check
kind: python

## Step 5. Write `cg_poles(gm, Rs, RL, Cin, Cout)` returning `(f_in, f_out)` for a common-gate stage.

```python starter
import math

def cg_poles(gm, Rs, RL, Cin, Cout):
    return 1 / (2 * math.pi * Rs * Cin), 1 / (2 * math.pi * RL * Cout)

print(cg_poles(4e-3, 10e3, 5e3, 2e-12, 0.5e-12))
```

```python solution
import math

def cg_poles(gm, Rs, RL, Cin, Cout):
    Rin = 1 / (1 / Rs + gm)
    return 1 / (2 * math.pi * Rin * Cin), 1 / (2 * math.pi * RL * Cout)

print(cg_poles(4e-3, 10e3, 5e3, 2e-12, 0.5e-12))
```

```python tests
fi, fo = cg_poles(4e-3, 10e3, 5e3, 2e-12, 0.5e-12)
assert abs(fi - 326267633) < 100 and abs(fo - 63661977) < 10, f"Expected 326 MHz and 63.7 MHz; got {fi}, {fo}"
```

::: right
Right. The input node sees the source in parallel with $1/g_m$, which pushes its pole far out.
:::
:::

::: check
kind: parts
given: gm = 2 | 5 | 10; RL = 2 | 10; Rs = 1 | 10; Cgs = 1 | 3; Cgd = 0.2 | 0.6

## A CS stage has $g_m$ = {gm} mS, $R_L$ = {RL} kΩ, a {Rs} kΩ source, $C_{gs}$ = {Cgs} pF and $C_{gd}$ = {Cgd} pF, no load capacitance.

::: part
answer: Rs*Cgs + Rs*Cgd*(1 + gm*RL) + RL*Cgd
unit: ns
tolerance: 0.5%

### What's the sum of time constants, in kΩ × pF = ns?

::: misses
- [Rs*Cgs + Rs*Cgd*(1 + gm*RL)] Include $C_{gd}R_L$.
- [any] $R_sC_{gs} + R_sC_{gd}(1 + g_mR_L) + R_LC_{gd}$.
:::
:::

::: part
answer: gm/(2*pi*Cgd)
unit: GHz
tolerance: 0.5%

### Where's the right-half-plane zero?

::: misses
- [any] $\frac{g_m}{2\pi C_{gd}}$.
:::
:::
:::

::: explain
## Why is the open-circuit time-constant estimate of the upper corner always a little low?

::: model
The sum of open-circuit time constants is exactly the coefficient of s in the denominator, and that coefficient equals the sum of the reciprocals of all the poles. The estimate treats that whole sum as if it belonged to a single pole. The dominant pole's own time constant is only part of it, so the estimate's pole lands slightly below the dominant pole. The other poles also roll off the response only a little near the dominant pole, so the true corner sits just above the estimate. When the poles are far apart the difference is tiny; as they approach each other the estimate becomes more conservative.
:::
:::

::: practice

::: check
given: gm = 3 | 8; Rs = 2 | 20; RL = 1 | 6
answer: 1/(1/(Rs*1000) + gm*1e-3)
unit: Ω
tolerance: 0.5%

## A common-gate stage with $g_m$ = {gm} mS is driven from {Rs} kΩ. What resistance does its input node see?

::: misses
- [any] $R_s \parallel \frac{1}{g_m}$.
:::
:::
:::
