Last modified: April 17, 2023
This article is written in: 🇺🇸
Heun's method is an improved version of Euler's method that enhances accuracy by using an average of the slope at the beginning and the predicted slope at the end of the interval.
Assuming a first order differential equation:
$$ \frac{du}{dt} = f(t, u), $$
given $u(t_0) = u_0$ and a step size $h$, Heun's method predicts the solution at time $(t_0 + h)$ as follows:
$$ \tilde{u}_{n+1} = u_n + h f(t_n, u_n), $$
$$ u_{n+1} = u_n + \frac{h}{2} [f(t_n, u_n) + f(t_{n} + h, \tilde{u}_{n+1})]. $$
This process is repeated for each point in the desired interval.
The second-order Taylor series expansion around $t$ is given by:
$$ u(t + h) = u(t) + h u'(t) + \frac{1}{2}(h)^2 u''(t) + O(h^3), $$
where we approximate $u''(t)$ by the first difference of $u'(t)$:
$$ u''(t) \approx \frac{u'(t+h) - u'(t)}{h} = \frac{f(t + h, u(t + h)) - f(t, u(t))}{h}. $$
Substituting this approximation into the Taylor series, we get:
$$ u(t + h) = u(t) + h u'(t) + \frac{1}{2}(h)^2 \frac{f(t + h, u(t + h)) - f(t, u(t))}{h} + O(h^3), $$
and approximating $u(t + h)$ by removing the higher order term yields Heun's method:
$$ u(t + h) \approx u(t) + \frac{h}{2} [f(t, u(t)) + f(t + h, \tilde{u}_{n+1})]. $$
Consider the differential equation
$$ u'(t) = u(t), $$
with the initial condition $u(0) = 1$. We want to estimate the value of $u$ at $t = 0.1$ using Heun's method with a step size of $h = 0.05$.
First, we calculate the Euler's step (predictor):
$$ \tilde{u} = u(0) + h \cdot f(t, u(0)) = 1 + 0.05 \cdot 1 = 1.05. $$
Then, we correct this estimation:
$$ u(0.05) \approx u(0) + \frac{h}{2} [f(t, u(0)) + f(t + h, \tilde{u}_{n+1})] = 1 + \frac{0.05}{2} [1 + 1.05] = 1.05125. $$
Similarly, we calculate the Euler's step:
$$ \tilde{u} = u(0.05) + h \cdot f(t, u(0.05)) = 1.05125 + 0.05 \cdot 1.05125 = 1.1025625. $$
Then, we correct this estimation:
$$ u(0.1) \approx u(0.05) + \frac{h}{2} [f(t, u(0.05)) + f(t + h, \tilde{u}_{n+1})] = 1.05125 + \frac{0.05}{2} [1.05125 + 1.1025625] = 1.105158203125. $$
So, the approximate solution to $u(0.1)$ with Heun's method is $1.105158203125$.