Add an ipywidgets step-size slider to 50_ode/10_Forward_Euler.ipynb showing convergence as h decreases — and, importantly, divergence / instability as h exceeds the stability boundary for stiff or oscillatory ODEs.
Code scope
- Slider for
h (e.g. log-scale 0.001 → 1.0).
- Plot: numerical solution overlaid with analytic / reference solution.
- Side: error vs reference; ideally a log-error subplot showing O(h) convergence in the stable regime.
- Demo on at least one stiff/oscillatory ODE so the stability boundary is visible — the trajectory blows up or rings, not just gets less accurate.
Explanation scope (the deliverable)
Forward Euler is in-curriculum but the intuition for stability is conceptually deep. Author:
- Step size vs accuracy — why halving
h halves the error (linear convergence), with one paragraph on truncation error vs roundoff.
- Step size vs stability — different concept from accuracy. For
y' = λy with Re(λ) < 0, Forward Euler is stable only when |1 + hλ| ≤ 1 — a finite disk in the complex plane. Outside the disk, the numerical solution grows even though the true solution decays.
- Why this matters — stiff ODEs (large
|λ|) force tiny h for stability even when accuracy doesn't demand it. Motivates implicit methods (lead-in to Heun 20, RK 30, and solve_ivp 11).
- What the slider should reveal — find the
h at which the trajectory transitions from convergent to oscillatory to divergent.
Why this framing
The slider is mechanical; the teaching value is in the stability story. Without that explanation the widget is just "smaller h = better answer", which misses the point of why we cover Forward Euler before the more sophisticated methods.
Add an ipywidgets step-size slider to
50_ode/10_Forward_Euler.ipynbshowing convergence ashdecreases — and, importantly, divergence / instability ashexceeds the stability boundary for stiff or oscillatory ODEs.Code scope
h(e.g. log-scale 0.001 → 1.0).Explanation scope (the deliverable)
Forward Euler is in-curriculum but the intuition for stability is conceptually deep. Author:
hhalves the error (linear convergence), with one paragraph on truncation error vs roundoff.y' = λywithRe(λ) < 0, Forward Euler is stable only when|1 + hλ| ≤ 1— a finite disk in the complex plane. Outside the disk, the numerical solution grows even though the true solution decays.|λ|) force tinyhfor stability even when accuracy doesn't demand it. Motivates implicit methods (lead-in to Heun20, RK30, andsolve_ivp11).hat which the trajectory transitions from convergent to oscillatory to divergent.Why this framing
The slider is mechanical; the teaching value is in the stability story. Without that explanation the widget is just "smaller h = better answer", which misses the point of why we cover Forward Euler before the more sophisticated methods.