A8 · Lesson 43 · Lab: the phase plane
Classifying, linearizing and simulating two-state systems
Lessons 40 to 42 read a two-state system's behavior from its equilibria, its Jacobians and its phase portrait. In this lab you'll automate that: a function that classifies any 2 × 2 linear system, a numerical Jacobian for any nonlinear one, a measurement of the van der Pol oscillator's limit cycle, and a search for the exact launch speed that sends a damped pendulum over the top.
- The flow is a double-well system, : a ball in a landscape with two valleys at and a hump at 0.
- Each trajectory settles into one valley or the other. Which one depends on where it starts, and the boundary between the basins runs through the saddle at the origin.
- With nothing settles: trajectories circle one valley, or both, forever.
Predict
How many stable equilibria does have, for ?
Two, at . There are three equilibria, , but the Jacobian has determinant at the origin, a saddle, and at , with negative trace: stable. A system with two stable states is bistable, the basis of every memory cell.
Name it
Classifying in code
From the trace and determinant of a 2 × 2 matrix:
- : saddle;
- and : spiral (center if ), stable if ;
- and : node, stable if .
Floating-point values are rarely exactly zero, so code should treat below a small tolerance as zero.
Numerical Jacobians
Each column of the Jacobian is the derivative of along one coordinate. Central differences estimate it:
with an error proportional to ; balances that against rounding. Circuit simulators linearize their device models this way when no analytic derivative is available.
Measuring with simulation
A limit cycle's amplitude is a property of the whole orbit, not of any equilibrium, so it has to be measured: simulate past the transient, then record the largest . A threshold, like the smallest launch speed that clears the top, is a root-finding problem whose function evaluation is a simulation; bisection on yes/no outcomes finds it reliably.
Worked example
Linearize the double well at .
Show the solution
- State form. and .
- Jacobian at .
- Classify. and , with : a stable spiral.
- Eigenvalues. so it rings at 1.41 rad/s and settles with time constant 6.7 s.
Answer a stable spiral with eigenvalues : it rings at 1.41 rad/s and settles with a 6.7 s time constant.
Worked example
How large does the van der Pol oscillator swing?
Show the solution
- Energy balance. Its amplitude is set by an energy balance over one cycle: the term adds energy while and removes it beyond.
- Small . For small the balance comes out at amplitude 2 exactly.
- At . Simulating with and measuring after the start-up gives 2.009: still close to 2, although the waveform is no longer a pure sine.
- Large . At large it becomes a relaxation oscillation, slow ramps and fast jumps, with an amplitude near 2 still.
Answer it swings to an amplitude of about 2: exactly 2 for small , 2.009 at , and still near 2 at large .
Check
In the double well , at what frequency do small oscillations in a valley ring?
Write units the way you normally would: 1.5 rad/s and 1500 mrad/s are the same answer.
Check
At what rate does a small displacement grow away from the hump at in ?
Check
Write classify(A) returning one of "saddle", "center", "stable spiral", "unstable spiral", "stable node" or "unstable node" for a 2 × 2 NumPy array, treating as zero.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write jacobian(f, x, h=1e-5) by central differences, where f maps a NumPy array to a NumPy array. Set J to the Jacobian of the damped pendulum at .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Simulate van der Pol with = 1, , from with RK4 ( = 0.001) to = 100. Set amp to the largest over .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A pendulum with damping = 0.3, , starts at the bottom with speed . Write over(w0) that simulates with RK4 ( = 0.005) for 40 s and returns whether ever exceeds . Then bisect between 1.5 and 3 (40 steps) for the smallest launch speed that goes over, and set w_crit.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Simulate predator and prey, , , from with RK4 ( = 0.001) for 30 time units. Set period to the time between the first two upward crossings of and linear to the linearization's .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why does a bistable system need a saddle between its two stable states?
Two stable equilibria each attract the trajectories near them, so the plane divides into two basins, and the basins must meet along a boundary. Trajectories on the boundary can't go to either stable state, so they must go somewhere else: to an equilibrium that attracts along the boundary and repels across it. That's a saddle, with its stable direction lying along the basin boundary and its unstable directions pointing into the two basins. In a latch, the saddle is the balanced point between 0 and 1, and a state that starts almost exactly on the boundary lingers near it before falling one way: metastability.
Practice
Keep practicing
4 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.