Solve a first-order ODE numerically: advance y one step at a time
using the slope at the current point. Example: y'=x+y, y(0)=1, h=1/2;
two steps give y(1)≈5/2 versus the true value 2e−2≈3.44.
The local error is O(h²); the global error is O(h).
Example
Advance the ODE solution using the current slope.
highlighted = computed this step
Step 1 — Set up
Set up Euler's method.
y′=x+yy(0)=1h=21
Step 2 — Euler step 1
Euler step 1: use the current slope to update y.
n1x0y1f1y next23
Step 3 — Euler step 2
Euler step 2: use the current slope to update y.
n12x021y123f12y next2325
Step 4 — Result
State the Euler approximation.
y(1)=25
eulers-method
Euler's method advances the solution by one step h using the slope at the current point: y_{n+1} = y_n + h·f(x_n, y_n)