SME
Numerical Methods for Engineers · Problem type
One Heun step (improved Euler)
Use this for “Take one Heun step of h = 0.5 on dy/dt = −0.5y from y = 10, and compare with the exact answer.”
Chart
Heun, 1 step of h = 0.5: y = 7.813 at t = 0.5; solid, the exact y = 7.788, off by 0.3145%
This is an example. Type your own values to start a new problem.
y₀
Starting value
example
k
Rate constant
example
h
Step size
example
k₁
Slope at the start
worked out (not typed)
k₂
Slope at the predicted end
worked out (not typed)
y₁
Value by Heun’s method
worked out (not typed)
yexact
Exact value
worked out (not typed)
ε
Error
worked out (not typed) · %
Formulas
k₁
=
k
×
y₀
−5 = −0.5 × 10
k₂
=
k
×
(
y₀
+
h
×
k₁
)
−3.75 = −0.5 × (10 + 0.5 × (−5))
y₁
=
y₀
+
h
2
×
(
k₁
+
k₂
)
7.8125
=
10
+
0.5
2
×
(−5
+
(−3.75))
yexact
=
y₀
×
e
k
×
h
7.788
=
10
×
e
−0.5 × 0.5
ε
=
|
y₁
−
yexact|
÷
|yexact|
×
100
0.3145 = |7.8125 − 7.788| ÷ |7.788| × 100
Assumptions
•
dy/dt = f(y) = ky; Heun predicts the end with an Euler step, then averages the two end slopes.
•
k₁ = f(y₀), k₂ = f(y₀ + hk₁), and y₁ = y₀ + (h ÷ 2)(k₁ + k₂).
•
Heun is second order: halving h cuts its error about 4 times.
Step-by-step
WE KNOW
y₀ = 10, k = −0.5, h = 0.5
FIND
slope at the start (k₁), slope at the predicted end (k₂), value by Heun’s method (y₁), exact value (yexact), error (ε)
Step 1 · Find slope at the start (k₁)
Use k₁ = k × y₀
The slope ky at the start of the step.
k₁
=
−0.5
×
10
k₁
=
−5
Step 2 · Find slope at the predicted end (k₂)
Use k₂ = k × (y₀ + h × k₁)
Predict
the
end
with
an
Euler
step
along
k₁
,
then
take
the
slope
there.
k₂
=
−0.5
×
(10
+
0.5
×
(−5))
k₂
=
−0.5
×
(10
+
(−2.5))
k₂
=
−0.5
×
7.5
k₂
=
−3.75
Step 3 · Find value by Heun’s method (y₁)
Use y₁ = y₀ + h ÷ 2 × (k₁ + k₂)
Correct
the
prediction:
step
h
along
the
mean
of
the
two
slopes.
y₁
=
10
+
0.5
2
×
(−5
+
(−3.75))
y₁
=
10
+
0.5
2
×
(−8.75)
y₁
=
10
+
0.25
×
(−8.75)
y₁
=
10
+
(−2.1875)
y₁
=
7.8125
Step 4 · Find exact value (yexact)
Use yexact = y₀ × ek × h
The exact solution of dy/dt = ky after one step.
yexact
=
10
×
e
−0.5 × 0.5
yexact
=
10
×
e
−0.25
yexact = 10 × 0.7788
yexact = 7.788
Step 5 · Find error (ε)
Use ε = |y₁ − yexact| ÷ |yexact| × 100
The gap between the step and the exact answer, as a percent of the exact one.
ε
=
|7.8125
−
7.788|
÷
|7.788|
×
100
ε
=
|0.0245|
÷
|7.788|
×
100
ε
=
0.0245
7.788
×
100
ε
=
0.003146
×
100
ε
=
0.3145%
Check
Put the numbers back in. Both sides should match.
−5 = −0.5 × 10 ✓
−3.75 = −0.5 × (10 + 0.5 × (−5)) ✓
7.8125
=
10
+
0.5
2
×
(−5
+
(−3.75))
✓
7.788
=
10
×
e
−0.5 × 0.5
✓
0.3145 = |7.8125 − 7.788| ÷ |7.788| × 100 ✓
Topic check
See what you know: 5 questions on this topic
New questions each time. Pass to mark it complete.
Related lessons
Numerical ODE solvers (Euler, Runge–Kutta)
Main lesson
One Runge–Kutta (RK4) step
Use this for “Take one RK4 step of h = 0.5 on dy/dt = −0.5y from y = 10, and compare with the exact answer.”
Step size for a stable Euler method
Use this for “For dy/dt = −50y, is Euler’s method with h = 0.05 stable? What step size is?”