import Mathlib /-! # Global error of the explicit Euler scheme for a Lipschitz autonomous ODE **Setting.** `E` is a real normed space, `F : E → E` is `K`-Lipschitz with `K > 0`, `T > 0`, and `y : ℝ → E` is an exact solution of `y' = F (y)` on `[0, T]` (derivative within `[0, T]`). As a regularity hypothesis we assume that `y'` (which is `t ↦ F (y t)`) is `M`-Lipschitz on `[0, T]`, i.e. `‖F (y s) - F (y t)‖ ≤ M |s - t|`; for `C²` solutions this is `sup ‖y''‖ ≤ M`. With `N ≥ 1` steps of size `h = T / N`, the Euler iterates are *defined* recursively by `Y 0 = y 0`, `Y (k+1) = Y k + h • F (Y k)` (`eulerIter`), and the global error at step `k` is `‖y (k h) - Y k‖` (`eulerError`). **Stated.** For every `k ≤ N`: `‖y (k h) - Y k‖ ≤ (h M / (2 K)) · (exp (K T) - 1)`. (This is the classical first-order bound: local error `≤ M h² / 2`, propagated by the discrete Grönwall inequality `e_{k+1} ≤ (1 + h K) e_k + M h² / 2`.) **Not stated.** Only explicit Euler for a deterministic ODE. This replaces the audited "time discretization" problem, whose mean-square error was an unconstrained structure field and whose one-step error was assumed. Nothing here concerns SDE schemes (Euler–Maruyama, strong order 1/2) or the HJB equation. -/ namespace NSHJB.EulerConvergence variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] /-- Explicit Euler iterates with step `h` started at `y₀`. -/ def eulerIter (F : E → E) (h : ℝ) (y₀ : E) : ℕ → E | 0 => y₀ | k + 1 => eulerIter F h y₀ k + h • F (eulerIter F h y₀ k) /-- Global error at step `k` with `N` uniform steps on `[0, T]`: `‖y (k h) - Y k‖`, `h = T / N`. -/ noncomputable def eulerError (F : E → E) (y : ℝ → E) (T : ℝ) (N k : ℕ) : ℝ := ‖y (k * (T / N)) - eulerIter F (T / N) (y 0) k‖ /-- First-order global error bound for explicit Euler. -/ theorem euler_global_error (F : E → E) (K : NNReal) (hF : LipschitzWith K F) (hK : 0 < (K : ℝ)) (T : ℝ) (hT : 0 < T) (y : ℝ → E) (hy : ∀ t ∈ Set.Icc 0 T, HasDerivWithinAt y (F (y t)) (Set.Icc 0 T) t) (M : ℝ) (hM : 0 ≤ M) (hy' : ∀ s ∈ Set.Icc 0 T, ∀ t ∈ Set.Icc 0 T, ‖F (y s) - F (y t)‖ ≤ M * |s - t|) (N : ℕ) (hN : 0 < N) : ∀ k ≤ N, eulerError F y T N k ≤ (T / N) * M / (2 * K) * (Real.exp (K * T) - 1) := by sorry end NSHJB.EulerConvergence