kangwonlee / kangwonlee/nmisp

Pedagogy: add step-size + stability slider to 50_ode/10_Forward_Euler with detailed explanations

Open
#380 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
12
Forks
76
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.