Read this lesson as text

Implementing Euler for y' = x + y

Differential Equations · Axiom Academy

EXAMPLE Implementing Euler's Method for y' = x + y Computing the first four Euler steps by hand and checking them against the exact solution Use Euler's Method with step size h = 0.1 to approximate the solution of y' = x + y , y(0) = 1 , at x = 0.1, 0.2, 0.3, 0.4 . Compare each approximation to the exact solution. Nice work — you just hand-computed four steps of Euler's Method and measured exactly how far it drifts from the true solution. Euler's formula: steps forward along the tangent line at the current point. Same two moves, every step: evaluate the slope f(x_n, y_n) , then multiply by h and add it to y_n . Error accumulates: in this example the error grew from 0.0103 at n=1 to 0.0554 at n=4 — each step's small linear error compounds into the next. Always benchmark against the exact solution when you have one — here y(x) = 2e^x - x - 1 — to see how accurate (or inaccurate) the numerical method really is. Step size drives accuracy: a smaller h shrinks the error per step, at the cost of more steps to compute. Euler's Method is the simplest numerical ODE solver — understanding its error is exactly what motivates more accurate methods like Runge–Kutta (RK4), which use multiple slope evaluations per step.

This is the written version of the interactive lesson above. See the full Differential Equations course.