Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
74 views

Solution of Nonlinear Equations F (X) 0: Professor Henry Arguello

This document is a chapter outline from a numerical methods textbook authored by Professor Henry Arguello of Universidad Industrial de Santander in Colombia. The chapter introduces numerical integration or quadrature formulas for approximating definite integrals. It defines quadrature formulas and their degree of precision. The first four closed Newton-Cotes quadrature formulas are the trapezoidal rule, Simpson's rule, Simpson's 3/8 rule, and Boole's rule along with their degree of precision.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

Solution of Nonlinear Equations F (X) 0: Professor Henry Arguello

This document is a chapter outline from a numerical methods textbook authored by Professor Henry Arguello of Universidad Industrial de Santander in Colombia. The chapter introduces numerical integration or quadrature formulas for approximating definite integrals. It defines quadrature formulas and their degree of precision. The first four closed Newton-Cotes quadrature formulas are the trapezoidal rule, Simpson's rule, Simpson's 3/8 rule, and Boole's rule along with their degree of precision.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 90

Solution of Nonlinear Equations f (x) = 0

Professor Henry Arguello

Universidad Industrial de Santander


Colombia

March 19, 2014

High Dimensional Signal Processing Group


www.hdspgroup.com
henarfu@uis.edu.co

Professor Henry Arguello Numerical methods March 19, 2014 1 / 81


Outline: Chapter 7

1 Introduction to Quadrature

2 Composite Trapezoidal and Simpson’s Rule

3 Recursive Rules and Romberg Integration

4 Gauss-Legendre Integration

Professor Henry Arguello Numerical methods March 19, 2014 2 / 81


Introduction to Quadrature
We now approach the subject of numerical integration. The goal is to
approximate the definite integral of f (x) over the interval [a, b] by
evaluating f (x) at a finite number of sample points.

Definition 7.1
Suppose that a = x0 < x1 < · · · < xM = b. A formula of the form.
M
X
Q[f ] = wk f (xk ) = w0 f (x0 ) + wq f (x1 ) + · · · + wM f (xM ) (1)
k=0

with the property that Z b


f (x)dx = Q[f ] + E[f ] (2)
a

is called a numerical integration or quadrature formula. The term E[f ]


 M
is called the truncation error for integration. The values xk k=0 are
 M
called the quadrature nodes, and wk k=0 are called the weights.

Professor Henry Arguello Numerical methods March 19, 2014 3 / 81


Introduction to Quadrature

Depending on the application, the nodes {xk } are chosen in various


ways. For the trapezoidal rule, Simpson’s rule, and Boole’s rule, the
nodes are chosen to be equally spaced. For Gauss-Legendre
quadrature, the nodes are chosen to be zeros of certain Legendre
polynomials. When the integration formula is used to develop a
predictor formula for differential equations, all the nodes are chosen
less than b. For all applications, it is necessary to know something
about the accuracy of the numerical solution.

Professor Henry Arguello Numerical methods March 19, 2014 4 / 81


Introduction to Quadrature

Definition 7.2
The degree of precision of a quadrature formula is the positive
integer n such that E[Pi ] = 0 for all polynomials Pi (x) of degree i ≤ n,
but for which E[Pn+1 ] 6= 0 for some polynomial Pn+1 (x) of degree n + 1.
The form of E[Pi ] can be anticipated by studying what happens when
f (x) is a polynomial. Consider the arbitrary polynomial
Pi (x) = ai xi + ai−1 xi−1 + · · · + a1 x + a0
(n+1) (n+1)
of degree i. If i ≤ n, then Pi (x) ≡ 0 for all x, and Pn+1 (x) = (n + 1)!
an−1 for all x. Thus it is not surprising that the general form for the
truncation error term is
E[ f ] = Kf (n+1) (c), (3)
where K is a suitably chosen constant and n is the degree of precision.

Professor Henry Arguello Numerical methods March 19, 2014 5 / 81


Introduction to Quadrature

The derivation of quadrature formula is sometimes based on


polynomial interpolation. Recall that there exists a unique polynomial
PM (x) of degree ≤ M passing through the M + 1 equally spaced points
(xk , f (xk ))M
k=0 . When this polynomial is used to approximate f (x) over
[a, b],and then the integral of f (x) is approximated by the integral of
PM (x), the resulting formula is called a Newton-Cotes quadrature
formula (see figure). When the sample points x0 = a and xM = b are
used, it is called a closed Newton-Cotes formula.

Professor Henry Arguello Numerical methods March 19, 2014 6 / 81


Introduction to Quadrature
y y

1.5 1.5
y=f(x) y=f(x)
1.0 1.0

0.5 0.5

x x
0.0 0.5 1.0 1.5 2.0 0.0 0.5 1.0 1.5 2.0

: :
y y

1.5 1.5
y=f(x) y=f(x)
1.0 1.0

0.5 0.5

x x
0.0 0.5 1.0 1.5 2.0 0.0 0.5 1.0 1.5 2.0

: :

Figure 7.2: (a) The trapezoidal rule integrates y = P1 (x) over


[x0 , xProfessor
1 ] = [0.0, Arguello(b) Simpson’s Numerical
Henry 0.5]. rule integrates
methods y = P2 (x) over March 19, 2014 7 / 81
Introduction to Quadrature

Theorem 7.1 (Closed Newton-Cotes Quadrature Formula).


Assume that xk = x0 + kh are equally spaced nodes and fk = f (xk ). The
first four closed Newton-Cotes quadrature formulas are
Z x1
h
f (x) dx ≈ ( f0 + f1 ) (trapezoidal rule), (4)
x 2
Z 0x2
h
f (x) dx ≈ ( f0 + 4f1 + f2 ) (Simpson’s rule), (5)
x 3
Z 0x3
3h 3
f (x) dx ≈ ( f0 + 3f1 + 3f2 + f3 ) (Simpson’s rule), (6)
x 8 8
Z 0x4
2h
f (x) dx ≈ (7f0 + 32f1 + 12f2 + 32f3 + 7f4 ) (Boole’s rule) (7)
x0 45

Professor Henry Arguello Numerical methods March 19, 2014 8 / 81


Introduction to Quadrature

Corollary 7.1 (Newton-Cotes Precision).


Assume that f (x) is sufficiently differentiable; then E[ f ] for
Newton-Cotes quadrature involves an appropriate higher derivative.
The trapezoidal rule has degree of precision n = 1. If f ∈ C2 [a, b], then
x1
h3
Z
h
f (x) dx = (f0 + f1 ) − f (2) (c). (8)
x0 2 12

Simpson’s rule has degree of precision n = 3. If f ∈ C4 [a, b], then


x2
h5
Z
h
f (x) dx = (f0 + 4f1 + f2 ) − f (4) (c). (9)
x0 3 90

Professor Henry Arguello Numerical methods March 19, 2014 9 / 81


Introduction to Quadrature

Corollary 7.1 (Newton-Cotes Precision).


3
Simpson’s 8 rule has degree of precision n = 3. If f ∈ C4 [a, b], then
x3
3h5 (4)
Z
3h
f (x) dx = (f0 + 3f1 + 3f2 + f3 ) − f (c). (10)
x0 8 80

Boole’s rule has degree of precision n = 5. If f ∈ C6 [a, b], then


x4
8h7 (6)
Z
2h
f (x) dx = (7f0 + 32f1 + 12f2 + 32f3 + 7f4 ) − f (c). (11)
x0 45 945

Professor Henry Arguello Numerical methods March 19, 2014 10 / 81


Introduction to Quadrature
proof of theorem 7.1
Start with the Lagrange polynomial PM (x) based on x0 , x1 , ..., xM that
can be used to approximate f (x) :
M
X
f (x) ≈ PM (x) = fk LM,k (x), (12)
k=0

where fk = f (xk ) for k = 0, 1, ..., M. An approximation for the integral is


obtained by replacing the integral f (x) with the polynomial PM (x). This
is the general method for obtaining a Newton-Cotes integration
formula:
Z xM Z xM
f (x) dx ≈ PM (x) dx
x0 x0
M
! M Z
Z xM X X xM 
= fk LM,k (x) dx = fk LM,k (x) dx (13)
x0 k=0 k=0 x0

M Z
X xM  M
X
= LM,k (x) dx fk = wk fk .
k=0 x0 k=0

Professor Henry Arguello Numerical methods March 19, 2014 11 / 81


Introduction to Quadrature

The details for the general computations of the coefficients of wk in (13)


are tedious. We shall give a sample proof of Simpson’s rule, which is
the case M = 2. This case involves the approximating polynomial
(x − x1 )(x − x2 ) (x − x0 )(x − x2 ) (x − x0 )(x − x1 )
P2 (x) = f0 + f1 + f2 . (14)
(x0 − x1 )(x0 − x2 ) (x1 − x0 )(x1 − x2 ) (x2 − x0 )(x2 − x1 )

Since f0 , f1 , and f2 are constants with respect to integration, the


relations in (13) lead to
Z x2 Z x2 Z x2
(x − x1 )(x − x2 ) (x − x0 )(x − x2 )
f (x) dx ≈ f0 dx + f1 dx
x0 x0 (x0 − x1 )(x0 − x2 ) x0 (x1 − x0 )(x1 − x2 )
Z x2
(x − x0 )(x − x1 )
+f2 dx. (15)
x0 (x2 − x0 )(x2 − x1 )

Professor Henry Arguello Numerical methods March 19, 2014 12 / 81


Introduction to Quadrature

We introduce the change of variable x = x0 + ht with dx = h dt to assist


with the evaluation of the integrals in (15). The new limits of integration
are from t = 0 to t = 2. The equal spacing of the nodes xk = x0 + kh
leads to xk − xj = (k − j)h and x − xk = h(t − k), which are used to
simplify (15) and get

Professor Henry Arguello Numerical methods March 19, 2014 13 / 81


Introduction to Quadrature

Z x2 Z 2 Z 2
h(t − 1)h(t − 2) h(t − 0)h(t − 2)
f (x) dx ≈ f0 h dt + f1 h dt (16)
x0 0 (−h)(−2h) 0 (h)(−h)
Z 2
h(t − 0)h(t − 1)
+f2 h dt
0 (2h)(h)
Z 2 Z 2 Z 2
h h
= f0 (t2 − 3t + 2) dt − f1 h (t2 − 2t)dt + f2 (t2 − t) dt
2 0 0 2 0
t=2 t=2
t3 3t2
  3
h t
= f0 − + 2t − f1 h − t2
2 3 2 t=0 3 t=0
2 t=2
 3 
h t t
+f2 −
2 3 2 t=0
     
h 2 −4 h 2
= f0 − f1 h + f2
2 3 3 2 3
h
= (f0 + 4f1 + f2 )
3
and the proof is complete.
Professor Henry Arguello Numerical methods March 19, 2014 14 / 81
Introduction to Quadrature
Example 7.1 Consider the function f (x) = 1 + e−x sin(4x), the equally
spaced quadrature nodes x0 = 0.0, x1 = 0.5, x2 = 1.0, x3 = 1.5, and
x4 = 2.0, and the corresponding function values
f0 = 1.00000, f1 = 1.55152, f2 = 0.72159, f3 = 0.93765, and f4 = 1.13390.
Apply the various quadrature formulas (4) through (7).

Professor Henry Arguello Numerical methods March 19, 2014 15 / 81


Introduction to Quadrature
Example 7.1 Consider the function f (x) = 1 + e−x sin(4x), the equally
spaced quadrature nodes x0 = 0.0, x1 = 0.5, x2 = 1.0, x3 = 1.5, and
x4 = 2.0, and the corresponding function values
f0 = 1.00000, f1 = 1.55152, f2 = 0.72159, f3 = 0.93765, and f4 = 1.13390.
Apply the various quadrature formulas (4) through (7).
The step size is h = 0.5, and the computations are
Z 0.5
0.5
f (x) dx ≈ (1.00000 + 1.55152) = 0.63788
0 2
Z 1.0
0.5
f (x) dx ≈ (1.00000 + 4(1.55152) + 0.72159) = 1.32128
0 3
Z 1.5
3(0.5)
f (x) dx ≈ (1.00000 + 3(1.55152) + 3(0.72159) + 0.93765)
0 8
= 1.64193
Z 2.0
2(0.5)
f (x) dx ≈ (7(1.00000) + 32(1.55152) + 12(0.72159)
0 45
+32(0.93765) + 7(1.13390)) = 2.29444.

Professor Henry Arguello Numerical methods March 19, 2014 15 / 81


Introduction to Quadrature

It is important to realize that the quadrature formulas (4) through (7)


applied in the illustration above give approximations for definite
integrals over different intervals. The graph of the curve y = f (x) and
the areas under the Lagrange polynomials
y = P1 (x), y = P2 (x), y = P3 (x), and y = P4 (x) are shown in Figure
7.2(a) through (d), respectively.
In Example 7.1 we applied the quadrature rules with h = 0.5. If the
endpoints of the interval [a, b] are held fixed, the step size must be
adjusted for each rule. The step sizes are
h = b − a, h = (b − a)/2, h = (b − a)/3, and h = (b − a)/4 for the
trapezoidal rule, Simpson’s rule, Simpson’s 38 rule, and Boole’s rule,
respectively.The next example illustrates this point.

Professor Henry Arguello Numerical methods March 19, 2014 16 / 81


Introduction to Quadrature

Example 7.2 Consider the integration of the function


f (x) = 1 + e−x sin(4x) over the fixed interval [a, b] = [0, 1]. Apply the
various formulas (4) through (7).

Professor Henry Arguello Numerical methods March 19, 2014 17 / 81


Introduction to Quadrature

Example 7.2 Consider the integration of the function


f (x) = 1 + e−x sin(4x) over the fixed interval [a, b] = [0, 1]. Apply the
various formulas (4) through (7).
For the trapezoidal rule, h=1 and
Z 1
1
f (x) dx ≈ (f (0) + f (1))
0 2
1
= (1.00000 + 0.72159) = 0.86079.
2

Professor Henry Arguello Numerical methods March 19, 2014 17 / 81


Introduction to Quadrature

Example 7.2 Consider the integration of the function


f (x) = 1 + e−x sin(4x) over the fixed interval [a, b] = [0, 1]. Apply the
various formulas (4) through (7).
For the trapezoidal rule, h=1 and
Z 1
1
f (x) dx ≈ (f (0) + f (1))
0 2
1
= (1.00000 + 0.72159) = 0.86079.
2
For Simpson’s rule, h = 1/2, and we get
Z 1
1/2 1
f (x) dx ≈ (f (0) + 4f ( ) + f (1))
0 3 2
1
= (1.00000 + 4(1.55152) + 0.72159) = 1.32128.
6

Professor Henry Arguello Numerical methods March 19, 2014 17 / 81


Introduction to Quadrature

3
For Simpson’s 8 rule, h = 1/3, and we obtain
Z 1
3(1/3) 1 2
f (x) dx ≈ (f (0) + 3f ( ) + 3f ( ) + f (1))
0 8 3 3
1
= (1.00000 + 3(1.69642) + 3(1.23447) + 0.72159) = 1.31440
8

Professor Henry Arguello Numerical methods March 19, 2014 18 / 81


Introduction to Quadrature

3
For Simpson’s 8 rule, h = 1/3, and we obtain
Z 1
3(1/3) 1 2
f (x) dx ≈ (f (0) + 3f ( ) + 3f ( ) + f (1))
0 8 3 3
1
= (1.00000 + 3(1.69642) + 3(1.23447) + 0.72159) = 1.31440
8
For Boole’s rule, h = 1/4, and the result is
Z 1
2(1/4) 1 1 3
f (x) dx ≈ (7f (0) + 32f ( ) + 12f ( ) + 32f ( ) + 7f (1))
0 45 4 2 4
1
= (7(1.00000) + 32(1.65534) + 12(1.55152)
90
+32(1.06666) + 7(0.72159)) = 1.30859.

Professor Henry Arguello Numerical methods March 19, 2014 18 / 81


Introduction to Quadrature

The true value of the definite integral is


Z 1
21e − 4cos(4) − sin(4)
f (x) dx = = 1.3082506046426...,
0 17e

and the approximation 1.30859 from Boole’s rule is best. The area
under each of the Lagrange polynomials P1 (x), P2 (x), P3 (x), and P4 (x)
is shown in Figure 7.3(a) through (d), respectively.

Professor Henry Arguello Numerical methods March 19, 2014 19 / 81


Introduction to Quadrature
y y
y=f(x) y=f(x)
1.5 1.5

1.0 1.0

0.5 0.5

x x
0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0
y y
y=f(x) y=f(x)
1.5 1.5

1.0 1.0

0.5 0.5

x x
0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0

Figure 7.2: (a) The trapezoidal rule used over [0, 1] yields the approximation
0.86079. (b) Simpson’s rule used over [0, 1] yields the approximation 1.32128.
(c) Simpson’s 38 rule used over [0, 1] yields the approximation 1.31440. (d)
Boole’s rule used over [0, 1] yields the approximation 1.30859.

Professor Henry Arguello Numerical methods March 19, 2014 20 / 81


Introduction to Quadrature

To make a fair comparison of quadrature methods, we must use the


same number of function evaluations in each method. Our final
example is concerned with comparing integration over a fixed interval
[a, b] using exactly five function evaluations fk = f (xk ),for k = 0, 1, ..., 4
for each method. when the trapezoidal rule is applied on the four
subintervals [x0 , x1 ], [x1 , x2 ], [x2 , x3 ], and [x3 , x4 ], it is called a composite
trapezoidal rule:
Z x4 Z x1 Z x2 Z x3 Z x4
f (x) dx = f (x) dx + f (x) dx + f (x) dx + f (x) dx
x0 x0 x1 x2 x3
h h h h
≈ (f0 + f1 ) + (f1 + f2 ) + (f2 + f3 ) (f3 + f4 ) (17)
2 2 2 2
h
= (f0 + 2f1 + 2f2 + 2f3 + f4 ).
2

Professor Henry Arguello Numerical methods March 19, 2014 21 / 81


Introduction to Quadrature

Simpson’s rule can also be used in this manner. When Simpson’s rule
is applied on the two subintervals [x0 , x2 ] and [x2 , x4 ], it is called a
composite Simpson’s rule:
Z x4 Z x2 Z x4
f (x) dx = f (x) dx + f (x) dx
x0 x0 x2
h h
≈ (f0 + 4f1 + f2 ) + (f2 + 4f3 + f4 ) (18)
3 3
h
= (f0 + 4f1 + 2f2 + 4f3 + f4 )..
3
The next example compares the values obtained with (17), (18), and
(7).

Professor Henry Arguello Numerical methods March 19, 2014 22 / 81


Introduction to Quadrature
Example 7.3 Consider the integration of the function
f (x) = 1 + e−x sin(4x) over [a, b] = [0, 1]. Use exactly five function
evaluations and compare the results from the composite trapezoidal
rule, composite Simpson rule, and Boole’s rule.
The uniform step size is h = 1/4. The composite trapezoidal rule (17)
produces
Z 1
1/4 1 1 3
f (x) dx ≈ (f (0) + 2f ( ) + 2f ( ) + 2f ( ) + f (1))
0 2 4 2 4
1
= (1.00000 + 2(1.65534) + 2(1.55152) + 2(1.06666) + 0.72159)
8
= 1.28358.
Using the composite Simpson’s rule (18), we get
Z 1
1/4 1 1 3
f (x) dx ≈ (f (0) + 4f ( ) + 2f ( ) + 4f ( ) + f (1))
0 3 4 2 4
1
= (1.00000 + 4(1.65534) + 2(1.55152) + 4(1.06666) + 0.72159)
12
= 1.30938.
Professor Henry Arguello Numerical methods March 19, 2014 23 / 81
Introduction to Quadrature

We have already seen the result of Boole’s rule in Example 7.2:


Z 1
2(1/4) 1 1 3
f (x) dx ≈ (7f (0) + 32f ( ) + 12f ( ) + 32f ( ) + 7f (1))
0 45 4 2 4
= 1.30859.

The true value of the integral is


Z 1
21e − 4cos(4) − sin(4)
f (x) dx = = 1.3082506046426...,
0 17e

and the approximation 1.30938 from Simpson’s rule is much better than
the value 1.28358 obtained from the trapezoidal rule. Again, the
approximation 1.30859 from Boole’s rule is closest. Graphs for the
areas under the trapezoids and parabolas are shown in Figure 7.4(a)
and (b), respectively.

Professor Henry Arguello Numerical methods March 19, 2014 24 / 81


Introduction to Quadrature

y y

1.5 y=f(x) 1.5 y=f(x)

1.0 1.0

0.5 0.5

t t
0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00

: :

Figure 7.4: (a) The composite trapezoidal rule yields the approximation
1.28358. (b) The composite Simpson rule yields the approximation 1.30938.

Professor Henry Arguello Numerical methods March 19, 2014 25 / 81


Introduction to Quadrature
3
Example 7.4 Determine the degree of precision of Simpson’s 8 rule.
It will suffice to apply Simpson’s 38 rule over the interval [0, 3] with the
five test functions f (x) = 1, x, x2 , x3 ,and x4 . For the first four functions,
Simpson’s 38 rule is exact.
Z 3
3
1 dx = 3= (1 + 3(1) + 3(1) + 1)
0 8
Z 3
9 3
x dx = = (0 + 3(1) + 3(2) + 3)
0 2 8
Z 3
3
x2 dx = 9= (0 + 3(1) + 3(4) + 9)
0 8
Z 3
81 3
x3 dx = = (0 + 3(1) + 3(8) + 27).
0 4 8
The function f (x) = x4 is the lowest power of x for which the rule is not
exact. Z 3
243 99 3
x4 dx = ≈ = (0 + 3(1) + 3(16) + 81).
0 5 2 8
Therefore, the degree of precision of Simpson’s 3/8 rule is n = 3.
Professor Henry Arguello Numerical methods March 19, 2014 26 / 81
Composite Trapezoidal and Simpson’s Rule
An intuitive method of finding the area under the curve y = f (x) over
[a, b] is by approximating that area with a series of trapezoids that lie
above the intervals {[xk , xk+1 ]}.
Theorem 7.2 (Composite trapezoidal rule
Suppose that the interval [a, b] is subdivided into M subintervals
[xk , xk+1 ] of width h = (b − a)/M by using the equally spaced nodes
xk = a + kh, for k = 0, 1, ..., M. The composite trapezoidal rule for M
subintervals can be expressed in any of three equivalent ways
M
hX
(1a) T(f , h) = (f (xk−1 ) + f (xk ))
2
k=1

h
(1b) T(f , h) = (f0 + 2f1 + 2f2 + 2f3 + ... + 2fM−2 + 2fM−1 + fM )
2
M−1
h X
(1c) T(f , h) = (f (a) + f (b)) + h (f (xk ))
2
k=1
Professor Henry Arguello Numerical methods March 19, 2014 27 / 81
Composite Trapezoidal and Simpson’s Rule

This is an approximation to the integral of f (x) over [a, b] and we write


Z b
(2) f (x)dx ≈ T(f , h)
a

Proof. Apply the trapezoidal rule over each subinterval [xk−1 , xk ]. Use
the additive property of integral for subintervals
Z b M Z xk M
X hX
(3) f (x)dx = f (x)dx ≈ (f (xk−1 ) + f (xk )
a xk−1 2
k=1 k=1

Since h/2 is a constant, the distributive law of addition can be applied to


obtain (1a). Formula (1b) is the expanded version of (1a). Formula (1c)
shows how to group all the intermediate terms in (1b) that are multiplied
by 2.

Professor Henry Arguello Numerical methods March 19, 2014 28 / 81


Composite Trapezoidal and Simpson’s Rule

Example. Consider f (x) = 2 + sin(2 x). Use the composite trapezoidal
rule with 11 sample points to compute an approximation to the integral
of f (x) taken over [1, 6]. To generate 11 sample points we use M = 10
and h = (6 − 1)/10 = 1/2. Using formula (1c), the computation is
T(f , 12 ) =
1/2 1 3 5 7 9 11
2 (f (1)+f (6))+ 2 (f ( 2 )+f (2)+f ( 2 )+f (3)+f ( 2 )+f (4)+f ( 2 )+f (5)+f ( 2 ))

1 1
= (2.90929743 + 1.01735756) + (2.63815764 + 2.30807174 + 1.97931647
4 2

+1.68305284+1.43530410+1.24319750+1.10831775+1.02872220+1.00024140)

1 1
= (3.92665499) + (14.42438165) = 0.98166375 + 7.21219083 = 8.19385457
4 2

Professor Henry Arguello Numerical methods March 19, 2014 29 / 81


Composite Trapezoidal and Simpson’s Rule
Theorem 7.3 (Composite Simpson Rule)
Suppose that [a, b] is subdivided into 2M subintervals [xk , xk+1 ] of equal width
h = (b − a)/2M by using xk = a + kh for k = 0, 1, ..., 2M. The composite
Simpson rule for 2M subintervals can be expressed in any of three equivalent
ways:
M
hX
(4a) S(f , h) = (f (x2k−2 ) + 4f (x2k−1 ) + f (x2k ))
3
k=1

h
(4b) S(f , h) = (f0 + 4f1 + 2f2 + 4f3 + ... + 2fM−2 + 4fM−1 + fM )
3
M−1 M
h 2h X 4h X
(4c) S(f , h) = (f (a) + f (b)) + f (x2k ) + f (x2k−1 )
3 3 3
k=1 k=1

This is an approximation to the integral of f (x) over [a, b], and we write
Z b
(5) f (x)dx ≈ S(f , h)
a
Professor Henry Arguello Numerical methods March 19, 2014 30 / 81
Composite Trapezoidal and Simpson’s Rule

Proof. Apply Simpson’s rule over each subinterval [xk−1 , xk ]. Use the
additive property of the integral for subintervals:

Z b M Z 2xk M
X hX
(3) f (x)dx = f (x)dx ≈ (f (x2k−2 ) + 4f (x2k−1 + f (x2k ))
a x2k−2 3
k=1 k=1

Since h/3 is a constant, the distributive law of addition can be applied


to obtain (4a). Formula (4b) is the expanded version of (4a). Formula
(4c) shows how to group all the intermediate terms in (4b) that are
multiplied by 2 and those that are multiplied by 4.

Professor Henry Arguello Numerical methods March 19, 2014 31 / 81


Composite Trapezoidal and Simpson’s Rule

Example Consider f (x) = 2 + sin(2 x). Use the composite Simpson
rule with 11 sample points to compute an approximation to the integral
of f (x) taken over [1, 6]. To generate 11 sample points, we must use
M = 5 and h = (6 − 1)/10 = 1/2. Using formula (4c), the computation is

S(f , 12 ) = 16 (f (1) + f (6)) + 13 (f (2) + f (3) + f (4) + f (5)) + 23 (f ( 23 ) + f ( 52 ) +


f ( 72 ) + f ( 92 ) + f ( 11
2 ))
1 1
= (2.90929743+1.01735756)+ (2.30807174+1.6835284+1.24319750+1.02872220
6 3

2
= (2.63815764 + 1.97931647 + 1.43530410 + 1.10831775 + 1.00024140)
3
1 1 2
= (3.926654499) + (6.26304429) + (8.16133735)
6 3 3

= 0.65444250 + 2.0876814 + 5.44089157 = 8.18301550.


Professor Henry Arguello Numerical methods March 19, 2014 32 / 81
Composite Trapezoidal and Simpson’s Rule

Error Analysis

The significance of the next two results is to understand that the error
terms ET (f , h) and ES (f , h) for the composite trapezoidal rule and com-
posite Simpson rule are of the order O(h2 ) and O(h4 ), respectively. This
shows that the error for Simpson’s rule converges to zero faster than
the error for the trapezoidal rule as the step size h decreases to zero. In
cases where the derivatives of f (x) are known, the formulas

−(b − a)f (2) (c)h2 −(b − a)f (4) (c)h4


ET (f , h) = and ES (f , h) =
12 180

Can be used to eliminate the number of subintervals required to achieve


a specified accuracy

Professor Henry Arguello Numerical methods March 19, 2014 33 / 81


Composite Trapezoidal and Simpson’s Rule

Corollary 7.2. (Trapezoidal rule error analysis)


Suppose that [a, b] is subdivided into M subintervals [xk , xk+1 ] of width
h = (b − a)/M. The composite trapezoidal rule
M−1
h X
(7) T(f , h) = (f (a) + f (b)) + h f (xk )
2
k=1

is an approximation to the integral


Z b
(8) f (x)dx = T(f , h) + ET (f , h).
a

Furthermore, if f ∈ C2 [a, b], there exists a value c with a < c < b so that
the error term ET (f , h) has the form
−(b − a)f (2) (c)h2
(9) ET (f , h) = = O(h2 ).
12

Professor Henry Arguello Numerical methods March 19, 2014 34 / 81


Composite Trapezoidal and Simpson’s Rule

Proof. We first determine the error term when the rule is applied over
[x0 , x1 ]. Integrating the Lagrange polynomial P1 (x) and its reminder
yields
x1 x1 x1
(x − x0 )(x − x1 )f (2) (c(x))
Z Z Z
(10) f (x)dx = P1 (x)dx + dx.
x0 x0 x0 21

The term (x−x0 )(x−x1 ) does not change sign on [x0 , x1 ], and f (2) (c(x)) is
continuous Hence the second mean value theorem for integrals implies
that there exist a value c1 so that
x1 x1
(x − x0 )(x − x1 )
Z Z
h
(11) f (x)dx = (f0 + f1 ) + f (2) (c1 ) dx.
x0 2 x0 2!

Professor Henry Arguello Numerical methods March 19, 2014 35 / 81


Composite Trapezoidal and Simpson’s Rule
Use the change of variable x = x0 + ht in the integral on the right side
of (11):
x1
f (2) (c1 ) 1
Z Z
h
(12) f (x)dx = (f0 + f1 ) + h(t − 0)h(t − 1)hdt.
x0 2 2 0

f (2) (c1 )h3 1 2


Z
h
= (f0 + f1 ) + (t − t)dt.
2 2 0

h f (2) (c1 )h3


= (f0 + f1 ) − .
2 12
Now we are ready to add up the error terms for all of the intervals
[xk , xk−1 ]:
Z b M Z
X xk
(13) f (x)dx = f (x)dx
a k=1 xk−1

M M
X h h3 X (2)
= (f (xk−1 ) + f (xk )) − f (ck ).
2 12
k=1 k=1
Professor Henry Arguello Numerical methods March 19, 2014 36 / 81
Composite Trapezoidal and Simpson’s Rule

The first sum is the composite trapezoidal rule T(f , h). In the second
term, one factor of h replaced with its equivalent h = (b − a)/M, and
the result is
b M
(b − a)h2
Z  
1 X (2)
f (x)dx = T(f , h) − f (ck )
a 12 M
k=1

The term in parentheses can be recognized as an average of values


for the second derivative and hence is replaced by f (2) (c). Therefore
we have established that
b
(b − a)f (2) (c)
Z
f (x)dx = T(f , h) − ,
a 12

and the proof of corollary is complete.

Professor Henry Arguello Numerical methods March 19, 2014 37 / 81


Composite Trapezoidal and Simpson’s Rule

Corollary 7.3. (Simpson’s rule: error analysis)


Suppose that [a, b] is subdivided into 2M subintervals [xk , xk+1 ] of equal
width h = (b − a)/2M. The composite Simpson rule
M−1 M
h 2h X 4h X
(14) S(f , h) = (f (a) + f (b)) + f (x2k ) + f (x2k−1 )
3 3 3
k=1 k=1

is an approximation to the integral


Z b
(15) f (x)dx = S(f , h) + ES (f , h).
a

Furthermore, if f ∈ C4 [a, b], there exists a value c with a < c < b so that
the error term ES (f , h) has the form
−(b − a)f (4) (c)h4
(16) ES (f , h) = = O(h4 ).
180

Professor Henry Arguello Numerical methods March 19, 2014 38 / 81


Composite Trapezoidal and Simpson’s Rule

Example7.8 Consider f (x) = 2 + sin(2 x). Investigate the error when
the composite trapezoidal rule is over [1, 6] and the number of subinter-
vals is 10, 20, 40, 80 and 160.

Table7.2Composite trapezoidal rule for f (x) = 2 + sin(2 x) over [1, 6]
M h T(f , h) ET (f , h) = O(h2 )
10 0.5 8.19385457 -0.01037540
20 0.25 8.18604926 -0.00257006
40 0.125 8.18412019 -0.00064098
80 0.0625 8.18363936 -0.00016015
160 0.03125 8.18351924 -0.00004003

Table 7.2 shows the approximations T(f , h). The antiderivative of f (x) is

√ √
sin(2 x)
F(x) = 2x − xcos(2 x) + ,
2
and the true value of definite integral is
Z 6
f (x)dx = F(x)|x=6
x=1 = 8.1834792077.
1

Professor Henry Arguello Numerical methods March 19, 2014 39 / 81


Composite Trapezoidal and Simpson’s Rule

This value was used to compute the values Et (f , h) = 8.1834792077 −


T(f , h) in table 7.2. It is important to observe that when h is reduced by
a factor of 1/2 the successive errors ET (f , h) are diminished by approxi-
mately 1/4. This confirm that the order is of O(h2 ).

Example7.9 Find the number M and the step size h so that the error
ET (f , h) for the Rcomposite trapezoidal rule is less than 5x10−9 for the
7
approximation 2 dx/x ≈ T(f , h). The integral is f (x) = 1/x and the
first two derivatives are f 0 (x) = −1/x2 and f (2) (x) = 2/x3 . The maximum
value of |f (2) (x)| taken over [2, 7] occurs at the endpoint x = 2, and those
we have the bound |f (2) (c)| ≤ |f (2) (2)| = 1/4, for 2 ≤ c ≤ 7. This is used
with formula (9) to obtain

| − (b − a)f (2) (c)h2 | (7 − 2) 14 h2 5h2


(17) |ET (f , h)| = ≤ = .
12 12 48

Professor Henry Arguello Numerical methods March 19, 2014 40 / 81


Composite Trapezoidal and Simpson’s Rule
The step size h and number M satisfy the relation h = 5/M, and this is
used in (17) to get the relation
125
(18) |ET (f , h)| ≤ ≤ 5 ∗ 10−9
48M 2
Now rewrite (18) so that is easier to solve for M:
25
(19) ≤ M2.
48 ∗ 109
Solving (19), we find that 22821.77 ≤ M. Since M must be an integer,
we choose M = 22822 and the corresponding step size is
h = 5/22822 = 0.000219086846. When the composite trapezoidal rule is
implemented with this main function evaluations, there is a possibility
that the rounded-off function evaluation will produce a significant
amount of error. When the computation was perform, the result was
 
5
T f, = 1.252762973
10000
Professor Henry Arguello Numerical methods March 19, 2014 41 / 81
Composite Trapezoidal and Simpson’s Rule

The composite trapezoidal rule usually requires a large number of


function evaluations to achieve and accurate answer. This is
contrasted in the next example with Simpson’s rule, which will require
significantly fewer evaluations

Example7.10 Find the number M and the step size h so that the error
ES (f , h) for the −9
R 7 composite Simpson rule is less than 5x10 for (4) the ap-
proximation 2 dx/x ≈ S(f , h). The integral is f (x) = 1/x and f (x) =
24/x5 . The maximum value of |f (4) (x)| taken over [2, 7] occurs at the
endpoint x = 2, and those we have the bound |f (4) (c)| ≤ |f (4) (2)| = 3/4,
for 2 ≤ c ≤ 7. This is used with formula (16) to obtain

| − (b − a)f (4) (c)h4 | (7 − 2) 34 h4 h4


(20) |ES (f , h)| = ≤ = .
180 180 48

Professor Henry Arguello Numerical methods March 19, 2014 42 / 81


Composite Trapezoidal and Simpson’s Rule
The step size h and number M satisfy the relation h = 5/2M, and this is
used in (20) to get the relation
625
(21) |ES (f , h)| ≤ ≤ 5 ∗ 10−9
768M 4
Now rewrite (21) so that is easier to solve for M:
125
(22) ∗ 109 ≤ M 4 .
768
Solving (22), we find that 112.95 ≤ M. Since M must be an integer, we
choose M = 113, and the corresponding step size is
h = 5/226 = 0.02212389381. When the composite Simpson rule was
perform, the result was
 
5
S f, = 1.252762969,
226
R7
which agrees with 2 dx/x = ln(x)|72 = 1.252762968.
Professor Henry Arguello Numerical methods March 19, 2014 43 / 81
Composite Trapezoidal and Simpson’s Rule

Experimentation shows that it takes about 129 function evaluations to


achieve the desired accuracy of 5 ∗ 10−9 and one the calculation is
performed with M = 64 the result is

 
5
S f, = 1.252762973.
128

So we see that the composite Simpson rule using 229 evaluations of


f (x) and the composite trapezoidal rule using 22823 evaluations of f (x)
achieve the same accuracy. In Example 7.10, Simpson’s rule required
1
about 100 the number of function evaluations.

Professor Henry Arguello Numerical methods March 19, 2014 44 / 81


Recursive Rules and Romberg Integration

Recursive Rules and Romberg Integration

Theorem (Successive Trapezoidal Rules)


Suppose that J ≥ 1 and the points{xk = a + kh} subdivide [a, b] into
2J = 2M subintervals of equal width h = (b − a)/2J . The trapezoidal
rules T(f , h) and T(f .2h) obey the relationship
M
T(f , 2h) X
(1) T(f , h) = +h f (x2k−1 ).
2
k=1

Definition (Sequence of trapezoidal Rules)


Define T(0) = (h/2)(f (a) + f (b)), which is the trapezoidal rule with step
size h = b − a. Then for each J ≥ 1 define T(J) = T(f , h), where T(f , h)
is the trapezoidal rule with step size h = (b − a)/2J .

Professor Henry Arguello Numerical methods March 19, 2014 45 / 81


Recursive Rules and Romberg Integration
Recursive Rules and Romberg Integration

Corollary (Recursive Trapezoidal Rules)


Start with t(0) = (h/2)(f (a) + f (b)). Then a sequence of trapezoidal
rules {T(J)} is generated by the recursive formula
M
T(J − 1) X
(2) T(J) = +h f (x2k−1 ). forJ = 1, 2, ...,
2
k=1

where h = (b − a)/2J and {xk = a + kh}

Professor Henry Arguello Numerical methods March 19, 2014 46 / 81


Recursive Rules and Romberg Integration
Recursive Rules and Romberg Integration

Corollary (Recursive Trapezoidal Rules)


Start with t(0) = (h/2)(f (a) + f (b)). Then a sequence of trapezoidal
rules {T(J)} is generated by the recursive formula
M
T(J − 1) X
(2) T(J) = +h f (x2k−1 ). forJ = 1, 2, ...,
2
k=1

where h = (b − a)/2J and {xk = a + kh}

Proof. For the even nodes x0 < x2 < ... < x2M−2 < x2M , we use the
trapezoidal rule with step size 2h:
2h
(3) T(J − 1) = (f0 + 2f2 + 2f4 + ... + 2f2M−4 + 2f2M−2 + f2M )
2
For all the nodes x0 < x2 < ... < x2M−2 < x2M , we use the trapezoidal
rule with step size h
Professor Henry Arguello Numerical methods March 19, 2014 46 / 81
Recursive Rules and Romberg Integration

h
(4) T(J) = (f0 + 2f1 + 2f2 + ... + 2f2M−2 + 2f2M−1 + f2M ).
2

Collecting the even and odd subscripts in (4) yields

M
h X
(5) T(J) = (f0 + 2f1 + 2f2 + ... + 2f2M−2 + 2f2M−1 + f2M ) + h f2k−1 .
2
k=1

Substituting (3) into (5) results in T(J)

Professor Henry Arguello Numerical methods March 19, 2014 47 / 81


Recursive rules and Romberg integration

Example

Use the sequential trapezoidal rule to compute the approximations T(0),


Rb
T(1), T(2), and T(3) for the integral a dx/x = ln(5)−ln(1) = 1.609437912.
The table shows the nine values required to compute T(3) and the mid-
points required to compute T(1), T(2), and T(3). Details for obtaining
the results are as follows:
4
When h=4: T(0) = (1.000000 + 0.200000)
2
T(0)
When h=2: T(1) = + 2(0.333333) = 1.200000 + 0.666666 = 1.866666.
2

Professor Henry Arguello Numerical methods March 19, 2014 48 / 81


Recursive rules

T(1)
When h = 1 : T(2) = +1(0.500000+0.250000) = 0.933333+0.750000 = 1.68333
2
1 T(2) 1
When h = : T(3) = + (0.666667 + 0.400000 + 0.285714 + 0.222222)
2 2 2
= 0.841667 + 0.787302 = 1.628968.

The nine points used to computed T(3) and the midpoints required to
compute T(1), T(2) and T(3)
Endpoints for Midpoints for Midpoints for Midpoints for,
x f (x) = 1x computing T(0) computing T(1) computing T(2) computing T(3)
1.0 1.000000 1.000000
1.5 0.666667 0.666667
2.0 0.500000 0.500000
2.5 0.400000 0.400000
3.0 0.333333 0.333333
3.5 0.285714 0.285714
4.0 0.250000 0.250000
4.5 0.222222 0.222222
5.0 0.200000 0.200000

Professor Henry Arguello Numerical methods March 19, 2014 49 / 81


Recursive rules

Our next result shows an important relationships between the trape-


zoidal rule and the Simpson’s rule. When the trapezoidal rule is com-
puted using step sizes 2h and h, the result is T(f , 2h) and T(f , h), re-
spectively. This values are combined to obtain Simpson‘s rule:

4T(f , h) − T(f , 2h)


(6) S(f , h) = .
3

Theorem (Recursive Simpson rules)


Suppose that {T(J)} is the sequence of trapezoidal rules generated by
Corollary. If J ≥ 1 and S(J) is Simpson’s rule for 2J subintervals of
[a, b], then S(J) and the trapezoidal rules T(J − 1) and {T(J)} obey the
relationship

4T(J) − T(J − 1)
(7) S(J) = for J = 1, 2, ...
3
Professor Henry Arguello Numerical methods March 19, 2014 50 / 81
Recursive rules
Proof. The trapezoidal rule T(J) with step size h yields the
approximation

Z b
h
(8) f (x)dx ≈ (f0 +2f1 +2f2 +...+2f2M−2 +2f2M−1 +f2M ) = T(J).
a 2
The trapezoidal rule T(J − 1) with step size 2h produces

Z b
(9) f (x)dx ≈ h(f0 + 2f1 + 2f2 + ... + 2f2M−2 + f2M ) = T(J − 1).
a

Multiplying relation (8) by 4 yields

Z b
(10) 4 f (x)dx ≈ h(2f0 +4f1 +4f2 +...+4f2M−2 +4f2M−1 +2f2M ) = 4T(J).
a

Professor Henry Arguello Numerical methods March 19, 2014 51 / 81


Recursive rules
Now subtract (9) from (10) and the result is

Z b
(11) 3 f (x)dx ≈ h(f0 + 4f1 + 2f2 + ... + 2f2M−2 + 4f2M−1 + f2M )
a

= 4T(J) − T(J − 1).

This can be rearranged to obtain


Z b
h
(12) f (x)dx ≈ (f0 + 4f1 + 2f2 + ... + 2f2M−2 + 4f2M−1 + f2M )
a 3
4T(J) − T(J − 1)
= .
3
The middle term in (12) is Simpson’s rule S(J) = S(f , h) and hence the
theorem is proved.
Professor Henry Arguello Numerical methods March 19, 2014 52 / 81
Recursive rules
Example
Use the sequential Simpson rule to compute the approximations S(1),
Rb
S(2) and S(3) for the integral a dx/x = ln(5) − ln(1) = 1.609437912.
Using the results of the example above and formula (7) with J = 1, 2
and 3, we compute
4T(1) − T(0) 4(1.866666) − 2.400000
S(1) = = = 1.688888,
3 3
4T(2) − T(1) 4(1.683333) − 1.866666
S(2) = = = 1.622222,
3 3
4T(3) − T(2) 4(1.628968) − 1.683333
S(3) = = = 1.610846.
3 3
We will now show that formulas (7) and (14) are special cases of the
process of Romberg integration. Let us announce that the next level of
approximation for the integral of the example is
64B(3) − B(2) 64(1.610088) − 1.617778
S(1) = = = 1.609490,
63 63
Professor Henry Arguello Numerical methods March 19, 2014 53 / 81
Romberg integration
Romberg Integration
We saw that the error terms ET (f , h) and ES (f , h) for the composite trape-
zoidal rule and composite Simpson rule are of order O(h2 ) and O(h4 ),
respectively. It is not difficult to show that the error term EB (f , h) for the
composite Boole rule is of the order O(h6 ). Thus we have the pattern
Z b
(15) f (x)dx = T(f , h) + O(h2 ),
a
Z b
(16) f (x)dx = S(f , h) + O(h4 ),
a
Z b
(17) f (x)dx = B(f , h) + O(h6 ),
a

The pattern for the remainders in (15) through (17) is extended in the
following sense. Suppose that an approximation rule is used with step
sizes h and 2h; then an algebraic manipulation of the two answers is
used to produces an improved answer.
Professor Henry Arguello Numerical methods March 19, 2014 54 / 81
Romberg integration

Each successive level of improvement increases the order of the error


term from O(h2N ) to O(h2N+2 ). This process, called Romberg integra-
tion, has its strengths and weaknesses.
The Newton-Cotes rules are seldom used past Boole’s rule. This is
because the nine-point Newton-Cotes quadrature rule involves negative
weights, and all the rules past the 10-point rule involve negative weights.
This could introduce loss of significance error due to round off. The
Romberg method has the advantages that all the weights are positive
and the equally spaced abscissas are easy to compute.
A computational weakness of romberg integration is that twice as many
function evaluations are needed to decrease the error from O(h2N ) to
O(h2N+2 ). The use of the sequential rules will help keep the number of
computations down.

Professor Henry Arguello Numerical methods March 19, 2014 55 / 81


Romberg integration
The development of Romberg integration relies on the theoretical as-
sumption that, if f ∈ CN [a, b] for all N, then the error term for the trape-
zoidal rule can be represented in a series involving only even powers of
h; that is, Z b
(18) f (x)dx = T(f , h) + ET (f , h),
a
where

(19) ET (f , h) = a1 h2 + a2 h4 + a3 h6 + ...
Since only even powers of h can occur in (19), the Richardson improvement
process is used successively first to eliminate a1 , next to eliminate a2 , then to
eliminate a3 , and so on. This process generates quadrature formulas whose
error terms have even orders O(h4 ), O(h6 ), O(h8 ), and so on. We shall show
that the first improvement is Simpson’s rule for 2M intervals. Start with T(f , 2h)
and T(f , h) and the equations
Z b
(20) f (x)dx = T(f , 2h) + a1 4h2 + a2 16h4 + a3 64h6 + ...
a

Professor Henry Arguello Numerical methods March 19, 2014 56 / 81


Romberg integration
And Z b
(21) f (x)dx = T(f , h) + a1 h2 + a2 h4 + a3 h6 + ...
a

Multiply equation (21) by 4 and obtain


Z b
(22) 4 f (x)dx = 4T(f , h) + a1 4h2 + a2 4h4 + a3 4h6 + ...
a

Eliminate a1 by subtracting (20) from (22). The result is


Z b
(23) 3 f (x)dx = 4T(f , h) − T(f , 2h) − a2 12h4 − a3 60h6 + ...
a

Now divide equation (23) by 3 and renamed the coefficients in the


series:
b
4T(f , h) − T(f , 2h)
Z
(24) f (x)dx = + a1 h4 + b2 h6 + ...
a 3

Professor Henry Arguello Numerical methods March 19, 2014 57 / 81


Romberg integration
As noted in (6), the first quantity on the right side of (24) is Simpson’s
rule S(f , h). This shows that Es (f , h) involves only even powers of h:
Z b
(25) f (x)dx = S(f , h) + b1 h4 + b2 h6 + b3 h8 + ...
a

To show that the second improvement is Boole’s rule, start with (25)
and write down the formula involving S(f , 2h)
Z b
(26) f (x)dx = S(f , 2h) + b1 16h4 + b2 64h6 + b3 256h8 + ...
a

When b1 is eliminated from (25) and (26), the results involves Boole’s
rule
b
16S(f , h) − S(f , 2h) b2 48h6 b3 240h8
Z
(27) f (x)dx = − − − ...
a 15 15 15

b2 48h6 b3 240h8
= B(f , h) − − − ...
15 15
Professor Henry Arguello Numerical methods March 19, 2014 58 / 81
Romberg integration

Lemma(Richardson’s improvement for Romberg integration


Given two approximations R(2h, K − 1) and R(h, K − 1) for the quantity
Q satisfy

(28) Q = R(h, K − 1) + c1 h2K + c2 h2K+2 + ...

And

(29) Q = R(2h, K − 1) + c1 4K h2k + c2 4K+1 hK+2 + ...

An improved approximation has the form


4K R(h, K − 1) − R(2h, K − 1)
(30) Q = + O(h2K+2 ).
4K − 1

Professor Henry Arguello Numerical methods March 19, 2014 59 / 81


Romberg integration

Definition
Define the sequence {R(J, K) : J ≥ K}∞
J=0 of quadrature formulas for
f (x) over [a, b] as follows:
R(J, 0) = T(J) for J ≥ 0, is the sequential trapezoidal rule.
(31) R(J, 1) = S(J) for J ≥ 1, is the sequential Smpson rule.
R(J, 2) = B(J) for J ≥ 2, is the sequential Boole’s rule.

The starting rules {R(J, 0)} are used to generate the first improvement,
{R(J, 1)}, which in turn is to generate the second improvement,
{R(J, 2)}. We have already seen the patterns
41 R(J, 0) − R(J − 1, 0)
(32) R(J, 1) = for J ≥ 1.
41 − 1

42 R(J, 1) − R(J − 1, 1)
(32) R(J, 2) = for J ≥ 2.
42 − 1

Professor Henry Arguello Numerical methods March 19, 2014 60 / 81


Romberg integration
which are the rules in (24) and (27) stated using the notation in (31).
The general rule for constructing improvements is
4K R(J, K − 1) − R(J − 1, K − 1)
(33) R(J, 3) = for J ≥ K.
4K − 1
Table 7.5. Romberg integration tableau
R(J, 0) R(J, 1) R(J, 2) R(J, 3) R(J, 4)
Trapezoidal Simpson’s Boole’s Third Fourth
J rule rule rule improvement improvement
0 R(0, 0)
1 R(1, 0) R(1, 1)
2 R(2, 0) R(2, 1) R(2, 2)
3 R(3, 0) R(3, 1) R(3, 2) R(3, 3)
4 R(4, 0) R(4, 1) R(4, 2) R(4, 3) R(4, 4)

Example Use Romberg integration to find approximation for the


definite integral
Z π/2
π π
(x2 + x + 1)cos(x)dx = −2 + + = 2.038197427067...
0 2 4

Professor Henry Arguello Numerical methods March 19, 2014 61 / 81


Romberg integration

The computation are given in Table 7.6. In each column the numbers
are converging to the value 2.038197427067... The values in the Simp-
son’s rule column converge faster than the values in the trapezoidal rule
column. For this example, convergence in columns to the right is faster
than the adjacent column to the left.

Convergence of the Romberg values in Table 7.6 is easier to see if we


look at the error terms E(J, K) = −2 + π/2 + π/4 − R(J, K). Suppose
that the interval width is h = b − a and that the higher derivatives of the
Romberg table diminishes by about a factor of 1/22K+2 = 1/4k+1 as one
progresses down its rows. The errors E(J, 0) diminish by a factor of 1/4,
the errors E(J, 1) diminish by a factor of 1/16, and so on. This can be
observed by inspecting the entries {E(J, K)} in Table 7.7

Professor Henry Arguello Numerical methods March 19, 2014 62 / 81


Romberg integration

Table 7.6. Romberg integration tableau for the example


R(J, 0) R(J, 1) R(J, 2) R(J, 3),
Trapezoidal Simpson’s Boole’s Third
J rule rule rule improvement
0 0.785398163397
1 1.726812656758 2.040617487878
2 1.960534166564 2.038441336499 2.038296259740
3 2.018793948078 2.038213875249 2.038198711166 2.038197162776
4 2.033347341805 2.038198473047 2.038197446234 2.038197426156
5 2.036984954990 2.038197492719 2.038197427363 2.038197427064

Table 7.7. Romberg error tableau for the example


J h E(J, 0) = O(h2 ) E(J, 1) = O(h4 ) E(J, 2) = O(h6 ) E(J, 3) = O(h8 )
0 b−a -1.252799263670
1 b − a/2 -0.311384770309 0.002420060811
2 b − a/4 -0.077663260503 0.000243909432 0.000098832673
3 b − a/8 -0.019403478989 0.000016448182 0.000001284099 -0.000000264291
4 b − a/16 -0.004850085262 0.000001045980 0.000000019167 -0.000000000912
5 b − a/32 -0.001212472077 0.000000065651 0.000000000296 - 0.000000000003

Professor Henry Arguello Numerical methods March 19, 2014 63 / 81


Romberg integration
Theorem 7.7 (Precision of Romberg Integration
Assume that f ∈ C2K+2 [a, b]. Then the truncation error term for the
Romberg approximation is given in the formula

Z b
(34) f (x)dx = R(J, K) + bK h(2k+2) f 2k+2 (cJ,K ) = R(J, K) + O(h2k+2 )
a

Where h = (b − a)/2J , bK is a constant that depends on K, and cJ,K ∈ [a, b].

Example. Apply Theorem and show that


Z 2
10x9 dx = 1024 ≡ R(4, 4).
0

The integral is f (x) = 10x9 , and f (10) (x) ≡ 0 . Thus the value K = 4
will make the error term identically zero. A numerical computation will
produce R(4, 4) = 1024.
Professor Henry Arguello Numerical methods March 19, 2014 64 / 81
Gauss-Legendre Integration

We wish to find the area under the curve


y = f (x) − 1 ≤ x ≤ 1.
What method gives the best answer if only two function evaluations are
to be made? We have already seen that the trapezoidal rule is a
method for finding the area under the curve and that it uses two
function evaluations at the endpoints (−1, f (−1)), and (1, f (1)). But if
the graph of y = f (x) is concave down, the error in approximation is the
entire region that lies between the curve and the line segment joining
the points; another instance is shown in Figure 7.10(a).
If we can use nodes x1 and x2 that lie inside the interval [−1, 1], the line
through the two points (x1 , f (x1 )) and (x2 , f (x2 )) crosses the curve, and
the area under the line more closely approximates the area under the
curve (see Figure 7.10(b)).

Professor Henry Arguello Numerical methods March 19, 2014 65 / 81


Gauss-Legendre Integration

y y

y=f(x)

y=f(x)

x x
-1 0 1 -1 x1 0 x2 1

: :

Figure 7.10: (a) Trapezoidal approximation using the abscissas −1 and 1. (b)
Trapezoidal approximation using the abscissas x1 and x2 .

Professor Henry Arguello Numerical methods March 19, 2014 66 / 81


Gauss-Legendre Integration
The equation of the line is
(x − x1 )(f (x2 ) − f (x1 ))
y = f (x1 ) + (1)
x2 − x1
and the area of the trapezoid under the line is
2x2 2x1
Atrap = f (x1 ) − f (x2 ). (2)
x2 − x1 x2 − x1
Notice that the trapezoidal rule is a special case of (2). When we
choose x1 = −1, x2 = 1, and h = 2, then
2 −2
T(f , h) = f (x1 ) − f (x2 ) = f (x1 ) + f (x2 ).
2 2
We shall use the method of undetermined coefficients to find the
abscissas x1 , x2 and weights w1 , w2 so that the formula
Z 1
f (x) dx ≈ w1 f (x1 ) + w2 f (x2 ) (3)
−1

is the exact for cubic polynomials (i.e, f (x) = a3 x3 + a2 x2 + a1 x + a0 ).


Professor Henry Arguello Numerical methods March 19, 2014 67 / 81
Gauss-Legendre Integration

Since four coefficients w1 , w2 , x1 , and x2 need to be determined in


equation (3), we can select four conditions to be satisfied. Using the
fact that integration is additive, it will suffice to require that (3) be exact
for the four functions f (x) = 1, x, x2 , x3 . The four integral conditions are
Z 1
f (x) = 1 : 1 dx = 2 = w1 + w2
−1
Z 1
f (x) = x : x dx = 0 = w1 x1 + w2 x2
−1
Z 1
2
f (x) = x2 : x2 dx = = w1 x12 + w2 x22 (4)
−1 3
Z 1
f (x) = x3 : x3 dx = 0 = w1 x13 + w2 x23 .
−1

Professor Henry Arguello Numerical methods March 19, 2014 68 / 81


Gauss-Legendre Integration

w1 + w2 = 2 (5)
w1 x1 = −w2 x2 (6)
2
w1 x12 + w2 x22 = (7)
3
w1 x13 = −w2 x23 (8)

We can divide (8) by (6) and the result is


x12 = x22 or x1 = −x2 . (9)

Use (9) and divide (6) by x1 on the left and −x2 on the right to get
w1 = w2 . (10)

Substituting (10) into (5) results in w1 + w2 = 2. Hence


w1 = w2 = 1 (11)

Professor Henry Arguello Numerical methods March 19, 2014 69 / 81


Gauss-Legendre Integration

Now using (11) and (9) in (7), we write


2 1
w1 x12 + w2 x22 = x22 + x22 = or x22 = . (12)
3 3
Finally, from(12) and (9) we see that the nodes are
−x1 = x2 = 1/31/2 ≈ 0.5773502692.

We have found the nodes and weights that make up the two-point
Gauss-Legendre rule. Since the formula is exact for cubic equations,
the error term will involve the fourth derivative.

Professor Henry Arguello Numerical methods March 19, 2014 70 / 81


Gauss-Legendre Integration

Theorem 7.8 (Gauss-Legendre Two-Point Rule).


If f is continuous on [−1, 1], then
Z 1    
−1 1
f (x) dx ≈ G2 (f ) = f √ +f √ . (13)
−1 3 3

The Gauss-Legendre rule G2 (f ) has degree of precision n = 3. If


f ∈ C4 [−1, 1], then
Z 1    
−1 1
f (x) dx = f √ +f √ + E2 (f ), (14)
−1 3 3

where
f (4) (c)
E2 (f ) = . (15)
135

Professor Henry Arguello Numerical methods March 19, 2014 71 / 81


Gauss-Legendre Integration
Example 7.17 Use the two-point Gauss-Legendre rule to approximate
Z 1
dx
= ln(3) − ln(1) ≈ 1.09861
−1 x+2

and compare the result with the trapezoidal rule T(f , h) with h = 2 and
Simpson’s rule S(f , h) with h = 1.

Professor Henry Arguello Numerical methods March 19, 2014 72 / 81


Gauss-Legendre Integration
Example 7.17 Use the two-point Gauss-Legendre rule to approximate
Z 1
dx
= ln(3) − ln(1) ≈ 1.09861
−1 x+2

and compare the result with the trapezoidal rule T(f , h) with h = 2 and
Simpson’s rule S(f , h) with h = 1.
Let G2 (f ) denote the two-point Gauss-Legendre rule; then
G2 (f ) = f (−0.57735) + f (0.57735)
= 0.70291 + 0.38800 = 1.09091,

T(f , 2) = f (−1.00000) + f (1.00000)


= 1.00000 + 0.33333 = 1.33333,

1
f (−1) + 4f (0) + f (1) 1+2+ 3
S(f , 1) = = = 1.11111.
3 3

Professor Henry Arguello Numerical methods March 19, 2014 72 / 81


Gauss-Legendre Integration

The errors are 0.00770, −0.23472, and −0.01250, respectively, so the


Gauss-Legendre rule is seen to be best. Notice that the
Gauss-Legendre rule required only two function evaluations and
Simpson’s rule required three. In this example the size of the error for
G2 (f ) is about 61% of the size of the error for S(f , 1).

Professor Henry Arguello Numerical methods March 19, 2014 73 / 81


Gauss-Legendre Integration

The general N-point Gauss-Legendre rule is exact for polynomial


functions of degree ≤ 2N − 1, and the numerical integration formula is

GN (f ) = wN,1 f (xN,1 ) + wN,2 f (xN,2 ) + · · · + wN,N f (xN,N ). (16)

The abscissas xN,k and weights wN,k to be used have been tabulated
and are easily available; Table 7.9 gives the value up to eight points.
Also include in the table is the form of the error term EN (f ) that
corresponds to GN (f ), and it can be used to determine the accuracy of
the Gauss-Legendre integration formula.
The nodes are actually roots of the Legendre polynomials, and the
corresponding weights must be obtained by solving a system of
equations. For the three-point Gauss-Legendre rule the nodes are
−(0.6)1/2 , 0, and (0.6)1/2 , and the corresponding weights are 5/9, 8/9,
and 5/9.

Professor Henry Arguello Numerical methods March 19, 2014 74 / 81


Gauss-Legendre Integration

Table 7.9 Gauss-Legendre Abscissas and Weights (1)


R1 PN
−1 f (x) dx = k=1 wN,k f (xN,k ) + EN (f )

Truncation error
N Abscissas, xN,k Weights, wN,k EN (f )

−0.5773502692 1.0000000000 f (4) (c)


2
0.5773502692 1.0000000000 135

±0.7745966692 0.5555555556 f (6) (c)


3
0.0000000000 0.8888888888 15,750

±0.8611363116 0.3478548451 f (8) (c)


4
±0.3399810436 0.6521451549 3,472,875

±0.9061798459 0.2369268851
5 f (10) (c)
±0.5384693101 0.4786286705
1,237,732,650
0.0000000000 0.5688888888

Professor Henry Arguello Numerical methods March 19, 2014 75 / 81


Gauss-Legendre Integration

Table 7.9 Gauss-Legendre Abscissas and Weights (2)


R1 PN
−1 f (x) dx = k=1 wN,k f (xN,k ) + EN (f )

Truncation error
N Abscissas, xN,k Weights, wN,k EN (f )

±0.9324695142 0.1713244924
6 f (12) (c)21 3(6!)4
±0.6612093865 0.3607615730
(12!)3 13!
±0.2386191861 0.4679139346

±0.9491079123 0.1294849662
±0.7415311856 0.2797053915 f (14) (c)21 5(7!)4
7
±0.4058451514 0.3818300505 (14!)3 15!
0.0000000000 0.4179591837

±0.9602898565 0.1012285363
±0.7966664774 0.2223810345 f (16) (c)21 7(8!)4
8
±0.5255324099 0.3137066459 (16!)3 17!
0.1834346425 0.3626837834

Professor Henry Arguello Numerical methods March 19, 2014 76 / 81


Gauss-Legendre Integration

Theorem 7.9 (Gauss-Legendre Three-Point Rule).


If f is continuous on [−1, 1], then
Z 1
p p
5f (− 3/5) + 8f (0) + 5f ( 3/5)
f (x) dx ≈ G3 (f ) = . (17)
−1 9

The Gauss-Legendre rule G3 (f ) has degree of precision n = 5. If


f ∈ C6 [−1, 1], then
Z 1
p p
5f (− 3/5) + 8f (0) + 5f ( 3/5)
f (x) dx = + E3 (f ), (18)
−1 9

where
f (6) (c)
E3 (f ) = . (19)
15, 750

Professor Henry Arguello Numerical methods March 19, 2014 77 / 81


Gauss-Legendre Integration

Example 7.18 Show that the three-point Gauss-Legendre rule is exact


for Z 1
5x4 dx = 2 = G3 (f ).
−1

Professor Henry Arguello Numerical methods March 19, 2014 78 / 81


Gauss-Legendre Integration

Example 7.18 Show that the three-point Gauss-Legendre rule is exact


for Z 1
5x4 dx = 2 = G3 (f ).
−1

Since the integral is f (x) = 5x4 and f (6) (x) = 0, we can use (19) to see
that E3 (f ) = 0. But it is instructive to use (17) and do the calculations in
this case. 2 2
5(5)(0.6) + 0 + 5(5)(0.6) 18
G3 (f ) = = = 2.
9 9
The next result shows how to change the variable of integration so that
the Gauss-Legendre rules can be used on the interval [a, b].

Professor Henry Arguello Numerical methods March 19, 2014 78 / 81


Gauss-Legendre Integration

Theorem 7.10 (Gauss-Legendre Translation).


Suppose that the abscissas {xN,k }Nk=1 and weights {wN,k }Nk=1 are given
for the N-point Gauss-Legendre rule over [−1, 1]. To apply the rule
over the interval [a, b], use the change of variable
a+b b−a b−a
t= + x and dt = dx (20)
2 2 2
Then the relationship
Z b Z 1  
a+b b−a b−a
f (t) dt = f + x dx (21)
a −1 2 2 2

is used to obtain the quadrature formula


Z b N  
b−a X a+b b−a
f (t) dt = wN,k f + xN,k . (22)
a 2 k=1 2 2

Professor Henry Arguello Numerical methods March 19, 2014 79 / 81


Gauss-Legendre Integration
Example 7.19 Use the three-point Gauss-Legendre rule to
approximate Z 5
dt
= ln(5) − ln(1) ≈ 1.609438
1 t
and compare the result with Boole’s rule B(2) with h = 1.

Professor Henry Arguello Numerical methods March 19, 2014 80 / 81


Gauss-Legendre Integration
Example 7.19 Use the three-point Gauss-Legendre rule to
approximate Z 5
dt
= ln(5) − ln(1) ≈ 1.609438
1 t
and compare the result with Boole’s rule B(2) with h = 1.
Here a = 1 and b = 5, so the rule in (22) yields
5f (3 − 2(0.6)1/2 ) + 8f (3 + 0) + 5f (3 + 2(0.6)1/2 )
G3 (f ) = (2) (23)
9
3.446359 + 2.666667 + 1.099096
= (2) = 1.602694. (24)
9

Professor Henry Arguello Numerical methods March 19, 2014 80 / 81


Gauss-Legendre Integration
Example 7.19 Use the three-point Gauss-Legendre rule to
approximate Z 5
dt
= ln(5) − ln(1) ≈ 1.609438
1 t
and compare the result with Boole’s rule B(2) with h = 1.
Here a = 1 and b = 5, so the rule in (22) yields
5f (3 − 2(0.6)1/2 ) + 8f (3 + 0) + 5f (3 + 2(0.6)1/2 )
G3 (f ) = (2) (23)
9
3.446359 + 2.666667 + 1.099096
= (2) = 1.602694. (24)
9
In Example 7.13 we saw that Boole’s rule gave B(2) = 1.617778. The
errors are 0.006744 and −0.008340, respectively, so that the
Gauss-Legendre rule is slightly better in this case. Notice that the
Gauss-Legendre rule requires three function evaluations and Boole’s
rule requires five. In this example the size of the two errors is about the
same.
Professor Henry Arguello Numerical methods March 19, 2014 80 / 81
Gauss-Legendre Integration

Gauss-Legendre integration formulas are extremely accurate, and the


should be considered seriously when many integrals of a similar
nature are to be evaluated. In this case, proceed as follows. Pick a few
representative integrals, including some with the worst behavior that is
likely to occur. Determine the number of sample points N that is
needed to obtain the required accuracy. Then fix the value N, and use
the Gauss-Legendre rule with N sample points for all the integrals.

Professor Henry Arguello Numerical methods March 19, 2014 81 / 81

You might also like