Absolute and relative error tolerances 2026-10-14
Absolute tolerances provide a nonzero error scale near zero, while relative tolerances follow component magnitude. A max-norm test controls every scaled estimated component locally. A root-mean-square test has a different componentwise implication. Neither test automatically certifies the complete trajectory's global error.
Write for the candidate accepted component and require . The absolute and relative error tolerances scale in the title produces the dimensionless maximum norm testAbsolute tolerances have the same units as the corresponding solution components; relative tolerances are dimensionless. Choose separate absolute scales for components measured in different units or with different significant magnitudes. Near zero, a purely relative test can demand a zero allowable error; a positive absolute scale avoids that difficulty. The crossover is when . Official solver documentation specifies the analogous blend and allows component-specific absolute tolerances; the old/new maximum above is the convention used in this example.[ref]
scipy.integrate.solve_ivp. solve_ivp, rtol and atol parameters: local error estimates, additive scaling and component-specific atol
A root mean square version replaces the maximum norm by . It permits one scaled component as large as when all others vanish, so passing that test does not mean every component is at most one. State the aggregation rule along with the absolute and relative error tolerances. Neither rule is a bound on actual global error.
Continue the initial value problem , , to using the Euler-Heun embedded pair. Choose absolute and relative error tolerances and , so the scalar scale is throughout. This intentionally absolute-only test makes the local and accumulated errors directly comparable. Start with , accept the Heun's method endpoint precisely when , and after every trial use the capped adaptive step-size controllerFor use the growth factor two. Cap every trial at ; on rejection retain the old time and state. These choices specify an original computation, rather than a claim about the defaults of a particular software solver.
The initial trial has and is rejected. Retrying from with gives and is accepted. The run takes 315 accepted steps and one rejected trial. Increasing exponential growth makes the local error estimator grow at a fixed , so subsequent steps shrink roughly like . The final step is additionally shortened to land at .
Computed Euler-Heun step sizes and errors: every accepted local estimate passes, but accumulated global error exceeds the absolute tolerance
. Details. The right panel plots errors against the accepted-step number, all divided by the same . The actual Heun local defect uses the restarted exact endpoint , while actual global error uses . All accepted are at most one, and the actual Heun local defects here are even smaller, at most about . Nevertheless the endpoint is , versus , with absolute error about . Passing local tests therefore does not certify the original trajectory's global error.
This failure of a global guarantee has an exact explanation for this example. Put and . ThenEach new local defect is added to the previous error amplified by . Iterating this identity, rather than merely inspecting , accounts for accumulation. The variable-step global ODE error bound describes the corresponding mechanism for more general ordinary differential equations.
Repeating with gives 98 accepted steps, one rejection and endpoint absolute error about ; with it gives 1001 accepted steps, two rejections and endpoint absolute error about . Accuracy improves on this smooth problem, but the endpoint error remains about fifteen times the requested local scale. A different initial value problem can amplify or damp defects differently.
Adaptive Euler step doubling for exponential decay Created 2026-10-14 Updated 2026-10-14
Consider the nonstiff scalar initial value problem , , on . Its exact solution is the exponential decay . Use step-doubling error estimation with the explicit Euler method: from the same numerical starting value , form one coarse step and two half steps giving :Accept when the absolute and relative error tolerances test passes, with . There is no Richardson extrapolation in the accepted value. Both approximations have order of a numerical method one, while this local error estimator has step exponent . Consequently the adaptive step-size controller uses a square root, not a cube root:Start with . A rejected trial retains both and , caps at one, and retries. A zero estimate uses . Before every trial, cap at . Stop with a failure if floating-point arithmetic gives , or after 100000 trials. These rules specify the example completely; they are not a prescription for every ordinary differential equation solver.
Adaptive two-half-step Euler decay: exact and numerical trajectories, accepted step sizes and rejected trials
. Details. The first two trials, and , have and and are rejected. The next trial has and and is accepted. For positive decreasing numerical values, , so the local error estimator givesWhen the relative term dominates, this suggests nearly constant accepted steps, approximately . When falls below the crossover size , the absolute term increasingly permits longer steps. The sharp final decrease in only lands on ; it does not indicate a sudden loss of smoothness.
The actual signed local defect from the same numerical input isHere is Big O notation, obtained from Taylor's theorem for the exponential function. Thus agrees with the leading term as , but is not identical to . At , , the estimate is while the actual local defect is . Their closeness improves for the smaller accepted steps. Had we added using Richardson extrapolation, the accepted formula would instead be , of order of a numerical method two; the same raw difference would still scale as and would not estimate that improved value's leading defect.
Estimated versus actual local Euler defects, rejected trials, and actual accumulated global error scaled by the local tolerance
. Details. The global error obeys an exact recurrence relation involving the actual local defects:Each previous global error contracts, yet the local defects keep adding. In the plotted run, 101 steps are accepted and two trials are rejected. Every accepted is at most approximately , while the largest is approximately . At , the numerical value is approximately , compared with the exact , giving absolute error approximately . The right-hand plot deliberately scales actual global error by the same used for local acceptance; it is not a new global error tolerance test.
Tightening both absolute and relative error tolerances by a factor ten gives 315 accepted steps and endpoint absolute error approximately ; tightening both by a factor one hundred gives 991 accepted steps and endpoint absolute error approximately . This is a convergence comparison for this particular initial value problem. The endpoint error decreases by about a factor three per tenfold tightening, rather than by ten: a first-order Euler method accumulates defects across many steps, while its local error estimator varies quadratically with . A variable-step global ODE error bound needs propagation information as well as accepted local tests.
The absolute stability boundary remains a separate constraint. On the Dahlquist test equation with , the accepted two-half-step formula has stability function . It strictly damps perturbations only for . Its local error estimator is , which can pass an absolute-tolerance test at tiny even outside this damping interval. In a stiff two-mode linear system, a fast mode can therefore constrain the step long after its visible amplitude has become small. An adaptive step-size controller does not turn an explicit Euler method into an A-stable method. Official solver documentation likewise distinguishes explicit Runge-Kutta methods for nonstiff problems from implicit Runge-Kutta methods and backward differentiation formulas for stiff equations.[ref]
scipy.integrate.solve_ivp. solve_ivp, method parameter: explicit versus implicit methods and stiffness
Embedded Runge-Kutta pair Created 2026-10-14 Updated 2026-10-14
Two Runge-Kutta methods share a stage matrix and nodes but use different output weights. An order- and order- pair with gives an output difference generally of order , estimating the lower-order defect. Shared stage evaluations reduce the cost. The adaptive step-size controller exponent must reflect this estimator order, rather than blindly the higher reported solution order.
Using the slope convention for Runge-Kutta stages, an embedded Runge-Kutta pair computesIts Butcher tableau has two output rows, and . Evaluating is often the expensive part of solving an ordinary differential equation; after the shared slopes have been computed, the extra row needs only another linear combination.[ref]
Write for the exact endpoint from the current numerical state, and define signed local defects and . Then . If and , with , the difference reproduces the leading lower-order defect. It does not reproduce the leading higher-order defect. Here the powers use big O notation and a smooth Taylor expansion; a vanishing leading coefficient or accidental cancellation can make the estimate misleading.
A common choice accepts after testing with absolute and relative error tolerances. With the scale approximately unchanged on a retry, the adaptive step-size controller uses exponent . Accepting a better endpoint does not change the power in the quantity being tested. The Euler-Heun embedded pair makes this visible without a large coefficient table.[ref]
Error control for ODE solvers Created 2026-10-14 Updated 2026-10-14
Error control selects discretization parameters and checks approximations against requested accuracy. Local error estimators, absolute and relative error tolerances and an adaptive step-size controller provide practical local control. Propagation of defects determines the global error, while stiffness, roundoff error and algebraic-solve accuracy impose additional limits.
For an ordinary differential equation, the practical loop is to propose a step, form a local error estimator, scale it by absolute and relative error tolerances, and accept or retry before choosing the next step. An embedded Runge-Kutta pair supplies two endpoints from shared Runge-Kutta stages, making this extra accuracy check inexpensive. The Euler-Heun embedded pair below exposes the distinction between the accepted formula's order of a numerical method and the estimator's step exponent; its Adaptive Euler-Heun integration of exponential growth shows accepted local tests alongside accumulated global error.


