Forward Euler Method #
We implement the explicit Euler method for ODEs and prove its convergence.
Generic infrastructure #
piecewiseLinear,piecewiseConst: Piecewise linear/constant interpolation on a regular grid.locallyFinite_Icc_grid: The regular grid is locally finite.ContinuousOn.of_Icc_grid: Cell-wise continuity implies continuity on[a, ∞).
Euler method #
ODE.EulerMethod.step,ODE.EulerMethod.point,ODE.EulerMethod.slope: The Euler iteration.ODE.EulerMethod.path,ODE.EulerMethod.deriv: Piecewise linear/constant interpolation of the Euler points.ODE.EulerMethod.dist_deriv_le: Global bound on the local truncation error.ODE.EulerMethod.dist_path_le: Error bound via Gronwall's inequality.ODE.EulerMethod.tendsto_path: Convergence ash → 0⁺.
Grid helpers #
If t ∈ [a + n * h, a + (n + 1) * h) and 0 < h, then ⌊(t - a) / h⌋₊ = n.
If 0 < h and a ≤ t, then t lies in the floor interval
[a + ⌊(t - a) / h⌋₊ * h, a + (⌊(t - a) / h⌋₊ + 1) * h).
Piecewise linear interpolation #
The piecewise linear interpolation of a sequence y with slopes c on a regular grid
with step size h starting at a. On [a + n * h, a + (n + 1) * h), the value is
y n + (t - (a + n * h)) • c n.
Equations
Instances For
The piecewise constant function taking value c n on [a + n * h, a + (n + 1) * h).
Instances For
The piecewise constant function equals c n on [a + n * h, a + (n + 1) * h).
The regular grid of closed intervals [a + n * h, a + (n + 1) * h] is locally finite.
A function continuous on each cell [a + n * h, a + (n + 1) * h] is continuous
on [a, ∞).
The piecewise linear interpolation at a grid point a + n * h equals y n.
A piecewise linear function whose grid values satisfy y (n + 1) = y n + h • c n
is continuous on [a, ∞).
The right derivative of a piecewise linear function is the piecewise constant slope.
Euler method #
A single step of the explicit Euler method: y + h • v(t, y).
Equations
- ODE.EulerMethod.step v h t y = y + h • v t y
Instances For
The sequence of Euler points, defined recursively:
point v h t₀ y₀ 0 = y₀ and point v h t₀ y₀ (n+1) = step v h (t₀ + n*h) (point v h t₀ y₀ n).
Equations
- ODE.EulerMethod.point v h t₀ y₀ 0 = y₀
- ODE.EulerMethod.point v h t₀ y₀ n.succ = ODE.EulerMethod.step v h (t₀ + ↑n * h) (ODE.EulerMethod.point v h t₀ y₀ n)
Instances For
The slope of the Euler method on the n-th cell: v(t₀ + n * h, yₙ).
Equations
- ODE.EulerMethod.slope v h t₀ y₀ n = v (t₀ + ↑n * h) (ODE.EulerMethod.point v h t₀ y₀ n)
Instances For
The piecewise linear Euler path, interpolating the Euler points with Euler slopes.
Equations
- ODE.EulerMethod.path v h t₀ y₀ = piecewiseLinear (ODE.EulerMethod.point v h t₀ y₀) (ODE.EulerMethod.slope v h t₀ y₀) h t₀
Instances For
The piecewise constant right derivative of the Euler path.
Equations
- ODE.EulerMethod.deriv v h t₀ y₀ = piecewiseConst (ODE.EulerMethod.slope v h t₀ y₀) h t₀
Instances For
Global bound on the difference between the Euler derivative and the vector field along the Euler path.
Error bound for the Euler method via Gronwall's inequality.
The Euler method converges to the true solution as h → 0⁺.