Romberg Integration
6.3 Romberg Integration
Romberg integration combines the composite trapezoidal rule with Richardson ex- trapolation (see Art. 5.3). Let us first introduce the notation
R i,1 =I i
where, as before, I + b
i represents the approximate value of a f (x)dx computed by the recursive trapezoidal rule using 2 i−1 panels. Recall that the error in this approximation
is E = c 1 h 2 +c 2 h 4 + · · ·, where b−a
h= 2 i−1
is the width of a panel. Romberg integration starts with the computation of R 1,1 =I 1 (one panel) and R 2,1 =I 2 (two panels) from the trapezoidal rule. The leading error term c 1 h 2 is then
eliminated by Richardson extrapolation. Using p = 2 (the exponent in the error term) in Eq. (5.9) and denoting the result by R 2,2 , we obtain
It is convenient to store the results in an array of the form
1,1 R 2,1 R 2,2
The next step is to calculate R 3,1 =I 3 (four panels) and repeat Richardson extra- polation with R 2,1 and R 3,1 , storing the result as R 3,2 :
(b) The elements of array R calculated so far are
Both elements of the second column have an error of the form c 2 h 4 , which can also
be eliminated with Richardson extrapolation. Using p = 4 in Eq. (5.9), we get
(c) This result has an error of O(h 6 ). The array has now expanded to
⎣ R 2,1 R 2,2
After another round of calculations we get
R 4,1 R 4,2 R 4,3 R 4,4 where the error in R 4,4 is O(h 8 ). Note that the most accurate estimate of the integral is always the last diagonal term of the array. This process is continued until the differ-
ence between two successive diagonal terms becomes sufficiently small. The general extrapolation formula used in this scheme is
4 j−1 R
i, j−1 −R i−1, j−1
= i, j
i > 1,
j = 2, 3, . . . , i (6.13a)
4 j−1
A pictorial representation of Eq. (6.13a) is
R i−1, j−1 ց
(6.13b)
ց R i, j−1 →β→R i, j
where the multipliers α and β depend on j in the following manner:
−1/3 (6.13c) −1/15 −1/63 −1/255 −1/1023
64/63 256/255 1024/1023 The triangular array is convenient for hand computations, but computer imple-
mentation of the Romberg algorithm can be carried out within a one-dimensional array r. After the first extrapolation—see Eq. (a)—R 1,1 is never used again, so that it can be replaced with R 2,2 . As a result, we have the array
1 =R 2,2 r 2 =R 2,1
In the second extrapolation round, defined by Eqs. (b) and (c), R 3,2 overwrites R 2,1 , and R 3,3 replaces R 2,2 , so that the array now contains
1 =R 3,3
⎣ r 2 =R 3,2 ⎥ ⎦ r 3 =R 3,1
and so on. In this manner, r 1 always contains the best current result. The extrapolation formula for the kth round is
4 k− j r
j+1 −r j
The algorithm for Romberg integration is implemented in the function romberg . It returns the value of the integral and the required number of function evaluations. Richardson’s extrapolation is performed by the subfunction richardson .
function [I,numEval] = romberg(func,a,b,tol,kMax) % Romberg integration. % USAGE: [I,numEval] = romberg(func,a,b,tol,kMax) % INPUT: % func
= handle of function being integrated. % a,b
= limits of integration. % tol
= error tolerance (default is 1.0e-8). % kMax
= limit on the number of panel doublings
% (default is 20). % OUTPUT: %I
= value of the integral. % numEval = number of function evaluations.
if nargin < 5; kMax = 20; end if nargin < 4; tol = 1.0e-8; end r = zeros(kMax); r(1) = trapezoid(func,a,b,0,1); rOld = r(1); for k = 2:kMax
r(k) = trapezoid(func,a,b,r(k-1),k); r = richardson(r,k); if abs(r(1) - rOld) < tol
numEval = 2ˆ(k-1) + 1; I = r(1); return
end rOld = r(1);
end error(’Failed to converge’)
function r = richardson(r,k) % Richardson’s extrapolation in Eq. (6.14). for j = k-1:-1:1
c = 4ˆ(k-j); r(j) = (c*r(j+1) - r(j))/(c-1); end
EXAMPLE 6.5 Show that R k,2 in Romberg integration is identical to the composite Simpson’s 1/3 rule
in Eq. (6.10) with 2 k−1 panels. Solution Recall that in Romberg integration R k,1 =I k denoted the approximate in-
tegral obtained by the composite trapezoidal rule with 2 k−1 panels. Denoting the abscissas of the nodes by x 1 , x 2 ,..., x n , we have from the composite trapezoidal rule in Eq. (6.5)
2 2 When we halve the number of panels (panel width 2h), only the odd-numbered ab-
i=2
scissas enter the composite trapezoidal rule, yielding
n−2
R k−1,1 =I k−1 =
Applying Richardson extrapolation yields
R k,2 = R
3 k,1 − R 3 k−1,1
3 n ) i=2,4,... h
which agrees with Simpson’s rule in Eq. (6.10). EXAMPLE 6.6
Use Romberg integration to evaluate + π
0 f (x) dx, where f (x) = sin x. Work with four decimal places.
Solution From the recursive trapezoidal rule in Eq. (6.9b) we get
R 1,1 = I (π) =
2 [ f (0) + f (π)] = 0
R 2,1 = I (π/2) =
2 I (π ) + 2 f (π /2) = 1.5708
R 3,1 = I (π/4) =
2 I (π /2) + [ f (π /4) + f (3π/4)] = 1.8961 4
R 4,1 = I (π/8) = [ f (π /8) + f (3π/8) + f (5π/8) + f (7π/8)]
2 I (π /4) + 8
Using the extrapolation formulas in Eqs. (6.13), we can now construct the following table:
R 4,1 R 4,2 R 4,3 R 4,4 1.9742 2.0003 2.0000 2.0000 + It appears that the procedure has converged. Therefore, π
0 sin x dx = R 4,4 = 2.0000, which is, of course, the correct result.
EXAMPLE 6.7
Use Romberg integration to evaluate 0 2x 2 cos x 2 dx and compare the results with Example 6.4.
Solution
>> format long >> [Integral,numEval] = romberg(@fex6 _ 7,0,sqrt(pi)) Integral =
-0.89483146948416 numEval = 257 >>
Here the M-file defining the function to be integrated is
function y = fex6 _ 7(x) % Function used in Example 6.7 y = 2*(xˆ2)*cos(xˆ2);
It is clear that Romberg integration is considerably more efficient than the trape- zoidal rule. It required 257 function evaluations as compared to 4097 evaluations with the composite trapezoidal rule in Example 6.4.
PROBLEM SET 6.1
0 ln(1 + tan x)dx. Explain the results.
1. Use the recursive trapezoidal rule to evaluate + π/ 4
2. The table shows the power P supplied to the driving wheels of a car as a function takes for the car to accelerate from 1 m/s to 6 m/s. Use the trapezoidal rule for 2. The table shows the power P supplied to the driving wheels of a car as a function takes for the car to accelerate from 1 m/s to 6 m/s. Use the trapezoidal rule for
, 6s
t=m
(v/P) dv
1s
which can be derived from Newton’s law F = m(dv/dt) and the definition of power P = F v.
v (m/s)
0 1.0 1.8 2.4 3.5 4.4 5.1 6.0 P (kW)
3. Evaluate + 1 −1 cos(2 cos −1 x)dx with Simpson’s 1/3 rule using 2, 4 and 6 panels. Explain the results.
1 (1 + x ) −1 dx with the trapezoidal rule using five panels and com- pare the result with the “exact” integral 0.243 75. Hint: use the transformation
4. Determine + ∞
x 3 = 1/t.
The table below gives the pull F of the bow as a function of the draw x. If the bow is drawn 0.5 m, determine the speed of the 0.075-kg arrow when it leaves the bow. Hint: the kinetic energy of arrow equals the work done in drawing the bow; that
0 f (x) dx as accurately as possible, where f (x) is defined by the data
f (x) 1.0000 0.3431 0.2500 0.3431 1.0000
8. Evaluate
, 1 sin x √ dx
with Romberg integration. Hint: use transformation of variable to eliminate the indeterminacy at x = 0.
9. Show that if y = f (x) is approximated by a natural cubic spline with evenly spaced
knots at x 1 , x 2 ,..., x n , the quadrature formula becomes
I= (y 1 + 2y 2 + 2y 2 3 + · · · + 2y n−1 +y n )
24 1 + 2k 2 +k 3 + · · · + 2k n−1 +k n ) where h is the spacing of the knots and k = y ′′ . Note that the first part is the
(k
composite trapezoidal rule; the second part may be viewed as a “correction” for curvature.
10. Use a computer program to evaluate
, π/ 4 dx √
0 sin x with Romberg integration. Hint: use the transformation sin x = t 2 .
11. The period of a simple pendulum of length L is τ = 4 L/g h(θ 0 ), where g is the gravitational acceleration, θ 0 represents the angular amplitude and
, π/ 2 dθ h(θ 0 )=
0 1 − sin 2 (θ 0 / 2) sin 2 θ Compute h(15 ◦ ), h(30 ◦ ) and h(45 ◦ ), and compare these values with h(0) = π/2 (the
approximation used for small amplitudes).
rq a P
The figure shows an elastic half-space that carries uniform loading of intensity q over a circular area of radius a. The vertical displacement of the surface at point
P can be shown to be
, π/ 2 cos 2 θ
w(r) = w 0 dθ
r≥a
0 (r/a) 2 − sin 2 θ 0 (r/a) 2 − sin 2 θ
xm b k
The mass m is attached to a spring of free length b and stiffness k. The coefficient of friction between the mass and the horizontal rod is µ. The acceleration of the mass can be shown to be (you may wish to prove this) ¨ x = − f (x), where
f (x) = µg + m (µb + x) 1− √
b 2 +x 2
If the mass is released from rest at x = b, its speed at x = 0 is given by ( , b
v 0 = 2 f (x)dx
Compute v 0 by numerical integration using the data m = 0.8 kg, b = 0.4 m,
µ = 0.3, k = 80 N/m and g = 9.81 m/s 2 .
14. Debye’s formula for the heat capacity C V of a solid is C V = 9Nkg(u), where
, 1/u
g(u) = u
dx
0 (e x − 1) 2
The terms in this equation are N = number of particles in the solid
k = Boltzmann constant
D T = absolute temperature
D = Debye temperature Compute g(u) from u = 0 to 1.0 in intervals of 0.05 and plot the results.
15. A power spike in an electric circuit results in the current
i(t) = i 0 e −t/t 0 sin(2t/t 0 ) i(t) = i 0 e −t/t 0 sin(2t/t 0 )
, ∞ E= 2 R [i(t)] dt
Find E using the data i 0 0 = 0.01 s.