Fundamentals / Numerical mathematics / Numerical ordinary differential equations

Absolute stability and stiffness

Determine the step sizes that damp a decaying mode and explain why fast, physically uninteresting modes can dominate the cost of explicit integration.

From first principles

Find a stability limit directly from repeated multiplication

A small perturbation around an equilibrium often satisfies a linear equation \(y'=\lambda y\). Begin with real \(\lambda<0\), for which the continuous value is multiplied by \(e^{h\lambda}\), strictly between zero and one. Apply Euler’s left- and right-endpoint approximations to the integral of this same rate. Let \(z=h\lambda\):

\[y_{n+1}=y_n+z y_n,\]
\[y_{n+1}=y_n+z y_{n+1}.\]

Solve each update for its new value and iterate \(n\) steps. Persistence of roundoff or initial error is governed by the same powers:

\[y_n=R(z)^n y_0,\]
\[R_{\rm forward}=1+z,\]
\[R_{\rm backward}=(1-z)^{-1}.\]

For strict decay, \(|R|<1\) is necessary. Forward Euler on this real mode requires \(-2<z<0\), and avoiding sign alternation further requires \(z\ge-1\). Backward Euler damps every negative real \(z\), even when the step is too large to approximate a transient accurately. With modes at \(-1\) and \(-1000\) s⁻¹, the fastest mode restricts a forward step to less than 0.002 s even after that transient has become tiny. This mismatch between stability and the resolution needed for the slow observable is the source of stiffness in this example.

Background · Stability function
\[y_{n+1}=R(h\lambda)y_n\]

On the scalar linear test equation, absolute stability depends on the point h times lambda. It gives only part of the story for a nonnormal matrix or nonlinear problem.

The exact decay stays positive. Forward Euler alternates signs with decreasing magnitude, while backward Euler stays positive and decays more slowly on the same grid.Open full-size diagram
A stable update can predict an impossible concentration Take a decay time τ and a time step h = 1.5τ. The exact one-step factor is exp(−1.5) ≈ 0.223. Forward Euler multiplies by −0.5 and backward Euler by 0.4. Both numerical magnitudes decay, yet the first update changes sign. Refinement tests accuracy even when positivity and stability hold.

Derivation and applications

Separate unconditional stability from damping of an unresolved mode

A stiff dissipative mode may have decayed almost completely during a single time step. Merely keeping its computed amplitude bounded is then a weak requirement. Examine the family of one-step formulas that weights the old and new slopes with \(1-\theta\) and \(\theta\). On the scalar test equation \(y'=-\lambda y\), \(\lambda>0\), define the dimensionless decay over a step as \(r=h\lambda\). Collecting the new value on the left gives

\[y_{n+1}=y_n-r[(1-\theta)y_n+\theta y_{n+1}],\]
\[G(r)=\frac{y_{n+1}}{y_n}=\frac{1-(1-\theta)r}{1+\theta r}.\]

The denominator is positive for \(\theta\ge0\). The amplification never exceeds one from above; enforcing \(G\ge-1\) supplies the other half of the real-axis stability condition:

\[|G|\le1\quad\Longleftrightarrow\quad 2+(2\theta-1)r\ge0 .\]

Thus all positive step sizes are stable along the negative real eigenvalue axis for \(\theta\ge1/2\). Now investigate what actually appears in the stored solution when the mode is unresolved:

\[\lim_{r\to\infty}G(r)=-\frac{1-\theta}{\theta}\quad(\theta>0),\]
\[\lim_{r\to\infty}e^{-r}=0 .\]

The trapezoidal choice \(\theta=1/2\) approaches a sign-reversing factor of unit magnitude. Backward Euler \(\theta=1\) suppresses the fast mode. These properties govern the handling of transients; the order of approximation for a smooth, resolved mode is a separate question.

Worked example

Check a relaxation after one coarse step

Take \(\lambda=1000\) s⁻¹, \(h=0.100\) s and an initial perturbation of \(1.00\) K. The exact remnant is \(e^{-100}\) K, negligible. Trapezoidal stepping leaves \((1-50)/(1+50)=-0.961\) K, while backward Euler leaves \(1/101=0.00990\) K. After two trapezoidal steps the perturbation becomes positive again at \(0.923\) K. That oscillatory persistence is numerical, even though the amplification satisfies the stability condition.

Second application

Choose a step for monotonically decreasing transients

Suppose a solver uses \(\theta=0.750\) and should preserve positivity for a spectrum of decay rates up to \(400\) s⁻¹. The numerator of \(G\) requires \(1-0.250h\lambda\ge0\), hence \(h\le0.0100\) s. A \(0.0200\) s step would remain stable on every mode but gives \(G=(1-2)/(1+6)=-1/7\) for the fastest one. A positivity requirement can impose a finite time step even when boundedness does not.

OneSimulation laboratory

Compare time-step error with conservation

Start from this chapter. Use the Euler amplification factor to distinguish stability from nonnegative concentration. Test the step that consumes the entire amount in one update.

Compare recorded OneSimulation runs on this page. To test your own inputs, download the Python model and run the model in an activated OneSimulation environment.

Run the isothermal reaction from \(A=1,\ B=0\) mol/m³ to \(t=5/k=6.25\) s. Measure the maximum A error over all stored times and the drift of \(A+B\). First double the number of RK4 steps. Then restore 100 steps and change the time integrator. Download the Python experiment · OneSimulation first-order decay model.

python ordinary-differential-equations.py
python ordinary-differential-equations.py --steps 200
python ordinary-differential-equations.py --method euler
Errors in species A and in the conserved sum over five decay times.
Method, stepsFinal A (mol/m³)Max. A error (mol/m³)Max. drift (mol/m³)
RK4, 1000.006737948832.00 × 10⁻⁸4.44 × 10⁻¹⁶
RK4, 2000.006737947111.22 × 10⁻⁹3.33 × 10⁻¹⁶
Euler, 1000.005920529229.39 × 10⁻³4.44 × 10⁻¹⁶
Halving the RK4 step reduces the largest concentration error by about sixteen. The logarithmic axis also shows the much larger Euler error at 100 steps.
Halving the RK4 step reduces the largest concentration error by about sixteen. The logarithmic axis also shows the much larger Euler error at 100 steps.

As a fourth run, try --method euler --steps 5. This lands exactly on the nonnegativity limit. Predict both the final concentration and the largest error before running it.

Change parameters · Change the laboratory inputs

Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.

Problem sheet 1 · Predict when a conservative calculation loses all reactant

Read the model setup and preparatory problems

Examine a single amplification factor

For the real decay problem \(y'=-\lambda y\), \(\lambda>0\), the physical solution multiplies by \(e^{-h\lambda}\) over a step. A linear one-step method replaces this by \(R(z)\), with \(z=-h\lambda\). Absolute stability at \(z\) means repeated multiplication does not amplify magnitude, conventionally \(|R(z)|\leq1\). A truly decaying mode requires a strict inequality for numerical damping. Positivity and phase fidelity impose additional requirements beyond this magnitude test.

Forward Euler has \(R=1+z\). In the complex plane the stability region is the disk of radius one centred at \(-1\). On the real negative axis, decay requires \(0<h\lambda<2\); nonnegative decay requires \(h\lambda\leq1\). Backward Euler has \(R=1/(1-z)\), and the trapezoidal method has \(R=(1+z/2)/(1-z/2)\). Both contain the entire left half-plane in their stability regions. As \(z\) becomes large and negative, backward Euler tends to zero while trapezoidal tends to minus one. The former strongly damps unresolved fast components; the latter can keep them as alternating numerical transients.

Follow a slow and a fast component together

Let \(u'=-u,\ v'=-1000v\), with \(u(0)=v(0)=1\). At \(t=0.1\) the exact slow state is 0.90484, while the fast state is \(e^{-100}\), effectively zero on a plot at unit scale. Suppose the slow state is the desired observable. One forward Euler step of 0.1 s gives \(u=0.9\) but \(v=-99\). The method becomes unstable even though the desired slow response is well resolved. To damp the fast mode explicitly, \(h\) must stay below 0.002 s whenever that mode can be excited.

Backward Euler with \(h=0.1\) gives

\[u=1/1.1=0.90909,\]
\[v=1/101=0.00990.\]

Trapezoidal gives

\[u=0.95/1.05=0.90476,\]
\[v=-49/51=-0.96078.\]

The second-order rule is especially accurate on the slow mode but retains a conspicuous oscillatory fast component. Neither the maximum order nor a broad stability region alone identifies the right integrator. The observable, acceptable transient error and stiffness all enter the decision.

Trace the cost back to the model

A diffusion equation discretised on a spatial mesh produces modes with rates up to order \(D/h_x^2\). Halving spatial spacing roughly quadruples the magnitude of the fastest eigenvalue. An explicit time step chosen for a coarse grid can therefore fail after spatial refinement, even if the initial physical signal looks smooth. Small high-frequency components from boundary changes, rounding or nonlinear interactions may excite modes absent from an idealised initial state.

Implicit stability shifts work into linear or nonlinear systems inside each time step. An oversized implicit step can miss a forcing pulse altogether, or produce a poor slow-phase estimate despite decaying every homogeneous mode. Compare the output on two time grids, distinguish the time required to resolve a source from the time required merely for stability, and inspect at least one fast component when interpreting unexpected oscillations. The distinction is visible in a reaction where exact species totals coexist with substantial errors in the individual states. Compare reaction histories under Euler and RK4.

Explain why a tiny initial fast component can still matter

Take the same two-rate model but start with \(v_0=10^{-12}\) and apply forward Euler with \(h=0.01\). The physical fast mode should disappear almost immediately. The numerical factor is \(1-10=-9\), so after twelve steps its magnitude is \(9^{12}10^{-12}\simeq0.282\). An initial disturbance that was invisible in the output has become comparable with the desired slow signal in little physical time.

If the fast variable started exactly at zero in a perfectly decoupled model, exact arithmetic would keep it zero. That special trajectory would give a misleading sense of stability. Roundoff, forcing or a weak coupling can generate a nonzero fast component at later stages. A robust experiment deliberately perturbs fast directions and examines whether numerical damping agrees with the model under those perturbations. This is especially relevant when a mesh refinement adds high-frequency modes that were absent from the coarser spectrum.

Separate damping of a perturbation from tracking a moving state

A useful stiff test has an exact slow path \(g(t)\) embedded in \(y'=\lambda(y-g(t))+g'(t)\), with \(\lambda<0\). Subtracting \(g\) gives

\[(y-g)'=\lambda(y-g).\]

An initial condition on the path stays on it, whereas an off-path disturbance decays exponentially. A numerical method must therefore address two different tasks: damp erroneous components perpendicular to the slow path and follow the path as it moves. A homogeneous stability test measures only the first.

Apply backward Euler and define \(e_n=y_n-g(t_n)\). Subtract \(g(t_{n+1})\) after the implicit update. The error satisfies

\[(1-h\lambda)e_{n+1}=e_n+h g'(t_{n+1})-[g(t_{n+1})-g(t_n)].\]

The last two terms are the error in approximating the change of \(g\) using its new endpoint derivative. Even with \(e_n=0\), this forcing can create error at the next time. The factor \(1/(1-h\lambda)\) damps both old error and newly created defect. Increasing stiffness changes their balance, while changing the time step alters both the source and its propagation.

Track a quadratic path with a fast relaxation

Take \(g=t^2,\ \lambda=-100\) per second, \(h=0.1\) s, \(e_0=0\). Since \(h(2t_{n+1})-(t_{n+1}^2-t_n^2)=h^2\), the recurrence is

\[e_{n+1}=(e_n+0.01)/11.\]

The first error is \(0.00090909\), so the first computed state is 0.01090909 when the exact value is 0.01. The second error is approximately 0.00099174. Solving the scalar recurrence shows that the error tends to 0.001, the fixed point of \(11e=e+0.01\). Stability does not force it to vanish because each step creates a new tracking defect.

For comparison, trapezoidal integration of the slow-path derivative integrates the linear function \(g'=2t\) exactly over each interval. Substituting the exact nodal values \(g(t_n)\) therefore satisfies its full discrete equations, so an exactly initialized trajectory stays on this particular path. However, a small off-path perturbation is multiplied per step by \((1-5)/(1+5)=-2/3\), whereas backward Euler multiplies it by \(1/11\). Thus one method is exact on the specified moving path and the other damps unrelated fast perturbations more rapidly.

A numerical test that initialises precisely on \(g\) and uses only this quadratic path could make the trapezoidal method appear flawless. Add a known small perturbation and measure its sign and amplitude separately. Conversely a test with \(g=0\) detects damping but cannot expose a tracking defect. Both controlled initialisations are needed to tell whether an observed error arises from resolving the moving forcing or dissipating the artificially fast component.

A final scaling experiment holds the stiffness fixed and halves the step. The long-time tracking error in this quadratic case is \(h/|\lambda|\), obtained by cancelling the fixed-point terms in the recurrence. With \(h=0.05\) and the same relaxation rate it becomes 0.0005. A one-step error alone, evaluated from the exact state on each grid, would not reveal the same accumulation mechanism. Report whether an observed order concerns a local defect, a settled tracking error or an initial fast transient.

Separate boundedness from physical decay in a stiff mode

For \(y'=-k y\) with positive initial state, an unresolved fast mode should disappear on the reporting timescale. Compare the actual signed factors. A magnitude-only graph would conceal a spurious sign change.

Separate boundedness from physical decay in a stiff mode. Horizontal axis: Step × positive decay rate. Vertical axis: Signed amplification per step. Data follow the figure.
At hk = 10 the exact factor is 4.54×10⁻⁵, backward Euler gives 1/11, and trapezoidal gives −2/3. The trapezoidal solution remains bounded but an alternating fast component can contaminate physically nonnegative output.
Read values from the plot
Signed amplification per step at selected values of Step × positive decay rate.
Step × positive decay rateExactBackward EulerTrapezoidal rule
0.010.990050.99010.99005
0.0880110.915750.919110.9157
0.77460.460890.563510.44165
6.81730.00109470.12792−0.54635
608.7565e−270.016393−0.93548

Download all 361 plotted samples (CSV)

Change parameters · Separate boundedness from physical decay in a stiff mode

Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.

Study the full derivation

Why stiff stability does not guarantee the expected order · Dynamics and numerical time integration

A differential equation is constructed to have a smooth, known solution and a rapidly damped error mode. Use it to distinguish stability of the homogeneous equation, tracking of a moving target and the effect of off-grid stage forcing.