Skip to content
Family Table Math
Auto

Euler's Method

Most differential equations can’t be solved with a neat formula. Euler’s method (say “OY-ler”) gets a numerical answer anyway: start at a known point, follow the tangent line a short distance, recompute the slope from the differential equation, and repeat. It is linearization used over and over, and it’s the numerical cousin of following a slope field. On the AP BC exam it usually appears as a short no-calculator part of a differential equations question.

Suppose dydx=f(x,y)\dfrac{dy}{dx} = f(x, y) and you know the point (x0,y0)(x_0, y_0) is on the solution. The slope there is f(x0,y0)f(x_0, y_0). Move right by a step size Δx\Delta x along the tangent line:

y1=y0+f(x0,y0) Δx,x1=x0+Δxy_1 = y_0 + f(x_0, y_0)\,\Delta x, \qquad x_1 = x_0 + \Delta x

In words: new yy = old yy + slope × step.

At the new point (x1,y1)(x_1, y_1), compute a new slope from the differential equation and step again. A table keeps the work organized:

xxyydydx\dfrac{dy}{dx} at this pointΔy=dydx⋅Δx\Delta y = \dfrac{dy}{dx}\cdot\Delta x
x0x_0y0y_0f(x0,y0)f(x_0, y_0)f(x0,y0) Δxf(x_0, y_0)\,\Delta x
x1x_1y1y_1f(x1,y1)f(x_1, y_1)f(x1,y1) Δxf(x_1, y_1)\,\Delta x
⋮\vdots⋮\vdots

To reach a target xx from x0x_0 with step Δx\Delta x, you need target−x0Δx\dfrac{\text{target} - x_0}{\Delta x} steps.

Each step follows a tangent line, which drifts away from the true curve. Smaller steps stay closer to the curve and usually give better estimates, at the cost of more arithmetic.

The answer depends on the concavity of the solution:

  • If the solution is concave up (d2ydx2>0\dfrac{d^2y}{dx^2} \gt 0), tangent lines lie below the curve, so Euler’s method gives an underestimate.
  • If the solution is concave down (d2ydx2<0\dfrac{d^2y}{dx^2} \lt 0), tangent lines lie above the curve, so Euler’s method gives an overestimate.

You can find d2ydx2\dfrac{d^2y}{dx^2} without solving the equation: differentiate dydx\dfrac{dy}{dx} implicitly, then substitute the differential equation in for every dydx\dfrac{dy}{dx}. On the AP exam, justify with a sentence like ”d2ydx2>0\dfrac{d^2y}{dx^2} \gt 0 on this interval, so the solution curve is concave up and lies above its tangent lines; the Euler approximation is an underestimate.”

Let y=f(x)y = f(x) be the solution of dydx=x+y\dfrac{dy}{dx} = x + y with f(0)=1f(0) = 1. Use Euler’s method with two steps of equal size to approximate f(1)f(1).

Solution. Two steps from x=0x = 0 to x=1x = 1 means Δx=0.5\Delta x = 0.5.

xxyydydx=x+y\dfrac{dy}{dx} = x + yΔy=dydx(0.5)\Delta y = \dfrac{dy}{dx}(0.5)
0011110.50.5
0.50.51.51.52211
112.52.5

So f(1)≈2.5f(1) \approx 2.5.

Example 2: A smaller step, and under or over?

Section titled “Example 2: A smaller step, and under or over?”

For the same equation, (a) approximate f(1)f(1) with four steps, (b) decide whether these approximations are under- or overestimates. (c) The exact solution is f(x)=2ex−x−1f(x) = 2e^x - x - 1. Compare.

Solution.

(a) Now Δx=0.25\Delta x = 0.25:

xxyydydx=x+y\dfrac{dy}{dx} = x + yΔy=dydx(0.25)\Delta y = \dfrac{dy}{dx}(0.25)
0011110.250.25
0.250.251.251.251.51.50.3750.375
0.50.51.6251.6252.1252.1250.531250.53125
0.750.752.156252.156252.906252.906250.72656250.7265625
112.88281252.8828125

So f(1)≈2.883f(1) \approx 2.883.

(b) Differentiate the differential equation:

d2ydx2=1+dydx=1+x+y\frac{d^2y}{dx^2} = 1 + \frac{dy}{dx} = 1 + x + y

Starting from (0,1)(0, 1), xx and yy both stay positive (the slope x+yx + y is positive, so yy keeps increasing). So d2ydx2=1+x+y>0\dfrac{d^2y}{dx^2} = 1 + x + y \gt 0 for 0≤x≤10 \le x \le 1: the solution is concave up, its tangent lines lie below it, and both Euler approximations are underestimates.

(c) Exactly, f(1)=2e−2≈3.437f(1) = 2e - 2 \approx 3.437. The two-step estimate is off by about 0.9370.937; the four-step estimate is off by about 0.5540.554. Halving the step size roughly halved the error.

The exact solution of dy/dx = x + y through (0, 1) curves upward, reaching about 3.437 at x = 1. Euler's method with step 0.5 is a two-segment broken line reaching 2.5 at x = 1. With step 0.25 it is a four-segment broken line reaching about 2.883. Both broken lines lie below the concave-up curve, and the smaller step stays closer to it. 0.5 1 1 2 3 exact: 3.437 Δx = 0.25: 2.883 Δx = 0.5: 2.5 (0, 1)
Euler’s method for dydx=x+y\frac{dy}{dx} = x + y, y(0)=1y(0) = 1: the polygons stay below the concave-up solution, and the smaller step gets closer.

Example 3: A cooling problem that overestimates

Section titled “Example 3: A cooling problem that overestimates”

A cold drink at 4 ∘C4\,^\circ\text{C} is set out in a 22 ∘C22\,^\circ\text{C} room. Its temperature TT (in ∘C^\circ\text{C}) after tt minutes satisfies dTdt=−0.5(T−22)\dfrac{dT}{dt} = -0.5(T - 22). (a) Use Euler’s method with Δt=1\Delta t = 1 to estimate T(2)T(2). (b) Is your estimate too high or too low?

Solution.

(a)

ttTTdTdt=−0.5(T−22)\dfrac{dT}{dt} = -0.5(T - 22)ΔT=dTdt(1)\Delta T = \dfrac{dT}{dt}(1)
00449999
1113134.54.54.54.5
2217.517.5

So T(2)≈17.5 ∘CT(2) \approx 17.5\,^\circ\text{C}.

(b) Differentiate:

d2Tdt2=−0.5 dTdt=−0.5(−0.5(T−22))=0.25(T−22)\frac{d^2T}{dt^2} = -0.5\,\frac{dT}{dt} = -0.5\big(-0.5(T - 22)\big) = 0.25(T - 22)

The drink stays colder than the room (T<22T \lt 22), so d2Tdt2<0\dfrac{d^2T}{dt^2} \lt 0. The solution is concave down, the tangent lines lie above it, and 17.517.5 is an overestimate.

(The exact solution is T=22−18e−0.5tT = 22 - 18e^{-0.5t}, so T(2)≈15.378 ∘CT(2) \approx 15.378\,^\circ\text{C}, which confirms it.)

Using the same slope for every step. The whole point is to recompute dydx\dfrac{dy}{dx} at each new point, using the new xx and the new yy.

Forgetting to multiply by the step size. The change is Δy=dydx⋅Δx\Delta y = \dfrac{dy}{dx}\cdot\Delta x, not just dydx\dfrac{dy}{dx}. With Δx=0.5\Delta x = 0.5, a slope of 22 only raises yy by 11.

Counting steps wrong. From x=0x = 0 to x=1x = 1 with Δx=0.25\Delta x = 0.25 is four steps, and the slope at the last point (x=1x = 1) is never used.

Mixing up concave up and under/over. Concave up means the curve bends above its tangent lines, so the tangent-line steps fall short: an underestimate. Picture y=x2y = x^2 and its tangent lines if you’re unsure.

Forgetting to substitute when finding the second derivative. ddx(x+y)=1+dydx\dfrac{d}{dx}(x + y) = 1 + \dfrac{dy}{dx}, and then you must replace dydx\dfrac{dy}{dx} with x+yx + y. An answer that still contains dydx\dfrac{dy}{dx} can’t be evaluated at a point.

1. (Warm-up) Let y=f(x)y = f(x) satisfy dydx=2x\dfrac{dy}{dx} = 2x with f(0)=1f(0) = 1. Use Euler’s method with Δx=0.5\Delta x = 0.5 to approximate f(1)f(1).

Solution
xxyydydx=2x\dfrac{dy}{dx} = 2xΔy\Delta y
00110000
0.50.511110.50.5
111.51.5

f(1)≈1.5f(1) \approx 1.5. (The exact solution y=x2+1y = x^2 + 1 gives 22; since y′′=2>0y'' = 2 \gt 0, the estimate is low, as expected.)

2. (Warm-up) Given dydx=y2−x\dfrac{dy}{dx} = y^2 - x and y(1)=2y(1) = 2, use one step of Euler’s method with Δx=0.1\Delta x = 0.1 to approximate y(1.1)y(1.1).

Solution

The slope at (1,2)(1, 2) is 22−1=32^2 - 1 = 3, so

y(1.1)≈2+3(0.1)=2.3y(1.1) \approx 2 + 3(0.1) = 2.3

3. (Warm-up) Given dydx=x−y\dfrac{dy}{dx} = x - y and y(0)=2y(0) = 2, use Euler’s method with two equal steps to approximate y(1)y(1).

Solution

Δx=0.5\Delta x = 0.5.

xxyydydx=x−y\dfrac{dy}{dx} = x - yΔy\Delta y
0022−2-2−1-1
0.50.511−0.5-0.5−0.25-0.25
110.750.75

y(1)≈0.75y(1) \approx 0.75.

4. (Core) Let y=f(x)y = f(x) be the solution of dydx=xy\dfrac{dy}{dx} = xy with f(0)=1f(0) = 1.

  • (a) Use Euler’s method with Δx=0.25\Delta x = 0.25 to approximate f(1)f(1). Give your answer to 3 decimal places.
  • (b) Find d2ydx2\dfrac{d^2y}{dx^2} in terms of xx and yy, and decide whether your answer to (a) is an under- or overestimate.
Solution

(a)

xxyydydx=xy\dfrac{dy}{dx} = xyΔy=dydx(0.25)\Delta y = \dfrac{dy}{dx}(0.25)
00110000
0.250.25110.250.250.06250.0625
0.50.51.06251.06250.531250.531250.13281250.1328125
0.750.751.19531251.19531250.8964843750.8964843750.224121093750.22412109375
111.419433593751.41943359375

f(1)≈1.419f(1) \approx 1.419.

(b) By the product rule, d2ydx2=y+xdydx=y+x(xy)=y(1+x2)\dfrac{d^2y}{dx^2} = y + x\dfrac{dy}{dx} = y + x(xy) = y\left(1 + x^2\right).

The slope xyxy is never negative for x≥0x \ge 0 and y>0y \gt 0, so yy never drops below 11. Then d2ydx2=y(1+x2)>0\dfrac{d^2y}{dx^2} = y(1 + x^2) \gt 0: the solution is concave up, so 1.4191.419 is an underestimate. (The exact value is e1/2≈1.649e^{1/2} \approx 1.649.)

5. (Core) Given dydx=y−x\dfrac{dy}{dx} = y - x and y(0)=2y(0) = 2:

  • (a) Use Euler’s method with Δx=0.2\Delta x = 0.2 to approximate y(0.4)y(0.4).
  • (b) Show that d2ydx2=y−x−1\dfrac{d^2y}{dx^2} = y - x - 1. Given that the solution satisfies y>x+1y \gt x + 1 for 0≤x≤0.40 \le x \le 0.4, is your estimate too high or too low?
Solution

(a)

xxyydydx=y−x\dfrac{dy}{dx} = y - xΔy\Delta y
0022220.40.4
0.20.22.42.42.22.20.440.44
0.40.42.842.84

y(0.4)≈2.84y(0.4) \approx 2.84.

(b) d2ydx2=dydx−1=(y−x)−1\dfrac{d^2y}{dx^2} = \dfrac{dy}{dx} - 1 = (y - x) - 1. If y>x+1y \gt x + 1, then y−x−1>0y - x - 1 \gt 0, so the solution is concave up and 2.842.84 is too low. (The exact solution y=x+1+exy = x + 1 + e^x gives y(0.4)≈2.892y(0.4) \approx 2.892.)

6. (Core) Water drains from a tank. The depth hh in metres after tt minutes satisfies dhdt=−0.2h\dfrac{dh}{dt} = -0.2\sqrt{h}, with h(0)=9h(0) = 9.

  • (a) Use Euler’s method with Δt=1\Delta t = 1 to approximate h(2)h(2). Give your answer to 3 decimal places.
  • (b) Is the approximation an under- or overestimate? Justify.
Solution

(a) At t=0t = 0: slope =−0.29=−0.6= -0.2\sqrt{9} = -0.6, so h(1)≈9−0.6=8.4h(1) \approx 9 - 0.6 = 8.4.

At t=1t = 1: slope =−0.28.4≈−0.5797= -0.2\sqrt{8.4} \approx -0.5797, so h(2)≈8.4−0.5797≈7.820h(2) \approx 8.4 - 0.5797 \approx 7.820 m.

(b) By the chain rule,

d2hdt2=−0.2⋅12h⋅dhdt=−0.1h(−0.2h)=0.02>0\frac{d^2h}{dt^2} = -0.2 \cdot \frac{1}{2\sqrt{h}} \cdot \frac{dh}{dt} = -\frac{0.1}{\sqrt{h}}\left(-0.2\sqrt{h}\right) = 0.02 \gt 0

The solution is concave up, so the estimate is an underestimate. (The exact solution is h=(3−0.1t)2h = (3 - 0.1t)^2, giving h(2)=7.84h(2) = 7.84.)

7. (Core) A quantity satisfies dydt=ky\dfrac{dy}{dt} = ky with y(0)=2y(0) = 2. One step of Euler’s method with Δt=0.5\Delta t = 0.5 gives y(0.5)≈3y(0.5) \approx 3. Find kk.

Solution

The slope at (0,2)(0, 2) is 2k2k, so one step gives

2+2k(0.5)=3⇒2+k=3⇒k=12 + 2k(0.5) = 3 \quad\Rightarrow\quad 2 + k = 3 \quad\Rightarrow\quad k = 1

8. (Challenge) Let y=f(x)y = f(x) satisfy dydx=(y−1)x2\dfrac{dy}{dx} = (y - 1)x^2 with f(0)=3f(0) = 3.

  • (a) Use Euler’s method with two equal steps to approximate f(1)f(1).
  • (b) Find d2ydx2\dfrac{d^2y}{dx^2} and explain why the approximation is an underestimate.
Solution

(a) Δx=0.5\Delta x = 0.5. At (0,3)(0, 3): slope =(2)(0)=0= (2)(0) = 0, so y(0.5)≈3y(0.5) \approx 3. At (0.5,3)(0.5, 3): slope =(2)(0.25)=0.5= (2)(0.25) = 0.5, so f(1)≈3+0.5(0.5)=3.25f(1) \approx 3 + 0.5(0.5) = 3.25.

(b) By the product rule,

d2ydx2=dydx x2+(y−1)(2x)=(y−1)x4+2x(y−1)=(y−1)(x4+2x)\frac{d^2y}{dx^2} = \frac{dy}{dx}\,x^2 + (y - 1)(2x) = (y - 1)x^4 + 2x(y - 1) = (y - 1)\left(x^4 + 2x\right)

Starting at y=3y = 3, the slope (y−1)x2(y - 1)x^2 is never negative while y>1y \gt 1, so yy stays at least 33. For 0<x≤10 \lt x \le 1, both y−1>0y - 1 \gt 0 and x4+2x>0x^4 + 2x \gt 0, so d2ydx2>0\dfrac{d^2y}{dx^2} \gt 0. The solution is concave up, so 3.253.25 is an underestimate. (The exact value is 1+2e1/3≈3.7911 + 2e^{1/3} \approx 3.791.)

9. (Challenge) For dydx=3−y\dfrac{dy}{dx} = 3 - y with y(0)=1y(0) = 1, show that Euler’s method with nn equal steps from x=0x = 0 to x=1x = 1 gives y(1)≈3−2(1−1n)ny(1) \approx 3 - 2\left(1 - \tfrac{1}{n}\right)^n. What happens as n→∞n \to \infty?

Solution

Let h=1nh = \tfrac{1}{n}. One step gives yk+1=yk+(3−yk)hy_{k+1} = y_k + (3 - y_k)h. Subtract both sides from 33:

3−yk+1=(3−yk)−(3−yk)h=(3−yk)(1−h)3 - y_{k+1} = (3 - y_k) - (3 - y_k)h = (3 - y_k)(1 - h)

So the gap 3−y3 - y is multiplied by (1−h)(1 - h) at each step. It starts at 3−1=23 - 1 = 2, so after nn steps it is 2(1−h)n2(1 - h)^n, and

y(1)≈3−2(1−1n)ny(1) \approx 3 - 2\left(1 - \tfrac{1}{n}\right)^n

As n→∞n \to \infty, (1−1n)n→e−1\left(1 - \tfrac{1}{n}\right)^n \to e^{-1}, so the estimates approach 3−2e≈2.2643 - \dfrac{2}{e} \approx 2.264. That is the exact value: the solution is y=3−2e−xy = 3 - 2e^{-x}. Smaller and smaller steps converge to the true answer.