Flow Lab

Syllabus / Module 7: Systems of ODEs & Dynamical Systems

Lesson 7.1

Systems & State Space

Why systems: coupled tanks, predator–prey, higher-order → first-order conversion, vector notation x' = f(t, x), phase space.

Written byClaude Sonnet

🌊
Why this matters for simulation: A fluid solver is a giant system of ODEs — one per grid cell — after discretizing space.

By the end of this lesson you can…

  • Write a coupled-tank mixing problem as a system $\mathbf x' = A\mathbf x + \mathbf b$ and read its equilibrium and its two concentrations off a numerical solution.
  • Convert any nth-order ODE into a first-order system for the state vector $(y, y', \ldots, y^{(n-1)})$, including a nonlinear one, and add $t$ as a state to make a system autonomous.
  • Explain a vector field in phase space, why trajectories of an autonomous system cannot cross, and how a time series and a phase-plane curve show the same solution.
  • Implement vectorised RK4 for $\mathbf x' = \mathbf f(t, \mathbf x)$ in one short function and measure its observed order from data (ratio about 16 per halving of $h$).
  • Use a conserved quantity as a drift detector, and say what it can and cannot tell you about a numerical solution.
  • Recognise a grid of $N$ cells as an $N$-dimensional ODE system (the method of lines) and write the diffusion matrix for it.
On this page
·
  1. Why one equation is not enough
  2. Vector notation and the state vector
  3. Phase space and the vector field
  4. Solving systems numerically
  5. Computing it
  6. Concept checks
  7. Problems
  8. Key Takeaways

Almost everything so far had one unknown. A fluid solver has millions: a velocity at every cell of the grid, all pushing on each other. A flight simulator has twelve or so (from memory for a rigid aircraft: three each for position, velocity, attitude and rotation rates). The trick that makes this manageable is the one you saw in 5.7 Higher-Order Linear Equations: stack the unknowns into a state vector x\mathbf x and write one equation, x′=f(t,x)\mathbf x' = \mathbf f(t, \mathbf x). This lesson builds that language and shows that the RK4 you wrote for a scalar in 4.3 Runge–Kutta Methods & Butcher Tableaux carries over line for line. It also introduces the picture the rest of the module lives in, phase space. 1.1 Vectors, Linear Combinations & Span supplied vectors as arrows and lists; here a vector is a state.

▶ Video Coupled tanks, an nth-order equation turned into a system, the vector field and trajectories in phase space, vectorised RK4, a conserved quantity as a drift detector, and a grid of cells as one big ODEcaptions only
Transcript
  1. Almost everything so far had one unknown. Now take two tanks, 100 and 50 litres, with pumps moving brine back and forth. The salt in tank 1 depends on tank 2, and the other way round, so neither equation solves alone. It is a coupled system: x prime equals A x plus b.
  2. Start both tanks with fresh water and integrate. At 30 minutes the tanks hold 194.115 and 78.018 grams, and at 60 minutes 260.211 and 122.707. The equilibrium solves A x equals minus b, giving 300 and 150 grams: 3 grams per litre, like the inflow.
  3. Any nth order equation is a system in disguise. Stack y, y prime and y double prime into a state vector. Each row says one is the derivative of the next; only the last carries the physics. The exact y of 1 is 0.7474195, and RK4 on the system prints 0.7474207.
  4. The phase space has one axis per component, so a point is a complete state. The vector field gives the velocity at every point, and a solution is a curve tangent to the arrows. At 0, 0 the field is 12, 0, so the curve leaves horizontally. Equilibria are where the arrows vanish.
  5. Trajectories of an autonomous system cannot cross. If two met at a point, both would solve the same initial value problem there, and uniqueness gives one solution, so they are the same curve. Loops can close, but a trajectory inside a loop is trapped inside it.
  6. Here is one solution two ways. The time series of the damped oscillator shows when. The phase plane drops time and shows where the state can go, spiralling into the origin. At t equals 10 the exact state is x equals minus 0.336852 and v equals 0.185346.
  7. The whole solver fits in a few lines. Make x an array and let f return an array: plus and scalar multiples act componentwise, so scalar RK4 becomes RK4 for a system. A step costs four evaluations of f, whatever n is. The order-4 proof carries over, from memory, so measure it.
  8. Is it really fourth order? Measure it. On the damped oscillator the RK4 error at t equals 10 falls by 16.11, 16.05 and 16.02 per halving of h. Two to the fourth is 16. Euler's ratios, 2.64, 2.29 and 2.13, slide toward 2: first order. Measured, not assumed.
  9. Predator-prey has a conserved quantity. Dividing the equations separates the variables, and integrating gives H equals x minus log x plus y minus log y. Its derivative along solutions is zero. At 2, 1 it equals 2.306853, so each orbit is a level curve of H.
  10. That makes H a drift detector. RK4 to t equals 60 drifts by minus 6.888 times 10 to the minus 5 at h 0.2, and minus 6.047 times 10 to the minus 9 at h 0.025. Euler drifts by plus 0.468, spiralling outward. H is blind to timing, so a small drift is necessary, not sufficient.
  11. Take a ring of six cells with heat flowing between neighbours: six coupled ODEs, u prime equals D u. With all the heat in cell 3, at t equals 5 the cells hold 0.1385, 0.1933, 0.2234, 0.1933, 0.1385 and 0.1129. By t equals 20 every cell is between 0.1664 and 0.1669.
  12. This is the method of lines. A flight simulator has about twelve states, from memory. A grid of 100 cubed cells with three velocity components has three million unknowns, an illustration, and still one state vector. From memory, Stam's stable fluids takes an implicit step, because the explicit step is limited by delta x squared.
  13. To sum up. A system is a state vector and one equation. Higher order equations become systems, and trajectories in phase space cannot cross. RK4 for systems is the same code, with order 4 measured. A conserved quantity detects drift. Next: linear systems, where eigenvalues solve x prime equals A x exactly.

Why one equation is not enough

Coupled tanks. Tank 1 holds 100 L and tank 2 holds 50 L. Brine at 3 g/L flows into tank 1 at 4 L/min. A pump moves 6 L/min from tank 1 to tank 2, another moves 2 L/min back, and tank 2 drains 4 L/min. Volumes stay constant (tank 1: in 4+24 + 2, out 66; tank 2: in 66, out 2+42 + 4). Let x1,x2x_1, x_2 be grams of salt. Each pipe carries concentration times flow:

x1′=4⋅3−6100x1+250x2,x2′=6100x1−250x2−450x2.x_1' = 4\cdot 3 - \tfrac{6}{100}x_1 + \tfrac{2}{50}x_2, \qquad x_2' = \tfrac{6}{100}x_1 - \tfrac{2}{50}x_2 - \tfrac{4}{50}x_2 .

Numerically, x1′=12−0.06x1+0.04x2x_1' = 12 - 0.06x_1 + 0.04x_2 and x2′=0.06x1−0.12x2x_2' = 0.06x_1 - 0.12x_2. Neither equation can be solved alone: x1′x_1' needs x2x_2 and vice versa. That is a coupled system. In matrix form x′=Ax+b\mathbf x' = A\mathbf x + \mathbf b with A=(−0.060.040.06−0.12)A = \begin{pmatrix}-0.06 & 0.04\\ 0.06 & -0.12\end{pmatrix} and b=(12,0)\mathbf b = (12, 0). Start both tanks with fresh water. Block A of the lab cell integrates this: at t=30t = 30 min the tanks hold (194.115,78.018)(194.115, 78.018) g, which is 1.9411.941 and 1.5601.560 g/L, and at t=60t = 60 they hold (260.211,122.707)(260.211, 122.707) g, 2.6022.602 and 2.4542.454 g/L. Both concentrations climb toward the inflow’s 33 g/L, tank 1 first. The equilibrium, where x′=0\mathbf x' = 0, solves Ax=−bA\mathbf x = -\mathbf b. The second row gives 0.06x1=0.12x20.06x_1 = 0.12x_2, so x1=2x2x_1 = 2x_2; the first then reads 12−0.12x2+0.04x2=012 - 0.12x_2 + 0.04x_2 = 0, so x2=150x_2 = 150 and x1=300x_1 = 300 g. Check: 12−18+6=012 - 18 + 6 = 0 and 18−18=018 - 18 = 0. In concentrations that is 33 g/L in both tanks, the same as the inflow, which is the only way the salt in the tanks can stop changing. The cell also solves the same system exactly (the matrix exponential, a later lesson) and the gap is below 10−910^{-9}.

Predator-prey, as a teaser. Let xx be prey and yy predators, scaled so every rate is 1: x′=x(1−y)x' = x(1 - y) and y′=y(x−1)y' = y(x - 1). Prey grow unless eaten, predators starve unless they eat. Populations oscillate: when prey are plentiful predators boom, then prey crash. Honest limits: this model has no carrying capacity and no randomness, and its perfect closed loops are fragile (from memory, change the equations slightly and the loops become spirals or a limit cycle; 7.8 Conservative Systems & Lyapunov Functions and 15.2 Predator–Prey & Competing Species return to this). We use it because it is nonlinear, has no closed-form x(t)x(t), and has a conserved quantity that makes a test for a solver.

Vector notation and the state vector

Write x=(x1,…,xn)\mathbf x = (x_1, \ldots, x_n) and x′=f(t,x)\mathbf x' = \mathbf f(t, \mathbf x), where f\mathbf f returns nn numbers. If tt does not appear, the system is autonomous: x′=f(x)\mathbf x' = \mathbf f(\mathbf x). Any non-autonomous system becomes autonomous by adding a state xn+1=tx_{n+1} = t with xn+1′=1x_{n+1}' = 1, so autonomous loses no generality.

Higher order becomes first order. For y(n)=g(t,y,y′,…,y(n−1))y^{(n)} = g(t, y, y', \ldots, y^{(n-1)}) set x1=y, x2=y′, …, xn=y(n−1)x_1 = y,\ x_2 = y',\ \ldots,\ x_n = y^{(n-1)}. Then

x1′=x2,x2′=x3, …,xn−1′=xn,xn′=g(t,x1,…,xn).x_1' = x_2,\quad x_2' = x_3,\ \ldots,\quad x_{n-1}' = x_n,\quad x_n' = g(t, x_1, \ldots, x_n).

The first n−1n - 1 equations just say “the derivative of each is the next one”; only the last carries the physics. For a linear equation this is the companion matrix of 5.7 Higher-Order Linear Equations, which proved its eigenvalues are the characteristic roots; the new point is that gg may be nonlinear. The pendulum θ′′=−sin⁡θ\theta'' = -\sin\theta is θ′=ω, ω′=−sin⁡θ\theta' = \omega,\ \omega' = -\sin\theta.

Worked example (third order). y′′′+6y′′+11y′+6y=0y''' + 6y'' + 11y' + 6y = 0 with y(0)=1y(0) = 1, y′(0)=y′′(0)=0y'(0) = y''(0) = 0. The state is x=(y,y′,y′′)\mathbf x = (y, y', y''):

x′=(x2x3−6x3−11x2−6x1),x(0)=(1,0,0).\mathbf x' = \begin{pmatrix} x_2 \\ x_3 \\ -6x_3 - 11x_2 - 6x_1 \end{pmatrix}, \qquad \mathbf x(0) = (1, 0, 0).

The roots of r3+6r2+11r+6=(r+1)(r+2)(r+3)r^3 + 6r^2 + 11r + 6 = (r+1)(r+2)(r+3) give y=c1e−t+c2e−2t+c3e−3ty = c_1e^{-t} + c_2e^{-2t} + c_3e^{-3t}. The initial conditions say c1+c2+c3=1c_1 + c_2 + c_3 = 1, −c1−2c2−3c3=0-c_1 - 2c_2 - 3c_3 = 0, c1+4c2+9c3=0c_1 + 4c_2 + 9c_3 = 0, solved by (3,−3,1)(3, -3, 1) (check each row). So y(1)=3e−1−3e−2+e−3=0.7474195y(1) = 3e^{-1} - 3e^{-2} + e^{-3} = 0.7474195. Block D runs RK4 on the system with h=0.1h = 0.1 and prints 0.74742070.7474207: the error is 1.2×10−61.2\times10^{-6}. The initial condition of a system is a vector, which is why an nth-order ODE needs nn initial values.

Phase space and the vector field

The phase space is the space of all states, one axis per component. A single point is a complete snapshot: tank 1 holds 194 g and tank 2 holds 78 g, nothing else is needed to say what happens next. The vector field f(x)\mathbf f(\mathbf x) attaches to each point the velocity with which the state moves there: arrows, exactly like the direction fields of 3.2 Direction Fields & Euler's Method Revisited, but now an arrow is an actual velocity vector, not a slope. A solution x(t)\mathbf x(t) is a curve everywhere tangent to the arrows, the trajectory. At (0,0)(0, 0) the tank field is (12,0)(12, 0): the first tank gains salt, the second has none to receive yet, so the curve leaves horizontally. In the sim, the short black arrow is f\mathbf f at the dot.

Trajectories of an autonomous system cannot cross. Suppose two trajectories met at a point p\mathbf p. Both are solutions of the initial value problem x′=f(x)\mathbf x' = \mathbf f(\mathbf x), x=p\mathbf x = \mathbf p there (shift the clock of one so they pass p\mathbf p at the same instant; this is legal only because f\mathbf f has no tt). The uniqueness theorem of 3.7 Existence & Uniqueness says that problem has one solution when f\mathbf f is smooth. (That lesson did the scalar case; the vector version needs the same Lipschitz idea, quoted from memory.) So the two curves are the same curve. They can close into a loop or approach an equilibrium, but not cross. In one dimension this meant solutions could not pass through each other; in the plane it means a trajectory that starts inside a closed loop is trapped inside it, and that is what organises the pictures in 7.3 Phase Portraits & the Trace–Determinant Plane.

Equilibria are the points where f=0\mathbf f = 0 and the arrows vanish. Solving f=0\mathbf f = 0 is an algebra problem and finds them before any integration: (300,150)(300, 150) for the tanks; (0,0)(0, 0) and (1,1)(1, 1) for predator-prey (from x(1−y)=0x(1-y) = 0 and y(x−1)=0y(x-1) = 0); (0,0)(0, 0) for the damped oscillator; and ω=0\omega = 0, sin⁡θ=0\sin\theta = 0, that is (kπ,0)(k\pi, 0), for the pendulum. The sim marks them with hollow circles (for the pendulum, those at 00 and ±π\pm\pi). Whether curves near an equilibrium approach it, circle it or leave it is the subject of the next lessons.

Two views of one solution. The time series plots x1(t)x_1(t) and x2(t)x_2(t) against tt. The phase-plane curve plots x2x_2 against x1x_1 with time removed. Time is recoverable only from the arrows’ lengths. The time series shows when; the phase plane shows where it can go, and for a periodic orbit it collapses an endless oscillation into one closed loop.

◆ Interactive Click the phase plane to seed trajectories; compare the phase curve, the time series and the invariant for tanks, predator-prey, a damped oscillator and a pendulum

Loading simulation…

The sim integrates every seed with the same vector stepper. Choose coupled tanks, keep the three default seeds and scrub the active seed (the starting-empty one) to t=30t = 30: the readout shows (194.115,78.018)(194.115, 78.018) and 1.941,1.5601.941, 1.560 g/L, the numbers above. Choose predator-prey and scrub the active seed (2,1)(2, 1) around: its time series oscillate while the phase curve is one closed loop that never meets the other seed’s loop. The damped oscillator (x′=vx' = v, v′=−x−0.2vv' = -x - 0.2v) spirals into the origin, and the pendulum shows the closed loops of small swings with open waves of full rotations outside them. Switch the method to Euler on the pendulum (seed (2,0)(2, 0), h=0.05h = 0.05, T=20T = 20): the energy panel climbs, and the readout gives a change of +0.598+0.598 to E=1.014E = 1.014. The separatrix between swinging and rotating is E=1E = 1 (the pendulum balanced at the top, cos⁡θ=−1\cos\theta = -1 at rest), so Euler has pumped the swing to the brink of going over the top, which no real pendulum with no forcing does. RK4 at the same hh changes EE by −8.9×10−8-8.9\times10^{-8}. The same step size, the same equations, a different physical conclusion: the integrator is part of the model.

Solving systems numerically

Here is the whole solver. It is written once, for any system:

def rk4(f, x0, T, h):
    x = np.array(x0, float); t = 0.0
    for _ in range(round(T / h)):
        k1 = f(t, x); k2 = f(t + h/2, x + h/2*k1); k3 = f(t + h/2, x + h/2*k2); k4 = f(t + h, x + h*k3)
        x = x + h/6*(k1 + 2*k2 + 2*k3 + k4); t += h
    return x

Cost. One RK4 step calls f\mathbf f four times, so the price of a step is four evaluations of the right-hand side plus a few vector additions, whatever nn is. For the six-cell ring below, f\mathbf f is a small matrix-vector product; for a grid solver it is a sweep over every cell. The error constant and the cost per step are the two numbers to weigh when choosing hh.

Observed order. Use the damped oscillator with x(0)=1x(0) = 1, v(0)=0v(0) = 0, which has an exact solution: x(10)=−0.336852x(10) = -0.336852, v(10)=0.185346v(10) = 0.185346. Block B measures the norm of the state error at t=10t = 10. RK4 with h=0.2,0.1,0.05,0.025h = 0.2, 0.1, 0.05, 0.025 gives errors 4.754×10−54.754\times10^{-5}, 2.951×10−62.951\times10^{-6}, 1.839×10−71.839\times10^{-7}, 1.148×10−81.148\times10^{-8}. Each halving divides the error by 16.1116.11, 16.0516.05, 16.0216.02. Order pp predicts 2p2^p, and 24=162^4 = 16: fourth order, measured, not assumed. Euler on the same problem with h=0.2,0.1,0.05,0.025h = 0.2, 0.1, 0.05, 0.025 has errors 0.6650.665, 0.2520.252, 0.1100.110, 0.05160.0516 and ratios 2.642.64, 2.292.29, 2.132.13, sliding toward 22: first order. The sim’s readout reports this error for the oscillator: choose it with the seed (1,0)(1, 0), T=10T = 10, and drag hh.

A conserved quantity as a drift detector. For predator-prey, dydx=y(x−1)x(1−y)\frac{dy}{dx} = \frac{y(x-1)}{x(1-y)} separates into 1−yydy=x−1xdx\frac{1-y}{y}dy = \frac{x-1}{x}dx, which integrates to

H(x,y)=x−ln⁡x+y−ln⁡y=constant.H(x, y) = x - \ln x + y - \ln y = \text{constant}.

Check directly: dHdt=(1−1x)x(1−y)+(1−1y)y(x−1)=(x−1)(1−y)+(y−1)(x−1)=0\frac{dH}{dt} = (1 - \tfrac1x)x(1 - y) + (1 - \tfrac1y)y(x - 1) = (x-1)(1-y) + (y-1)(x-1) = 0. So each orbit lies on a level curve of HH, and a numerical solution that leaves it is wrong by exactly the amount it left. Start at (2,1)(2, 1), where H=2.306853H = 2.306853. Block C reports H(T)−H(0)H(T) - H(0). RK4 to T=60T = 60 with h=0.2,0.1,0.05,0.025h = 0.2, 0.1, 0.05, 0.025 drifts by −6.888×10−5-6.888\times10^{-5}, −2.710×10−6-2.710\times10^{-6}, −1.208×10−7-1.208\times10^{-7}, −6.047×10−9-6.047\times10^{-9}, ratios 25.425.4, 22.422.4, 20.020.0: not yet 1616 at these step sizes, but falling toward it. Euler is very different: to T=20T = 20, h=0.05h = 0.05 drifts by +0.468+0.468 and h=0.01h = 0.01 by +0.0659+0.0659. Positive drift means the orbit spirals outward, the telltale of Euler on a centre (the pendulum energy E=ω2/2−cos⁡θE = \omega^2/2 - \cos\theta behaves like this too; RK4 at h=0.1h = 0.1 and 0.050.05 over T=20T = 20 from (2,0)(2, 0) changes it by −2.5×10−6-2.5\times10^{-6} and −8.9×10−8-8.9\times10^{-8}, shown in the sim’s readout). The slow, systematic leak that RK4 has is the topic of 4.7 Energy & Symplectic Integrators.

What the detector cannot see. HH depends only on where the state is, not when. A solution that stays exactly on the right orbit but runs it slightly too fast has zero drift and is still wrong. So a small drift is necessary, not sufficient. Block B’s comparison with an exact solution is the stronger test when one exists.

Computing it

🐍 PythonLab: tanks, observed order, the Lotka-Volterra invariant, a third-order ODE and a ring of cells (blocks A to E)
⌘/Ctrl + Enter

Now build the solver yourself, and convert a third-order ODE. The test equation y′′′+3y′′+3y′+y=0y''' + 3y'' + 3y' + y = 0 with y(0)=1y(0) = 1, y′(0)=−1y'(0) = -1, y′′(0)=1y''(0) = 1 has the exact solution e−te^{-t} (all three roots are −1-1, and these are the initial values of e−te^{-t}), so y(2)y(2) should be e−2=0.135335e^{-2} = 0.135335.

🧪 Coding exerciseExercise: vectorised RK4 for systems, and a third-order ODE as a system
⌘/Ctrl + Enter

Concept checks

✅ Concept check

Which first-order system is equivalent to $y''' = t\,y'' - y\,y' + \cos t$, with $x_1 = y$, $x_2 = y'$, $x_3 = y''$?

✅ Concept check

A 2D grid has $20 \times 20$ cells, with two velocity components stored in each. How many ODEs is the method-of-lines system? (Give a number.)

✅ Concept check

Why can two trajectories of an autonomous system $\mathbf x' = \mathbf f(\mathbf x)$ (with smooth $\mathbf f$) not cross?

✅ Concept check

An RK4 run of predator-prey keeps $H(x, y)$ constant to $10^{-9}$. What can you conclude?

Problems

✏️ Pen & paperThe state vector of a nonlinear equation●○○

Write y′′′=t y′′−y y′+cos⁡ty''' = t\,y'' - y\,y' + \cos t as x′=f(t,x)\mathbf x' = \mathbf f(t, \mathbf x). Then make it autonomous, and state how many initial values the IVP needs.

Show worked solution

With x=(y,y′,y′′)\mathbf x = (y, y', y''): f=(x2, x3, tx3−x1x2+cos⁡t)\mathbf f = (x_2,\ x_3,\ t x_3 - x_1 x_2 + \cos t). To remove tt, add x4=tx_4 = t with x4′=1x_4' = 1, x4(0)=0x_4(0) = 0, and write t=x4t = x_4 in f\mathbf f: the autonomous system x′=(x2,x3,x4x3−x1x2+cos⁡x4,1)\mathbf x' = (x_2, x_3, x_4x_3 - x_1x_2 + \cos x_4, 1) in four variables. The IVP needs three initial values, y(0),y′(0),y′′(0)y(0), y'(0), y''(0): the dimension of the original state (the fourth is fixed at 00).

✏️ Pen & paperTanks by hand●●○

For the tank system, find f\mathbf f at (0,0)(0, 0) and at (300,150)(300, 150). Then find the nullcline x2′=0x_2' = 0 and say what it means for the direction of the arrows.

Show worked solution

At (0,0)(0, 0): f=(12,0)\mathbf f = (12, 0), so the curve leaves in the +x1+x_1 direction. At (300,150)(300, 150): x1′=12−18+6=0x_1' = 12 - 18 + 6 = 0 and x2′=18−18=0x_2' = 18 - 18 = 0, an equilibrium, with concentrations 300/100=150/50=3300/100 = 150/50 = 3 g/L equal to the inflow. The nullcline x2′=0x_2' = 0 is 0.06x1=0.12x20.06x_1 = 0.12x_2, the line x1=2x2x_1 = 2x_2: there the arrow is purely horizontal (x2x_2 momentarily constant). Below that line (x1>2x2x_1 \gt 2x_2, tank 2 relatively dilute) x2′>0x_2' \gt 0 and arrows point up; above it they point down. So every curve is pushed vertically toward that line, and the equilibrium sits on it (300=2⋅150300 = 2\cdot150).

✏️ Pen & paperProve the invariant●●○

Show that H=x−ln⁡x+y−ln⁡yH = x - \ln x + y - \ln y is constant along solutions of x′=x(1−y)x' = x(1-y), y′=y(x−1)y' = y(x-1), and find H(1,1)H(1, 1), the equilibrium value.

Show worked solution

dHdt=(1−1x)x′+(1−1y)y′=x−1x x(1−y)+y−1y y(x−1)=(x−1)(1−y)+(y−1)(x−1)\frac{dH}{dt} = (1 - \tfrac1x)x' + (1 - \tfrac1y)y' = \frac{x-1}{x}\,x(1-y) + \frac{y-1}{y}\,y(x-1) = (x-1)(1-y) + (y-1)(x-1). Factor (x−1)(x-1): (x−1)[(1−y)+(y−1)]=0(x-1)\bigl[(1-y) + (y-1)\bigr] = 0. At (1,1)(1, 1), H=1−0+1−0=2H = 1 - 0 + 1 - 0 = 2. The start (2,1)(2, 1) has H=3−ln⁡2=2.306853H = 3 - \ln 2 = 2.306853, above 22, and H≥2H \ge 2 everywhere (each of x−ln⁡xx - \ln x, y−ln⁡yy - \ln y has minimum 11 at 11), so the level curves around (1,1)(1, 1) are closed loops: no orbit can escape, in line with the sim.

Key Takeaways

  • A coupled system x′=f(t,x)\mathbf x' = \mathbf f(t, \mathbf x) has one unknown per state; a model like the two tanks gives x′=Ax+b\mathbf x' = A\mathbf x + \mathbf b and approaches the equilibrium (300,150)(300, 150) g.
  • An nth-order ODE is a first-order system for (y,y′,…,y(n−1))(y, y', \ldots, y^{(n-1)}); only the last equation carries the physics, and nonlinear right-hand sides work the same way. Adding tt as a state makes any system autonomous.
  • Phase space is the space of states, the vector field f(x)\mathbf f(\mathbf x) gives the velocity there, and trajectories of an autonomous system cannot cross, by uniqueness of the IVP.
  • A time series and a phase-plane curve are two views of one solution; time is hidden in the phase plane.
  • Scalar RK4 is vector RK4 with arrays; the measured error ratio per halving of hh was 16.1,16.05,16.0216.1, 16.05, 16.02 for RK4 and 2.64,2.29,2.132.64, 2.29, 2.13 for Euler.
  • A conserved quantity detects drift off the orbit (RK4 about −6×10−9-6\times10^{-9} at h=0.025h = 0.025, Euler +0.468+0.468 at h=0.05h = 0.05) but is blind to errors along the orbit.
  • The method of lines turns a grid of NN cells into an NN-dimensional linear system u′=Du\mathbf u' = D\mathbf u whose total is conserved. Next, 7.2 Linear Systems & the Eigenvalue Method solves x′=Ax\mathbf x' = A\mathbf x exactly, with the eigenvectors of 1.5 Eigenvectors & Eigenvalues and the linear theory of 5.1 Second-Order Linear Equations: Structure in a new role.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.

Where this leads

These later lessons build directly on this one: