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

Numerical Integration

Numerical integration, or quadrature, involves approximating the definite integral of a continuous function using interpolation polynomials and distinct nodes. The document discusses various quadrature formulas, including Newton-Cotes formulas and their composite versions, detailing their degrees of precision and error estimates. Examples illustrate the application of these formulas, such as the Trapezoidal and Cavalieri-Simpson rules, along with their respective error bounds.

Uploaded by

Williams Ademola
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Numerical Integration

Numerical integration, or quadrature, involves approximating the definite integral of a continuous function using interpolation polynomials and distinct nodes. The document discusses various quadrature formulas, including Newton-Cotes formulas and their composite versions, detailing their degrees of precision and error estimates. Examples illustrate the application of these formulas, such as the Trapezoidal and Cavalieri-Simpson rules, along with their respective error bounds.

Uploaded by

Williams Ademola
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Chapter 1

Numerical Integration

Numerical integration is also known as numerical quadrature. The problem is to


compute, with a prescribed degree of accuracy, the definite integral
Z b
I= f (x)dx
a

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 we have defined


Z b
(n)
Ai := li (x)dx, i = 0, . . . , n
a

More generally, we give the definition

Definition 1.1 Consider the computation of the integral


Z b
I= ω(x)f (x)dx
a

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.

Example 1.1 Consider the quadrature formula


Z 1√ 1
X
xf (x)dx ≈ αi f (xi )
0 i=0

Since n = 1, the maximum degree of precision is s = 2 · 1 + 1 = 3. So, we can


choose weights and nodes in order to have a formula which gives the correct result
for each polynomial of degree at most 3. Since a quadrature formula is exact for
each polynomial of degree at most n if and only if it is exact for xi , i = 0, . . . , n, we
impose the conditions
Z 1

x · 1 dx = α0 + α1
0
Z 1

x · x dx = α0 x0 + α1 x1
0
Z 1

x · x2 dx = α0 x20 + α1 x21
0
Z 1

x · x3 dx = α0 x30 + α1 x31
0

The solution of this non linear system gives


√ √
5 2 70 1 70
x0 = 9 − 63 α0 = 3 − 150
√ √
5 2 70 1 70
x1 = 9 + 63 α1 = 3 + 150

The quadrature formula is then


Z 1 √ ! √ ! √ ! √ !
√ 1 70 5 2 70 1 70 5 2 70
xf (x)dx ≈ − f − + + f +
0 3 150 9 63 3 150 9 63

which gives the correct result for each f (x) = pn (x), n ≤ 3.


1.1. NEWTON COTES FORMULAS (CLOSED FORM) 3

1.1 Newton Cotes formulas (closed form)


We have these formulas if the n + 1 distinct nodes are equally spaced in [a, b] as

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).

Theorem 1.2 The Cotes numbers fulfill the relation


n
(n)
X
Ci = 1.
i=0

Proof. Just take f (x) = 1, x ∈ [a, b]. In this case, we have


Z b n
Z bX n Z b n n
(n) (n)
X X X
b−a= 1 dx = li (x)dx = li (x)dx = nhCi = (b − a) Ci
a a i=0 i=0 a i=0 i=0

since nh = b − a. The proof is complete. 2

Note that the Cotes numbers do not depend on the function nor on the integration
interval. So, they may be computed just once.

Example 1.2 (Trapezoidal rule) Consider the case n = 1 and so x0 = a, x1 = b,


h = b − a. We have
Z 1 1
s2

(1) s−1 1
C0 = ds = − +s =
0 0−1 2 0 2
Z 1  2 1
(1) s−0 s 1
C1 = ds = =
0 1−0 2 0 2

and so the corresponding quadrature formula is


1  
X (1) 1 1 (b − a)[ f (a) + f (b) ]
I1 = Ai f (xi ) = (b − a) f (x0 ) + f (x1 ) =
2 2 2
i=0
4 CHAPTER 1. NUMERICAL INTEGRATION

So I1 is the area of the trapezoid in the next figure.

Example 1.3 (Cavallieri-Simpson rule) Consider the case n = 2 and so x0 = a,


x1 = (a + b)/2, x2 = b and h = (b − a)/2. We have
1 2 (s − 1)(s − 2) 1
Z
(2)
C0 = ds =
2 0 (0 − 1)(0 − 2) 6

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].

Theorem 1.4 Let f ∈ C 4 ( [a, b] ). The error of the Cavalieri-Simpson formula is


(b − a)5 (4)
E2 = − f (ξ)
2880
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

1.2 Composite Newton-Cotes formulas


It is not a good idea to have an interpolation polynomial of high degree due to
its oscillatory behaviour at the endpoints. It is better to divide the integration
interval [a, b] into m intervals and to apply a Newton-Cotes formula (with a low
degree interpolation polynomial) to each of these intervals. Proceeding in this way
we obtain the composite Newton-Cotes formulas.

1.2.1 Composite trapezoidal formula


The idea is shown in the following figure where m = 4 since [a, b] is divided into 4
intervals. At each interval we apply the trapezoidal rule.

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.

1.2.2 Composite Cavalieri-Simpson formula


Proceeding in the same way, we find the composite Cavalieri-Simpson formula. In
this case, however, each interval has also a point in the middle. The comparison
between the two rules is given in the figure (in both cases we have m = 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

In the same way the error is

(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

1.3 Richardson extrapolation


Consider the composite trapezoidal rule. Assuming that the second derivative does
not change much in the integration interval, we know that E2m /Em ≈ 1/4. Defining
Qm and Q2m approximations with m and 2m intervals, we can write

Qm = I + 4E2m
Q2m = I + Em

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

1.3.1 Romberg method


Setting m = 2p , p = 0, 1, 2, . . . it is possible to obtain a table (a subinterval is of the
kind [xk , xk+1 ])

p number of subintervals 0 1 2 3 4 ...

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
... ... ... ... ... ... ... ...

where Ap are obtained using the composite trapezoidal formula and

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.

Exercise 1.1 Consider the definte integral


Z 2
I= x ln(x) dx.
1

1. Compute by hands the exact value of the integral I.

2. Using Cavalieri-Simpson formula, compute the approximation I1 of the integral;


give the maximum possible error of the approximation and the real error E1 =
|I − I1 |.

3. Using the composite Cavalieri-Simpson with m = 2, compute the approximation


I2 of the integral; give the maximum possible error of the approximation and
the real error E2 = |I − I2 |.

4. Using the Richardson extrapolation formula, find the best possible approxima-
tion of the integral and the corresponding error ER = |I − IR |.

5. Find and justify the ratios


Emax,1 E1
, .
Emax,2 E2
8 CHAPTER 1. NUMERICAL INTEGRATION

6. Find the best possible approximation of the integral using Romberg and m = 4
subdivision of the interval.

7. Find an estimation of the number m of intervals needed to have for sure an


absolute value of the error less then 10−6 .

Answer. Using the integration by parts, we find


2 2 Z 2 2  2
x2 22 12 1 x2

x 1
Z
x ln(x) dx = · ln(x) − · dx = · ln(2) − · ln(1) −
1 2 1 1 2 x 2 2 2 2 1
 2 2

1 2 1 3
= 2 ln(2) − · − = 2 ln(2) − ≈ 0.6362943611
2 2 2 4

since ln(1) = 0. The Cavalieri-Simpson gives

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)

since x0 = a, x2 = b e x1 = (a + b)/2. Thus, we obtain


   
1/2 3 3
I1 = · 0 + 4 · · ln + 2 · ln(2) ≈ 0.6365141683.
3 2 2

The maximum (absolute value of the) error is

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

E1 = |I − I1 | ≈ |0.6362943611 − 0.6365141683| ≈ 2.2 · 10−4 .

Now, take into account the composite Cavalieri-Simpson formula with m = 2.


The distance between consecutive nodes is
1 b−a 2−1 1
h= · = = .
2 m 2·2 4
Setting x0 = a, nodes xk = x0 + k · h and values f (xk ), k = 0, · · · , 2m are
The following figure give also a picture of the nodes.
1.3. RICHARDSON EXTRAPOLATION 9

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.

The maximum error we can have is


(b − a)5 (4) (2 − 1)5 2
Emax,2 = · max |f (ξ)| = · ≈ 4.3 · 10−5
2880 · m4 ξ∈[a,b] 2880 · 24 13
whereas the real error we have is

E2 = |I − I2 | ≈ |0.6362943611 − 0.6363098298| ≈ 1.5 · 10−5 .

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

ER = |I − IR | = |0.6362943611 − 0.6362962072| ≈ 1.8 · 10−6 .

The ratios between maximum errors and real errors are


Emax,1 6.9 · 10−4 E1 2.2 · 10−4
= ≈ 16.0, = ≈ 14.7
Emax,2 4.3 · 10−5 E2 1.5 · 10−5
as expected, since the ratio between maximum error is exactly 16 whereas the other
ratio depends also on the ratio of the derivative in two distinct points. Finally,
Romberg method gives

1 A0
2 A1 B1
4 A2 B2 C2

where B1 = I1 = 0.6365141683 and B2 = I2 = 0.6363098298. So the best approxi-


mation for the integral is
16B2 − B1
IRG = C2 = = IR
15
10 CHAPTER 1. NUMERICAL INTEGRATION

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]

So, requiring that Emax,m < ǫ with ǫ = 10−6 we find


s r
(b − a)5 (2 − 1)5 2
4
m> 4 max |f (4) (ξ)| = −6
· 3 ≈ 5.1
2880 ǫ ξ∈[a,b] 2880 · 10 1

Thus, we need m = 6.

You might also like