Graphics Programs Reference
In-Depth Information
formulas. The final result isobtainedbyaveraging
y
n
in Eq. (7.26) and the estimate
y
n
≈
y
n
−
1
+
h
F
n
available fromEuler formula:
2
(
y
n
+
y
n
−
1
+
h
F
n
1
y
(
x
0
+
H
)
=
(7.27)
Richardson Extrapolation
It can be shown that the errorinEq. (7.27) is
c
1
h
2
c
2
h
4
c
3
h
6
E
=
+
+
+···
Herein lies the great utility of the midpoint method: wecan eliminate as many of the
leading error terms as we wish by Richardson'sextrapolation. For example, wecould
compute
y
(
x
0
+
H
) with a certain valueof
h
and thenrepeat the process with
h
/
2.
Denoting the corresponding results by
g
(
h
) and
g
(
h
/
2), Richardson'sextrapolation—
see Eq. (5.9)—thenyields the improvedresult
4
g
(
h
/
2)
−
g
(
h
)
y
better
(
x
0
+
H
)
=
3
which isfourth-orderaccurate.Anotherround of integrationwith
h
/
4 followedby
Richardson'sextrapolationget ussixth-orderaccuracy, etc.
The
y
's in Eqs. (7.26) shouldbe viewedas aintermediate variables, because unlike
y
(
x
0
+
H
), they cannot be refinedbyRichardson'sextrapolation.
midpoint
The function
midpoint
in this module combines the midpoint methodwith Richard-
son extrapolation. The first application of the midpoint methoduses two integration
steps. The number of steps is doubledinsuccessive integrations, each integration
being followedbyRichardson extrapolation. The procedure is stoppedwhen twosuc-
cessive solutions differ (in the root-mean-squaresense) by less thanaprescribed
tolerance.
functiony=midpoint(dEqs,x,y,xStop,tol)
% Modified midpoint method for intergration of y' = F(x,y).
%USAGE:y=midpoint(dEqs,xStart,yStart,xStop,tol)
% INPUT:
% dEqs = handle of function that returns the first-order
% differential equations F(x,y) = [dy1/dx,dy2/dx,...].
% x, y = initial values; y must be a row vector.
% xStop = terminal value of x.
% tol
= per-step error tolerance (default = 1.0e-6).
Search WWH ::
Custom Search