







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








In this section we will discuss methods for evaluation of the integral of the function f (x) in the interval [a, b]:
∫ (^) b
a
f (x)dx.
The function f (x) is defined either analytically or on a set of discrete points a = x 0 , x 1 ,.. ., xN = b. All integration formulas, also called quadrature formulas, are of the form
j=
wj f (xj ),
where wj are usually referred to as weights. The specific choice of these weights is what distinguishes the different quadrature formulas.
One of the easiest ways to obtain quadrature formulas is to use Lagrange interpolation on an evenly spaced mesh and integrate the result. Divide the range of integration into N intervals:
xi = a + ih, h =
b − a N
, i = 0, 1 ,... , N.
Pass a Lagrange interpolating polynomial of degree N through the points (xi, f (xi)):
P (x) =
j=
L( jN )(x)f (xj ).
Now integrate this polynomial
∫ (^) b
a
P (x)dx =
j=
f (xj )
∫ (^) b
a
L( jN )(x)dx = (b − a)
j=
CjN f (xj ),
where
CNj =
b − a
∫ (^) b
a
L( jN )(x)dx
are pure numbers, called Cotes numbers, and are given in the table below. Observe that in this case the weights are
wj = (b − a)CjN.
It can be easily shown that
∑^ N
j=
CjN = 1 and CjN = CNN −j.
N M M CN 0 M CN 1 M C 2 N M C 3 N M C 4 N M C 5 N M C 6 N Truncation Error 0 1 1 4. 2 × 10 −^2 h^3 f ′′ 1 2 1 1 8. 3 × 10 −^2 h^3 f ′′ 2 6 1 4 1 3. 5 × 10 −^4 h^5 f (iv) 3 8 1 3 3 1 1. 6 × 10 −^4 h^5 f (iv) 4 90 7 32 12 32 7 5. 2 × 10 −^7 h^7 f (vi) 5 288 19 75 50 50 75 19 3. 6 × 10 −^7 h^7 f (vi) 6 840 41 216 27 272 27 216 41 6. 4 × 10 −^10 h^9 f (viii)
Table 5.1: Newton-Cotes coefficients.
Using Table 5.1 we recover some well known formulas:
N = 0 - i) Rectangular rule:
I ≈ (b − a)f (a) ;
ii) Midpoint rule:
I ≈ (b − a)f
a + b 2
N = 1 - Trapezoidal rule:
I ≈
(b − a) [f (a) + f (b)] ;
N = 2 - Simpson’s rule:
I ≈
(b − a)
f (a) + 4f
a + b 2
etc. Usually the formulas are not applied over the whole interval, but at each subinterval, i.e. we use piecewice Lagrange intepolating polynomials, rather than a single interpolation over the complete integration interval. Subsequently, the error estimates are for a single interval; it should be summed up over all intervals to get an overall error estimate.
For one interval, trapezoidal rule is given by
Ii =
∫ (^) xi+
xi
f (x)dx ≈
hi 2
(fi + fi+1).
For the entire interval, [a, b], the trapezoidal rule is
i=
Ii ≈ h
f 0 +
fN +
j=
fj
where uniform spacing is assumed.
To obtain the integral for the entire domain, we sum both sides of equation (5.4); assuming uniform spacing, we have
i=
∫ (^) xi+
xi
f (x)dx =
h 2
f (a) + f (b) + 2
j=
fj
(^) − h
3 12
i=
f ′′(yi) −
h^5 480
i=
f (iv)(yi) − · · ·. (5.5)
Now, we will apply the mean value theorem to the summations. The mean value theorem states that there exists a point x in the interval [a, b] such that
N∑ − 1
i=
f ′′(yi) = N f ′′(x).
Similarly, there is a point ξ in [a, b] such that
N∑ − 1
i=
f (iv)(yi) = N f (iv)(ξ).
Noting that N = (b − a)/h, and substituting in equation (5.5), we obtain
h 2
f (a) + f (b) + 2
j=
fj
(^) − (b − a) h
2 12
f ′′(x) − (b − a) h^4 480
f (iv)(ξ) − · · ·. (5.6)
Thus, the trapezoidal rule for the entire interval is second order accurate. One can easily show that Simpson’s formula for one panel, [xi, xi+2], can be written as
S(f ) =
M (f ) +
T (f ),
where M (f ) and T (f ) denote midpoint and trapezoidal rules applied to the function f. Note that the midpoint of the interval is xi+1. Using equations (5.3) and (5.4), and the mean value theorem we see that Simpson’s rule is fourth order accurate for the entire interval [a, b].
This rule is easily derived by simply substituting in equation (5.4) the second order central difference formula for f ′′(yi):
Ii = hi
fi + fi+ 2
h^3 i
f (^) i′+1 − f (^) i′ hi
− O(h^5 i ).
Let hi = h = const, then
h 2
i=
(fi + fi+1) −
h^2 12
i=
f (^) i′+1 − f (^) i′
− O(h^4 ).
Cancellations in the second summation leads to
h 2
f (a) + f (b) + 2
i=
fi
h^2 12
[f ′(b) − f ′(a)] − O(h^4 ).
Thus, trapezoidal rule with end-correction is fourth order accurate, and can be readily applied provided that the derivatives of the integrand at the end points are known.
Richardson extrapolation is a powerful technique for obtaining an accurate numerical solution of a quan- tity (e.g., integral, derivative, etc.) by combining less accurate solutions. The essential ingredient for application of the technique is knowledge of the form of the truncation error of the basic numerical method used. We shall demonstrate application of Richardson extrapolation by using it to improve the accuracy of the integral
∫ (^) b
a
f (x)dx
with the trapezoidal rule as the basic numerical method. From our error analysis for trapezoidal rule, we have
h 2
f (a) + f (b) + 2
j=
fj
(^) + c 1 h^2 + c 2 h^4 + c 3 h^6 + · · ·. (5.7)
Let
I˜ 1 = h 2
f (a) + f (b) + 2
j=
fj
The trapezoidal expressions can be written as
I˜ 1 = I − c 1 h^2 − c 2 h^4 − c 3 h^6 − · · ·. (5.9)
Now, suppose we evaluate the integral with half the step size h 1 = h/2. Let’s call this estimate I˜ 2
I^ ˜ 2 = I − c 1 h
2 4
− c 2 h^4 16
− c 3 h^6 64
Now we can eliminate O(h^2 ) terms by taking a linear combination of equations (5.9) and (5.10)
4 I˜ 2 − I˜ 1 3
c 2 h^4 +
c 3 h^6 + · · ·. (5.11)
This is a fourth order approximation for I. In fact, equation (5.11) is a rediscovery of Simpson’s rule. We have combined two estimates of I to obtain a more accurate estimate. This procedure is called Richardson’s extrapolation. We continue with this procedure. Let’s evaluate I with h 2 = h/4:
I˜ 3 = I − c 1 h
2 16
− c 2
h^4 256
− c 3
h^6 4096
Combining with I˜ 2 , we get 4 ˜I 3 − I˜ 2 3
c 2 h^4 +
c 3 h^6 + · · ·. (5.13)
Now, we can eliminate O(h^4 ) terms between equations (5.11) and (5.13). The result will be sixth order accurate. This process can be continued indefinitely. The essence of the Romberg integration algorithm just described is illustrated in the following diagram:
O(h^2 ) O(h^4 ) O(h^6 )
ց I^ ˜ 2 −→ Eqn. (5.11) ց ց I^ ˜ 3 −→ Eqn. (5.13) −→ ·
Note that in each step of calculations, half of the needed functions have already been used in the preceding calculation and need not be recalculated. Also, in principle arbitrary accuracy can be achieved. In practice, we are limited by the particular machine accuracy.
So the error in S i(2) is about 1/15 of the difference between S i(1) and S i(2) : ∣ ∣ ∣Ii − S (2) i
(2) i −^ S
(1) i
If 1 15
∣S i(2) − S(1) i
hi b − a
ǫ = δi(ǫ), (5.16)
then S i(2) is sufficiently accurate for the interval [xi, xi+1], and we move on to the next interval. If condition (5.16) is not satisfied, the interval will be subdivided further. We note that condition (5.16) guarantees that ǫ is an upper bound on the total integration error since
∣ ∣ ∣I^ −^ I˜
i=
Ii − S(2) i
i=
S(2) i − S i(1)
i=
(2) i −^ S
(1) i
ǫ b − a
i=
hi = ǫ.
This is the essence of adaptive quadrature algorithms. Similar methodology can be divised for other base methods such as the trapezoidal rule. As with Richardson extrapolation, the knowledge of the truncation error can be used to obtain estimates for the accuracy of the numerical solution without knowing the exact solution.
Recall that any quadrature formula can be written as
∫ (^) b
a
f (x)dx ≈
j=
wj f (xj ).
If the function f is given analytically or we are at liberty to choose the locations xj , we have two important choices to make. We have to select the location of the points xj and the weights wj. The main idea behind Gauss quadrature is to make these choices for best accuracy. The criterion for accuracy is the highest degree polynomial that can be integrated exactly. Recall that the trapezoidal rule integrates a straight line exactly and Simpson’s rule integrates a cubic exactly. In general, Newton-Cotes algorithms integrate polynomials up to order N (N even) with N + 1 points exactly. As we will show below, Gauss quadrature integrates a polynomial of degree 2N + 1 using only N + 1 points. Let f be a polynomial of degree 2N +1. Suppose we represent f by an N th^ order Lagrange polynomial, P. Let x 0 , x 1 ,... , xN be the points on the x axis where the function f is evaluated. Using Lagrange interpolation, we have:
P (x) =
j=
L( jN )(x)f (xj ).
This representation is exact if f is a polynomial of degree N. f (x)−P (x) is a polynomial of degree 2N + which vanishes at x 0 , x 1 ,... , xN , because P was constructed to pass through f (x 0 ), f (x 1 ),... , f (xN ) at x 0 , x 1 ,... , xN. Let
F (x) = (x − x 0 )(x − x 1 ) · · · (x − xN ).
Thus, we can write the difference f (x) − P (x) in the following form:
f (x) − P (x) = F (x)
k=
qkxk.
Integrating this equation (for the moment without affixing limits):
∫ f (x)dx =
P (x)dx +
F (x)
k=
qkxkdx.
Interchange summation and integration, and suppose we demand that ∫ F (x)xk^ dx = 0, k = 0, 1 ,... , N.
This corresponds to a system of N + 1 equations for x 0 , x 1 ,... , xN. We will choose x 0 , x 1 ,... , xN such that this condition is satisfied. Choosing the abscissas in this manner leads to the following expression for the integral
∫ f (x)dx =
P (x)dx =
j=
wj f (xj ),
where
wj =
L( jN )(x)dx
are the weights. F is a polynomial of degree N + 1 that is orthogonal to all polynomials of degree less than or equal to N. x 0 , x 1 ,... , xN are the zeros of this polynomial. These polynomials are called Legendre polynomials when x varies between −1 and +1, and they can be generated by Rodrigues’ formula
Fn(x) = (−1)n 2 nn!
dn dxn
1 − x^2
)n ,
where Fn is the Legendre polynomial of degree n (e.g., F 0 (x) = 1, F 1 (x) = x, F 2 (x) = 12 (3x^2 − 1),.. .). They are orthogonal to each other, that is
∫ (^1)
− 1
Fm(x)Fn (x)dx =
2 n + 1
δmn.
Their zeros are documented in Table 5.2. Having the zeros, the weights wj can be readily computed, and they are also documented in Table 5.2. In the table N , not N + 1, denotes the number of points. Note that we can always transform the interval a ≤ x ≤ b into − 1 ≤ ξ ≤ 1 by the tranformation
x =
b + a 2
b − a 2
ξ.
Typically, to use Legendre-Gauss quadrature tables to evaluate the integral
∫ (^) b
a
f (x)dx,
one first changes the independent variable to ξ and obtains the weights wj and the points on the abscissa, ξ 0 , ξ 1 ,... , ξN , from the tables (for the chosen N ). The integral is then approximated by
b − a 2
j=
wj f
b + a 2
b − a 2
ξj
In addition, if one wishes to improve the accuracy by going to a higher order method, the calculation must be done from scratch since the abscissas of the various orders are different.
If we have the integral
0
g(x)dx,
0
cos x √ x dx =
∫ (^) π
0
dx √ x
∫ (^) π
0
cos x − 1 √ x dx.
Now the first part can be integrated analytically, and the second part is not singular any more.
Table 5.4: Abscissas and weight factors for Hermite integration.