Transfer Functions and Stability
Engineers rarely solve a linear ODE for one particular input. They describe the system once, by its transfer function, and read off everything important from it: stability, the response to a step, the response to every frequency. This lesson connects the Laplace transform to that viewpoint.
The transfer function
For a linear constant-coefficient system with input and output ,
zero initial conditions give with
The roots of the denominator are the poles (they are the characteristic roots of the ODE), the roots of the numerator are the zeros.
Stability from the poles
The impulse response is a sum of terms , one family per pole . So:
- all poles with : , every bounded input gives a bounded output. The system is stable.
- any pole with : unstable.
- simple poles on the imaginary axis: marginally stable (undamped oscillation; a resonant input makes it blow up).
import numpy as np
systems = {"damped spring s^2 + 0.5s + 4": [1, 0.5, 4],
"undamped spring s^2 + 4": [1, 0, 4],
"third order s^3 + 2s^2 + 3s + 10": [1, 2, 3, 10],
"third order s^3 + 3s^2 + 3s + 1": [1, 3, 3, 1]}
for name, den in systems.items():
p = np.roots(den)
status = "stable" if np.all(p.real < -1e-9) else ("marginal" if np.all(p.real < 1e-9) else "unstable")
print(f"{name:34s} poles {np.round(p, 3)} -> {status}")damped spring s^2 + 0.5s + 4 poles [-0.25+1.984j -0.25-1.984j] -> stable
undamped spring s^2 + 4 poles [-0.+2.j 0.-2.j] -> marginal
third order s^3 + 2s^2 + 3s + 10 poles [-2.445+0.j 0.223+2.01j 0.223-2.01j] -> unstable
third order s^3 + 3s^2 + 3s + 1 poles [-1.+0.j -1.+0.j -1.-0.j] -> stable
The polynomial looks harmless, all coefficients positive, but it has two poles in the right half-plane. (For cubics with positive coefficients, stability needs , a case of the Routh-Hurwitz criterion; here .)
Step response
The response to a unit step is . Its final value, if the system is stable, is (the "DC gain"), a consequence of the final value theorem .
import numpy as np
from scipy import signal
H = signal.lti([4], [1, 1.2, 4]) # a spring with zeta = 0.3, DC gain 1
t = np.linspace(0, 15, 1501)
t, y = signal.step(H, T=t)
print(f"final value {y[-1]:.4f} (H(0) = 1)")
print(f"overshoot {100 * (y.max() - 1):.1f} %, peak at t = {t[np.argmax(y)]:.2f}")
zeta = 0.3
print(f"theory: overshoot {100 * np.exp(-zeta * np.pi / np.sqrt(1 - zeta**2)):.1f} %, peak at {np.pi / (2 * np.sqrt(1 - zeta**2)):.2f}")final value 1.0001 (H(0) = 1)
overshoot 37.2 %, peak at t = 1.65
theory: overshoot 37.2 %, peak at 1.65
Frequency response
For a stable system, the steady-state response to is . The amplitude is exactly the resonance curve of Forced Oscillations and Resonance, now computed by plugging into . Plotted on log scales it is the Bode plot.
import numpy as np
H = lambda s: 1 / (s**2 + 0.2 * s + 1) # m = 1, c = 0.2, k = 1
for w in (0.5, 1.0, 2.0):
v = H(1j * w)
print(f"omega = {w}: gain {abs(v):.4f}, phase {np.degrees(np.angle(v)):7.2f} degrees")omega = 0.5: gain 1.3216, phase -7.59 degrees
omega = 1.0: gain 5.0000, phase -90.00 degrees
omega = 2.0: gain 0.3304, phase -172.41 degrees
At resonance the gain is and the output lags the input by exactly 90 degrees.
In software
scipy.signal(lti,step,impulse,bode,freqresp) and MATLAB's Control System Toolbox work directly with transfer functions.- PID controllers in drones, 3D printers and thermostats are tuned by placing the closed-loop poles in the left half-plane with enough damping; an unstable pole is a drone that oscillates itself out of the sky.
- Audio equalizers are designed by their frequency response .
Exercises
Exercise 1: Poles and stability
Find the poles of . Is the system stable?
Answer
; stable.
Solution
. Both poles have real part .
Exercise 2: DC gain
What is the final value of the step response of ?
Answer
Solution
The system is stable (roots , both negative), so the final value is .
Exercise 3: Find the unstable range (code)
For which is stable? Check and numerically.
Answer
.
Solution
The cubic criterion gives .
import numpy as np
for K in (5, 7):
print(K, np.round(np.roots([1, 3, 2, K]), 4))5 [-2.9042+0.j -0.0479+1.3112j -0.0479-1.3112j]
7 [-3.0867+0.j 0.0434+1.5053j 0.0434-1.5053j]
At a complex pair has crossed into the right half-plane.
Test yourself
A system is stable when all poles of …
- are real
- have negative real parts
- are zero
- lie on the imaginary axis
The steady-state gain at frequency is…
The final value of a stable system's unit step response is…
- 0
- 1 always