Euler's Method
Textbook Reference
| Primary source | OpenStax Calculus Volume 2, Section 4.2: “Direction Fields and Numerical Methods” |
| Direct link | https://openstax.org/books/calculus-volume-2/pages/4-2-direction-fields-and-numerical-methods |
| Textbook used in class | Stewart, Calculus, Section 9.2: “Direction Fields and Euler’s Method” (Examples 3, 4) |
Quick Reference
Euler’s Method: given $y' = f(x, y)$ and an initial condition $y(x_0) = y_0$, choose a step size $h > 0$ and iterate: $$x_{n+1} = x_n + h, \qquad y_{n+1} = y_n + h\,f(x_n, y_n).$$
Each step moves one horizontal distance $h$ along the tangent line at $(x_n, y_n)$, then starts fresh from the new point.
Smaller $h$ gives a more accurate approximation but requires more steps.
Motivation
Most differential equations have no closed-form solution. Euler’s method is the simplest numerical scheme for approximating one. It converts the geometric idea of a direction field -- at each point, the solution curve is tangent to the slope $f(x, y)$ -- into an algorithm. You follow the indicated slope for one short step, reset at the new point, and repeat.
The result is a polygonal path that tracks the true solution curve, with accuracy improving as the step size $h$ shrinks. Euler’s method is not the most efficient numerical scheme, but its derivation makes the error analysis transparent and motivates the more sophisticated Runge-Kutta methods used in practice.
Key Concept
At the point $(x_n, y_n)$, the tangent line to the solution has slope $f(x_n, y_n)$, so after a step of width $h$ the tangent-line estimate of $y$ is: $$y_{n+1} \approx y_n + h\, f(x_n, y_n).$$
The local error (error in one step) is proportional to $h^2$. After $N = (b-a)/h$ steps, the global error on $[a, b]$ is proportional to $h$: halving the step size halves the global error. Euler’s method is a first-order method.
Worked Example
Use Euler’s method with step size $h = 0.5$ to approximate $y(1)$ for the IVP $y' = y$, $y(0) = 1$.
The exact solution is $y = e^x$, so $y(1) = e \approx 2.718$.
| $n$ | $x_n$ | $y_n$ | $f(x_n, y_n) = y_n$ | $h\cdot f$ |
|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 0.5 |
| 1 | 0.5 | 1.5 | 1.5 | 0.75 |
| 2 | 1.0 | 2.25 | -- | -- |
The Euler approximation gives $y(1) \approx 2.25$, an error of about $0.47$ (17%).
With $h = 0.25$ (four steps) the approximation would be $(1.25)^4 = 2.441$, halving the error as predicted for a first-order method.
smaller step size always reduces accumulated error. Smaller $h$ does reduce truncation error (the error from approximating with a tangent line). However, on a computer, very small $h$ introduces round-off error because floating-point arithmetic has finite precision. There is an optimal step size below which round-off error grows faster than truncation error shrinks. In practice, use $h$ small enough for the needed accuracy but no smaller than necessary.
Common Misconceptions
Euler’s method uses the same slope for the entire interval $[x_0, x_n]$, so taking more steps does not change the computation.
This is the rate-as-fixed-number error. Each Euler step recomputes the slope $f(x_n, y_n)$ at the current approximate point $(x_n, y_n)$ before advancing. The slope is generally different at each step because both $x$ and the approximate $y$ change. For $y' = y$ starting at $(0,1)$ with $h = 0.5$, the slope at the first step is $f(0,1) = 1$, but at the second step it is $f(0.5, 1.5) = 1.5$, a different value. Using one slope for the whole interval would give a straight-line approximation, which is a cruder estimate than Euler’s method with multiple steps.
the Euler approximation at the final point $x_n$ is exact if the step size is chosen to divide the interval evenly.
This is the concept-image-conflicts-definition error. Euler’s method replaces each curve segment with a tangent-line segment, introducing truncation error in every step regardless of how evenly $h$ divides the interval. An integer number of equal steps eliminates rounding in the $x$-values but does not eliminate the geometric error of approximating a curved path by straight pieces. For $y' = y$ on $[0,1]$ with $h = 0.5$ (two equal steps), the Euler approximation gives $y(1) \approx 2.25$ while the exact value is $e \approx 2.718$, an error of about $17\%$.
Leveled Practice
Problem 1. Apply Euler’s method with $h = 1$ for two steps to $y' = x - y$, $y(0) = 0$.
Show answer
Step 0: $x_0 = 0$, $y_0 = 0$, $f = 0 - 0 = 0$. $y_1 = 0 + 1\cdot 0 = 0$.
Step 1: $x_1 = 1$, $y_1 = 0$, $f = 1 - 0 = 1$. $y_2 = 0 + 1\cdot 1 = 1$.
Euler approximation: $y(2) \approx 1$. (The exact solution is $y = x - 1 + e^{-x}$, giving $y(2) = 1 + e^{-2} \approx 1.135$.)