0% found this document useful (0 votes)
7 views3 pages

Addaptive Quadrarture

Notes

Uploaded by

Mayur Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Addaptive Quadrarture

Notes

Uploaded by

Mayur Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

640 INTEGRATION OF EQUATIONS

FUNCTION Romberg (a, b, maxit, es)


LOCAL I(10, 10)
n 5 1
I1,1 5 TrapEq(n, a, b)
iter 5 0
DO
iter 5 iter 1 1
n 5 2iter
Iiter11,1 5 TrapEq(n, a, b)
DOFOR k 5 2, iter 1 1
j 5 2 1 iter 2 k
Ij,k 5 (4k21 * Ij11,k21 2 Ij,k21) y (4k21 2 1)
END DO
FIGURE 22.4
Pseudocode for Romberg ea 5 ABS((I1,iter11 2 I2,iter) y I1,iter11) * 100
integration that uses the IF (iter $ maxit OR ea # es) EXIT
equal-size-segment version of END DO
the trapezoidal rule from Romberg 5 I1,iter11
Fig. 22.1. END Romberg

22.3 ADAPTIVE QUADRATURE


Although Romberg integration is more efficient than the composite Simpson’s 1y3
rule, both use equally spaced points. This global perspective ignores the fact that many
functions have regions of high variability along with other sections where change is
gradual.
Adaptive quadrature methods remedy this situation by adjusting the step size so that
small intervals are used in regions of rapid variations and larger intervals are used where
the function changes gradually. Most of these techniques are based on applying the
composite Simpson’s 1y3 rule to subintervals in a fashion that is very similar to the way
in which the composite trapezoidal rule was used in Richardson extrapolation. That is,
the 1y3 rule is applied at two levels of refinement and the difference between these two
levels is used to estimate the truncation error. If the truncation error is acceptable, no
further refinement is required and the integral estimate for the subinterval is deemed
acceptable. If the error estimate is too large, the step size is refined and the process
repeated until the error falls to acceptable levels. The total integral is then computed as
the summation of the integral estimates for the subintervals.
The theoretical basis of the approach can be illustrated for an interval x 5 a to x 5 b
with a width of h1 5 b 2 a. A first estimate of the integral can be estimated with Simpson’s
1y3 rule,
h1
I(h1 ) 5 ( f(a) 1 4 f(c) 1 f(b)) (22.10)
6
where c 5 (a 1 b)y2.
22.3 ADAPTIVE QUADRATURE 641

As in Richardson extrapolation, a more refined estimate can be obtained by halving the


step size. That is, by applying the multiple-application Simpson’s 1y3 rule with n 5 4,
h2
I(h2 ) 5 ( f(a) 1 4 f(d) 1 2 f(c) 1 4 f(e) 1 f(b)) (22.11)
6
where d 5 (a 1 c)y2, e 5 (c 1 b)y2, and h2 5 h1y2.
Because both I(h1) and I(h2) are estimates of the same integral, their difference
provides a measure of the error. That is,
E > I(h2 ) 2 I(h1 ) (22.12)

In addition, the estimate and error associated with either application can be represented
generally as
I 5 I(h) 1 E(h) (22.13)

where I 5 the exact value of the integral, I(h) 5 the approximation from an n-segment
application of the Simpson’s 1y3 rule with step size h 5 (b 2 a)yn, and E(h) 5 the
corresponding truncation error.
Using an approach similar to Richardson extrapolation, we can derive an estimate
for the error of the more refined estimate, I(h2), as a function of the difference between
the two integral estimates,
1
E(h2 ) 5 [I(h2 ) 2 I(h1 )] (22.14)
15
The error can then be added to I(h2) to generate an even better estimate
1
I 5 I(h2 ) 1 [I(h2 ) 2 I(h1 )] (22.15)
15
This result is equivalent to Boole’s rule.
The equations developed above can now be combined into an efficient algorithm.
Figure 22.5 presents pseudocode for such an algorithm that is based on a MATLAB
software M-file developed by Cleve Moler (2005).
The function consists of a main calling function, quadapt, along with a recursive
function, qstep, that actually performs the integration. As set up in Fig. 22.5, both qadapt
and qstep must have access to another function, f, that evaluates the integrand.
The main calling function, quadapt, is passed the integration limits, a and b. After
setting the tolerance, the function evaluations required for the initial application of Simpson’s
1y3 rule (Eq. 22.10) are computed. These values along with the integration limits are then
passed to qstep. Within qstep, the remaining step sizes and function values are deter-
mined and the two integral estimates (Eqs. 22.10 and 22.11) are computed.
At this point, the error is estimated as the absolute difference between the integral
estimates. Depending on the value of the error, two things can then happen:
1) If the error is less than or equal to the tolerance, Boole’s rule is generated, the func-
tion terminates and the result is returned.
2) If the error is larger than the tolerance, qstep is invoked twice to evaluate each of
the two subintervals of the current call.
642 INTEGRATION OF EQUATIONS

FUNCTION quadapt(a, b) (main calling function)


tol 5 0.000001
c 5 (a 1 b)/2 (initialization)
fa 5 f(a)
fc 5 f(c)
fb 5 f(b)
quadapt 5 qstep(a, b, tol, fa, fc, fb)
END quadapt

FUNCTION qstep(a, b, tol, fa, fc, fb) (recursive function)


h1 5 b 2 a
h2 5 h1/2
c 5 (a 1 b)/2
fd 5 f((a 1 c)/2)
fe 5 f((c 1 b)/2)
I1 5 h1/6 * (fa 1 4 * fc 1 fb) (Simpson’s 1/3 rule)
I2 5 h2/6 * (fa 1 4 * fd 1 2 * fc 1 4 * fe 1 fb)
IF |I2 2 I1| # tol THEN (terminate after Boole’s rule)
I 5 I2 1 (I2 2 I1)/15
ELSE (recursive calls if needed)
Ia 5 qstep(a, c, tol, fa, fd, fc)
FIGURE 22.5 Ib 5 qstep(c, b, tol, fc, fe, fb)
Pseudocode for simplified adap- I 5 Ia 1 Ib
tive quadrature algorithm based END IF
on a MATLAB M-file presented qstep 5 I
in Moler (2005). END qstep

The two recursive calls in the second step represent the real beauty of this algorithm.
They just keep subdividing until the tolerance is met. Once this occurs, their results are
passed back up the recursive path, combining with the other integral estimates along the
way. The process ends when the final call is satisfied and the total integral is evaluated
and returned to the main calling function.
It should be stressed that the algorithm in Fig. 22.5 is a stripped down version of
the quad function which is the professional quadrature function employed in MATLAB.
Thus, it does not guard against failure such as cases where integrals do not exist.
Nevertheless, it works just fine for many applications, and certainly serves to illustrate
how adaptive quadrature works.

22.4 GAUSS QUADRATURE


In Chap. 21, we studied the group of numerical integration or quadrature formulas known
as the Newton-Cotes equations. A characteristic of these formulas (with the exception of
the special case of Sec. 21.3) was that the integral estimate was based on evenly spaced
function values. Consequently, the location of the base points used in these equations
was predetermined or fixed.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy