Two-Dimensional Phase Portraits
For a system , the eigenvalues of decide the shape of every trajectory near the origin. There are only a handful of possible pictures, and learning them pays off twice: once here, and again for nonlinear systems, which look like one of these pictures near each equilibrium.
The catalogue
The origin is always an equilibrium (a critical point). With eigenvalues , :
| Eigenvalues | Name | Behaviour | Stable? |
|---|---|---|---|
| real, both negative | sink (stable node) | all trajectories enter the origin | yes |
| real, both positive | source (unstable node) | all trajectories leave | no |
| real, opposite signs | saddle | in along one eigenvector, out along the other | no |
| complex, real part negative | spiral sink | spirals inward | yes |
| complex, real part positive | spiral source | spirals outward | no |
| purely imaginary | center | closed orbits (ellipses) | stable, not attracting |
Repeated eigenvalues give degenerate (improper) nodes, covered in Repeated Eigenvalues.
Trace and determinant
The eigenvalues of a matrix are the roots of with and . So the type can be read without computing eigenvalues:
- : saddle.
- and : node (sink if , source if ).
- and : spiral (sink if , source if ), or a center if .
import numpy as np
def classify(A):
T, D = np.trace(A), np.linalg.det(A)
disc = T**2 - 4 * D
if D < 0: return "saddle"
if abs(T) < 1e-12 and D > 0: return "center"
kind = "node" if disc > 0 else ("spiral" if disc < 0 else "degenerate node")
return kind + (" sink" if T < 0 else " source")
for A in ([[1, 1], [4, 1]], [[-3, 1], [1, -3]], [[0, 1], [-4, 0]], [[-1, 2], [-2, -1]], [[2, -5], [1, 0]]):
A = np.array(A, dtype=float)
print(np.round(np.linalg.eigvals(A), 3), "->", classify(A))[ 3. -1.] -> saddle
[-2. -4.] -> node sink
[0.+2.j 0.-2.j] -> center
[-1.+2.j -1.-2.j] -> spiral sink
[1.+2.j 1.-2.j] -> spiral source
Drawing a portrait
streamplot draws trajectories of a vector field directly. Here is a saddle with its two eigenvector lines: trajectories come in along () and leave along ().
import numpy as np
import matplotlib.pyplot as plt
A = np.array([[1.0, 1.0], [4.0, 1.0]])
x, y = np.meshgrid(np.linspace(-3, 3, 30), np.linspace(-3, 3, 30))
u = A[0, 0] * x + A[0, 1] * y
v = A[1, 0] * x + A[1, 1] * y
fig, ax = plt.subplots(figsize=(5, 5))
ax.streamplot(x, y, u, v, density=1.2, color="gray")
s = np.linspace(-3, 3, 2)
ax.plot(s, 2 * s, "r", lw=2, label="eigenvector (1, 2), lambda = 3")
ax.plot(s, -2 * s, "b", lw=2, label="eigenvector (1, -2), lambda = -1")
ax.set_xlim(-3, 3); ax.set_ylim(-3, 3); ax.legend(loc="lower right", fontsize=7)
print("saddle: in along (1, -2), out along (1, 2)")saddle: in along (1, -2), out along (1, 2)
Nodes: fast and slow directions
For a sink with , the term dies first, so trajectories approach the origin tangent to the slow eigenvector . The example has with and with :
import numpy as np
from scipy.integrate import solve_ivp
A = np.array([[-3.0, 1.0], [1.0, -3.0]])
sol = solve_ivp(lambda t, x: A @ x, (0, 4), [2.0, -1.0], t_eval=[0, 0.5, 1, 2, 4], rtol=1e-10, atol=1e-14)
for t, x in zip(sol.t, sol.y.T):
d = x / np.linalg.norm(x)
print(f"t = {t}: x = {np.round(x, 5)}, direction {np.round(d, 4)}")t = 0.0: x = [ 2. -1.], direction [ 0.8944 -0.4472]
t = 0.5: x = [ 0.38694 -0.01906], direction [ 0.9988 -0.0492]
t = 1.0: x = [0.09514 0.04019], direction [0.9212 0.3892]
t = 2.0: x = [0.00966 0.00865], direction [0.7448 0.6672]
t = 4.0: x = [0.00017 0.00017], direction [0.7078 0.7064]
The direction converges to , the slow eigenvector.
In software
- Control engineers place eigenvalues ("poles") deliberately: a controller is designed so that the closed-loop system is a sink, often a lightly damped spiral sink for fast response.
- In ML, the dynamics of gradient descent near a minimum are a linear system whose matrix is ; a saddle point of the loss shows up as a saddle of this map (Gradient Descent).
Exercises
Exercise 1: Classify by trace and determinant
Classify .
Answer
Stable node (sink), eigenvalues and .
Solution
, , : a node with , so a sink. Roots of .
Exercise 2: A center
For which is the origin of a center?
Answer
For all with .
Solution
always, and . A center needs : . For it is a saddle.
Exercise 3: Saddle directions (code)
For , find the stable and unstable directions and check that the trajectory from goes to the origin.
Answer
Unstable along (), stable along (); from , .
Solution
import numpy as np
from scipy.integrate import solve_ivp
A = np.array([[0.0, 1.0], [1.0, 0.0]])
print(np.linalg.eigvals(A))
sol = solve_ivp(lambda t, x: A @ x, (0, 5), [1.0, -1.0], rtol=1e-12, atol=1e-14)
print(np.round(sol.y[:, -1], 6), round(np.exp(-5), 6))[ 1. -1.]
[ 0.006738 -0.006738] 0.006738
Starting exactly on the stable line is essential: any tiny error has a component along that eventually grows.
Test yourself
Eigenvalues and make the origin a…
- sink
- source
- saddle
- center
For a matrix with , the origin is…
- always a saddle
- a spiral
- a center
- a sink
Eigenvalues give…
- a spiral sink
- a center with closed orbits
- a saddle
- a source