
Numerical Solution of Differential Equations 151
Next we approximate P (1) using one step of the Heun method, the improved
polygon method, and Ralston’s method, and compare absolute errors for each
method. We have h =1,f(t, P )=0.1P
$
1 −
P
500
%
,t
0
=0,P
0
= 300, and the
exact solution P (t)=
150000
300+200 exp (−0.1t)
,soP (1) ≈ 311.8713948706.
Using the Heun method, we obtain
f
1
= f(t
0
,P
0
)=30
$
1 −
300
500
%
=12,
f
2
= f(t
0
+ h, P
0
+ hf
1
)=f(1, 312) = 11.7312,
P
1
= P
0
+ h
$
1
2
f
1
+
1
2
f
2
%
= 300 + 0.5(12 + 11.7312) = 311.8656,
and the absolute error is P
1
− P (1) ≈ 311.8656 − 311.8714 = −0.0058.
The improved polygon method gives
f
1
= f(t
0
,P
0
)=12,
f
2
= f(t
0
+0.5h, P
0
+0.5hf
1
)=f(0.5, 306)