/-- Show that `n` steps of explicit Euler for `y' = λ y` multiply the initial value by
`(1 + hλ)ⁿ`.
Hint: induction on `n`; rewrite with `Function.iterate_succ_apply'` and the induction hypothesis,
then `ring`. -/
theorem explicit_euler_iterate (h lam y₀ : ℝ) (n : ℕ) :
(fun y => y + h * (lam * y))^[n] y₀ = (1 + h * lam) ^ n * y₀ := by
sorryShow the compiled solution
/-- **Explicit Euler on `y' = λ y`** is `yₙ₊₁ = yₙ + h λ yₙ = (1 + hλ) yₙ`, so after `n` steps
`yₙ = (1 + hλ)ⁿ y₀`. The exact solution is `e^{λ n h} y₀`. -/
theorem explicit_euler_iterate (h lam y₀ : ℝ) (n : ℕ) :
(fun y => y + h * (lam * y))^[n] y₀ = (1 + h * lam) ^ n * y₀ := by
induction n with
| zero => simp
| succ n ih => rw [Function.iterate_succ_apply', ih]; ringAxioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NumericalAnalysis.leanTry it in the Lean web editor