A843 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

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, x¨=x−x3−cx˙: a ball in a landscape with two valleys at x=±1 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 c=0 nothing settles: trajectories circle one valley, or both, forever.

Predict

How many stable equilibria does x¨=x−x3−cx˙ have, for c>0?

Name it

Classifying in code

From the trace T and determinant D of a 2 × 2 matrix:

  • D<0: saddle;
  • D>0 and T2<4D: spiral (center if T=0), stable if T<0;
  • D>0 and T2≥4D: node, stable if T<0.

Floating-point values are rarely exactly zero, so code should treat |T| below a small tolerance as zero.

Numerical Jacobians

Each column of the Jacobian is the derivative of 𝐟 along one coordinate. Central differences estimate it:

J:,k≈𝐟(𝐱+h𝐞k)−𝐟(𝐱−h𝐞k)2h

with an error proportional to h2; h≈10−5 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 |x|. 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 x¨=x−x3−0.3x˙ at x=1.

Show the solution
  1. State form. f=y and g=x−x3−0.3y.
  2. Jacobian at x=1. J=[011−3x2−0.3]x=1=[01−2−0.3]
  3. Classify. T=−0.3 and D=2, with T2<4D: a stable spiral.
  4. Eigenvalues. λ=−0.15±j2−0.0225=−0.15±1.406j so it rings at 1.41 rad/s and settles with time constant 6.7 s.

Answer a stable spiral with eigenvalues −0.15±1.406j: 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 x¨−μ(1−x2)x˙+x=0 swing?

Show the solution
  1. Energy balance. Its amplitude is set by an energy balance over one cycle: the (1−x2) term adds energy while |x|<1 and removes it beyond.
  2. Small μ. For small μ the balance comes out at amplitude 2 exactly.
  3. At μ=1. Simulating with μ=1 and measuring after the start-up gives 2.009: still close to 2, although the waveform is no longer a pure sine.
  4. 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 μ=1, and still near 2 at large μ.

Check

In the double well x¨=x−x3−1x˙, 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 x=0 in x¨=x−x3−0.5x˙?

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 |T|<10−12 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 f(θ,ω)=(ω,−sin⁡θ−0.5ω) at (π,0).

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, x¨=μ(1−x2)x˙−x, from (0.1,0) with RK4 (h = 0.001) to t = 100. Set amp to the largest |x| over t>50.

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 c = 0.3, θ¨=−sin⁡θ−0.3θ˙, starts at the bottom with speed ω0. Write over(w0) that simulates with RK4 (h = 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, x˙=x(2−y), y˙=y(x−1), from (1.05,2) with RK4 (h = 0.001) for 30 time units. Set period to the time between the first two upward crossings of x=1 and linear to the linearization's 2π/2.

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?

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.