Numerical Integration
Numerical Integration
Numerical Integration
where f is a continuous function, at lest in the interval [a, b], with a < b. The main
idea, is to replace, in the interval [a, b], the function f with an interpolation polyno-
mial pn (x) of degree n and to compute the intergral of pn (x) as an approximation of
I: Z b Z b
I= f (x)dx ≈ pn (x)dx =: In
a a
Consider a set of n + 1 distinct points in [a, b], called nodes. Using the Lagrange
expression for the interpolation polynomial, we find a first example of quadrature
formula
n n n
Z b X ! Z b
(n)
X X
In = f (xi )li (x) dx = f (xi ) li (x)dx = Ai f (xi )
a i=0 i=0 a i=0
where ω(x), x ∈ [a, b] is a given positive function. Consider a set of distinct nodes
xi , i = 0, . . . , n in [a, b]. A quadrature formula is any sum of the kind
n
X
In = αi f (xi ) (1.1)
i=0
using to approximate the integral I. Numbers αi are called weights and xi nodes of
the quadrature formula.
1
2 CHAPTER 1. NUMERICAL INTEGRATION
Note that in the quadrature formula does not appear the function ω(x). Clearly, the
purpose of any quadrature formula is to give good (possible exact) approximations
of I. A way to quantify the goodness of a quadrature formula is throughout the
following definition.
Definition 1.2 (Degree of precision) A quadrature formula has degree of preci-
sion s ∈ N if
• is correct for each polynomial of degree n ≤ s;
• there is at least one polynomial of degree n = s + 1 for which the formula is
not correct (that is, In 6= I).
It is possible to prove the following
Theorem 1.1 The quadrature formula (1.1) has at most degree of precision s =
2n + 1 (obtained for the Gaussian quadrature formulas).
Let’s see how a way, not the best one indeed, to compute the coefficients and the
nodes in order to have the maximum degree of precision.
b−a
xi = a + ih, i = 0, . . . , n with h =
n
We can see an example of 5 nodes (and so n = 4) in the following figure. In this
case, h = (b − a)/4.
Using the Lagrange expression for the interpolating polynomial, it is possible rewrite
the numbers Ani as
Z n Qn
(n) (n) 1 =i (s − r)
Ani = nhCi where Ci = Qr=0,r6
n ds
n 0 r=0,r6=i (i − r)
(n)
where Ci are called the Cotes numbers. The idea of the proof is just change the
integration variable as x = x0 + hs in the integral of li (x).
Note that the Cotes numbers do not depend on the function nor on the integration
interval. So, they may be computed just once.
1 2 (s − 0)(s − 2) 4
Z
(2)
C1 = ds =
2 0 (1 − 0)(1 − 2) 6
Z 2
(2) 1 (s − 0)(s − 1) 1
C2 = ds =
2 0 (2 − 0)(2 − 1) 6
and so we have the Cavalieri-Simpson quadrature formula
2
X (2) b−a 1 4 1
I2 = Ai f (xi ) = f (x0 ) + f (x1 ) + f (x2 )
2 3 3 3
i=0
The previous formulas, as any quadrature formula, are not correct in the general
case, i.e. we have I = In + En where En is the error. Just as an example, we have
Z 1
1 1 (1 − 0)[03 + 13 ]
I= x3 dx = 6= = = I1
0 4 2 2
where we have used the trapezoidal formula. We have the following theorems.
Theorem 1.3 Let f ∈ C 2 ( [a, b] ). The error of the Trapezoidal formula is
(b − a)3 ′′
E1 = − f (ξ)
12
where ξ is a suitable point in [a, b].
From these theorems we see that trapezoidal formula has degree of precision s = 1
whereas Cavalieri-Simpson has s = 3 (with just one more node).
1.2. COMPOSITE NEWTON-COTES FORMULAS 5
In the general case, each interval has length h = (b − a)/m and so we get, using the
additivity of the integral,
Z b m−1
X Z xk+1 m−1
X h[ f (xk ) + f (xk+1 ) ]
f (x)dx = f (x)dx ≈
a 2
k=0 xk k=0
m−1
" #
b−a 1 X 1
= f (x0 ) + f (xk ) + f (xm )
m 2 2
k=1
since each internal point, i.e, for k = 1 to k = m−1, is counted twice. The global error
is the sum of the errors we have in each interval; denoting as E1,k k = 0, . . . , m − 1
the error in the interval Ik = [xk , xk+1 ] , we get
m−1 m−1
X h3 (b − a)3 m−1 ′′
P
k=0 f (ξk )
X
′′
Em = E1,k = − f (ξk ) = − ·m
12 12m3 m
k=0 k=0
(∗) a)3
(b −
= − f ′′ (ξ)
12m3
where ξ is some suitable point inside [a, b]. To state equality (∗) we need the conti-
nuity of f ′′ (x) inside [a, b]; then, we apply the all values theorem since we have
Pm−1 ′′
′′ f (ξk )
min f (x) ≤ k=0 ≤ max f ′′ (x)
x∈[a,b] m x∈[a,b]
6 CHAPTER 1. NUMERICAL INTEGRATION
Remark 1.1 Assuming that f ′′ (x) does not change to much in [a, b], we have the
following behaviour of the error.
(b−a) 3
− 12(2m) ′′
E2m 3 f (ξ2m ) f ′′ (ξ2m ) 1
= (b−a)3 = ′′
≈ .
Em − 12m3 f ′′ (ξm ) 4 · f (ξm ) 4
Thus, doubling the number of points, the error E2m reduces to about Em /4.
Thus, the intervals are now Ik = [x2k , x2k+2 ], k = 0, 1 . . . , m − 1. So, recalling the
Cavalieri-Simpson rule, we obtain
Z b
b−a 1 2 X 4 X 1
f (x)dx ≈ f (x0 ) + f (xk ) + f (xk ) + f (x2m )
a 2m 3 3 3 3
internal internal
even odd
(b − a)5 (4)
Em = − f (ξ)
2880m4
since each one of the m intervals has length (b − a)/m; again, ξ is a suitable point in
[a, b]. As in the previous remark, if f (4) (x) does not change much in [a, b], we have
E2m 1
≈ .
Em 16
Solving for I we get the Richardson extrapolation formula (for the trapezoidal)
4Q2m − Qm
I=
3
1.3. RICHARDSON EXTRAPOLATION 7
In the same way but using composite Cavalieri-Simpson formula, for which it is
E2m /Em ≈ 1/16, we find the Richardson extrapolation formula (for Cavalieri-Simpson)
16Q2m − Qm
I=
15
0 1 A0
1 2 A1 B1
2 4 A2 B2 C2
3 8 A3 B3 C3 D4
4 16 A4 B4 C4 D4 E4
... ... ... ... ... ... ... ...
4Ap − Ap−1
Bp = , p≥1
41 − 1
16Bp − Bp−1
Cp = , p≥2
42 − 1
64Cp − Cp−1
Dp = , p≥3
43 − 1
and so on. It is possible to prove that the best approximation of the integral is on
the right lower side of the table.
4. Using the Richardson extrapolation formula, find the best possible approxima-
tion of the integral and the corresponding error ER = |I − IR |.
6. Find the best possible approximation of the integral using Romberg and m = 4
subdivision of the interval.
h b−a 2−1 1
I1 =
[ f (x0 ) + 4f (x1 ) + f (x2 ) ] , h= = =
3 2 2 2
with nodes xk = x0 + k h and fk = f (xk ) = xk · ln(xk ), k = 0, 1, 2 given by
k 0 1 2
3
xk 1 2 2
3 3
fk 0 2 · ln 2 2 · ln(2)
h5 (1/2)5 2
Emax,1 = · max |f (4) (ξ)| = · 3 ≈ 6.9 · 10−4
90 ξ∈[a,b] 90 1
since f (4) (x) = 2/x3 is a decreasing function in [1, 2] and so has its maximum for
ξ = 1. The real error is
k 0 1 2 3 4
5 6 7
xk 1 4 4 4 2
5 5 3 3 7 7
fk 0 4 · ln 4 2 · ln 2 4 · ln 4 2 · ln(2)
Thus, we get
h
I2 = [f0 + 4 (f1 + f3 ) + 2f2 + f4 ]
3
1/4 5 5 7 7 3 3
= 0+4· · ln + · ln + 2 · · ln + 2 ln(2)
3 4 4 4 4 2 2
≈ 0.6363098298.
Since I1 and I2 are computed using the composite Cavalieri-Simpson formula with
m = 1 and m = 2 we can find a better approximation using Richardson extrapolation:
16 · I2 − I1 16 · 0.6363098298 − 0.6365141683
IR = = ≈ 0.6362962072
15 15
with an error
1 A0
2 A1 B1
4 A2 B2 C2
For the last question, the maximum absolute value of the error using m intervals is
(b − a)5
Emax,m = max |f (4) (ξ)|
2880 m4 ξ∈[a,b]
Thus, we need m = 6.