Differential equations
An ordinary differential equation y′ = F(t, y) with a starting value y(t₀) = y₀ usually has no formula for its solution. A numerical method such as Runge–Kutta gives good approximations, but with no statement of how good. A validated solver gives an enclosure: a tube of functions that provably contains the true solution on the whole time span.
The fixed-point idea
Integrating both sides turns the equation into a fixed-point problem. The solution is the function y with
Picard iteration applies Φ repeatedly, starting from the constant y₀. Each application adds one correct Taylor coefficient. That gives the polynomial part of the enclosure. The proof comes from looking for a set that Φ maps into itself.
One validated step
On a step [t₀, t₀ + h]:
- Iterate Φ on polynomials, n times for order n, to get P ≈ y on the step.
- Guess a remainder interval I and evaluate Φ(P + I) in Taylor-model arithmetic. If the result lies inside P + I, Φ maps the set of functions within I of P into itself. That set is convex and Φ is compact there, so by Schauder's fixed-point theorem it holds a fixed point, which is a solution; for the smooth right-hand sides here the solution is unique, so the true solution stays within I of P on the whole step.
- If the inclusion fails, widen I a few times; if it still fails, halve h and start the step again.
- Once it holds, apply Φ again: the image is a tighter enclosure, often by a lot.
The step ends with an enclosure of y(t₀ + h), which is the starting set for the next step.
import { ode } from "@ratmath/analytic";
const sol = ode.solve({ f: "y^2 + t", y0: "1/2", until: "1/2", order: 10 });
sol.quick.value; // { t, y }: an RK4 preview on 200 steps
const S = sol.exact(); // an ODESolution
S.final; // RationalInterval enclosing y(1/2)
S.at("1/4"); // enclosure at any t in the span
S.steps; // [{ t0, t1, models }]: one Taylor model per step
S.describe();
Step sizes
A long step needs fewer steps but a larger remainder; a short one is tighter but costs more. The solver measures how much width each step adds beyond the width it inherited. It halves h while halving still reduces that excess, doubles h after a success (up to the first step size), and gives up on a span only when h falls below minStep. A solution that blows up, such as y′ = y² from y(0) = 1 near t = 1, ends with complete: false and a reason, never with a wrong enclosure.
Uncertain starting values
The starting value can be an interval. Then the enclosure contains every solution that starts in it. For y′ = y the solutions are y₀·eᵗ, so the true set of solutions grows in width by exactly eᵗ. The enclosure grows faster than that, because each step treats its starting interval as a fresh interval and loses the fact that all its points move together. The answer is still a proof; it is just looser than it could be. Keeping the dependence on y₀ as an extra variable of the Taylor models would fix this, and is on the list of things not built yet.
Systems and the wrapping effect
A system has one equation per component, and the enclosure is a box: one interval per component. Give the right-hand sides as a list and name the variables:
ode.solve({ f: ["v", "-x"], vars: ["x", "v"], y0: [1, 0], until: 3 }); // x″ = −x
ode.solve({ f: ["y2", "-y1 + mu*(1 - y1^2)*y2"], y0: [2, 0], until: 1, params: { mu: 1 } });
Boxes have a weakness. A rotating flow turns each box, and the smallest box around a turned box is larger than the box was. Each step inherits that larger box, so over long spans the enclosure grows even when the true set of solutions does not. This is the wrapping effect, first described by Moore. The solver counters it by also following how the solution depends on its starting value (the variational equation) and carrying the uncertainty in coordinates that turn with the flow, so the box is not redrawn at every step. For the oscillator this ends near 10⁻¹⁴ wide at t = 3. Pass track: false to switch it off: steps are then 2 to 5 times faster and the box grows as described. until may also be less than t0, which integrates backward in time.
@ratmath/analytic and Core's R, Rational, RationalInterval in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.