Information Technology Reference
In-Depth Information
A typical choice of n i is .b a/=2 i .If is too small, the adaptive algorithm can
run for an unacceptable long time (or forever if is so small that round-off errors
destroy the convergence of the integral as n grows). We should therefore return when
n exceeds a prescribed large value. Algorithm 6.6 lists the pseudo code.
Algorithm 6.6
Adaptive Integration: Repeated Evaluations.
adaptive integration ( a , b , f , I , , n max )
r D I.a; b; f; n 0 /
for n D n 1 ;n 2 ;n 3 ;:::
s D I.a; b; f; n/
if js rj then
return s
else
r D s
end if
if n>n max then
print error message, return s
end if
end for
Another strategy for developing adaptive rules is to base the integration on an
unequal spacing of the evaluation points x i in the interval Œa; b . In the case of
the trapezoidal rule, we introduce evaluation points x i ,where x 0 D a , x n D b ,
and x i <x iC1 , i D 0; n 1 . The trapezoidal rule for unequal spacing can be
expressed as
Z b
f.x/dx n X
iD1
1
2 .x i x i1 /.f .x i1 /C f.x i // :
(6.5)
a
This can be directly expressed in pseudo code. In case f is expensive to evaluate,
we could develop an optimized version where f is evaluated only once at every
point:
Z b
f.x/dx n X
iD1
1
2 .x i x i1 /.f .x i1 / Cf.x i //
(6.6)
a
DC 1
2 .x i x i1 /.f .x i1 / C f.x i //C
(6.7)
1
2 .x iC1 x i /.f .x i /C f.x iC1 // C
(6.8)
 
Search WWH ::




Custom Search