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=12y'= x+y \quad y( 0 )= 1 \quad h= \frac{1}{2}

Step 2 — Euler step 1

Euler step 1: use the current slope to update y.

nxyfy next101132\begin{array}{ccccc}\text{n} & \text{x} & \text{y} & \text{f} & \text{y next} \\ \hlmath{1} & \hlmath{0} & \hlmath{1} & \hlmath{1} & \hlmath{\frac{3}{2}}\end{array}

Step 3 — Euler step 2

Euler step 2: use the current slope to update y.

nxyfy next10113221232252\begin{array}{ccccc}\text{n} & \text{x} & \text{y} & \text{f} & \text{y next} \\ 1 & 0 & 1 & 1 & \frac{3}{2} \\ \hlmath{2} & \hlmath{\frac{1}{2}} & \hlmath{\frac{3}{2}} & \hlmath{2} & \hlmath{\frac{5}{2}}\end{array}

Step 4 — Result

State the Euler approximation.

y(1)=52y( 1 )= \hlmath{\frac{5}{2}}
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)