2. Euler’s method¶
Derivation¶
Taylor’s theorem gives, for a smooth solution,
for some \(\xi\) between \(t\) and \(t + h\). Dropping the last term gives Euler’s method:
The term we dropped is the local truncation error, of size \(O(h^2)\) per step. To reach a fixed final time \(T\) we take \(N = (T - t_0)/h\) steps, so these errors add up to a global error of size \(O(h)\): Euler’s method has order 1. Halving \(h\) should roughly halve the error. Section 3 shows how to check that.
Your task¶
Open student/steps.py and write euler_step(f, t, y, h). It must:
evaluate \(f\) once, at \((t, y)\);
return \(y + h f(t, y)\) as a new array (do not write
y += ...).
Then run python verify.py. If your Euler step is correct you will see
4/4 gates passed and an observed order close to 1.
If a gate fails¶
The report says which gate failed and gives a hint. The most common Euler mistakes are forgetting the factor \(h\), and returning \(h f(t, y)\) (the increment) instead of \(y + h f(t, y)\).