TExcelTAD
Home › Differential Equations › Two-Dimensional Phase Portraits

Two-Dimensional Phase Portraits

For a 2×22 \times 2 system x′=Ax\mathbf{x}' = A\mathbf{x}, the eigenvalues of AA 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 λ1\lambda_1, λ2\lambda_2:

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 2×22 \times 2 matrix are the roots of λ2−Tλ+D=0\lambda^2 - T\lambda + D = 0 with T=tr⁡AT = \operatorname{tr}A and D=det⁡AD = \det A. So the type can be read without computing eigenvalues:

  • D<0D < 0: saddle.
  • D>0D > 0 and T2−4D>0T^2 - 4D > 0: node (sink if T<0T < 0, source if T>0T > 0).
  • D>0D > 0 and T2−4D<0T^2 - 4D < 0: spiral (sink if T<0T < 0, source if T>0T > 0), or a center if T=0T = 0.
python · try it yourself
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 v2=(1,−2)\mathbf{v}_2 = (1, -2) (λ=−1\lambda = -1) and leave along v1=(1,2)\mathbf{v}_1 = (1, 2) (λ=3\lambda = 3).

python · try it yourself
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 λ1<λ2<0\lambda_1 < \lambda_2 < 0, the term eλ1te^{\lambda_1 t} dies first, so trajectories approach the origin tangent to the slow eigenvector v2\mathbf{v}_2. The example A=[−311−3]A = \begin{bmatrix} -3 & 1 \\ 1 & -3 \end{bmatrix} has λ=−2\lambda = -2 with v=(1,1)\mathbf{v} = (1, 1) and λ=−4\lambda = -4 with v=(1,−1)\mathbf{v} = (1, -1):

python · try it yourself
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 (1,1)/2≈(0.7071,0.7071)(1, 1)/\sqrt{2} \approx (0.7071, 0.7071), 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 I−γHI - \gamma H; 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 A=[1−23−4]A = \begin{bmatrix} 1 & -2 \\ 3 & -4 \end{bmatrix}.

Answer

Stable node (sink), eigenvalues −1-1 and −2-2.

Solution

T=−3T = -3, D=−4+6=2>0D = -4 + 6 = 2 > 0, T2−4D=1>0T^2 - 4D = 1 > 0: a node with T<0T < 0, so a sink. Roots of λ2+3λ+2\lambda^2 + 3\lambda + 2.

Exercise 2: A center

For which kk is the origin of x′=[k1−5−k]x\mathbf{x}' = \begin{bmatrix} k & 1 \\ -5 & -k \end{bmatrix}\mathbf{x} a center?

Answer

For all kk with ∣k∣<5\lvert k\rvert < \sqrt{5}.

Solution

T=0T = 0 always, and D=−k2+5D = -k^2 + 5. A center needs D>0D > 0: k2<5k^2 < 5. For ∣k∣>5\lvert k\rvert > \sqrt{5} it is a saddle.

Exercise 3: Saddle directions (code)

For A=[0110]A = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}, find the stable and unstable directions and check that the trajectory from (1,−1)(1, -1) goes to the origin.

Answer

Unstable along (1,1)(1, 1) (λ=1\lambda = 1), stable along (1,−1)(1, -1) (λ=−1\lambda = -1); from (1,−1)(1, -1), x=e−t(1,−1)→0\mathbf{x} = e^{-t}(1, -1) \to \mathbf{0}.

Solution
python · try it yourself
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 (1,1)(1, 1) that eventually grows.

Test yourself

Eigenvalues −2-2 and 55 make the origin a…

  1. sink
  2. source
  3. saddle
  4. center

For a 2×22 \times 2 matrix with det⁡A<0\det A < 0, the origin is…

  1. always a saddle
  2. a spiral
  3. a center
  4. a sink

Eigenvalues ±3i\pm 3i give…

  1. a spiral sink
  2. a center with closed orbits
  3. a saddle
  4. a source