---
title: The argument principle and Nyquist's criterion
heading: Counting zeros inside a curve, and judging a feedback loop's stability from its frequency response
eyebrow: A12 · Lesson 21 · The argument principle
xp: 40
---

::: hook
To know whether a feedback loop is stable, you need to know whether $1 + L(s)$ has any zeros in the right half-plane. Finding those zeros can be hard, and often you only have $L(j\omega)$ as measured data. Complex analysis offers a way around this: you can count the zeros inside a curve without finding them, by watching how many times the function's value winds around the origin as you walk the curve. That's the **argument principle**, and applied to a feedback loop it becomes **Nyquist's criterion**, which reads stability straight off a plot of $L(j\omega)$.
:::

::: play
- The curve is the Nyquist plot of $L(s) = \frac{K}{(s + 1)^3}$: the values of $L(j\omega)$ as ω runs from −∞ to ∞. The dot marks −1.
- The closed loop is stable while the curve does not encircle −1. Raise K: the curve grows, and at K = 8 it passes through −1.
- The readouts give the gain margin and the real part of the rightmost closed-loop pole, which crosses zero at the same moment.
:::

```sim plot
view: complex
range: 4
slider: K = 0.5..20 step 0.1 = 4
curve: K/(j*tan(u) + 1)^3 | over: u = -1.565..1.565 | color: ch2
dot: -1 | label: −1
readout: crossing of the negative real axis = -K/8 | digits: 3
readout: gain margin = 8/K | digits: 3
readout: real part of the rightmost closed-loop pole = -1 + K^(1/3)/2 | digits: 3
```

::: predict
## A function f is analytic inside and on a circle and has 3 zeros inside it, none on it. As z goes once around the circle counterclockwise, how many times does f(z) wind around the origin?

- [ ] Once
- [x] Three times, counterclockwise
- [ ] Three times, clockwise
- [ ] Not at all, by Cauchy's theorem

::: reveal
Three times, counterclockwise. Near each zero, f behaves like $c(z - z_k)$, and the factor $z - z_k$ turns once around as z circles $z_k$. The angles of the three factors add, so f's angle turns three times. Poles inside would each subtract a turn.
:::
:::

::: nameit
## The argument principle

If f is analytic inside and on a simple closed curve C, except for poles inside, and has no zeros or poles on C, then

$$\frac{1}{2\pi j}\oint_C\frac{f'(z)}{f(z)}dz = Z - P,$$

where Z and P count the zeros and poles inside, each with its multiplicity. Since $\frac{f'}{f} = (\ln f)'$, the integral measures the change in $\ln f$ around C, which is $j$ times the change in $\arg f$. So $Z - P$ is the number of times $f(C)$ winds counterclockwise around the origin.

## Rouché's theorem

If $\lvert g\rvert < \lvert f\rvert$ everywhere on C, then $f$ and $f + g$ have the same number of zeros inside C. The small term g can't pull $f + g$ around the origin, so their winding numbers agree. This locates polynomial roots in rings without solving for them.

## Nyquist's criterion

A loop with open-loop gain $L(s)$ has closed-loop poles at the zeros of $1 + L(s)$. Take C to be the **Nyquist contour**: up the imaginary axis and around a huge half circle through the right half-plane, traversed clockwise. Map it through L. Counting clockwise encirclements of −1 by the plot (encirclements of 0 by $1 + L$),

$$Z = N + P,$$

where P is the number of open-loop poles in the right half-plane, N the number of clockwise encirclements of −1, and Z the number of closed-loop poles in the right half-plane. The loop is stable when Z = 0: an open-loop-stable L must not encircle −1 at all, and an open-loop-unstable one must encircle it counterclockwise once for each unstable pole.

## Margins

If the plot crosses the negative real axis at $-a$ with $a < 1$, the gain can rise by a factor $1/a$ before it touches −1: that's the **gain margin**.
:::

::: example
## How many zeros does $p(z) = z^5 + 3z + 1$ have inside $\lvert z\rvert < 1$, and how many in the ring $1 < \lvert z\rvert < 2$?

::: solution
1. **On the unit circle.** $\lvert 3z\rvert = 3$ while $\lvert z^5 + 1\rvert \le 2$. By Rouché, p has as many zeros inside as $3z$ does: one.
2. **On |z| = 2.** $\lvert z^5\rvert = 32$ while $\lvert 3z + 1\rvert \le 7$. So inside $\lvert z\rvert < 2$, p has as many zeros as $z^5$: all five.
3. **None on the unit circle.** There $\lvert z^5 + 3z + 1\rvert \ge 3 - 2 = 1$, so four zeros lie in the ring.
4. **No algebra needed.** We never solved the quintic.

**Answer:** one zero inside $\lvert z\rvert < 1$, and four in the ring $1 < \lvert z\rvert < 2$.
:::
:::

::: example
## For which gains K is the loop $L(s) = \frac{K}{(s + 1)^3}$ stable?

::: solution
1. **The stability condition.** L has no right-half-plane poles, so the closed loop is stable when the Nyquist plot doesn't encircle −1.
2. **Where the phase is −180°.** That's where the plot crosses the negative real axis:
   $$3\tan^{-1}\omega = 180°$$
   so $\omega = \tan 60° = \sqrt3$.
3. **The gain there.**
   $$\begin{aligned} \lvert L\rvert &= \frac{K}{(1 + 3)^{3/2}} \\ &= \frac K8 \end{aligned}$$
4. **Compare with −1.** For $K < 8$ the crossing is at $-K/8$, inside −1, and the loop is stable. At K = 8 it passes through −1, and above that it encircles −1 twice clockwise (once for each of the two conjugate poles that cross).
5. **Check with Routh.** Routh's test on $s^3 + 3s^2 + 3s + 1 + K$ gives the same bound, $3 \cdot 3 > 1 + K$.

**Answer:** the loop is stable for $K < 8$.
:::
:::

::: example
## $L(s) = \frac{K}{s - 1}$ has an unstable open-loop pole. For which K does feedback stabilize it?

::: solution
1. **What's needed.** P = 1, so the plot must encircle −1 once counterclockwise.
2. **The Nyquist plot.**
   $$L(j\omega) = \frac{K(-1 - j\omega)}{1 + \omega^2}$$
   traces a circle through 0 and −K, centered at $-K/2$.
3. **Its direction.** It runs counterclockwise as ω increases: at ω = −1 it's at $-\frac K2 + \frac K2j$, at ω = 0 at −K, at ω = 1 at $-\frac K2 - \frac K2j$.
4. **When it encircles −1.** It does exactly when $K > 1$. Then N = −1 and Z = N + P = 0: stable.
5. **Check directly.** $1 + \frac{K}{s - 1} = 0$ gives $s = 1 - K$, which is in the left half-plane for K > 1.

**Answer:** feedback stabilizes it for $K > 1$.
:::
:::

::: check
given: n = 6 | 7; m = 2 | 3; a = 4 | 5
answer: m
tolerance: 0

## How many zeros does $z^{\given{n}} + \given{a}z^{\given{m}} + 1$ have inside $\lvert z\rvert < 1$?

::: right
Right. On the unit circle $\lvert az^m\rvert = a > 2 \ge \lvert z^n + 1\rvert$, so by Rouché it has as many zeros as $az^m$: m of them.
:::

::: misses
- [n] Inside the unit circle the middle term dominates, not the highest power.
- [any] Compare the sizes of the terms on $\lvert z\rvert = 1$.
:::
:::

::: check
given: a = 2 | 3 | 5
answer: 8*a^3
tolerance: 0.5%

## $L(s) = \frac{K}{(s + \given{a})^3}$. What is the largest K for a stable closed loop?

::: right
Right. The phase reaches −180° at $\omega = a\sqrt3$, where $\lvert L\rvert = \frac{K}{8a^3}$.
:::

::: misses
- [8] That's for a = 1; the poles' distance scales the answer as $a^3$.
- [any] Find where $3\tan^{-1}(\omega/a) = 180°$ and set $\lvert L\rvert = 1$ there.
:::
:::

::: check
given: K = 1 | 2 | 4
answer: 20*log(8/K)
unit: dB
tolerance: 0.5%

## What is the gain margin of $L(s) = \frac{\given{K}}{(s + 1)^3}$, in decibels?

::: right
Right. The plot crosses the axis at $-K/8$, so the gain can grow by $8/K$.
:::

::: misses
- [8/K] That's the ratio; convert to decibels.
- [any] $20\log_{10}\frac{8}{K}$.
:::
:::

::: check
kind: parts
given: a = 1 | 2; b = 3 | 5

## $L(s) = \frac{K}{s(s + \given{a})(s + \given{b})}$.

::: part
answer: sqrt(a*b)
unit: rad/s
tolerance: 0.5%

### At what frequency, in rad/s, does its phase reach −180°?

::: misses
- [a + b] Solve $\tan^{-1}\frac{\omega}{a} + \tan^{-1}\frac{\omega}{b} = 90°$.
- [any] The two lags add to 90° when $\omega^2 = ab$.
:::
:::

::: part
answer: a*b*(a + b)
tolerance: 0.5%

### What is the largest K for a stable loop?

::: misses
- [a*b] Include the magnitudes of all three factors at $\omega = \sqrt{ab}$.
- [any] $\lvert L\rvert = \frac{K}{ab(a + b)}$ at the crossing.
:::
:::
:::

::: check
given: P = 1 | 2; N = 1 | 2
answer: N + P
tolerance: 0

## A loop has {P} open-loop poles in the right half-plane, and its Nyquist plot circles −1 clockwise {N} times. How many closed-loop poles are in the right half-plane?

::: right
Right. $Z = N + P$.
:::

::: misses
- [N - P] Clockwise encirclements add to the open-loop count.
- [any] $Z = N + P$.
:::
:::

::: check
given: m = 2 | 3 | 4
answer: m - 1
tolerance: 0

## $f(z) = \frac{(z - 1)^{\given{m}}(z + 3)}{z - 0.5}$. What is $\frac{1}{2\pi j}\oint\frac{f'}{f}dz$ around $\lvert z\rvert = 2$?

::: right
Right. m zeros at 1 inside, the zero at −3 outside, and one pole inside: $m - 1$.
:::

::: misses
- [m] Subtract the pole at 0.5.
- [m + 1] The zero at −3 is outside the circle.
- [any] Zeros minus poles inside, with multiplicity.
:::
:::

::: check
kind: choice

## What does Nyquist's criterion need that a root finder doesn't?

- [ ] The closed-loop transfer function
- [x] Only the open-loop frequency response and the number of open-loop unstable poles
- [ ] A model with no time delay
- [ ] The location of every closed-loop pole

::: right
Right. That's why it works on measured data and on loops with time delays, where the characteristic equation isn't a polynomial.
:::

::: misses
- [1] It works from L alone.
- [3] Delays are no problem: $e^{-sT}$ just spins the plot.
- [4] It counts the unstable ones without locating them.
:::
:::

::: check
kind: derivation
vars: K = 0.1..5

## $L(s) = \frac{K}{s - 1}$ in unity feedback.

::: step
answer: 1 - K

### Where is the closed-loop pole?
:::

::: step
answer: -K

### Where is $L(j\omega)$ at ω = 0?
:::

::: right
Right. The plot is a circle from 0 to −K, so it encircles −1 exactly when K > 1, which is when the pole $1 - K$ crosses into the left half-plane.
:::
:::

::: check
kind: python

## For $L(s) = \frac{K}{(s + 1)^3}$, find by bisection the frequency `wc` in (0.1, 10) where the phase $-3\tan^{-1}\omega$ reaches −π, and set `Kmax` to the gain that makes $\lvert L(j\omega_c)\rvert = 1$.

```python starter
import math

wc = 1.0
Kmax = 1.0
print(wc, Kmax)
```

```python solution
import math

lo, hi = 0.1, 10.0
for _ in range(100):
    mid = (lo + hi) / 2
    if -3 * math.atan(mid) > -math.pi:
        lo = mid
    else:
        hi = mid
wc = (lo + hi) / 2
Kmax = (1 + wc**2)**1.5
print(wc, Kmax)
```

```python tests
import math
assert abs(wc - math.sqrt(3)) < 1e-9, f"The phase crosses -180 degrees at sqrt(3); got {wc}."
assert abs(Kmax - 8) < 1e-8, f"The largest stable gain is 8; got {Kmax}."
```

::: right
Right. $\sqrt3$ rad/s and K = 8, the same as Routh's test. The search works just as well on measured phase data.
:::
:::

::: explain
## Why does the number of times f(z) circles the origin count the zeros minus the poles inside the curve?

::: model
Factor f as $\frac{(z - z_1)\cdots(z - z_Z)}{(z - p_1)\cdots(z - p_P)}g(z)$, where g is analytic with no zeros inside. The angle of f is the sum of the angles of the factors on top, minus those below, plus the angle of g. As z goes once around C, each factor $z - z_k$ with $z_k$ inside turns through a full 360°, and each factor whose root is outside comes back to its starting angle. g has no zeros inside, so $\ln g$ is analytic there and its angle returns too. So the total change in $\arg f$ is $360°(Z - P)$, which is the number of turns around the origin.
:::
:::

::: practice

::: check
given: a = 0.5 | 1 | 1.5 | 2 | 3 | 4
answer: 8*a^3
tolerance: 0.5%

## Largest stable K for $\frac{K}{(s + \given{a})^3}$?

::: misses
- [any] $8a^3$.
:::
:::

::: check
given: a = 2 | 4; b = 6 | 10
answer: a*b*(a + b)
tolerance: 0.5%

## Largest stable K for $\frac{K}{s(s + \given{a})(s + \given{b})}$?

::: misses
- [any] $ab(a + b)$.
:::
:::

::: check
given: P = 1 | 3; N = 0 | 2
answer: N + P
tolerance: 0

## Closed-loop RHP poles with P = {P}, N = {N} clockwise?

::: misses
- [any] $Z = N + P$.
:::
:::
:::
