1. What this solves
A model with fast decay may need a tiny explicit step even when only its slow evolution matters. BDF2 uses the last two states and a new implicit slope to advance at second order. Fast decaying modes become small within a few steps. The method is L-stable in the multistep sense given below.
2. When to use
Use a smooth stiff ODE with unwanted fast damped modes, a constant grid, and a reliable endpoint solve. Supply and a Jacobian or solver for the same residual. If you already have two states, they must lie one step apart and be accurate to or better.
3. When not to use (and what to use instead)
| Situation | Use instead |
|---|---|
| Rough stiff decay or a robust first damping step | backward-euler. |
| Stiff problem with changing steps, requested tolerances, or dense output | radau-iia-5 or a variable-step BDF implementation such as CVODE BDF. |
| Persistent conservative oscillations and long-time invariants | implicit-midpoint or gauss-legendre-4 for canonical Hamiltonians. |
| Smooth nonstiff dynamics or explicit constraints | rk4 or dormand-prince-rk45 for the former, rattle for constrained conservative mechanics with constant masses. |
4. Algorithm
Let and be the states at and . From alone, start by solving the backward Euler equation . The error of that single startup step is , enough for second-order global convergence.
Set , and . Solve
Start Newton at and solve , then set . The starter uses the same solve with , . Shift the two-state history after a successful step. The reference accepts a small scaled Newton correction and reports nonfinite arithmetic, a singular matrix or exhausted iterations.
For and , the amplification roots satisfy . The roots satisfy the A-stability root condition for , and both tend to zero as tends to infinity there. This is the L-stability claim for BDF2, expressed in terms of both multistep roots. A small sign change in a stiff component is compatible with rapid decay.
5. Parameters
| Parameter | How to choose it |
|---|---|
| Fixed nonzero step | Resolve the quantities of interest and compare at least two step refinements. The fixed-step coefficients depend on equal spacing. For changing steps use coefficients derived from the step ratio and a variable-step stability and error controller. |
| Newton tolerance and limit | For each component, let scale be its largest absolute value in the step input, the old iterate, and the updated iterate. Require that component’s correction to be at most max(tol * scale, 4 * ulp(scale)), where ulp is floating-point spacing. The reference defaults to tol=1e-13 and allows 20 updates. Tighten the solve to check that time discretization dominates the error. |
7. Verification
Create port_adapter.py with start(fun, jac, t, y, h) -> y1 and step(fun, jac, t, previous, current, h) -> y_next. States and returned slopes are sequences, and jac(t,y)[i][j] differentiates equation with respect to component . The time of current is t; the RHS for a BDF2 step is evaluated at t+h. Run python <skill>/checks/check_port.py from the adapter directory and show the output. Other languages can use checks/cases.json directly.
On your model check fixed-time errors under refinement, track the fast component over its first few steps, and compare with backward-euler at the same grid. Both methods can step over fast decay. The difference in order should appear on the slow component once the step resolves it.
8. Failure signatures
| Symptom | Likely cause |
|---|---|
| Order collapses after changing the step | Fixed-grid weights were applied to unequally spaced states, or the startup history is inaccurate. |
| A large stiff component survives startup | The starter or main step used an explicit slope, or Newton returned a poor root. |
| Small correction is hard to obtain | Check the Jacobian, variable scales, and whether the chosen step admits a useful nearby root. |
9. Files and commands
reference/bdf2.py contains the starter, step and fixed-grid iterator. uv run examples/relaxation.py compares BDF2 and backward Euler. uv run verify/check_cases.py checks second order, stiff decay, startup and BDF2 steps on mixed-scale states, and four broken ports. uv run checks/make_cases.py prints the fixture JSON.
10. Sources
- Curtiss and Hirschfelder introduce stiff equations and derive implicit backward-difference formulas, including the two-step one, for a scalar model equation. Curtiss and Hirschfelder (1952)
- Hairer and Wanner give the BDF root locus curves and show that the two-step formula is A-stable (Sect. V.1). Solving Ordinary Differential Equations II (1996)