Topic 14.2: Heun's Method (Examples)

Contents Previous Chapter Start of Chapter Previous Topic Introduction Notes Theory HOWTO Examples Engineering Error Questions Matlab Maple Next Topic Next Chapter

Example 1

Given the IVP y(1)(t) = 1 - t y(t) with y(0) = 1, approximate y(1) with one step.

First, let t0 = 0, y0 = 1, and h = 1. Thus, we calculate

K0 = f(0, 1) = 1
K1 = f(1, 2) = -1
½(K0 + K1) = 0

Therefore, approximation is y1 = y0 + h = 1 + 1⋅0 = 1. The actual value is 1.331309118 and therefore the absolute error is approximately 0.331, or approximately half that of what we found using Euler's method.

Example 2

Given the same IVP shown in Example 1, approximate y(0.5).

K0 = f(0, 1) = 1
K1 = f(0.5, 1.5) = 0.25
½(K0 + K1) = 0.625

Therefore, approximation is y1 = y0 + h = 1 + 0.5⋅0.625 = 1.3125. The actual value is 1.342841185 and therefore the absolute error is approximately 0.0303, or approximately 1/8 the error when we used h = 1.

Example 3

Repeat Examples 1 and 2 but with with the initial value y(0.5) = 2.5 and approximating y(1.5) and y(1.0).

First, let t0 = 0.5, y0 = 2.5, and h = 1. Therefore

K0 = f(0.5, 2.5) = -0.25
K1 = f(1.5, 2.5 - 1 ⋅ 0.25) = -2.375
½(K0 + K1) = -1.3125

Therefore, our approximation is y1 = y0 + h(-1.3125) = 2.5 + 1(-1.3125) = 1.1875. The actual value is 1.502483616 and therefore the absolute error is approximately 0.315.

Next, let t0 = 0.5, y0 = 2.5, and h = 0.5. Therefore

K0 = f(0.5, 2.5) = -0.25
K1 = f(1.5, 2.5 - 1 ⋅ 0.25) = -1.375
½(K0 + K1) = -0.8125

Therefore, our approximation is y1 = y0 + h(-0.8125) = 2.5 + 0.5 (-0.8125) = 2.09375. The actual value is 2.126611964 and therefore the absolute error is approximately 0.0329. Again, the error is approximately 1/8th that of the previous calculation where h = 1.

If we tabulate the errors for various values of h, as is shown in Table 1, we note that as h gets smaller, the error drops by almost exactly 1/8 each time we divide h by two.

Table 1. Errors when approximating y(t0 + h) for decreasing values of h.

hApproximation
of y(0.5 + h)
Error
11.18750.315
0.52.093750.0329
0.252.3652343750.00338
0.1252.4504394531250.000366
0.06262.4797668460.0000421
0.031252.4910316470.00000502
0.016252.4958043100.000000612
0.00781252.4979744550.0000000755
0.003906252.4990053250.00000000937

You will note that with each step, the error goes down by approximately a factor of 1/8.

Copyright ©2005 by Douglas Wilhelm Harder. All rights reserved.