0% found this document useful (0 votes)
87 views

Numerical Integration

The document discusses numerical integration methods. It introduces the concepts of quadrature and three procedures for finding quadratures: geometric arguments, interpolation, and setting degree of exactness. Specific methods are then described, including the rectangle method, composite rectangle method, midpoint method, and composite midpoint method. These numerical methods approximate integrals by dividing the interval into subintervals and applying simple integration rules over each subinterval.

Uploaded by

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

Numerical Integration

The document discusses numerical integration methods. It introduces the concepts of quadrature and three procedures for finding quadratures: geometric arguments, interpolation, and setting degree of exactness. Specific methods are then described, including the rectangle method, composite rectangle method, midpoint method, and composite midpoint method. These numerical methods approximate integrals by dividing the interval into subintervals and applying simple integration rules over each subinterval.

Uploaded by

Sangram Bhosale
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

Numerical Integration

Motivation. We have learned how to calculate some integrals analytically; such as


∫ 1 [ ]
2 1 3 1 1
x dx = x =
0 3 0 3
∫4
e−x dx , cannot be calculate analytically. In this chapter we
2
But most integrals , e.g. 1

introduce several methods for approximating integrals.

A numerical integration formula is called a quadrature.

We employ three procedures to find quadratures:




 geometric arguments


interpolation



 setting degree of exactness

∫b
A quadrature for a f (x)dx uses some points of the interval [a, b] to approximate this integral.
For example:
a+b
midpoint method f( )(b − a)
2
b − a[ a+b ]
Simpson method f (a) + 4f ( ) + f (b)
6 2
a+b
The midpoint method uses the point 2 and the Simpson method uses the points
{a , a+b
2 , b} to approximate the true integral. The Simpson method uses the endpoints a and
b; therefore it is called a closed method. On the other hand, the midpoint rule is called an
open method because it does not use the endpoints a and b.

1
1 Rectangle and Midpoint methods (some one-point methods)
(from section 9.2)

In this method , the area under a curve y = f (x) is approximated by the rectangle with one
side being the interval [a, b] and the other side being f (a) , as shown in the following figure.

f(a)

a b

So , in this method we approximate:


∫ b
f (x)dx ≈ (b − a)f (a)
a

Usually a better approximation is found if we divide the interval [a, b] into a few subintervals
b−a
of equal length, n subintervals each with length h = n :

b−a
a = x1 < x2 < · · · < xn < xn+1 xi+1 − xi = , i = 1, ..., n
n

we may denote this common length by h:

b−a
h=
n

2
and then apply the rectangle rule to each subinterval :
∫ x2
f (x)dx ≈ (x2 − x1 )f (x1 ) = h f (x1 )
x1

Similarly :
∫ x3
f (x)dx ≈ (x3 − x2 )f (x2 ) = h f (x2 )
x2

and so on , and on the last subinterval we will have:


∫ xn+1
f (x)dx ≈ (xn+1 − xn )f (xn ) = h f (xn )
xn

Adding up these values gives:


∫ x2 ∫ x3 ∫ xn+1
f (x)dx + f (x)dx + · · · + f (x)dx ≈ h f (x1 ) + h f (x2 ) + · · · + h f (xn )
x1 x2 xn

equivalently:
∫ b { }
f (x)dx ≈ h f (x1 ) + · · · + f (xn )
a

This quadrature is called the composite rectangle method

Example (from exercise 1 of the textbook). The following values of a function f are
given:

x 0 0.3 0.6 0.9 1.2 1.5 1.8


f(x) 0.5 0.6 0.8 1.3 2 3.2 4.8
∫ 1.8
Use the composite rectangle method to approximate the integral 0 f (x)dx

Solution.

The step size h = 0.3 .

∫ 1.8 { }
0 f (x)dx ≈ h f (0) + f (0.3) + f (0.6) + f (0.9) + f (1.2) + f (1.5)

= (0.3){0.5 + 0.6 + 0.8 + 1.3 + 2 + 3.2} = 2.52

3
The next method in this section is the midpoint method. In this method we approximate
the under-the-curve area with the area of the triangle with the length of one side being b − a
and the length of the other side being f ( a+b
2 ).

f ( a+b
2 )

a a+b b
2

∫ b
f (x)dx ≈ (b − a)f (a)
a

Usually a better approximation is found if we divide the interval [a, b] into a few subintervals
b−a
of equal length, n subintervals each with length h = n :

b−a
a = x1 < x2 < · · · < xx < xn+1 xi+1 − xi = i = 1, ..., n
n

we may denote this common length by h:

b−a
h=
n

and then apply the midpoint rule to each subinterval :


∫ x2
x1 + x2 x1 + x2
f (x)dx ≈ (x2 − x1 )f ( ) = h f( )
x1 2 2

4
Similarly :
∫ x3
x2 + x3 x2 + x3
f (x)dx ≈ (x3 − x2 )f ( ) = h f( )
x2 2 2
and so on , and on the last subinterval we will have:
∫ xn+1
xn−1 + xn xn−1 + xn
f (x)dx ≈ (xn+1 − xn )f ( ) = h f( )
xn 2 2

Adding up these values gives:


∫ x2 ∫ x3 ∫ xn+1
x1 + x2 x2 + x3 xn−1 + xn
f (x)dx+ f (x)dx+· · ·+ f (x)dx ≈ h f ( )+h f ( )+· · ·+h f ( )
x1 x2 xn 2 2 2

equivalently:
∫ { }
b
x1 + x2 xn−1 + xn b−a
f (x)dx ≈ h f ( ) + · · · + f( ) h= step size
a 2 2 n

This quadrature is called the composite midpoint method. This is an example of an open
method.
∫ 1
2
Example . Approximate the integral ex dx using the composite midpoint rule with step
0
b−a 1
size h = 10 = 10 = 0.1

Solution.

Set f (x) = exp(x2 ). The nodes corresponding to h = 0.1 are

0 , 0.1 , 0.2 , · · · , 0.9 , 1

∫1 { }
0 f (x)dx ≈ h f (0.05) + · · · + f (0.15) + · · · + f (0.95)

{ }
= (0.1) exp(0.052 ) + exp(0.152 ) + exp(0.852 ) + exp(0.952 )

= 1.4604

5
Figure 1 of the Trapezoidal Method

f(b)

f(a)

a b

The next method we learn is the trapezoidal method. In this method we approximate the
under-the-curve area with the area of the trapezoid as shown in the figure 1 below.

The trapezoid has the bases of lengths f (a) and f (b) and has height b − a, therefore its area is
[ ]
1
2 (b − a) f (a) + f (b) . This is the value we use to approximate the area under the curve. So
we approximate:
∫ b
b − a[ ]
f (x)dx ≈ f (a) + f (b)
a 2

Question: What is the trapezoidal method on [0 , 1] ?

Answer:
∫ 1
1[ ] 1 1
f (x)dx ≈
f (0) + f (1) = f (0) + f (1)
0 2 2 2
Usually a better approximation is found if we divide the interval [a, b] into a few subintervals
and then apply the trapezoidal method to each subinterval.
b−a
We actually divide the interval [a, b] into n subintervals each with length n :

b−a
a = x1 < x2 < · · · < xn < xn+1 xi+1 − xi = , i = 1, ..., n
n

6
Figure 2 of the Trapezoidal Method

x2 x3 xn xn+1

we may denote this common length by h and we call it the step size:

b−a
h=
n

Then on the subintervals we have the following approximations; see Figure 2 below:
∫ x2
x2 − x1 [ ] h[ ]
f (x)dx ≈ f (x1 ) + f (x2 ) = f (x1 ) + f (x2 )
x1 2 2

and
∫ x3
x3 − x2 [ ] h[ ]
f (x)dx ≈ f (x2 ) + f (x3 ) = f (x2 ) + f (x3 )
x2 2 2
and so on , and on the last subinterval we will have:
∫ xn+1
xn+1 − xn [ ] h[ ]
f (x)dx ≈ f (xn ) + f (xn+1 ) = f (xn ) + f (xn+1 )
xn 2 2

Adding up these values gives:


∫ x2 ∫ x3 ∫ xn+1 [ ]
x1 f (x)dx + x2 f (x)dx + · · · + xn f (x)dx ≈ h
2 f (x1 ) + 2 f (x2 ) + · · · + 2f (xn ) + f (xn+1 )

[ ]
= h
2 f (a) + 2 f (x2 ) + · · · + 2f (xn ) + f (b)

7
so
∫ b
h[ ]
f (x)dx ≈ f (a) + 2f (x1 ) + · · · + 2f (xn ) + f (b)
a 2

or equivalently, as written in the textbook:


∫ b
h[ ] { }
f (x)dx ≈ f (a) + f (b) + h f (x1 ) + · · · + f (xn )
a 2

This quadrature is called the Composite Trapezoidal Method

Example (from exercise 1 of the textbook). The following values of a function f are
given:

x 0 0.3 0.6 0.9 1.2 1.5 1.8


f(x) 0.5 0.6 0.8 1.3 2 3.2 4.8
∫ 1.8
Use the composite rectangle method to approximate the integral 0 f (x)dx

Solution.

The step size h = 0.3 .

∫ 1.8 { }
0 f (x)dx ≈ h
2 f (0) + 2f (0.3) + 2f (0.6) + 2f (0.9) + 2f (1.2) + 2f (1.5) + f (1.8)

{ }
= (0.15) (0.5) + 2(0.6) + 2(0.8) + 2(1.3) + 2(2) + 2(3.2) + (4.8)

= 3.1650

compare this value with the approximate value we found from the composite rectangle
method.

8
2 Numerical Integration Using Interpolating Polynomials

One method of approximating integrals is by use of interpolating polynomials. Indeed, if p(x)


is the interpolating polynomial of a function f (x) at some distinct nodes {x1 , ... , xn } from
∫b ∫b
the interval [a, b], then we may approximate the integral a f (x)dx by a p(x)dx which is
easily calculated as p(x) is a polynomial.

Example. The following data of a function f is given:

x 2 4 5 7
f(x) 5 -5 -40 10
∫7
By finding the interpolation polynomial, estimate the integral 2 f (x)dx.

cm
Solution.

xk f [ ] = f () f[ , ] f[ , , ] f[ , , , ]
2 5
−5−5
4−2 = −5
−35−(−5)
4 -5 5−2 = −10
−40−(−5) 20−(−10)
5−4 = −35 7−2 =6
25−(−35)
5 -40 7−4 = 20
10−(−40)
7−5 = 25
7 10

and then

p(x) = 5 − 5(x − 2) − 10(x − 2)(x − 4) + 6(x − 2)(x − 4)(x − 5)

Collecting terms gives:

9
p(x) = 6x3 − 76x2 + 283x − 305

Then:
∫ 7 ∫ 7 ∫ 7
f (x)dx ≈ p(x)dx = (6x3 − 76x2 + 283x − 305)dx
2 2 2

[ ]x=7
6 4 76 3 283 2 200
= x − x + x − 305x = −
4 3 2 x=2 3

We saw in the preceding sections how to create some numerical quadratures base some logic.
For example, the trapezoidal method on the interval [0, 1] is
∫ 1
1 1
f (x)dx = f (0) + f (1)
0 2 2

Example. Find the quadrature Af (a) + Bf (b) using two nodes {a , b} for approximating the
∫b
integral a f (x)dx.

Solution.

xk f [ ] = f () f[ , ]
a f(a)
f (b)−f (a)
b−a

b f(b)

The interpolating polynomial:

f (b) − f (a)
p(x) = f (a) + (x − a)
b−a

Now use this polynomial to approximate the integral of the function f :

10
∫b ∫b ∫b ∫b
a
f (x)dx ≈ a
p(x)dx = a
f (a)dx + f (b)−f (a)
b−a a
(x − a)dx

[ ]x=b
= f (a)(b − a) + f (b)−f (a)
b−a
1
2
(x − a)2
x=a

= f (a)(b − a) + f (b)−f (a) 1


b−a 2
(b − a)2

= f (a)(b − a) + 12 [f (b) − f (a)](b − a)

b−a
= 2
[f (a) + f (b)]

But this is the trapezoidal method for the nodes {a , b} !. This discussion in here substitutes
the discussion that appears in the textbook from the beginning of section 9.3 up to the
beginning of section 9.3.1.

Example. Find the quadrature using the nodes {a , a+b


2 , b} for approximating the integral
∫b
a f (x)dx.

Solution. The discussion involving two nodes we just had seems to be more complicated if we
have three nodes. Therefore we break the solution into two steps:

Step 1. We first solve the problem for simple case of three notes {−1 , 0 , 1} and the integral
∫1
−1 f (x) dx. Then we deal with the general case.

xk f [ ] = f () f[ , ] f[ , , ]
-1 f (−1)
f (0)−f (−1)
0−(−1)

0 f (0) ???
f (1)−f (0)
1−0

1 f (1)

11
Simplify and continue:

xk f [ ] = f () f[ , ] f[ , , ]
-1 f (−1)
f (0) − f (−1)
( ) ( )
f (1)−f (0) − f (0)−f (−1)
0 f (0) 1−(−1)

f (1) − f (0)
1 f (1)

Simplify:

xk f [ ] = f () f[ , ] f[ , , ]
-1 f (−1)
B = f (0) − f (−1)
{ }
0 f (0) C= 1
2 f (1) − 2f (0) + f (−1)
f (1) − f (0)
1 f (1)

The interpolating polynomial:

p(x) = f (−1) + B(x + 1) + C(x + 1)(x − 0)


= f (−1) + B(x + 1) + C(x + 1)x
= {f (−1) + B} + (B + C)x + Cx2
= f (0) + (B + C)x + Cx2

Approximate:
∫ ∫ [
1 1
B + C 2 C 3 ]1 C
f (x) dx ≈ p(x) dx = f (0) x + x + x = 2 f (0) + 2
−1 −1 2 3 −1 3

12
1{ } 1{ }
= 2 f (0) + f (1) − 2f (0) + f (−1) = f (1) + 4f (0) + f (−1)
3 3

So we have got the approximation:


∫ 1
1{ }
f (x) dx ≈ f (1) + 4f (0) + f (−1)
−1 3
∫b
Step 2 (the general case). Now we deal with the general case of approximating a f (x) dx
by using a formula that would involve the nodes {a , a+b
2 , b}. We first do a transformation
and define a function g on [−1 , 1] through:
( )
a+b b−a
g(t) = f +t
2 2

a+b
By putting x = 2 + t b−a
2 we have dx =
b−a
2 dt equivalently dt = 2
b−a dx , and so through
change of variable in integration we can write:
∫ ∫ ∫ ∫
1
2 b b
b−a 1
g(t) dt = f (x) dx ⇒ f (x) dx = g(t) dt
−1 b−a a a 2 −1

Then from the approximating formula we found for the functions on interval [−1 , 1] we can
write:
∫ ∫
b
b−a 1
b − a{1{ }}
f (x) dx = g(t) dt ≈ g(1) + 4g(0) + g(−1)
a 2 −1 2 3

b − a{ } b − a{ a+b }
= g(1) + 4g(0) + g(−1) = f (a) + 4f ( ) + f (b)
6 6 2

So:

∫b { }
a
f (x) dx ≈ b−a
6
a+b
f (a) + 4f ( 2 ) + f (b)

13
3 Finding Quadratures By Means of Setting Degree of
Exactness

Example. Find a, b, and c such that the approximation


∫ 2
f (x)dx ≈ af (0) + bf (1) + cf (2)
0

is exact for polynomials of degree less than or equal to 2.

Solution. We force the above approximation to be exact for the polynomials 1 , x , x2 :


∫ 2
af (0) + bf (1) + cf (2) = f (x) dx for f (x) = 1 , f (x) = x , f (x) = x2
0

 ∫ 2



 f (x) = 1 ⇒ a + b + c = (1)dx = 2 (1)




0



 ∫ 2
 [ 1 ]2
f (x) = x ⇒ 0 + b + 2c = (x)dx = x2 = 2 (2)

 2 0


0





 ∫ 2 [ 1 ]2 8


 f (x) = x2 ⇒ 0 + b + 4c = (x2 )dx = x3 = (3)
0 3 0 3

From (2) we have:

b = 2 − 2c

We put this value of b into equality (3) to get:

8 8
(2 − 2c) + 4c = ⇒ 2 + 2c = ⇒ c= 1
3
3 3

2 4
⇒ b = 2 − 2c = 2 − = ⇒ b= 4
3
3 3

14
By putting these values of b and c into equality (1) we get:

4 1 1
a=2−b−c=2− − = ⇒ a= 1
3
3 3 3

So:

∫ 2
1 4 1
f (x)dx ≈ f (0) + f (1) + f (2) ✓
0 3 3 3

Example. Find A, B, such that the approximation


∫ 1
f (x) dx ≈ A f (−1) + B f (0) + C f ′ (1)
−1

is exact for polynomials of degree less than or equal to 2.

Solution. We force the above approximation to be exact for the polynomials 1 , x , x2 :


∫ 1

A f (−1) + B f (0) + C f (1) = f (x) dx for f (x) = 1 , f (x) = x , f (x) = x2
−1

 ∫1

 f (x) = 1 ⇒ A + B + 0 = −1 (1)dx = 2








 ∫1 [ ]1
f (x) = x ⇒ −A + 0 + C = −1 (x)dx = 21 x2 =0

 −1





 [ ]1

 ∫2 2
 f (x) = x2 ⇒ A + 0 + 2C = (x )dx = 1 3
x = 23
0 3 −1

15


 A+B = 2 (1)








−A + C = 0 (2)









 A + 2C = 2
3 (3)

Solving this system, one gets:

2 16 2
A= B= C=
9 9 9

16
4 The Simpson’s Methods

(section 9.4)

The quadrature

∫b { }
a
f (x) dx ≈ b−a
6
f (a) + 4f ( a+b
2
) + f (b)

is called the Simpson’s 13 -Method. The name “ 13 -Method” comes from this: In this
discussion, the nodes are {a , a+b
2 , b}, so each step is worth h = b−a
2 , and by putting h for b−a
2

in the recently found formula, we get

∫b { }
a
f (x) dx ≈ h
3
f (a) + 4f ( a+b
2
) + f (b) , h= b−a
2

Now we seek a composite form of this method. In the composite method we first divide the
b−a
interval [a, b] into an even number 2n if subintervals all of equal length h = 2n (step size);
the endpoints of the intervals are:

a = x1 , x2 , x3 , x4 , x5 , · · · , x2n−1 , x2n , x2n+1

Then on each pair of subintervals we approximate:


∫ x3
h[ ]
f (x)dx ≈ f (x1 ) + 4f (x2 ) + f (x3 )
x1 3
∫ x5
h[ ]
f (x)dx ≈ f (x3 ) + 4f (x4 ) + f (x5 )
x3 3

..
.
∫ x2n+1
h[ ]
f (x)dx ≈ f (x2n−3 ) + 4f (x2n−2 ) + f (x2n−1 )
x2n−1 3
∫ x2n+1
h[ ]
f (x)dx ≈ f (x2n−1 ) + 4f (x2n ) + f (x2n+1 )
x2n−1 3

17
∫b
Adding up these values, one gets an approximation for a f (x) dx by the following expression:

h[ ]
f (x1 ) + +4f (x2 ) + 2f (x3 ) + 4f (x4 ) + 2f (x5 ) + · · · + 2f (x2n−1 ) + 4f (x2n ) + f (x2n+1 )
3

But as x1 = a and x2n+1 = b, we equivalently get the approximation:

∫b [ ]
a f (x)dx ≈ h
3 f (a) + 4f (x2 ) + 2f (x3 ) + 4f (x4 ) + 2f (x5 ) + · · · + 2f (x2n−1 ) + 4f (x2n ) + f (b)

This method for approximating integrals is called the Composite Simpson’s 13 -Method. In
this formula, and every method we have seen so far, h is the step size and is equal to the
common length of the subintervals.

Example . The following values of a function f are given:

x -18 -12 -6 0 6 12 18
f(x) 0 2.6 3.2 4.8 5.6 6 6.2
∫ 18
Use the composite rectangle method to approximate the integral −18 f (x) dx

Solution. Since the number of nodes is even and the subintervals are of equal length, we can
apply the composite Simpson’s 13 -Method. We have h = 6. Then

∫ 18 [ ]
−18 f (x) dx ≈
h
3 f (x1 ) + 4f (x2 ) + 2f (x3 ) + 4f (x4 ) + 2f (x5 ) + 4f (x6 ) + f (x7 )

[ ]
6
= 3 (0) + 4(2.6) + 2(3.2) + 4(4.8) + 2(5.6) + 4(6) + (6.2) = 154.8

Example . Find a quadrature


∫ 3
f (x) dx ≈ A f (0) + B f (1) + C f (2) + D f (3)
0

that is exact for polynomials of degree less than or equal to 3.

Solution . We force the above approximation to be exact for the polynomials 1 , x , x2 , and
x3 :

18
∫ 3
A f (0) + B f (1) + C f (2) + D f (3) = f (x) dx for f (x) = 1 , f (x) = x , f (x) =
0
x2 , f (x) = x3
 ∫ 3

 f (x) = 1 ⇒ A + B + C + D =

 (1)dx = 3

 0





 ∫ 3

 [ 1 ]3 9



 f (x) = x ⇒ 0 + B + 2C + 3D = (x)dx = x2 =

 0 2 0 2


 ∫ 3 [ 1 ]3



 2
⇒ 2
x3 = 9


f (x) = x 0 + B + 4C + 9D = (x )dx =

 0 3 0





 ∫ 3

 [ 1 ]3 81

 f (x) = x3 ⇒ 0 + B + 8C + 27D = (x3 )dx = x4 =
0 4 0 4

In summary, we get the following system:




 A+B+C +D = 3 (1)











 B + 2C + 3D = 92 (2)







 B + 4C + 9D = 9 (3)









 81
B + 8C + 27D = 4 (4)

Note . If one takes a quadrature


∫ 3
f (x) dx ≈ A f (0) + B f (1) + C f (2) + D f (3)
0

and imposes the condition that the formula be exact for the polynomials with degree less than
or equal to 3, then one gets these values:
3 9 9 3
A= B= C= D=
8 8 8 8

Solve for A, B, C, and D ⇒ A= 3


8 , B= 9
8 , C= 9
8 , D= 3
8

19
so the quadrature becomes
∫ 3
3 9 9 3 3[ ]
f (x) dx ≈ f (0) + f (1) + f (2) + f (3) = f (0) + 3f (1) + 3f (2) + f (3)
0 8 8 8 8 8

By use of transformation, we can find a formula on any interval [a , b]. In fact, one must
divide this interval into 3 subintervals each of length h, and then a transformation will change
the above formula to this formula over [a , b]:
∫ 3
3 [ ]
f (x) dx ≈ h f (a) + 3f (x2 ) + 3f (x3 ) + f (b)
0 8
∫b
Now let’s transform this quadrature to a quadrature on an arbitrary integral a f (x)dx.
Correspondingly we divide the interval [a, b] into three subintervals of equal length. For this
we need the nodes:
2a + b a + 2b
a , x1 = , x2 = , b
3 3

b−a
The step size is h = 3 . Now to transform this “old” interval to the “new” interval [0, 3] we
do the transformation

(x − a) × (length of new interval)  t = 3(x−a)
b−a
t= ⇒
length of old interval  dt = 3 dx
b−a

Then, corresponding to the function f on [a, b] we define a function g on [0, 3] via

g(t) = f (x)

∫ ∫ ( ) ∫ ∫
b 3
b−a b−a 3 3
f (x) dx = g(t) dt = g(t)dt = h g(t)dt ≈
a 0 3 3 0 0

3 [ ] 3 [ ]
≈ h( ) g(0) + 3g(1) + 3g(2) + g(3) = h f (a) + 3f (x1 ) + 3f (x2 ) + f (b)
8 8

So:

∫b [ ]
a f (x)dx ≈ 3
8 h f (a) + 3f (x1 ) + 3f (x2 ) + f (b)

20
This method for approximating integrals is called the Simpson’s 38 -Method. In this formula,
and every method we have seen so far, h is the step size and is equal to the common length of
the subintervals.
∫ 2.3
(x2 − 1)e−x dx
2
Example . Use the Simpson’s 38 -Method to approximate the integral
−1.2

Solution .

2.3−(−1.2)
Each step size is 3 = 1.667. So the nodes are:

−1.2 , −0.0333 , 1.1333 , 2.3



 f (−1.2) = 0.1042




 f (−0.0333) = −0.9978
f (x) = (x2 − 1)e−x
2




 f (1.1333) = 0.0787


 f (2.3) = 0.0216

Then:

∫ 2.3
3 [ ]
(x2 − 1)e−x dx ≈
2
h f (a) + 3f (x1 ) + 3f (x2 ) + f (b)
−1.2 8

3 [ ]
= h f (−1.2) + 3f (−0.0333) + 3f (1.1333) + f (2.3)
8

3 [ ]
= ( )(1.667) (0.1042) + 3(−0.9978) + 3(0.0787) + (0.0216) = −1.6450
8

The Composite Simpson’s 38 -Method is this :

∫b [ ∑ ∑ ]
a f (x)dx ≈ 3
8 h f (a) + 3 [f (xi ) + f (xi+1 )] + 2 f (xi ) + f (b)
i=2 , 5 , 8 , ... i=4 , 7 , 10 , ...

Note . This formula is good if you want to write a Matlab code.

Example . Write the Composite Simpson’s 38 -Method for the interval [0 , 15] if we divide this

21
interval into 15 subintervals ((note that for the 38 -method the number of subintervals must be
a multiple of 3).

b−a 15
Solution . The step size is h = 15 = 15 = 1. So , the nodes are:

0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15

These points are the points


x1 , x2 , · · · , x16

So,

3 { } 3 { }
h f (0) + 3f (1) + 3f (2) + f (3) + h f (3) + 3f (4) + 3f (5) + f (6)
8 8

3 { } 3 { }
+ h f (6) + 3f (7) + 3f (8) + f (9) + h f (9) + 3f (10) + 3f (11) + f (12)
8 8

3 { }
+ h f (12) + 3f (13) + 3f (14) + f (15)
8

which due to h = 1, it simplifies to :

3{
f (0) + 3f (1) + 3f (2) + 2f (3) + 3f (4) + 3f (5) + 2f (6) + 3f (7)
8 }
+3f (8) + 2f (9) + 3f (10) + 3f (11) + 2f (12) + 3f (13) + 3f (14) + f (15)

22
5 Romberg Integration

(section 9.10)

Consider a composite model, e.g. the composite trapezoidal method or a composite Simpson
method. You may want to know what step size h , which is the length of each subinterval,
gives a better approximation. Do we get better approximation if h is small?. The following
order of convergence can be verified for the composite methods but an exact analysis requires
some advanced knowledge of Calculus , so we skip it.

Composite Method Order of Convergence


composite midpoint method O(h2 )
composite trapezoidal method O(h2 )
composite Simpson’s 13 -method O(h4 )
composite Simpson’s 38 -method O(h4 )

Let us study the composite trapezoidal method :


∫ b
h[ ] { }
f (x)dx = f (a) + f (b) + h f (x1 ) + · · · + f (xn ) +O(h2 )
a |2 {z }
D(h)
∫ b
f (x)dx = D(h) + O(h2 )
a
In more advanced courses of Numerical Analysis it is shown that there are some constants γ1 ,
γ2 ,..., not depending on h such that
∫ b
f (x)dx = D(h) + γ1 h2 + γ2 h4 + γ3 h6 + · · ·
a

We can improve the composite trapezoidal method by applying the extrapolation technique:
1{ h }
4 D( ) − D(h)
3 2
This gets rid of the term h2 and we will have
∫ b
1{ h }
f (x)dx = 4 D( ) − D(h) + γ2′ h4 + γ3′ h6 + · · ·
a 3 2

23
with some new constants γ2′ , γ3′ , ...

Now let us divide the interval [a, b] in to n, 2n, 4n , ... number of subintervals, and calculate
the composite trapezoidal approximation for each. Put the approximate values in the first
column and call them I1,1 , I2,1 , I3,1 , ... , as shown below:

# of subintervals composite trapezoidal


n I1,1

2n I2,1

4n I3,1

8n I4,1

Note that I1,1 is the composite trapezoidal approximation corresponding to some initial step
b−a
size h0 = n while I2,1 is the composite trapezoidal approximation corresponding to the step
h0 b−a
size 2 = 2n ; so if I1,1 is denoted by D(h), then I2,1 is actually D( h2 ). But we recall from the
extrapolation method that in order to get an improved approximate value, we must take the
{ } { }
combination 13 4 D( h2 ) − D(h) , which is 13 4 I2,1 − I1,1 . Indeed, to improve the values Ii,1
{ }
of the first column, one should form the combinations 31 4 Ii+1,1 − Ii,1 . We denote these
combinations by Ii,2 :
1{ }
Ii,2 = 4 Ii+1,1 − Ii,1
3
We put these values in the second column:

24
step size composite trapezoidal
h0 I1,1
I1,2
h0
2 I2,1
I2,2
h0
4 I3,1
I3,2
h0
8 I4,1

The values of the first column, which are some composite trapezoidal values, are of order
O(h2 ). The improved values, which are in the second column, are of order O(h4 ). To improve
the values of the second column we must employ an extrapolation technique for improving
O(h4 ) methods. Generally, as we have learned before, to improve a method D(h) of order
{ }
O(hm ) we must take the combination 4m1−1 4m D( h2 ) − D(h) . Therefore to improve the
values of the second column, we take the combinations

1 { 4 } 1 { 2 }
2 I i+1,2 − I i,2 = 4 Ii+1,2 − Ii,2
24 − 1 42 − 1

We denote these values by Ii,3 and put them in the third column:

1 { 2 }
Ii,3 = 4 I i+1,2 − Ii,2
42 − 1

composite
step size trapezoidal
h0 I1,1
I1,2
h0
2 I2,1 I1,3
I2,2
h0
4 I3,1 I2,3
I3,2
h0
8 I4,1

25
As you guess, the elements in the next column are form from:

1 { 3 }
Ii,4 = 4 I i+1,3 − Ii,3
43 − 1

composite
step size trapezoidal
h0 I1,1
I1,2
h0
2 I2,1 I1,3
I2,2 I1,4
h0
4 I3,1 I2,3
I3,2
h0
8 I4,1

and in general if we want to construct the elements of the j-th column , we use the formula:

1 { }
Ii , j = 4j−1 Ii+1 , j−1 − Ii , j−1
4j−1 − 1

In Matlab, due to format of arrays, we put them in this order:

composite
step size trapezoidal
h0 I1,1 I1,2 I1,3 I1,4

h0
2 I2,1 I2,2 I2,3

h0
4 I3,1 I3,2

h0
8 I4,1

26
∫π
Example. Here we approximate the integral 0 sin x dx using the Romberg Integration
technique. The true value of this integral is 2. We start with h0 = π as the initial step size.

h Ii,1 Ii,2 Ii,3 Ii,4 Ii,5 Ii,6


π=3.1416 0.00000000 0.95221404 2.37929775 1.97462375 2.00040288 1.99999842
π
2 =1.5708 0.71416053 A=2.29010502 C=1.98094678 2.00030218 1.99999882
π
4 =0.7854 1.89611890 B=2.00026917 1.99999975 2.00000000
π
8 =0.3927 1.97423160 2.00001659 2.00000000
π
16 =0.1963 1.99357034 2.00000103
π
32 =0.0982 1.99839336

42 B − A 16B − A
C= =
42 − 1 15

27
6 Integrals With Singularities

(section 9.11.1)
∫b
Definition . A singularity for an integral f (x)dx is a point in the interval at which the
a
∫1 1
function f is undefined. For example, in the integral −1 |x| dx the integrand is not defined at
x = 0, so the point x = 0 is considered as a singularity for the integral. The point x = 1 is a
∫3
singularity for the integral 1 √ 1 2 . Some of such integrals are convergent, meaning that
(x−1)
∫3
the value of the integral exists, and some are divergent. For example, the integral 1 √ 1 2
(x−1)
∫1 1
is convergent and the integral −1 |x| dx is divergent. Numerical procedures can be applied to
evaluate the values of the convergent integrals. To evaluate the value of the integrals such as
∫1 1
−1
√ dx where the singularity is an interior point, one must split he integral into two parts
|x|
such that the singularity appear at one endpoint; so we write
∫ 1 ∫ 0 ∫ 1
1 1 1
√ dx = √ dx + √ dx
−1 |x| −1 |x| 0 |x|

So we are always able to put a singularity at one of the endpoints. Let us now see how to deal
∫3
with an integral such as 1 √ 1 2 in which the singularity is at one of the endpoints. For
(x−1)
such integral we use an “Open Method” such as the composite midpoint method. For example
4−1
we may split the interval [1, 4] into 10 subintervals with step size h = 10 = 0.3 using these
nodes :
1 , 1.3 , 1.6 , 1.9 , 2.2 , 2.5 , 2.8 , 3.1 , 3.4 , 3.7 , 4

Now on each subinterval take the midpoint; here are the midpoints:

1.15 , 1.45 , 1.75 , 2.05 , 2.35 , 2.65 , 2.95 , 3.25 , 3.55 , 3.85

∫ 3
1
√ ≈
1 (x − 1)2
{ }
h f (1.15)+f (1.45)+f (1.75)+f (2.05)+f (2.35)+f (2.65)+f (2.95)+f (3.25)+f (3.55)+f (3.85)

28
{
= 0.3 (44.4444) + (4.9383) + (1.7778) + (0.9070) + (0.5487) + (0.3673) + (0.2630) + (0.1975) +
}
(0.1538) + (0.1231) = 16.1163

7 Integrals With Unbounded Limits

(section 9.11.2)
∫b ∫∞ ∫ +∞
Integrals of the forms −∞ f (x)dx and I = a f (x)dx and −∞ f (x)dx can be evaluated
either of the following method:

∫∞
For example to evaluate the integral 0 e−x dx we may first approximate it with an integral
2

∫ M −x2 ∫M
dx where M is large, and then apply one the methods of this chapter to 0 e−x dx.
2
0 e

For example
∫ ∞ ∫ 10
−x2
e−x dx = using the trapezoidal method with h=0.5 = 0.8862
2
e dx ≈
0 0

29
8 Solving Double Integrals Numerically

∫b∫d ∫ b [∫ d ]
Consider a double integral I = a c f (x, y)dxdy = a c f (x, y)dy dx. We may, for
example, apply the trapezoidal rule on the variable y first and then on the variable x to write:
∫ b [∫ d ]
I = f (x, y)dy dx
a c

∫ b{ ]}
d − c[
≈ f (x, c) + f (x, d) dx
a 2


d−c b
= [f (x, c) + f (x, d)]}dx
2 a

{∫ ∫ }
d−c b b
= f (x, c)dx + f (x, d)dx
2 a a

d − c{b − a{ } b − a{ }}
≈ f (a, c) + f (b, c) + f (a, d) + f (b, d)
2 2 2

b − a d − c{ }
= f (a, c) + f (b, c) + f (a, d) + f (b, d)
2 2

{ }
hk
= 4 f (a, c) + f (b, c) + f (a, d) + f (b, d) h and k are step sizes

30


 f11 = f (a, c)




 f1,2 = f (b, c)
If we denote the four values by , then we rewrite:



 f2,1 = f (b, d)


 f = f (a, d)
2,2

hk{ }
I≈ f1,1 + f1,2 + f2,1 + f2,2
4

In the following figure you see the coefficients of these terms.

b−a
Now if you want to use a composite trapezoidal on both x and y, with step sizes h = 3 and
d−c
k= 2 for example, then the coefficients are as follows:

hk { }
{f11 + 2f12 + 2f13 + f14 } + 2{f21 + 2f22 + 2f23 + f24 } + {f31 + 2f32 + 2f33 + f34 }
4

hk { }
= {f11 + 2f12 + 2f13 + f14 } + {2f21 + 4f22 + 4f23 + 2f24 } + {f31 + 2f32 + 2f33 + f34 }
4

In general, the coefficients of a composite trapezoidal method are:

31
1 2 2 2 ··· 2 2 1
2 4 4 4 ··· 4 4 2
2 4 4 4 ··· 4 4 2
.. .. .. .. .. .. ..
. . . . . . .
2 4 4 4 ··· 4 4 2
2 4 4 4 ··· 4 4 2
1 2 2 2 ··· 2 2 1

and for a composite Simpson they are:

1 4 2 4 2 ··· 2 4 1
4 16 8 16 8 · · · 8 16 4
2 8 4 8 4 ··· 4 8 2
4 16 8 16 8 · · · 8 16 4
2 8 4 8 4 ··· 4 8 2
.. .. .. .. .. .. .. ..
. . . . . . . .
2 8 4 8 4 ··· 4 8 2
4 16 8 16 8 · · · 8 16 4
1 4 2 4 2 ··· 2 4 1

∫π∫π
Example . Approximate the integral 0 0 cos(x + y)dxdy using the trapezoidal composite
b−a π c−d π
rule with step sizes h = 3 = 3 = 1.0472 and k = 2 = 2 = 1.5708.

Solution . The x-nodes are:


π 2π
0, , , π
3 3
and the y-nodes are:
π
0, , π
2

The location of the double-nodes on the plane:

32
(0 , π) ( π3 , π) ( 2π
3 , π) (π , π)
π
(0 , 2) ( π3 , π
2) ( 2π
3 ,
π
2) (π , π
2)

(0 , 0) ( π3 , 0) ( 2π
3 , 0) (π , 0)

Then the values of the function multiplies by the weights:

f (0 , π) 2 f ( π3 , π) 2 f ( 2π
3 , π) f (π , π)
π
A= 2 f (0 , 2) 4 f ( π3 , π
2) 4 f ( 2π
3 ,
π
2) 2 f (π , π
2)

f (0 , 0) 2 f ( π3 , 0) 2 f ( 2π
3 , 0) f (π , 0)

-1.0000 1.0000 1.0000 1.0000


A= 0.0000 -3.4641 -3.4641 -0.0000
1.0000 1.0000 -1.0000 -1.0000

Add up these values: -6.9282

hk (1.0472)(1.5708)
Then multiply by 4 = 4 = 0.4112 to get the approximate value for the integral:

(−6.9282)(0.4112) = −2.8489

33

You might also like