Chapter 22 — Teaching Notes
One-line purpose. Get students to (1) read a method's order off its Taylor expansion, (2) measure that order with the halving test, and (3) internalize that a finite-difference derivative has a best step near $\sqrt\varepsilon$ — smaller is worse. If they leave able to do the convergence test on their own code, the chapter succeeded.
Key ideas to emphasize
- The exponent of $h$ is everything. Order of accuracy is the single most important idea. Drill it: $O(h)$ halves the error when you halve $h$; $O(h^2)$ quarters it; $O(h^4)$ divides it by 16. Return to the "ratio $\to 2^p$" slogan after every method.
- Symmetry buys an order. The central difference is $O(h^2)$ only because subtracting the two Taylor expansions cancels the even terms. Do the expansion live; it is the source of every error term in the chapter, and students who see it once stop memorizing.
- Measure, don't trust. The halving experiment (§22.4, and the Project Checkpoint) is the deliverable skill. Make them run it on a method whose order they think they know and confirm the ratio. Then hand them a subtly broken method and let the wrong ratio expose it.
- The round-off floor. The counterintuitive crown jewel: smaller $h$ eventually makes a derivative worse. Tie it explicitly to Chapter 20's catastrophic cancellation. Case Study 1 is built entirely on this — assign it.
- Simpson is exact for cubics; Gauss is exact to degree $2n-1$. The "exactness degree" reframing is what makes Gauss click. Show that 2 Gauss points reach as far as Simpson's 3.
- Integration is safe; differentiation is dangerous. Integration adds (no cancellation, no floor); differentiation subtracts near-equals (a floor). This asymmetry is worth stating as a headline.
- Accuracy per function evaluation. The performance framing: when $f$ is expensive, the rule that needs fewer evaluations wins. This is why Gauss exists.
Misconceptions to preempt
- "Smaller $h$ is always more accurate." (The whole point of §22.4 — there is an optimal $h$; below it, cancellation wins. The #1 misconception.)
- "The central difference is magic — it's exact." (It is exact only for functions whose relevant higher derivative vanishes, e.g. central difference of a quadratic. Add the $x^4$ test in CS-01 to break the illusion.)
- "Simpson is only for quadratics." (It is exact through cubics — the $f^{(4)}$ error term vanishes for degree $\le 3$.)
- "Use the fanciest rule (Gauss) always." (Not for sampled data — you can't move the nodes; use the trapezoidal rule. CS-02's core lesson.)
- "A convergence ratio near $2^p$ means the code is fully correct." (No — it confirms the order; a wrong constant, e.g. missing the $\tfrac12$ endpoints in trapezoid, still shows the right ratio. Check the absolute value against a known integral too — Exercise 22.11.)
- "
pureis decoration." (It is required for the integrator to call the dummyf, and it frees the optimizer — Chapter 6 payoff.)
A live-coding demo (25 minutes)
- Type the three finite differences for $f(x)=x^3$ at $x=2$ (exact 12). Predict forward=12.61, central=12.01
before compiling. Compile, run, confirm. (
example-01.) - Wrap it in the halving loop (
convergence_study/example— but hand-type it). Watch the forward ratio sit near 2 and the central ratio at exactly 4. Ask: "what order is each?" - Now drive $h$ down to
1.0e-14_dpand watch the central estimate degrade. Ask why. Elicit "cancellation / Chapter 20." This is the emotional peak of the lesson. - Pivot to integration:
simpsonon $\int_0^1 x^2$ returns exactly $1/3$ — ask why (cubic exactness), then on $x^4$ to see the real $O(h^4)$ error and the ratio-16.
Time budget (a ~5-hour chapter)
- §22.1 finite differences + Taylor derivation: 70 min (the core; do the derivation carefully).
- §22.2 trapezoid + Simpson: 45 min.
- §22.3 Gauss + adaptive/Richardson: 45 min.
- §22.4 order of accuracy + round-off floor: 50 min (the second core; the halving test + the U-curve).
- §22.5 multidimensional note: 15 min.
- Project Checkpoint (stencil order verification): 25 min.
- Exercises / a case study in section: remainder.
Prerequisites to review before teaching
- Chapter 20 §20.3 (catastrophic cancellation) — the round-off floor is meaningless without it.
- Chapter 6 (procedure arguments,
pure) — the integrator design depends on it. - Chapter 5 (array sections) — for the whole-array central difference and the stencil.
- A one-line reminder of Taylor series with remainder; some students need it refreshed.