SME
Differential Equations · Problem type
Euler’s method
Use this for “Use Euler’s method with h = 0.25 to estimate y(1) for y′ = 2x − y, y(0) = 3. How far is it from the exact value?”
Diagram
Slope field of y′ = x + y
The solid curve is the solution through (0, 1)
Euler, h = 0.1: y₁ = 1.1 at x = 0.1, y₂ = 1.22 at x = 0.2
Exact y(0.2) = 1.243: Euler is off by 0.02281
This is an example. Type your own values to start a new problem.
y′
=
a
x
+
b
y
+
c
y(
x₀
)
=
y₀
,
h
=
h
,
n
=
n
y(
xₙ
)
≈
yₙ
y(xₙ)
Exact value at xₙ
worked out (not typed)
E
Error of the estimate
worked out (not typed)
Formulas
xₙ
=
x₀
+
n
×
h
0.2 = 0 + 2 × 0.1
yₙ
=
Euler’s
method
on
y′
=
ax
+
by
+
c
from
(
x₀
,
y₀
),
n
steps
of
h
1.22 = Euler’s method on y′ = 1x + 1y + 0 from (0, 1), 2 steps of 0.1
y(xₙ)
=
the
solution
of
y′
=
ax
+
by
+
c
through
(
x₀
,
y₀
)
at
xₙ
1.2428 = the solution of y′ = 1x + 1y + 0 through (0, 1) at 0.2
E
=
y(xₙ)
−
yₙ
0.02281 = 1.2428 − 1.22
Assumptions
•
Euler’s method follows the slope f(x, y) = ax + by + c at the start of each step for a run of h: yₖ₊₁ = yₖ + h × f(xₖ, yₖ).
•
y′ = ax + by + c is linear, so it has an exact solution to compare: a line plus Ceb(x − x₀), or a parabola when b = 0.
•
Where the curve bends away from its tangents, each step misses a little. Halving h roughly halves the error.
Step-by-step
WE KNOW
a = 1, b = 1, c = 0, x₀ = 0, y₀ = 1, h = 0.1, n = 2
FIND
last x (xₙ), Euler’s estimate at xₙ (yₙ), exact value at xₙ (y(xₙ)), error of the estimate (E)
Step 1 · Find last x (xₙ)
Use xₙ = x₀ + n × h
Each
of
the
n
steps
moves
h
to
the
right.
xₙ = 0 + 2 × 0.1
xₙ = 0.2
Step 2 · Find Euler’s estimate at xₙ (yₙ)
Use yₙ = Euler’s method on y′ = ax + by + c from (x₀, y₀), n steps of h
Each
step
adds
h
times
the
slope
f
(x,
y)
=
ax
+
by
+
c
where
it
starts.
The
lines
below
take
one
step
each:
the
slope,
then
the
step.
f
(0,
1)
=
1
×
0
+
1
×
1
+
0
=
1
y₁ = 1 + 0.1 × 1 = 1.1
f
(0.1,
1.1)
=
1
×
0.1
+
1
×
1.1
+
0
=
1.2
y₂ = 1.1 + 0.1 × 1.2 = 1.22
yₙ = 1.22
Step 3 · Find exact value at xₙ (y(xₙ))
Use y(xₙ) = the solution of y′ = ax + by + c through (x₀, y₀) at xₙ
A
line
px
+
q
solves
it
when
p
=
−
a
b
and
q
=
p −
c
b
.
Add
C
e
b
(x −
x₀
)
,
with
C
fitting
y(
x₀
)
=
y₀
.
y′ = x + y
particular
line:
p
=
−
a
b
=
−1,
q
=
p −
c
b
=
−1
C
=
y₀
−
(px₀
+
q)
=
1
−
((−1)
×
0
+
(−1))
=
2
y(x) = −x − 1 + 2eˣ
y(0.2)
=
−0.2
−
1
+
2
e
0.2
=
1.2428
y(xₙ) = 1.24281
Step 4 · Find error of the estimate (E)
Use E = y(xₙ) − yₙ
The error is how far Euler’s estimate falls short of (or past) the exact value.
E
=
1.24281
−
1.22
E
=
0.02281
Check
Put the numbers back in. Both sides should match.
0.2 = 0 + 2 × 0.1 ✓
1.22 = 1.1 + 0.1 × 1.2 ✓
1.2428
=
(−1)
×
0.2
+
(−1)
+
2
×
e
1 × (0.2 − 0)
✓
0.02281 = 1.24281 − 1.22 ✓
Topic check
See what you know: 5 questions on this topic
New questions each time. Pass to mark it complete.
Related lessons
First-order ODEs
Main lesson
Logistic growth
Use this for “A pond can hold 2000 fish. It is stocked with 200 and grows by dP/dt = 0.3P(1 − P/2000), t in years. How many fish are there after 5 years?”
A mixing tank
Use this for “A 400 L tank of fresh water takes in brine with 25 g/L of salt at 8 L/min, and the mixture drains at the same rate. How much salt is in it after 30 minutes?”
A linear equation by an integrating factor
Use this for “Solve y′ + 3y = 6x + 1 with y(0) = 2, and find y(0.5).”
Separable, linear, both or neither
Use this for “Is y′ = y cos x separable, linear, or both? Which method solves it?”