Euler's Method
Practise this section (12)You leave a can of soda at $40\,^\circ\mathrm{F}$ in a car where the air is $80\,^\circ\mathrm{F}$. A physics rule tells you how fast the can warms up at every moment, but not its temperature. How warm is the soda after 10 minutes? Most differential equations cannot be solved with a formula, so we need a way to build the answer one small step at a time.
Following the Slope Field
A differential equation $\dfrac{dy}{dx}=f(x,y)$ tells you the slope of the solution at every point $(x,y)$. That is exactly what a slope field draws. If you know one starting point, the initial condition, you can walk along the slope field: go a short distance in the direction of the slope at your current point, then look at the new slope and change direction.
Each short walk is a tangent line approximation, which you already know from AP Calculus AB (local linearization). Near $x=x_0$,
$$y(x) \approx y(x_0) + y'(x_0)\,(x-x_0).$$ One Euler step: from (xₙ, yₙ) the tangent line is followed a horizontal distance h, to xₙ + h. It ends at Euler yₙ₊₁, slightly off the true solution; the gap is the error, and it is small for small h.The tangent line leaves the curve a little, so the endpoint is not exactly on the solution. For a small step the error is small. That is the whole idea of Euler's method.
Let $\dfrac{dy}{dx}=xy$ with $y(1)=2$. (a) Write the equation of the tangent line to the solution at $x=1$ and use it to approximate $y(1.2)$. (b) Use one step of…
Let $\dfrac{dy}{dx}=xy$ with $y(1)=2$.
(a) Write the equation of the tangent line to the solution at $x=1$ and use it to approximate $y(1.2)$.
(b) Use one step of Euler's method with $h=0.2$ to approximate $y(1.2)$. What do you notice about the two results?
The Euler's Method Formula
Start at $(x_0,y_0)$ and choose a step size $h$. Over one step the slope is about $\dfrac{\Delta y}{\Delta x}$, so $\Delta y \approx \text{slope}\cdot h$. Repeating this gives the method.
The number of steps is $\dfrac{x_{\text{end}}-x_0}{h}$. To go from $x=0$ to $x=1$ with $h=0.5$ you need $2$ steps.
Let $\dfrac{dy}{dx} = x+y$ with $y(0)=1$. Use Euler's method with two steps of size $h=0.5$ to approximate $y(1)$. Show the slope you use at each step.
Let $\dfrac{dy}{dx} = x+y$ with $y(0)=1$. Use Euler's method with two steps of size $h=0.5$ to approximate $y(1)$. Show the slope you use at each step.
Let $\dfrac{dy}{dx} = 2y$ with $y(0)=3$. Use Euler's method with two steps of size $h=0.25$ to approximate $y(0.5)$.
Let $\dfrac{dy}{dx} = 2y$ with $y(0)=3$. Use Euler's method with two steps of size $h=0.25$ to approximate $y(0.5)$.
A function satisfies $\dfrac{dy}{dx} = ky$ for a constant $k$, with $y(0)=2$. One step of Euler's method with $h=0.5$ gives the approximation $3.5$ for $y(0.5)$. (a)…
A function satisfies $\dfrac{dy}{dx} = ky$ for a constant $k$, with $y(0)=2$. One step of Euler's method with $h=0.5$ gives the approximation $3.5$ for $y(0.5)$.
(a) Find $k$.
(b) Use a second step of Euler's method, with the same step size, to approximate $y(1)$.
(c) The exact solution is $y=2e^{kx}$. Explain whether your approximation is an underestimate or overestimate, and why.
Organizing the Steps in a Table
With three or more steps, keep your work in a table. This is also the clearest way to show your work on the AP exam.
| $x_n$ | $y_n$ | $\dfrac{dy}{dx}$ at $(x_n,y_n)$ | $y_{n+1}=y_n+h\cdot\dfrac{dy}{dx}$ |
|---|---|---|---|
Each row's last entry becomes the next row's $y_n$, and $x_n$ goes up by $h$.
| $x_n$ | $y_n$ | $\dfrac{dy}{dx}$ | $y_{n+1}$ |
|---|---|---|---|
| $0$ | $1$ | $1$ | $1.5$ |
| $0.5$ | $1.5$ | $1.75$ | $2.375$ |
| $1$ | $2.375$ | $3.375$ | $4.0625$ |
On a calculator-active problem, keep full decimals while you work and round only the final answer. The AP exam asks for three decimal places unless told otherwise.
Let $\dfrac{dy}{dx}=y-x$ with $y(0)=2$. Copy and complete the table for Euler's method with $h=0.5$ and three steps. Use the columns $x_n$, $y_n$, $\dfrac{dy}{dx}$ at…
Let $\dfrac{dy}{dx}=y-x$ with $y(0)=2$. Copy and complete the table for Euler's method with $h=0.5$ and three steps. Use the columns $x_n$, $y_n$, $\dfrac{dy}{dx}$ at $(x_n,y_n)$, and $y_{n+1}$.
(Calculator active) Let $\dfrac{dy}{dx}=2x-y$ with $y(0)=1$. (a) Use Euler's method with four steps of size $h=0.25$ to approximate $y(1)$. Organize your work in a…
(Calculator active) Let $\dfrac{dy}{dx}=2x-y$ with $y(0)=1$.
(a) Use Euler's method with four steps of size $h=0.25$ to approximate $y(1)$. Organize your work in a table.
(b) The exact solution is $y = 2x-2+3e^{-x}$. Find the exact value of $y(1)$ and the error of your approximation to three decimal places.
Underestimate or Overestimate?
Euler's method follows tangent lines. Look back at the first figure. The curve was concave up, so the tangent line stayed below the curve and the Euler value came out too small.
To find $y''$, differentiate $\dfrac{dy}{dx}=f(x,y)$ with respect to $x$ (using the chain rule wherever $y$ appears), and then replace $\dfrac{dy}{dx}$ by $f(x,y)$.
Let $\dfrac{dy}{dx}=y^2$ with $y(0)=1$. (a) Use Euler's method with two steps of size $h=0.25$ to approximate $y(0.5)$. (b) Find $\dfrac{d^2y}{dx^2}$ in terms of $y$ and…
Let $\dfrac{dy}{dx}=y^2$ with $y(0)=1$.
(a) Use Euler's method with two steps of size $h=0.25$ to approximate $y(0.5)$.
(b) Find $\dfrac{d^2y}{dx^2}$ in terms of $y$ and explain why your approximation is an underestimate. (The exact value is $y(0.5)=2$; you do not need it for the explanation.)
Let $\dfrac{dy}{dx}=x-y$ with $y(0)=1$. (a) Use Euler's method with two steps of size $h=0.5$ to approximate $y(1)$. (b) The exact solution is $y=x-1+2e^{-x}$. Find…
Let $\dfrac{dy}{dx}=x-y$ with $y(0)=1$.
(a) Use Euler's method with two steps of size $h=0.5$ to approximate $y(1)$.
(b) The exact solution is $y=x-1+2e^{-x}$. Find $\dfrac{d^2y}{dx^2}$ for this solution and use its sign to decide whether Euler's method gives an underestimate or overestimate of $y(1)$.
(a) Let $\dfrac{dy}{dx}=\dfrac{y}{x}$ with $y(1)=2$. Use Euler's method with two steps of size $h=0.5$ to approximate $y(2)$. Then solve the equation exactly and explain…
(a) Let $\dfrac{dy}{dx}=\dfrac{y}{x}$ with $y(1)=2$. Use Euler's method with two steps of size $h=0.5$ to approximate $y(2)$. Then solve the equation exactly and explain why Euler's method gives the exact value here.
(b) Now let $\dfrac{dy}{dx}=\dfrac{2y}{x}$ with $y(1)=2$. Use the same step size to approximate $y(2)$. The exact solution is $y=2x^2$. Explain, using concavity, why your approximation is an underestimate.
Step Size and Accuracy
A smaller $h$ means shorter tangent segments, so the path hugs the true curve more closely. The next figure compares Euler's method with $h=0.5$ for $\dfrac{dy}{dx}=y$, $y(0)=1$ against the exact solution $y=e^x$.
With h = 0.5, the Euler path (straight segments, 1 → 1.5 → 2.25) stays below the exact curve y = eˣ, which reaches 2.72 at x = 1. Each tangent underestimates the growth, and the error accumulates.Here is the same problem with several step sizes. The exact value is $y(1)=e\approx 2.718$.
| Step size $h$ | Steps | Euler approximation of $y(1)$ | Error |
|---|---|---|---|
| $1$ | $1$ | $2.000$ | $0.718$ |
| $0.5$ | $2$ | $2.250$ | $0.468$ |
| $0.25$ | $4$ | $2.441$ | $0.277$ |
| $0.1$ | $10$ | $2.594$ | $0.125$ |
The error shrinks as $h$ shrinks. For small $h$ it is roughly proportional to $h$: cut the step size in half and the error is cut roughly in half. The price is more steps, and so more arithmetic.
When you can solve the equation exactly (for example by separation of variables, as in AP Calculus AB), you can measure the error as $|\text{exact}-\text{approx}|$. Euler's method is mainly for the equations you cannot solve.
(Calculator active) Let $\dfrac{dy}{dx}=xy$ with $y(0)=1$. (a) Use Euler's method with two steps of size $h=0.5$ to approximate $y(1)$. (b) Solve the differential…
(Calculator active) Let $\dfrac{dy}{dx}=xy$ with $y(0)=1$.
(a) Use Euler's method with two steps of size $h=0.5$ to approximate $y(1)$.
(b) Solve the differential equation by separation of variables and find the exact $y(1)$.
(c) Use Euler's method with four steps of size $h=0.25$ to approximate $y(1)$. Compare the errors of (a) and (c) and explain what the comparison shows about step size.
Let $y=f(x)$ be the solution of $\dfrac{dy}{dx}=2x-y$ with $f(1)=3$. (a) Find $f''(1)$ and state whether the graph of $f$ is concave up or concave down at $x=1$. (b)…
Let $y=f(x)$ be the solution of $\dfrac{dy}{dx}=2x-y$ with $f(1)=3$.
(a) Find $f''(1)$ and state whether the graph of $f$ is concave up or concave down at $x=1$.
(b) Write the tangent line at $x=1$ and use it to approximate $f(1.2)$. Is this an underestimate or overestimate?
(c) Use Euler's method with two steps of size $h=0.1$ to approximate $f(1.2)$.
(d) Which approximation, (b) or (c), do you expect to be closer to $f(1.2)$? Justify your answer.
Euler's Method in Context
Many real situations give a rate of change directly. A rate law like Newton's Law of Cooling or Warming says that an object's temperature changes at a rate proportional to the difference between its temperature and the room's.
Back to the start: the soda is about $70\,^\circ\mathrm{F}$ after 10 minutes by Euler's method, and really a little cooler, about $65.3\,^\circ\mathrm{F}$. Always give units when the problem is in context.
(Calculator active) A cup of coffee at $190\,^\circ\mathrm{F}$ is placed in a $70\,^\circ\mathrm{F}$ room. Its temperature $T$, in degrees Fahrenheit, after $t$ minutes…
(Calculator active) A cup of coffee at $190\,^\circ\mathrm{F}$ is placed in a $70\,^\circ\mathrm{F}$ room. Its temperature $T$, in degrees Fahrenheit, after $t$ minutes satisfies $\dfrac{dT}{dt}=-0.1(T-70)$.
(a) Use Euler's method with three steps of size $h=2$ minutes to approximate $T(6)$.
(b) Find $\dfrac{d^2T}{dt^2}$ in terms of $T$ and use it to decide whether your approximation is an underestimate or overestimate.
(c) The exact solution is $T(t)=70+120e^{-0.1t}$. Find $T(6)$ to the nearest hundredth of a degree and verify your answer to (b).
Summary
Can't find your problem here?
The AI checks one of your exercises: paste the problem with your answer or take a photo of it.