Euler’s Method

Euler’s method is a step-by-step way to approximate the solution of a differential equation dy/dx = f(x, y) with a starting point. From the current point, you follow the tangent line for a short step h, land on a new point, find the new slope there, and repeat. Smaller steps give better estimates.

Before this lesson: Slope Fields and Linear Approximation

The idea: follow the slope field in small steps

A differential equation tells you the slope at every point, but not the curve itself. If you know one point on the solution, you know the slope there, so you can walk a short distance along the tangent line.

That walk lands you near the curve, not exactly on it. At the new point, the equation gives a fresh slope, so you turn and take another short step. String the steps together and you get a broken-line path that tracks the true solution. It is the same idea as linear approximation, used over and over.

Graph of the exact solution y = eˣ of dy/dx = y with y(0) = 1, from x = 0 to x = 1, drawn as a solid blue curve ending near 2.718. Two dashed Euler paths start at (0, 1): an orange path with step 0.5 through (0.5, 1.5) to (1, 2.25), and a green path with step 0.25 through (0.25, 1.25), (0.5, 1.5625) and (0.75, 1.953) to (1, 2.441). Both paths stay below the curve.
Euler’s method follows tangent segments. The smaller step (0.25) stays closer to the true curve y = eˣ.

Euler’s method formula

Start at the initial point (x₀, y₀) and choose a step size h. Each step uses the slope at the point you are on:

y_{n+1} = y_n + h\,f(x_n, y_n), \qquad x_{n+1} = x_n + h
  1. Find the slope at the current point: m = f(xₙ, yₙ).
  2. Multiply by the step size to get the change in y: Δy = h·m.
  3. Add it to get the new y-value, and add h to get the new x-value.
  4. Repeat until you reach the x-value you want. The number of steps is (target x − x₀)/h.

A table with columns for x, y, the slope and h × slope keeps the work organized, especially on tests that don’t allow a calculator for every step.

Euler’s method examples

Example 1: Two steps

Use Euler’s method with h = 0.1 to estimate y(0.2) for dy/dx = x + y with y(0) = 1.

f(0, 1) = 0 + 1 = 1

Find the slope at the starting point (0, 1).

0.1(1) = 0.1

Multiply the slope by h to get the change in y.

y_1 = 1 + 0.1 = 1.1, \quad x_1 = 0.1

Add the change to y, and add h to x.

f(0.1, 1.1) = 0.1 + 1.1 = 1.2

Find the slope at the new point (0.1, 1.1).

0.1(1.2) = 0.12

Multiply by h.

y_2 = 1.1 + 0.12 = 1.22, \quad x_2 = 0.2

Add to get the second point.

Answer: y(0.2) ≈ 1.22. The exact solution is y = 2eˣ − x − 1, so y(0.2) ≈ 1.2428, and the error is about 0.023.

Example 2: Using a table

Estimate y(2) for dy/dx = 2x − y with y(0) = 3, using h = 0.5.

The number of steps is (2 − 0)/0.5 = 4. Each row uses the slope at the start of that row.

nxₙyₙSlope 2xₙ − yₙh × slopeyₙ₊₁
003−3−1.51.5
10.51.5−0.5−0.251.25
211.250.750.3751.625
31.51.6251.3750.68752.3125
f(0, 3) = 2(0) - 3 = -3

Slope at (0, 3).

y_1 = 3 + 0.5(-3) = 3 - 1.5 = 1.5

Step to x = 0.5 (see multiplying and dividing integers).

f(0.5, 1.5) = 2(0.5) - 1.5 = -0.5

Slope at (0.5, 1.5).

y_2 = 1.5 + 0.5(-0.5) = 1.5 - 0.25 = 1.25

Step to x = 1.

f(1, 1.25) = 2(1) - 1.25 = 0.75

Slope at (1, 1.25).

y_3 = 1.25 + 0.5(0.75) = 1.25 + 0.375 = 1.625

Step to x = 1.5.

f(1.5, 1.625) = 2(1.5) - 1.625 = 1.375

Slope at (1.5, 1.625).

y_4 = 1.625 + 0.5(1.375) = 1.625 + 0.6875 = 2.3125

Step to x = 2.

Answer: y(2) ≈ 2.3125. The exact solution, y = 2x − 2 + 5e⁻ˣ, gives y(2) ≈ 2.6767, so this large step size misses by about 0.36.

Example 3: How step size changes the error

For dy/dx = y with y(0) = 1, the exact solution is y = eˣ, so y(1) = e ≈ 2.7183. Estimate y(1) with h = 0.5 and with h = 0.25, and compare the errors.

y_{n+1} = y_n + h\,y_n = (1 + h)\,y_n

Here f(x, y) = y, so factor out yₙ (see distributive property).

h = 0.5: \; y_1 = 1.5(1) = 1.5

First step with h = 0.5.

y_2 = 1.5(1.5) = 2.25

Second step reaches x = 1.

h = 0.25: \; y_1 = 1.25(1) = 1.25

First step with h = 0.25.

y_2 = 1.25(1.25) = 1.5625

Second step, x = 0.5.

y_3 = 1.25(1.5625) = 1.953125

Third step, x = 0.75.

y_4 = 1.25(1.953125) = 2.44140625

Fourth step reaches x = 1.

2.7183 - 2.25 \approx 0.468

Error with h = 0.5.

2.7183 - 2.4414 \approx 0.277

Error with h = 0.25.

Answer: about 2.25 and 2.441. Halving the step cut the error from 0.468 to 0.277, a bit more than 40%. For small h, the error of Euler’s method is roughly proportional to h, so halving h roughly halves the error.

Example 4: Overestimate or underestimate?

For dy/dx = xy with y(1) = 2, estimate y(1.2) using two steps of h = 0.1. Then decide whether the estimate is too high or too low.

f(1, 2) = 1(2) = 2

Slope at (1, 2).

y_1 = 2 + 0.1(2) = 2.2

Step to x = 1.1.

f(1.1, 2.2) = 1.1(2.2) = 2.42

Slope at (1.1, 2.2).

y_2 = 2.2 + 0.1(2.42) = 2.2 + 0.242 = 2.442

Step to x = 1.2.

\dfrac{d^2y}{dx^2} = \dfrac{d}{dx}(xy) = y + x\dfrac{dy}{dx}

Differentiate xy (see product rule).

y + x(xy) = y(1 + x^2)

Substitute dy/dx = xy and factor out y.

y(1 + x^2) \gt 0 \text{ when } y \gt 0

Both factors are positive, so the solution is concave up.

Answer: y(1.2) ≈ 2.442, an underestimate. On a concave up curve, tangent lines lie below the curve, so each step lands low. (The exact value is 2e^0.22 ≈ 2.4922.)

Example 5: Cooling coffee (word problem)

A cup of coffee at 90°C sits in a 20°C room. Its temperature T (in °C) after t minutes follows dT/dt = −0.1(T − 20). Use Euler’s method with h = 2 minutes to estimate the temperature after 6 minutes.

\dfrac{dT}{dt} = -0.1(90 - 20) = -0.1(70) = -7

Rate at t = 0: the coffee loses 7°C per minute.

T_1 = 90 + 2(-7) = 90 - 14 = 76

Step to t = 2.

\dfrac{dT}{dt} = -0.1(76 - 20) = -0.1(56) = -5.6

Rate at t = 2.

T_2 = 76 + 2(-5.6) = 76 - 11.2 = 64.8

Step to t = 4.

\dfrac{dT}{dt} = -0.1(64.8 - 20) = -0.1(44.8) = -4.48

Rate at t = 4.

T_3 = 64.8 + 2(-4.48) = 64.8 - 8.96 = 55.84

Step to t = 6.

Answer: about 55.8°C after 6 minutes. The exact model, T = 20 + 70e^(−0.1t), gives about 58.4°C. Euler’s estimate is low because the cooling slows down, but each step uses the faster rate from its start. This model is Newton’s law of cooling, coming up later in this unit.

Common mistakes

MistakeExample of the errorFix
Using the new x with the old yFor dy/dx = x + y from (0, 1), using f(0.1, 1) for the first slopeEach step uses the slope at the point you are on: f(0, 1).
Forgetting to multiply by hWriting y₁ = 1 + 1 = 2 instead of 1 + 0.1(1)The change in y is h times the slope, not the slope itself.
Wrong number of stepsTaking 2 steps of h = 0.5 to go from x = 0 to x = 2Steps = (target − start)/h = 4.
Updating y but not xUsing x = 0 in every slopeAdd h to x at every step.
Calling the estimate exactWriting y(2) = 2.3125Euler’s method gives an approximation: write y(2) ≈ 2.3125.
Guessing over or under from the slope sign“The slope is positive, so it overestimates”Use concavity: concave up means an underestimate, concave down means an overestimate.

Related methods

Slope fields

A slope field shows the same slopes as a picture. Euler’s method turns that picture into numbers by walking along the segments.

Tangent lines and linear approximation

One Euler step is the tangent line at the current point, evaluated a distance h away. With one step, Euler’s method is exactly linear approximation.

Other numerical methods

Euler’s method is the simplest of many step methods. Improved methods average two slopes per step, much like the trapezoidal rule improves on a single-rectangle estimate. Newton’s method also uses tangent lines, but to find zeros, not to solve differential equations.

Exact solutions

Many equations, such as dy/dx = ky, can also be solved exactly by separating variables, coming up next in this unit. Exact formulas let you measure how good an Euler estimate is.

Practice problems

  1. Use h = 0.5 to estimate y(1) for dy/dx = 2x with y(0) = 1.
  2. Use h = 0.1 to estimate y(0.2) for dy/dx = y with y(0) = 2.
  3. Use h = 0.5 to estimate y(1) for dy/dx = x − y with y(0) = 1.
  4. Use h = 0.5 to estimate y(1.5) for dy/dx = 3 − y with y(0) = 0.
  5. Use h = 0.5 to estimate y(1) for dy/dx = x + y² with y(0) = 0.
  6. For dy/dx = y with y(0) = 1, estimate y(1) with h = 0.2. Compare the error with Example 3.
  7. For dy/dx = −2y with y(0) = 5, use one step of h = 0.1 to estimate y(0.1). Is it an overestimate or an underestimate?
  8. For dy/dx = x + y with y(1) = 2, use one step of h = −0.1 to estimate y(0.9).
  9. A town of 500 people grows by dP/dt = 0.04P, with t in years. Use h = 1 to estimate the population after 3 years.
  10. A fish population (in thousands) follows dP/dt = 0.5P(1 − P/100) with P(0) = 20. Use h = 1 year to estimate P(2).
Show answers

1.

f(0, 1) = 2(0) = 0

Slope at (0, 1).

y_1 = 1 + 0.5(0) = 1

Step to x = 0.5.

f(0.5, 1) = 2(0.5) = 1

Slope at (0.5, 1).

y_2 = 1 + 0.5(1) = 1.5

Step to x = 1.

Answer: y(1) ≈ 1.5 (exact: y = x² + 1 gives 2)

2.

f(0, 2) = 2

Slope at (0, 2).

y_1 = 2 + 0.1(2) = 2.2

Step to x = 0.1.

f(0.1, 2.2) = 2.2

Slope at (0.1, 2.2).

y_2 = 2.2 + 0.1(2.2) = 2.2 + 0.22 = 2.42

Step to x = 0.2.

Answer: y(0.2) ≈ 2.42

3.

f(0, 1) = 0 - 1 = -1

Slope at (0, 1).

y_1 = 1 + 0.5(-1) = 0.5

Step to x = 0.5.

f(0.5, 0.5) = 0.5 - 0.5 = 0

Slope at (0.5, 0.5).

y_2 = 0.5 + 0.5(0) = 0.5

Step to x = 1.

Answer: y(1) ≈ 0.5 (exact: 2/e ≈ 0.7358)

4.

f(0, 0) = 3 - 0 = 3

Slope at (0, 0).

y_1 = 0 + 0.5(3) = 1.5

Step to x = 0.5.

f(0.5, 1.5) = 3 - 1.5 = 1.5

Slope at (0.5, 1.5).

y_2 = 1.5 + 0.5(1.5) = 1.5 + 0.75 = 2.25

Step to x = 1.

f(1, 2.25) = 3 - 2.25 = 0.75

Slope at (1, 2.25).

y_3 = 2.25 + 0.5(0.75) = 2.25 + 0.375 = 2.625

Step to x = 1.5.

Answer: y(1.5) ≈ 2.625 (exact: 3 − 3e^(−1.5) ≈ 2.3306)

5.

f(0, 0) = 0 + 0^2 = 0

Slope at (0, 0).

y_1 = 0 + 0.5(0) = 0

Step to x = 0.5.

f(0.5, 0) = 0.5 + 0^2 = 0.5

Slope at (0.5, 0).

y_2 = 0 + 0.5(0.5) = 0.25

Step to x = 1.

Answer: y(1) ≈ 0.25

6.

y_{n+1} = (1 + 0.2)\,y_n = 1.2\,y_n

Each step multiplies y by 1.2.

y_1 = 1.2, \; y_2 = 1.2(1.2) = 1.44

Steps 1 and 2.

y_3 = 1.2(1.44) = 1.728

Step 3.

y_4 = 1.2(1.728) = 2.0736

Step 4.

y_5 = 1.2(2.0736) = 2.48832

Step 5 reaches x = 1.

2.7183 - 2.4883 \approx 0.230

Error.

Answer: y(1) ≈ 2.488, with error about 0.230, smaller than 0.277 for h = 0.25

7.

f(0, 5) = -2(5) = -10

Slope at (0, 5).

y_1 = 5 + 0.1(-10) = 5 - 1 = 4

Step to x = 0.1.

\dfrac{d^2y}{dx^2} = -2\dfrac{dy}{dx} = -2(-2y) = 4y \gt 0

Concave up while y is positive.

Answer: y(0.1) ≈ 4, an underestimate (exact: 5e^(−0.2) ≈ 4.094)

8.

f(1, 2) = 1 + 2 = 3

Slope at (1, 2).

y_1 = 2 + (-0.1)(3) = 2 - 0.3 = 1.7

Step back to x = 0.9.

Answer: y(0.9) ≈ 1.7 (exact ≈ 1.7193)

9.

\dfrac{dP}{dt} = 0.04(500) = 20

Rate at t = 0.

P_1 = 500 + 1(20) = 520

Step to t = 1.

\dfrac{dP}{dt} = 0.04(520) = 20.8

Rate at t = 1.

P_2 = 520 + 20.8 = 540.8

Step to t = 2.

\dfrac{dP}{dt} = 0.04(540.8) = 21.632

Rate at t = 2.

P_3 = 540.8 + 21.632 = 562.432

Step to t = 3.

Answer: about 562 people (exact: 500e^0.12 ≈ 564; compare compound interest at 4% a year)

10.

\dfrac{dP}{dt} = 0.5(20)(1 - 0.2) = 10(0.8) = 8

Rate at P = 20.

P_1 = 20 + 1(8) = 28

Step to t = 1.

\dfrac{dP}{dt} = 0.5(28)(1 - 0.28) = 14(0.72) = 10.08

Rate at P = 28.

P_2 = 28 + 10.08 = 38.08

Step to t = 2.

Answer: P(2) ≈ 38.08 thousand fish

Euler’s method FAQ

What is Euler’s method used for?

It approximates the solution of a differential equation with a starting value, especially when the equation can’t be solved exactly. Computers use the same idea, with tiny steps, to model motion, weather and populations.

What is the formula for Euler’s method?

yₙ₊₁ = yₙ + h·f(xₙ, yₙ) and xₙ₊₁ = xₙ + h, where h is the step size and f(x, y) is the slope given by dy/dx.

How do you know if Euler’s method overestimates or underestimates?

Check the sign of the second derivative. If the solution is concave up, Euler’s method underestimates; if it is concave down, it overestimates.

How do you make Euler’s method more accurate?

Use a smaller step size. The error is roughly proportional to h, so halving the step roughly halves the error, but it doubles the number of steps.

Summary

  • Euler’s method approximates a solution of dy/dx = f(x, y) from a starting point.
  • Each step: yₙ₊₁ = yₙ + h·f(xₙ, yₙ) and xₙ₊₁ = xₙ + h.
  • Always use the slope at the point you are on, and update both x and y.
  • Number of steps = (target x − starting x)/h.
  • Concave up solutions give underestimates; concave down solutions give overestimates.
  • Smaller steps give smaller errors, roughly in proportion to h.

Previous lesson: Slope Fields

Next lesson: Separable Differential Equations

Back to the Calculus 2 Index