Numerical Integration - I

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Numerical Integration - I

Dr. Sukanta Deb


Department of Physics, Cotton University
Panbazar, Guwahati, Pin 781001
Assam (India)
k [email protected]
T 9810362087
Í https://sites.google.com/site/sukantodeb
1

Learning Objectives:
• Derivation of General Quadrature Formula

• Derivation of Trapezoidal Rule and Its Geometrical Significance

• Derivation of Simpson’s 1/3 Rule and Its Geometrical Significance

• Derivation of Simpson’s 3/8 Rule and Its Geometrical Significance


2

Numerical Quadrature
The evaluation of integral forms an important ingredient in engineering and scientific calculations.
For an instance, in order to calculate the total amount of a quantity which continuously varies
with position or time, one has to perform integration. The integration is always performed with
respect to an independent variable called the integration variable. Integration is considered as
inverse of the differentiation [1]. We know that the speed of an object is defined as the rate of
change of distance given by
ds
v= .
dt
The total distance covered in an interval of time [0, tf ] is given by
Z tf Z tf
s= ds = v(t)dt.
0 0

The objective of integration is to find the function g(x) whose derivative g ′(x) is given. Therefore,
the integral can be thought of as an anti-derivative and is defined as:
Z b Z b
I = g(x) = g ′ (x)dx = f (x)dx.
a a

Here f (x) is called the integrand. x represents the variable of integration such that x ∈ [a, b].
a and b denote the limits of integration. An analytic solution of the integral may exist if the
integrand is well-behaved and continuous within the limits of the integration.
An analytic solution of an integral is always a preferred method because it provides the exact
result. However, not all the integrals can be solved analytically either because the integrand
function becomes singular at some point within the interval of integration or the function is not
continuous. In many instances either the functional form of f (x) is not known explicitly or the
value of the integral is difficult to obtain. In many other instances, we are given a discrete set of
values of the function at some tabulated values of the integration variable. In order to deal with
the above situations, the numerical methods of integration can be used to obtain the value of the
definite intgeral. Numerical quadrature deals with the use of numerical methods to solve a definite
integral [1]. Fig. (1) depicts the geometrical interpretation of the integral ab f (x)dx.
R

Numerical Integration Problem:


Given a set of (n + 1) tabulated data points (x0 , f0 ), (x1 , f1 ), . . . , (xn , fn ) of a function f (x),
it is required to compute an approximate value of the integral
Z b
I= f (x)dx.
a
3

Rb
Figure 1: Geometrical interpretation of the process of integration. The integral a f (x)dx repre-
sents the area under the curve f (x) between the limits [a, b] of integtration.

General Quadrature Formula


Let us consider a set of (n + 1) tabulated data points (x0 , f0 ), (x1 , f1 ), . . . , (xn , fn ) of the function
f (x), where fi ≈ f (xi ), i = 0, 1, 2, . . . , n. Here, the form of the function f (x) is not known
explicitly. Numerical quadrature deals with the evaluation of the following integral
Z b
I= f (x)dx,
a

where a = x0 and b = xn denote the lower and the upper limit of the integral, respectively. In the
case of numerical integration, the given interval is divided into a number of subintervals of equal
width h and function tabulated at the points (called nodes) of subdivision is replaced by any one of
the interpolating polynomials like Lagrange interpolating polynomial, Newton-Gregory’s, Bessel’s
or Stirling’s interpolating polynomials over each of the subintervals and the integral is evaluated.
A polynomial has always the distinct advantage that it can be easily integrated and hence it is
popular in developing numerical integration schemes [2].
In this section, we derive a general formula of numerical integration based on the Netwon-
Gregory’s forward difference interpolating polynomial formula. Let us divide the interval [a, b]
into n subintervals [xi , xi+1 ] of equal width h = xi+1 − xi such that xi = xi + ih, i = 0, 1, . . . , n.
Therefore, we have

x0 = a, x1 = x0 + h, x2 = x0 + 2h, . . . , xn = x0 + nh = b.

Let us approximate f (x) by the Newton-Gragory’s forward difference interpolating polynomial


formula which approximate the behaviour of f (x) at all known values. From the Newton-Gregory’s
4

forward difference interpolation formula, we have

p(p − 1) 2 p(p − 1)(p − 2) 3


f (x) = f0 + p∆f0 + ∆ f0 + ∆ f0 + . . . .
2! 3!

Therefore, the integral Z b


I= f (x)dx
a
becomes
" #
Z x0 +nh p(p − 1) 2 p(p − 1)(p − 2) 3
I= f0 + p∆f0 + ∆ f0 + ∆ f0 + . . . dx (1)
x0 2! 3!

where x is given by

x = x0 + ph
⇒ dx = hdp

Therefore, equation (1) becomes


" #
np(p − 1) 2 p(p − 1)(p − 2) 3
Z
I =h f0 + p∆f0 + ∆ f0 + ∆ f0 + . . . dp
0 2 6
p2 1 p3 p2 1 p4
Z n" ! ! #
2 3 2 3
⇒I =h f0 + pf0 + ∆f0 + − ∆ f0 + − p + p ∆ f0 + . . .
0 2 2 3 2 6 4
n(n − 2)2
" #
n n(2n − 3) 2
⇒ I = nh f0 + ∆f0 + ∆ f0 + ∆f0 + . . . . (2)
2 12 24

This is the general quadrature formula [2] and is also called Newton-Cotes formula [1]. Differ-
ent integration formulae can be derived by putting n = 1, 2, 3, . . . , etc. n = 1, 2, 3 give rise to
Trapezoidal, Simpson’s 1/3 rules and Simpson’s 3/8 rules [2].
5

Some Important Facts::

We know that n denotes the degree of a polynomial. A first degree polynomial (n = 1)


is a straight line and can be used to interpolate data points that lie at the end of each
subinteval. Since the interval [a, b] of integration is subdivided into n subintervals, the
interpolating function can be represented by a series of staright lines represented piecewise
over the n subintervals. The resulting numerical integration using linear interpolation or
piecewise linear interpolation of the data is called the Trapezoidal rule.
A second degree polynomial (n = 2), i.e., a quadratic function can be used to interpolate
three data points two of which are located at the ends of the subinterval and a third point
bisects the first two. The resulting integration using a quadratic interpolation is called
Simpson’s 1/3 rd rule.
A third degree polynomial (n = 3), i.e., a cubic funcion connects four equally spaced data
points within each subinterval and the resulting integration is called Simpson’s 3/8 rule
[3, 2].

Trapezoidal Rule
Putting n = 1 into the equation (2) of general quadrature formula, then all the differences higher
than the first will become zero. Then, we get

• in the interval [x0 , x1 ]:

x1 1
Z  
f (x)dx = h f0 + ∆f0
x0 2
1
Z x1  
⇒ f (x)dx = h f0 + (f1 − f0 )
x0 2
h
Z x1
⇒ f (x)dx = [f0 + f1 ] .
x0 2

• in the interval [x1 , x2 ]:

x2 h
Z
f (x)dx = [f1 + f2 ]
x1 2

• Similarly, in the last interval [xn−1 , xn ]:

xn h
Z
= [fn−1 + fn ] .
xn−1 2
6

Figure 2: Geometrical interpretation of the Trapezoidal rule. The curve y = f (x) is replaced by
n straight lines joining (x0 , f (x0 )) and (x1 , f (x1 )), (x1 , f (x1 )) and (x2 , f (x2 ));. . . ; (xn−1 , f (xn−1 ))
and (xn , f (xn )). The area bounded by the curve f (x) in the interval [x0 , xn ] is approximately equal
to the sum of the area of the n trapeziums.

Adding the above integrals, we have


Z xn Z x1 Z x2 Z xn
f (x)dx = f (x)dx + f (x)dx + · · · + f (x)dx
x0 x0 x1 xn−1
Z xn
h h h
⇒ f (x)dx = [f0 + f1 ] + [f1 + f2 ] + · · · + [fn−1 + fn ]
x0 2 2 2
h
Z xn
⇒ f (x)dx = [f0 + 2(f1 + f2 + · · · + fn−1 ) + fn ] .
x0 2
This is known as the Trapezoidal rule.

Geometrical interpretation of the Trapezoidal rule


Let us try to calculate an integral Z b
I= f (x)dx
a
Let the interval [a, b] be divided into n equal subintervals, each of width equal to h. Let x0 =
a, x1 = a + h, . . . , xn = a + nh = b. Let the ordinates of these points be deonted by f0 , f1 , . . . , fn ,
respectively, where fi = f (xi ) = f (a + ih), i = 0, 1, 2, . . . , n. If each segments of the curve between
two succesive ordinates are connected by a straight line, then each strip becomes a trapezium. The
area of each trapezium is summed up to yield the approximate value of the integral for interval
7

Rb
[a, b]. Since the interval [a, b] is divided into n equal subintervals then the integral a f (x)dx can
be written as
Z b Z x1 Z x2 Z xn
f (x)dx = f (x)dx + f (x)dx + · · · + f (x)dx
a x0 x1 xn−1
Z b
⇒ f (x)dx = A0 + A1 + · · · + An−1
a
Z b
h h h h
⇒ f (x)dx =
(f0 + f1 ) + (f1 + f2 ) + · · · + (fn−2 + fn−1 ) + (fn−1 + fn )
a 2 2 2 2
h
Z b
⇒ f (x)dx = (f0 + fn + 2(f1 + f2 + · · · + fn−1 ))
a 2"
n−1
#
h
Z b X
⇒ f (x)dx = f0 + fn + 2 fi
a 2 1
n−1
" #
b h
Z X
⇒ f (x)dx = f (x0 ) + f (xn ) + 2 f (xi )
a 2 i=1

This formula is called the Trapezoidal rule for subinterval of equal width. Fig. (2) depicts the
geometrical interpretation of the Trapezoidal rule.

Error in the Trapezoidal rule


The error in the Trapezoidal method can be obtained as follows: Let f (x) be a continuous, well-
defined function whose derivative is continuous in the interval [x0 , xn ]. Let us try to find the error
in the interval [x0 , x1 ]. Expanding f (x) in a Taylor series expansion around x0 , we get

(x − x0 )2 ′′
" #
Z x1 Z x1
f (x)dx = f0 + (x − x0 )f0′ + f (0) + . . . dx
x0 x0 2
x1 h2 ′ h3 ′′
Z
⇒ f (x)dx =hf0 + f + f0 + . . . . (3)
x0 2 0 6
Similarly, it can be shown that

h2 h3
" #
h h
[f0 + f1 ] = f0 + f0 + f0′ + f0′′ + f0′′′ + . . .
2 2 2 6
2 3
h h h
⇒ [f0 + f1 ] =hf0 + f0′ + f0′′ + . . . (4)
2 2 4
The error in the interval [x0 , x1 ] is given by
x1 h
Z
E[x0 , x1 ] = f (x)dx − [f0 + f1 ]
x0 2
1
⇒ E[x0 , x1 ] = − h3 f0′′ + . . . .
2
8

Proceeding in the similar manner, we can show that the error in the interval [x1 , x2 ] is given by
Z x2 h
E[x1 , x2 ] = f (x)dx − [f1 + f2 ]
x1 2
1
⇒ E[x1 , x2 ] = − h3 f1′′ + . . . .
2
and the error in the [xn−1 , xn ] is
xn h
Z
E[xn−1 , xn ] = f (x)dx − [fn−1 + fn ]
xn−1 2
1
E[xn−1 , xn ] = − h3 fn−1
′′
+ ....
2
Therefore, the total error is given by

E[x0 , xn ] =E[x0 , x1 ] + E[x1 , x2 ] + · · · + E[xn−1 , xn ]


1 h i
⇒ E[x0 , x1 ] = − h3 f0′′ + f1′′ + · · · + fn−1 ′′
12
1
⇒ E[x0 , x1 ] = − h3 [f ′′ (ξ0 ) + f ′′ (ξ1 ) + · · · + f ′′ (ξn−1 )]
12
n
(b − a)3 X
⇒E =− f ′′ (ξi ).
n3 i=1

Let us define where ξi ∈ [xi−1 , xi ] is a point located within the the ith subinterval. Let us define
n
1X
f¯′′ = f ′′ (ξi)
n i=1

Therefore, the total error becomes

(b − a)3 f¯′′
E=−
12n2
(b − a)2 h2 f¯′′
⇒E=−
12
2
⇒ E ≈ O(h )

Thus we have found that the total error in the Trapezoidal rule over n subintervals is of the order
of h2 . The error of is exactly zero for any function whose second odrer derivative is equal to zero.
Therefore the Trapezoidal rule produces an exact result for a linear function.

Example 1. Evaluate the following integral using the the Trapezoidal rule for five subintervals.
Z 1
x3 dx.
0

Solution 1. Since the interval [0, 1] is divided into five subintervals, the width of each subinterval
is given by h = (1−0)
5
= 0.2. The x values are xi = x0 + ih, i = 0, 1, 2, 3, 4, 5. Here x0 = 0, x1 =
9

x: 0 0.2 0.4 0.6 0.8 1.0


f (x) = x2 : 0 0.008 0.064 0.216 0.512 1.000
(f0 ) (f1 ) (f2 ) (f3 ) (f4 ) (f5 )

0.2, x2 = 0.4, x3 = 0.6, x4 = 0.8, x5 = 1.0. The values of f (x) at these fives values of x are given
by f (x) = x3 and are shown in the following table.
From the Trapezoidal rule, we know that
Z 1 h
x3 dx = [f0 + 2(f1 + f2 + f3 + f4 ) + f5 ]
0 2
0.2
Z 1
⇒ x3 dx = [0 + 2(0.008 + 0.064 + 0.216 + 0.512) + 1]
0 2
Z 1
⇒ x3 dx =0.1 × 2.6
0
Z 1
⇒ x3 dx =0.26
0

Example 2. Using the the Trapezoidal rule, evaluate the following integral for eight subintervals.
1 1
Z
dx.
0 1+x
Solution 2. Since the interval [0, 1] is divided into eight subintervals, the width of each subinterval
is given by h = (1−0) 8
= 0.125. The f (x) values for the corresponding x values: xi = x0 + ih, i =
0, 1, 2, 3, 4, 5, 6, 7 are shown in the following table.

x: 0 0.125 0.250 0.375 0.50 0.625 0.750 0.875 1.0


1
f (x) = 1+x : 1.0 0.8889 0.8000 0.7273 0.6667 0.6154 0.5714 0.5333 0.5
(f0 ) (f1 ) (f2 ) (f3 ) (f4 ) (f5 ) (f6 ) (f7 ) (f8 )

From the Trapezoidal rule, we know that


1 1 h
Z
dx = [f0 + 2(f1 + f2 + f3 + f4 + f5 + f6 + f7 ) + f8 ]
0 1+x 2
1 1 0.125
Z
⇒ dx = [1 + 2(0.8889 + 0.800 + 0.7273 + 0.6154 + 0.5714 + 0.5333) + 0.5]
0 1+x 2
1 1
Z
⇒ dx =0.0625 × 11.106
0 1+x
1 1
Z
⇒ dx =0.0625 × 11.106
0 1+x
1 1
Z
⇒ dx =0.69413
0 1+x
10

Example 3. Using the the Trapezoidal rule, evaluate the following integral for six subintervals.
Z 6 1
dx.
0 1 + x2
Solution 3. Since the interval [0, 6] is divided into six subintervals, the width of each subinterval
is given by h = (6−0) 6
= 1. The f (x) values for the corresponding x values: xi = x0 + ih, i =
0, 1, 2, 3, 4, 5, 6 are shown in the following table.

x: 0 1 2 3 4 5 6
1
f (x) = 1+x 2 : 1.0 0.5 0.2 0.1 0.0588235 0.0384615 0.0270270
(f0 ) (f1 ) (f2 ) (f3 ) (f4 ) (f5 ) (f6 )

From the Trapezoidal rule, we know that


1 1 h
Z
2
dx = [f0 + 2(f1 + f2 + f3 + f4 + f5 ) + f6 ]
0 1+x 2
1 1 1
Z
⇒ dx = [1.0 + 2(0.5 + 0.2 + 0.1 + 0.0588235 + 0.0384615) + 0.0270270]
0 1 + x2 2
1 1
Z
⇒ dx =1.4108
0 1 + x2

Example 4. FInd the area bounded by the curve for the following from the following table for
the interval [7.47, 7.52].

x: 7.47 7.48 7.49 7.50 7.51 7.52


f (x) : 1.93 1.95 1.98 2.01 2.03 2.06
(f0 ) (f1 ) (f2 ) (f3 ) (f4 ) (f5 )

Solution 4. Here We have to find out the area under the curve in the interval [7.47, 7.52]. That
is we have to evaluate
Z 7.52
Area = f (x)dx, using h = 0.01.
7.47
From the Trapezoidal rule, we know that
7.52 h
Z
f (x)dx = [f0 + 2(f1 + f2 + f3 + f4 ) + f5 ]
7.47 2
0.01
Z 7.52
f (x)dx = [1.93 + 2(1.95 + 1.98 + 2.01 + 2.03) + 2.06]
7.47 2
Z 7.52
⇒ f (x)dx =0.09965.
7.47

Therefore, the required area is 0.09965.


11

Example 5. Using the the Trapezoidal rule, evaluate the following integral for five subintervals.
Z 2 x
dx.
−2 5 + 2x
Solution 5. Since the interval [−2, 2] is divided into five subintervals, the width of each subinterval
is given by h = (2−(−2))5
= 0.8. The f (x) values for the corresponding x values: xi = x0 + ih, i =
0, 1, 2, 3, 4, 5 are shown in the following table. From the Trapezoidal rule, we know that

x: −2.00 −1.20 −0.40 0.40 1.20 2.00


x
f (x) = 5+2x : −2.00000 −0.461538 −0.0952381 0.0689655 0.162162 0.222222
(f0 ) (f1 ) (f2 ) (f3 ) (f4 ) (f5 )

2 x h
Z
dx = [f0 + 2(f1 + f2 + f3 + f4 ) + f5 ]
−2 5 + 2x 2
2 x 0.8
Z
⇒ dx = [−2.00000 + 2(−0.461538 + (−0.0952381) + 0.0689655 + 0.162162) + 0.222222]
−2 5 + 2x 2
Z2 x
⇒ dx = − 0.971630
−2 5 + 2x

Simpson’s 1/3rd rule


Putting n = 2 into the equation (2) of general quadrature formula and interpolating the curve
through (x0 , f0 ), (x1 , f1 ) and (x2 , f2 ) as a polynomial of degree so that finite differences of order
higher than two vanish. In the interval [x0 , x2 ], we have
x2 1
Z  
f (x)dx = 2h f0 + ∆f0 + ∆2 f0
x0 6
2h
Z x2
⇒ = [6f0 + 6(f1 − f0 ) + (f2 − 2f1 + f0 )]
x0 6
h
Z x2
⇒ = [f0 + 4f1 + f2 ]
x0 3
Similarly, in the interval [x2 , x4 ], the integral
Z x4 h
f (x)dx = [f2 + 4f3 + f4 ]
x2 3
Proceeding in the similar way, finally, in the interval [xn−2 , xn ], the integral
xn h
Z
f (x)dx = [fn−2 + 4fn−1 + fn ]
xn−2 3
12

Therefore the integral Z xn


f (x)dx
x0

can be wriiten as
Z xn Z x2 Z x4 Z xn
f (x)dx = f (x)dx + f (x)dx + · · · + f (x)dx
x0 x0 x2 xn−2
h h h
Z xn
⇒ f (x)dx = [f0 + 4f1 + f2 ] + [f2 + 4f3 + f4 ] + · · · + [fn−2 + 4fn−1 + fn ]
x0 3 3 3
Z xn
h
⇒ f (x)dx = [f0 + 4(f1 + f3 + f5 + · · · + yn−1 ) + 2(f2 + f4 + f6 + · · · + fn−2 ) + fn ]
x0 3
This is known as the Simpson’s 1/3rd rule.

Geometrical interpretation of Simpson’s 1/3 rd rule


In Simpson’s 1/3 rd rule, the integrand function is approximated with a quadratic polynomial.
Therefore the accuracy of the Simpsons 1/3 rd method is more than the Trapezoidal method as
a quadratic curve lies closer to the real curve in the given function than a straight line. Since
a quadratic function requires three points of interpolation, this method requires pairs of two
subintervals for approximation. As two subintervals are required in each pair, the total number of
subintervals in the given interval must be an even number. Let us consider the subintervals [x0 , x1 ]
and [x1 , x2 ] which involve the points (x0 , f (x0 )), (x1 , f (x1 )) and (x2 , f (x2 )). Let P2 = a0 +a1 x+a2 x2
be an approximation to the real curve, where a0 , a1 and a2 are the constants to be determined.
Since the points (x0 , f (x0 )), (x1 , f (x1 )) and (x2 , f (x2 )) are on P2 (x), we have

f0 = a0 + a1 x0 + a2 x20
f1 = a0 + a1 x1 + a2 x21
f2 = a0 + a1 x2 + a2 x22

The above system of linear equations can be solved for a0 , a1 and a2 to get
x2 h
Z
f (x)dx ≈ (f0 + 4f1 + f2 )
x0 3
The above equation can be extended into the case of n even intervals for x = x0 to x = xn .
The total area is found as a sum of n/2 subareas, where each subarea contains two subintervals.
13

Therefore the total area obtained from the n subintervals is given by


h h h
Z xn
f (x)dx ≈ (f0 + 4f1 + f2 ) + (f2 + 4f3 + f4 ) + · · · + (fn−2 + 4fn−1 + fn )
x0 3 3 3
h
Z xn
⇒ f (x)dx ≈ [(f0 + fn ) + 4(f1 + f3 + · · · + fn−1 ) + 2(f2 + f4 + · · · + fn−2 )]
x0 3
 n n 
−1
xn h 2 2
Z X X
⇒ f (x)dx ≈ f0 + f1 + 4 f2i−1 + 2 ff2i 
x0 3 i=1 i=1
 n n 
−1
Z xn h 2
X 2
X
⇒ f (x)dx ≈ f (x0 ) + f (xn ) + 4 f (x0 + (2i − 1)h) + 2 f (x0 + 2ih)
x0 3 i=1 i=1
5
The error in the Simpson’s 1/3 rd rule can be shown to be equal to E = − h90 f 4 (ξ). Therefore
Simpson’s 1/3rd rule is a fifth order method. Since the error term contains the fourth derivative
of the function, the Simpson’s 1/3 rd rule is exact for any function whose fourth order derivative
over the entire interval is exactly zero.

☞ The degree of precision of Simpson’s 1/3 rule is 3, i.e, it produces exact results in the
case of integrands that are polynomial of order 3. The order of error in the case of
Simpson’s 1/3 rule is O(h5 ).

☞ The accuracy of the Simpson’s 1/3 rule can be greatly improved if the integration
interval is subdivided into smaller intervals.

Example 6. Using the the Simpson’s 1/3 rule, evaluate the following integral for four subintervals.
1
Z 1
dx.
0 1 + x2

Solution 6. Since the interval [0, 1] is divided into four subintervals, the width of each subinterval
is given by h = (1−0)4
= 0.25. The f (x) values for the corresponding x values: xi = x0 + ih, i =
0, 1, 2, 3, 4 are shown in the following table. From the Simpson’s 1/3 rule, we know that

x: 0 0.25 0.50 0.75 1.00


1
f (x) = 1+x 2 : 1.00000 0.941176 0.800000 0.640000 0.500000
(f0 ) (f1 ) (f2 ) (f3 ) (f4 )

Z 1 1 h
2
dx = [(f0 + 4f1 + f2 ) + (f2 + 4f3 + f4 )]
0 1+x 3
1 1 h
Z
⇒ 2
dx = [f0 + 4(f1 + f3 ) + 2f2 + f4 ]
0 1+x 3
1 1 0.25
Z
⇒ dx = [1.00000 + 4(0.941176 + 0.640000) + 2(0.800000) + 0.500000]
0 1 + x2 2
1 1
Z
⇒ dx =0.785392
0 1 + x2
14

Example 7. Using the the Simpson’s 1/3 rule, evaluate the following integral for eight subintervals.
1 1
Z
dx.
0 1+x
Hence find the value of log2e approximately.
Solution 7. Since the interval [0, 1] is divided into eight subintervals, the width of each subinterval
is given by h = (1−0) 8
= 0.125. The f (x) values for the corresponding x values: xi = x0 + ih, i =
0, 1, 2, 3, 4, 5, 6, 7 are shown in the following table. From the Simpson’s 1/3 rule, we know that

x: 0.000 0.125 0.250 0.375 0.500 0.625 0.750 0.875 1.000


1
f (x) = 1+x 2 : 1.000 0.889 0.800 0.727 0.667 0.615 0.571 0.533 0.500
(f0 ) (f1 ) (f2 ) (f3 ) (f4 ) (f5 ) (f6 ) (f7 ) (f8 )

Z 11 h
dx = [(f0 + 4f1 + f2 ) + (f2 + 4f3 + f4 ) + (f4 + 4f5 + f6 ) + (f6 + 4f7 + f8 )]
0 1+x 3
Z 1
1 h
⇒ dx = [f0 + 4(f1 + f3 + f5 + f7 ) + 2(f2 + f4 + f6 ) + f8 ]
0 1+x 3
1 0.125
Z 1
⇒ dx = [1.000 + 4(0.889 + 0.727 + 0.615 + 0.533) + 2(0.800 + 0.667 + 0.571) + 0.500]
0 1+x 3
1
Z 1
⇒ dx =0.693155
0 1+x
Now let us try to calculate the integral analytically
Z 1
1
dx = ln (1 + x)|10
0 1+x
Z 1
1
⇒ dx = ln 2
0 1+x
1
Z 1
⇒ dx =0.693147
0 1+x

Example 8. Using the the Simpson’s 1/3 rule, evaluate the following integral for four s ubintervals.
Z 2 x
e− 2 dx.
1

Solution 8. Since the interval [1, 2] is divided into four subintervals, the width of each subinterval
is given by h = (2−1)4
= 0.25. The f (x) values for the corresponding x values: xi = x0 + ih, i =
0, 1, 2, 3, 4 are shown in the following table. From the Simpson’s 1/3 rule, we know that
Z 2
x h
e− 2 dx = [(f0 + 4f1 + f2 ) + (f2 + 4f3 + f4 )]
1 3
h
Z 2
x
⇒ e− 2 dx = [f0 + 4(f1 + f3 ) + 2f2 + f4 ]
1 3
0.25
Z 2
x
⇒ e− 2 dx = [0.60653 + 4(0.53526 + 0.41686) + 2(0.47237) + 0.36788]
1 3
Z 2 x
⇒ e− 2 dx =0.477303
1
15

x: 1.00 1.25 1.50 1.75 2.00


x
f (x) = e− 2 : 0.60653 0.53526 0.47237 0.41686 0.36788
(f0 ) (f1 ) (f2 ) (f3 ) (f4 )

Simpson’s 3/8 rule


Putting n = 3 into the equation (2) of general quadrature formula and interpolating the curve
through (x0 , f0 ), (x1 , f1 ), (x2 , f2 ) and (x2 , f2 ) as a polynomial of degree three so that finite differ-
ences of order higher than three vanish. In the interval [x0 , x3 ], we have
x3 3 3 1
Z  
f (x)dx = 3h f0 + ∆f0 + ∆2 f0 + ∆3 f0
x0 2 4 8
Z x3
3 3 1
 
⇒ f (x)dx = 3h f0 + (f1 − f0 ) + (f2 − 2f1 + f0 ) + (f3 − 3f2 + 3f1 − f0 )
x0 2 4 8
3h
Z x3
⇒ f (x)dx = [8f0 + +12(f1 − f0 ) + 6(f2 − 2f1 + f0 ) + (f3 − 3f2 + 3f1 − f0 )]
x0 8
Z x3
3h
⇒ f (x)dx = [f + 0 + 3f1 + 3f2 + f3 ]
x0 8
Similarly, in the interval [x3 , x6 ], the integral
x6 3h
Z
f (x)dx = [f3 + 3f4 + 3f5 + f6 ]
x3 8
Proceeding in the similar way, finally, in the interval [xn−3 , xn ], the integral
xn 3h
Z
f (x)dx = [fn−3 + 3fn−2 + 3fn−1 + fn ]
xn−3 8
Therefore the integral Z xn
f (x)dx
x0

can be wriiten as
Z xn Z x3 Z x6 Z x3
f (x)dx = f (x)dx + f (x)dx + · · · + f (x)dx
x0 x0 x3 xn−3
3h 3h 3h
Z xn
⇒ f (x)dx = [f0 + 3f1 + 3f2 + f3 ] + [f3 + 3f4 + 3f5 + f6 ] + · · · + [fn−3 + 3fn−2 + 3fn−1 + fn ]
x0 8 8 8
This is known as the Simpson’s 3/8rd rule.

Geometrical interpretation of Simpson’s 3/8 rule


The Simpson’s 3/8 rule is an extension to the Simpson’s 1/3 rule. In this rule, the integrand
funtion is approxmated with a cubic polynomial. Since a cubic function requires four points
16

of interpolation, this method requires three pairs of subintervals for approximation. As three
subintervals are required in each pair, the total number of subintervals in the given interval must
be a multiple of three. Let us consider the subintervals [x0 , x1 ], [x1 , x2 ] and [x2 , x3 ] which involve
the points (x0 , f (x0 )), (x1 , f (x1 )), (x2 , f (x2 )). Let the the interpolating curve be a cubic polynomial
given by
P3 = a0 + a1 x + a2 x2 + a3 x3 ,
where a0 , a1 , a2 and a3 are constants to be determined.The above curve is interpolated at (x0 , f0 ), (x1 , f1 ),
(x2 , f2 ) and (x3 , f3 ) to produce an approximated subarea, given by
x3 3h
Z
f (x)dx ≈ (f0 + 3f1 + 3f2 + f3 ) ,
x0 8
where each subarea contains three intervals, namely, [x0 , x1 ], [x1 , x2 ] and [x2 , x3 ]. The total area
is obtained as a sum of n/3 subareas. Therefore, the total area obtained from the n subintervals
is given by
Z xn Z x3 Z x6 Z xn
f (x)dx ≈ f (x)dx + f (x)dx + · · · + f (x)dx
x0 x0 x3 xn−3
xn 3h 3h 3h
Z
f (x)dx = (f0 + 3f1 + 3f2 + f3 ) + (f3 + 3f4 + 3f5 + f6 ) + · · · + (fn−3 + 3fn−2 + 3fn−1 + fn )
x0 8 8 6
3h
Z xn
⇒ f (x)dx ≈ [(f0 + fn ) + 2(f3 + f6 + · · · + yn−3) + 3(f1 + f2 + f4 + f5 + · · · + fn−2 + fn−1 )]
x0 8
 
n/3 n/3−1
Z xn 3h  X X
⇒ f (x)dx ≈ f (x0 ) + f (xn ) + 3 [f (x3i−2 ) + f (x3i−1 )] + 3 f (x3i )
x0 8 i=1 i=1

It can be shown that the error associated with the Simpson’s 3/8 rule is O(h5 ) which is of the same
order as Simpson’s 1/3 rule. The degree of precision of the Simpos’s 3/8 rule is 3. The Simpson’s
1/3 rule is preferred over the 4/8 rule since it requires fewer data points as compared with 3/8
rule to achieve the same level of accuracy.
R 1.0
Example 9. Evaluate the value of the integral 0.1 f (x)dx from the given table.

x: 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
f (x) : 1.001 1.008 1.027 1.064 1.125 1.216 1.343 1.512 1.729 2.000
(f0 ) (f1 ) (f2 ) (f3 ) (f4 ) (f5 ) (f6 ) (f7 ) (f8 ) (f9 )

Solution 9. Here n = 9 (Number of subintervals), h = 0.1. From the Simpson’s 3/8 rule, we
17

know that
Z x9 3h
[(f0 + 3f1 + 3f2 + f3 ) + (f3 + 3f4 + 3f5 + f6 ) + (f6 + 3f7 + 3f8 + f9 )]
f (x)dx =
x0 8
3(0.1)
Z 1.0
⇒ f (x)dx = [f0 + 3(f1 + f2 + f4 + f5 + f7 + f8 ) + 2(f3 + f6 ) + f9 ]
0.1 8
Z 1.0
3(0.1)
⇒ f (x)dx = [1.001 + 3(1.008 + 1.027 + 1.125 + 1.216 + 1.512 + 1.729) + 2(1.064 + 1.343) + 2.000]
0.1 8
Z 1.0
⇒ f (x)dx =1.14998
0.1

Example 10. Let us consider a train moving at the spped of 30 ms−1 . Suddenly, the brakes are
applied. The spped of the train after t seconds is given by Determine the distance moved by the

t: 0 5 10 15 20 25 30 35 40 45
v(t) : 30 24 19 16 13 11 10 8 7 5
(v0 ) (v1 ) (v2 ) (v3 ) (v4 ) (v5 ) (v6 ) (v7 ) (v8 ) (v9 )

train in 45 seconds using the Simpson’s 3/8 rule.

Solution 10. Let s be the distance covered in t seconds. Then


ds
=v(t)
dt
Z 45
⇒ [ds]t=45
t=0 = v(t)dt
0

Here n = 9 (Number of subintervals), h = 5. From the Simpson’s 3/8 rule, we know that
Z t9 3h
v(t)dt =
[(v0 + 3v1 + 3v2 + v3 ) + (v3 + 3v4 + 3v5 + v6 ) + (v6 + 3v7 + 3v8 + v9 )]
t0 8
Z 45
3(5)
⇒ f (x)dx = [v0 + 3(v1 + v2 + v4 + v5 + v7 + v8 ) + 2(v3 + v6 ) + v9 ]
0 8
3(5)
Z 1.0
⇒ v(t)dt = [30 + 3(24 + 19 + 13 + 11 + 8 + 7) + 2(16 + 10) + 30]
0.1 8
Z 1.0
⇒ f (x)dx =624.375.
0.1

Therefore, the distance moved by the train in 45 seconds is 624.375 meters.

Example 11. Applying the Simpson’s 3/8 rule evaluate the integral
Z 0.2
f (x)dx
−0.6

from the following table:


18

x: −0.6 −0.5 −0.4 −0.3 −0.2 −0.1 0 0.1 0.2 0.3


f (x) : 4 2 5 3 −2 1 6 4 2 8
(f0 ) (f1 ) (f2 ) (f3 ) (f4 ) (f5 ) (f6 ) (f7 ) (f8 ) (f9 )

Solution 11. Here n = 9 (Number of subintervals), which is a multiple of 3, h = 0.1. From the
Simpson’s 3/8 rule, we know that
Z x9 3h
f (x)dx =
[(f0 + 3f1 + 3f2 + f3 ) + (f3 + 3f4 + 3f5 + f6 ) + (f6 + 3f7 + 3f8 + f9 )]
x0 8
Z 0.3
3(0.1)
⇒ f (x)dx = [f0 + 3(f1 + f2 + f4 + f5 + f7 + f8 ) + 2(f3 + f6 ) + f9 ]
−0.6 8
3(0.1)
Z 0.3
⇒ f (x)dx = [4 + 3(2 + 5 − 2 + 1 + 4 + 4) + 2(3 + 6) + 8.0]
−0.6 8
Z 0.3
⇒ f (x)dx =2.475
−0.6

Example 12. Evaluate the value of the integral


1 1
Z
dx
0 1 + x2
using h = 1/6 and hence find an approximate value of π.
1 1 2 3 4 5
Solution 12. The values of f (x) = 1+x 2 at x = 0, 6 , 6 , 6 , 6 , 6 , 1 are given in the following table:

Here n = 9 (Number of subintervals), which is a multiple of 3, h = 0.1. From the Simpson’s 3/8
1 2 3 4 5
x: 0 6 6 6 6 6
1
36 9 4 9 36 1
f (x) : 1 37 10 5 13 61 2
(f0 ) (f1 ) (f2 ) (f3 ) (f4 ) (f5 ) f6

rule, we know that


x9 1 3h
Z
2
dx = [(f0 + 3f1 + 3f2 + f3 ) + (f3 + 3f4 + 3f5 + f6 )]
x0 1+x 8
Z 1 1 3( 16 )
⇒ dx = [f0 + 3(f1 + f2 + f4 + f5 ) + 2f3 + f6 ]
0 1 + x2 8
1 1 3( 16 ) 36 9 9 36 4 1
Z  
⇒ dx = 1 + 3( + + + ) + 2( ) +
0 1 + x2 8 37 10 13 61 5 2
We know that
11 π
Z
2
dx = tan−1 (x)|10 =
0 1+x 4
π
⇒ 0.785395862 =
4
⇒ π =3.141583.
19

Exercises
1. Evaluate the value of the integral
Z 1 1
I= dx
0 1 + x2
using the Trapezoidal rule with h = 0.5, 0.25 and 0.125. Compare the results obtained with
the true value.

2. Obtain the approximate value of the integral


Z 1
I= cos xdx
0

using the Trapezoidal rule with h = 0.2.

3. Evalaute the value of the integral


Z π
2 √
I= cos θdθ
0

with the help of Trapezoidal rule using six subintervals.

4. Evaluate the integral


6 1
Z
I= dx
0 (1 + x)2
using the Trapezoidal rule for eight subintervals.

5. Evaluate the value of the integral


1 3
Z
dx
1 x

using the Simpson’s 1/3 rule consider four and eight subintervals. Determine the error in
obtained in both the two cases from the direct integration.

6. Obtain the approximate value of the integral


Z π
2 √
sin θdθ
0

π
usign the Simpson’s 1/3 rule with h = 12
.

7. Obtain an approximate value of the integral


Z 7
I= x2 ln xdx
3

using the Simpson’s 1/3 rule by taking eight subintervals.


20

t[min] : 0 2 4 6 8 10 12
v(t)[kmh−1 ] : 0 22 30 27 18 7 0

8. The velocities of a car at intervals of two minutes are given in the following table:
Applying the Simpson’s 1/3 rule find the distance covered by the car.

9. Obtain an approximate value of the integral


Z 0.3
(1 − 8x3 )1/2 dx
0

using the Simpson’s 3/8 rule.

10. Obtain an approximate value of the integral


Z 6 1
dx
0 1 + x4
using the Simpson’s 3/8 rule.

11. Evaluate the value of the integral


π sin x
Z
dx
0 x
using the Simpson’s 3/8 rule.

12. Evaluate value of the integral


ln (1 + x2 )
1
Z
dx
0 1 + x2
using the Simpson’s 3/8 rule by taking nine subintervals. using the Simpson’s 3/8 rule.

Summary
In this chapter various rules for numerical integration have been discussed. Numerical integration
is an important tool in various scientific and engineering calculations. Numerical quadrature deals
with the use of numerical methods to solve a definite integral. A general quadrature formula using
the Newton-Gregory’s forward difference interpolating polynomial formula has been derived. The
Trapezoidal rule, Simpson’s 1/3 rule and Simpson’s 3/8 rule have been found to be the special
cases for n = 1, 2, 3, respectively for the general quadrature formula. A detailed derivation of all
these three methods along with their geometrical interpretations have been discussed. A number
of solved examples have been provided in order to illustrate these methods. All these methods
are based on intervals of equal width. We have found that the Simpson’s 1/3 and Simpson’s 3/8
rule give more accurate results as compared to the Trapezoidal rule. The Simpson’s 1/3 rule is
preferred over the Simpson’s 3/8 rule since it requires fewer data points as compared with 3/8 rule
to achieve the same level of accuracy.
21

References
[1] Michael R. King and Nipa A. Mody. Numerical and Statistical Methods for Bioengineering:
Applications in MATLAB. Cambridge University Press, New York, NY, USA, 1st edition,
2010.

[2] S.S. Sastry. Introductory Methods of Numerical Analysis. Prentice-Hall of India Private Lim-
ited, 2005.

[3] Richard L. Burden and J. Douglas Faires. Numerical Analysis: 4th Ed. PWS Publishing Co.,
Boston, MA, USA, 1989.

You might also like