Page 285 - Applied Numerical Methods Using MATLAB
P. 285
274 ORDINARY DIFFERENTIAL EQUATIONS
Hamming method with modification formulas
4h
Predictor: p k+1 = y k−3 + (2f k−2 − f k−1 + 2f k ) (6.4.9a)
3
112
Modifier: m k+1 = p k+1 + (c k − p k ) (6.4.9b)
121
1
Corrector: c k+1 = {9y k − y k−2 + 3h(−f k−1 + 2f k + f(t k+1 , m k+1 ))}(6.4.9c)
8
9
y k+1 = c k+1 − (c k+1 − p k+1 ) (6.4.9d)
121
In this section, we introduce just the algorithm of the Hamming method [H-1]
summarized in the box above and the corresponding routine “ode_Ham()”, which
is another multistep predictor–corrector method like the Adams–Bashforth–
Moulton (ABM) method.
This scheme also needs only two function evaluations (calls) per iteration,
5
while having the error of O(h ) and so is comparable with the ABM method
discussed in the previous section.
6.4.3 Comparison of Methods
The major factors to be considered in evaluating/comparing different numeri-
cal methods are the accuracy of the numerical solution and its computation
time. In this section, we will compare the routines “ode_RK4()”, “ode_ABM()”,
“ode_Ham()”, “ode23()”, “ode45()”, and “ode113()” by trying them out on
the same differential equations, hopefully to make some conjectures about their
performances. It is important to note that the evaluation/comparison of numer-
ical methods is not so simple because their performances may depend on the
characteristic of the problem at hand. It should also be noted that there are other
factors to be considered, such as stability, versatility, proof against run-time
error, and so on. These points are being considered in most of the MATLAB
built-in routines.
The first thing we are going to do is to validate the effectiveness of the mod-
ifiers (Eqs. (6.4.8b,d) and (6.4.9b,d)) in the ABM (Adams–Bashforth–Moulton)
method and the Hamming method. For this job, we write and run the program
“nm643_1.m” to get the results depicted in Fig. 6.3 for the differential equation
y (t) =−y(t) + 1 with y(0) = 0 (6.4.10)
which was given at the beginning of this chapter. Fig. 6.3 shows us an interesting
fact that, although the ABM method and the Hamming method, even without
modifiers, are theoretically expected to have better accuracy than the RK4 (fourth-
order Runge–Kutta) method, they turn out to work better than RK4 only with
modifiers. Of course, it is not always the case, as illustrated in Fig. 6.4, which