Chapter 23 — Instructor Notes: Ordinary Differential Equations
Teaching Notes
Where this sits. Chapter 23 is the ODE chapter of Part V and the conceptual hinge of the heat-solver project: it reframes the time loop the students have built since Ch. 4 as an ODE integrator via the method of lines, setting up Ch. 24's PDE core. It is intermediate and leans hardest on Ch. 6 (procedures) and Ch. 22 (accuracy).
The three ideas that matter most, in priority order:
1. RK4 is the default; Euler is for understanding. Students should leave able to write both, and to
explain why four evaluations per step beat one — the order argument (error $\sim h^4$ vs $\sim h$),
not raw per-step cost.
2. A PDE is a giant system of ODEs (method of lines). This is the threshold concept. If they get only
one thing, it is that u = u + dt*rhs(u) is Euler's method — so the "PDE solver" and "ODE solver"
are the same machinery.
3. Stiffness forces implicit methods. They need to recognize the symptom (tiny steps for a smooth
solution, or NaN) and know the cure exists (backward Euler, A-stable), even though the full treatment
is a preview.
Emphasize: the RHS-as-procedure-argument pattern (abstract interface + procedure(rhs) :: f). It is
the modern-Fortran payoff of the chapter — one hardened integrator, any equation — and it recurs in both
case studies. Have them notice the same rk4_sys integrates the oscillator, predators, and the heat
system.
Misconceptions to preempt: - "RK4 is 4× slower than Euler." No — 4× per step, but thousands of times fewer steps for a given accuracy. Do the order arithmetic on the board (F1). - "Smaller step is always better." Round-off (Ch. 20) and, for stiff/PDE problems, wasted work say otherwise; and for a conserved system, accuracy over a step ≠ fidelity over an eon (energy drift). - "A mistyped RK4 still basically works." It runs and looks plausible but silently loses order — the reason the chapter hammers "test the order numerically" (halve $h$, expect $\times 16$). - "Stiffness means the equation is hard/nonlinear." No — it means separated time scales; the linear $y' = -10^6 y$ is stiff. Stability, not accuracy, sets the step. - "The CFL condition is a PDE thing." Show it is the ODE absolute-stability limit of Euler on the MOL system — $\Delta t \le \Delta x^2/(2\alpha)$ falls out of $|1 + h\lambda| \le 1$.
Live-coding demo (≈15 min). Start from example-01-euler.f90. (1) Run it mentally to $y(1) = 2.44$,
note the 10% error. (2) Add the four RK4 stages live and get $2.708$ in one step — the "wow." (3) Change
only the RHS function to $y' = -y$ and show explicit Euler with $h = 3$ blowing up ($0, \dots$ actually
$1 \to -2 \to 4$), then flip to backward Euler $y/(1 - h\lambda)$ and watch it stay sane. The whole arc —
accuracy then stability — in one file with two edits. Reinforce that we never ran it: predict, then let
them compile at home and confirm.
Time budget (≈5 hours): - §23.1 Euler + IVP: 45 min (get the procedure-argument pattern down here). - §23.2 RK4: 60 min (the core; do the hand trace and the order test). - §23.3 adaptive: 30 min (concept + the controller formula; don't over-invest). - §23.4 systems + method of lines: 75 min (the pivot; spend time here). - §23.5 stiffness: 30 min (preview only; the $y' = \lambda y$ picture). - §23.6 applications + Project Checkpoint: 40 min.
Prerequisites to review before teaching: Ch. 6 (dummy procedures, intent, assumed-shape,
pure), Ch. 5 (whole-array operations — the vector RK4), Ch. 22 (order of accuracy, central differences),
Ch. 20 (why dp). A five-minute recap of "passing a function to a function" pays off all chapter.
Assessment pointers. The quiz targets 16/20. In exercises, C1 (order-loss bug) and E1 (RK4 on the heat MOL) are the highest-value problems; G4 (RK4 weights = Simpson) rewards the students who see the integration connection. CS-01 (port + verify) is the accessible one; CS-02 (build a reusable adaptive module) is the stretch.