Stiff Systems: Adaptive Steps and Implicit Methods

Claude prompt

This page was generated by Claude Code from the following prompt (with additional prompting):

let's build a van-der-pol stiff system javascript demo with BS23 and implicit Euler, let's also add fixed-step RK4 and explicit euler to see things that blow up

Test problem: the van der Pol oscillator, \[ \ddot{x} = \mu\,(1 - x^2)\,\dot{x} - x, \qquad x(0) = 2,\quad \dot{x}(0) = 0. \] For small \(\mu\) it is a gentle oscillator. For large \(\mu\) it becomes stiff: the solution creeps along slowly for most of each cycle, then jumps almost instantaneously. The reference curve is BS23 with \(E_s = 10^{-9}\).

\[ \vec{x}_3 = \vec{x}_i + h\left(\tfrac{2}{9}\vec{k}_1 + \tfrac{1}{3}\vec{k}_2 + \tfrac{4}{9}\vec{k}_3\right), \qquad E_a = \lVert \vec{x}_3 - \vec{x}_2 \rVert, \qquad h \leftarrow 0.9\,h\,(E_s/E_a)^{1/3} \]

Bogacki–Shampine 3(2), the method inside MATLAB's ode23, with the error estimate from an embedded second-order step. Still explicit: when a step crosses the stability limit the error estimate explodes and the step is rejected, so the method never blows up. It just crawls.

Trajectories

Black: reference solution. Colored: the selected method, with a dot at each step when there are few enough to see. The red bar at \(t_f\) is the error in each component.

Efficiency of the adaptive methods at the current \(\mu\): error at \(t_f\) against the number of evaluations of \(\vec{f}\), one point per value of \(E_s\). Down and to the left is better. The red circle is the current setting.


Back to top

ASEN 3502, CU Boulder. Last built Oct 7, 2026 at 11:14 AM MDT.