Learning Objectives
By the end of this section you will be able to:
- Interpret any 2D linear system as a velocity field on the plane and a flow of curves.
- Recognise the five fundamental portraits — saddle, stable node, unstable node, stable spiral, unstable spiral — and the two boundary cases (center, degenerate) by looking at the picture.
- Predict the portrait type from just two scalars: and , via the discriminant .
- Locate any 2×2 matrix as a single dot in the trace–determinant plane and read off its qualitative behaviour.
- Implement the velocity field, integrate trajectories by hand-written RK4, and verify against a closed-form solution.
- Batch-classify thousands of systems in one PyTorch call using a vectorised companion-matrix construction.
Why We Need Phase Portraits
"Forget the formula. Look at the picture." Henri Poincaré's decisive move in the 1880s — the move that founded modern dynamical systems.
For a single scalar ODE we already have a graphical habit: draw against , mark the zeros (the equilibria), and read off the direction of motion from the sign of . That picture often tells us everything we want to know without solving the ODE.
For a system of two ODEs , the state lives on the -plane. The single- variable trick no longer works because there are two variables and only one time. We need a richer picture — one where every point of the plane has an arrow telling us where the state will move next. That picture is the phase portrait.
The promise of this section
For 2×2 linear systems we will prove that the entire qualitative behaviour is determined by and . A 4-number matrix collapses to two scalars, and those two scalars choose one of seven labelled regions on a single 2D map. Once you can read that map, you can sketch the portrait of any linear system in seconds.
State Space and the Velocity Field
A state of our system is a point . The plane of all such points is the state space (also called phase space). For a linear system , the ODE does not give us where the state IS; it tells us how fast and in which direction it MOVES from wherever it happens to be:
Think of as wind blowing across the plane. At every point , the wind direction and speed are given by the linear function . Drop a leaf at any starting position; the leaf's path is the trajectory through that seed, and the collection of all such trajectories — the whole "weather pattern" — is the phase portrait.
Three things to notice about linear vector fields
- The origin is always a fixed point. Because , the wind speed at the origin is zero. A leaf placed at the origin never moves.
- The field is invariant under scaling. If doubles, so does the arrow. The picture is self-similar: zooming in does not change the local geometry.
- The eigenvectors are special directions. If , then along the line through the arrow is parallel to the line itself. Solutions that start on an eigenvector stay on it forever — sliding to or from the origin at exponential rate .
The Five Fundamental Portraits
Even before we look at the algebra, the eye can already classify every linear 2D system into a handful of shapes. Each shape is ruled by the eigenvalues of :
| Portrait | Eigenvalues | What the flow does |
|---|---|---|
| Saddle | λ₁ > 0, λ₂ < 0 | Two real eigenvalues of opposite sign. Along v₁ trajectories fly outward; along v₂ they fall inward. Everywhere else they bend like hyperbolae. The origin is unstable. |
| Stable node | λ₁ < λ₂ < 0 | Both eigenvalues negative. Every trajectory crashes into the origin, tangent to the SLOWER eigenvector (the one with the less-negative λ). |
| Unstable node | 0 < λ₁ < λ₂ | Both eigenvalues positive. Every trajectory shoots away from the origin, tangent to the SLOWER eigenvector. |
| Stable spiral | α ± iβ, α < 0 | Complex-conjugate pair with negative real part. Trajectories rotate at angular frequency β while the radius shrinks like e^(αt). The origin is a stable focus. |
| Unstable spiral | α ± iβ, α > 0 | Same shape rotation, but radius grows. The origin is an unstable focus. |
Two further boundary cases sit between these five:
| Boundary | Eigenvalues | Behaviour |
|---|---|---|
| Center | ± iβ (pure imaginary) | Trajectories are perfect closed ellipses around the origin. Energy-like quantities are conserved exactly. Marginally stable. |
| Degenerate | one λ = 0 | An entire line of fixed points (along the kernel of A). Off that line, motion is along the other eigendirection only. |
A reading habit
Always look first at where the arrows go near the origin. That tiny region tells you the topological type. The far-field arrows are just a stretched version of the same picture — linear fields look the same at every scale.
From Matrix to Portrait: Trace and Determinant
The eigenvalues of a 2×2 matrix satisfy the characteristic polynomial
where and .
Vieta's formulas give us the eigenvalues without ever solving the quadratic:
From these two identities and the discriminant , we can decide every question we care about without ever computing the eigenvalues themselves:
| Question about the portrait | Answer in (T, D) |
|---|---|
| Are the eigenvalues real or complex? | Δ > 0 ⇒ real distinct. Δ = 0 ⇒ repeated. Δ < 0 ⇒ complex conjugate. |
| Do the eigenvalues have the same sign? | Yes iff D > 0 (product is positive). |
| Is the origin attracting (stable)? | Yes iff Re(λ₁) < 0 and Re(λ₂) < 0 ⇔ T < 0 and D > 0. |
| Is the origin repelling (unstable)? | Yes iff at least one real part > 0 ⇔ T > 0 or D < 0. |
| Is it a saddle? | Yes iff D < 0 (eigenvalues opposite sign). |
| Is it a center? | Yes iff T = 0 and D > 0 (purely imaginary eigenvalues). |
The single most useful fact in this chapter
A 2D linear system is stable at the origin iff
That single sentence is the gateway to control theory, circuit design, and most of mathematical biology. Whenever an engineer asks "is this linearisation stable?", they are checking the sign of two numbers.
The Discriminant Parabola
On the plane, the curve — equivalently — is a parabola opening upwards. Above the parabola the discriminant is negative and the eigenvalues are complex (spirals and centers). Below the parabola the discriminant is positive and the eigenvalues are real distinct (nodes and saddles). The parabola itself is the boundary — repeated real eigenvalues — where nodes degenerate into a single eigendirection.
The other crucial curves are the two axes:
- The positive D-axis (T = 0, D > 0) is the home of centers. Cross it and a stable spiral becomes an unstable spiral.
- The T-axis (D = 0) is the boundary between saddles and nodes. Crossing it makes one eigenvalue change sign — the dramatic event of bifurcation in nonlinear theory.
Why this map matters far beyond linear ODEs
In Section 23.7 we will linearise nonlinear systems near each fixed point and read off the local picture from the same map. The (T, D) plane therefore IS the dictionary that translates algebra into geometry for nearly every model you will encounter in physics, biology, and engineering.
Worked Example: A Stable Spiral by Hand
Take the matrix
Before any computation, eyeball the structure: the diagonal entries are equal and negative, the off-diagonal entries are equal in magnitude and opposite in sign. That symmetry is the algebraic fingerprint of a rotation plus contraction. Let's verify.
Show the full hand-computation (try it yourself first)
Step 1 — Trace, determinant, discriminant. , , . So eigenvalues are complex, T < 0 and D > 0 — by our table, a stable spiral.
Step 2 — Eigenvalues. . Decay rate , angular frequency .
Step 3 — Complex eigenvector for . Solve : row 1 reads , so . Take .
Step 4 — Real basis of solutions. Compute :
Real and imaginary parts give two independent real solutions:
Step 5 — Match the seed . Write . At : , , so , . Therefore
Step 6 — Numerical samples.
| t | x(t) | y(t) | Radius e^(-t/2) · 2 |
|---|---|---|---|
| 0 | 2.000 | 0.000 | 2.000 |
| π/2 | 0.000 | -0.910 | 0.910 |
| π | -0.416 | 0.000 | 0.416 |
| 3π/2 | 0.000 | 0.189 | 0.189 |
| 2π | 0.086 | 0.000 | 0.086 |
After one full revolution the radius has shrunk by a factor of — a ~23-times decay per loop. That number, the logarithmic decrement, is exactly how engineers measure damping from oscilloscope traces.
Interactive Phase Portrait Explorer
Below, every slider edits one entry of the 2×2 matrix . The vector field updates instantly, eigenvalues are recomputed, the classification label changes, and seed trajectories are re-integrated by RK4. Click anywhere in the canvas to drop a new seed — useful for studying how nearby orbits differ.
Things to try
- Move slider b from -2 to +2 with all others fixed. Watch the spiral first tighten, then become a node, then become a saddle as the determinant crosses zero.
- Set a = d = 0 and b = -c. You get exact centers — closed elliptical orbits at every radius.
- Set a = d = -1 and b = c = 0. Repeated real eigenvalue, but every direction is an eigenvector — a star node.
The Trace–Determinant Plane
The previous explorer lets you change the matrix and watch the portrait. The next visualiser inverts that: it lets you navigate the qualitative-behaviour map directly. Drag the red dot over the shaded regions and the canvas on the right shows the corresponding portrait. The yellow parabola is the discriminant boundary.
Crossing boundaries = bifurcation
Walking the dot from the stable-spiral region across the positive D-axis (T = 0) takes a damped oscillator and turns it into a pure oscillator and then into an unstable spiral. That three-step crossing — stable → marginal → unstable — is the Hopf bifurcation, one of the universal routes a dynamical system can take into self-sustained oscillation (think heartbeat onset, laser threshold, predator-prey cycles).
Python: Drawing the Velocity Field
Three lines of NumPy — meshgrid, the matrix–vector product, and — produce every phase- portrait poster you have ever seen. The function below is the skeleton you can reuse for any 2×2 linear system in this course.
Python: Integrating Trajectories with RK4
Arrows alone are not enough — students want to see a leaf ride the wind. We add a Runge–Kutta-4 integrator that walks a seed point forward and backward in time, then verify the result against the closed-form solution we derived by hand above.
Pure NumPy is fine here
For a 2D linear system the right-hand side is one matrix–vector multiply. We do NOT need SciPy's adaptive solvers. The point of writing RK4 by hand is to expose the FOUR-stage structure that gives the method its O(h⁴) accuracy. After this section you should be able to integrate any linear system to ~10⁻⁸ precision with twenty lines of NumPy.
PyTorch: Batched Classification of Many Systems
A single 2×2 system is easy. But what if you have ten thousand? Imagine sweeping over candidate controller gains in a robotics loop, or scanning a (T, D) grid to colour the bifurcation diagram of a model. We want to classify them all at once — and PyTorch is the natural language for that. Eigenvalue decomposition broadcasts over leading batch dimensions automatically.
Why "companion matrix"?
Every 2×2 matrix is similar (via change of basis) to its companion matrix — the unique matrix whose entries are read directly off the characteristic polynomial . Two matrices with the same trace AND the same determinant give phase portraits of the same topological type, so for classification we lose nothing by sampling the companion family.
Where This Shows Up
| Domain | What x = (x₁, x₂) is | Why the portrait matters |
|---|---|---|
| Mass-spring-damper | (position, velocity) | Stable spiral = underdamped ringing. Stable node = overdamped slump. Repeated root on the parabola = critical damping (the engineer's target). |
| RLC circuit | (capacitor charge, loop current) | Exactly the same picture as the mechanical oscillator. The trace = -R/L is the damping rate; det = 1/(LC) is the natural frequency squared. |
| Predator–prey (linearised) | (prey deviation, predator deviation) | Lotka–Volterra near coexistence gives pure imaginary eigenvalues — a center. The neutrally closed orbits are why both species oscillate indefinitely in the textbook model. |
| Chemical reactor | (temperature deviation, concentration deviation) | Saddles indicate runaway risk. Stable spirals indicate damped chemical oscillations. Hopf crossings predict the onset of sustained chemical clocks. |
| Neural ODEs | (hidden state coordinates) | A learnable A trained to be stable (T<0, D>0) gives memory cells that decay. Pushing onto the imaginary axis gives oscillator-like memory used in continuous RNNs. |
Common Pitfalls
- Forgetting unequal aspect ratio. A non-square axes box turns circles into ellipses and lies about spirals versus centers. Always .
- Reading the eigenvector direction off the wrong row. From , if row 1 is degenerate, USE row 2. Otherwise you get the zero vector.
- Confusing "stable node" tangency rules. Trajectories enter a stable node tangent to the slowest eigenvector (least-negative eigenvalue) — not the fastest. The fastest direction is the one along which trajectories first shed radius.
- Calling a center a spiral. Numerical integrators on a center system will drift over many revolutions because floating-point noise injects a small spurious . To check if you have a true center, look at the matrix (T = 0?), not the integrator output (which always lies a little).
- Drawing only forward trajectories near a saddle. The unstable manifold is the one going OUT; the stable manifold is the one coming IN. Without backward-time integration you will miss the stable manifold entirely.
Summary
- The phase portrait of is the velocity field plus the integral curves it produces.
- All 2D linear portraits fall into five generic types — saddle, two kinds of node, two kinds of spiral — and two boundary cases (center, degenerate).
- The classification is governed by two scalars, and . The discriminant parabola separates the real-eigenvalue regions (below) from the complex ones (above).
- is the gateway condition for stability — the half-line every control engineer aims at.
- Computationally, the velocity field is one broadcast ; trajectories follow from any first-order ODE integrator (we used RK4); batched classification is one PyTorch eigenvalue call.
Looking forward: In Section 23.4 we will read off the trajectory formula when eigenvalues are real and distinct, and in Section 23.5 we will handle the complex-eigenvalue spirals algebraically. Section 23.7 then explains why these linear portraits remain useful for nonlinear systems near each fixed point.