Numerical Integration - I
Numerical Integration - I
Numerical Integration - I
Learning Objectives:
• Derivation of General Quadrature Formula
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
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.
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.
where x is given by
x = x0 + ph
⇒ dx = hdp
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
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
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
x2 h
Z
f (x)dx = [f1 + f2 ]
x1 2
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.
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.
(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
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
(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
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.
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 )
Example 4. FInd the area bounded by the curve for the following from the following table for
the interval [7.47, 7.52].
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
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
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
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.
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
☞ 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
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
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
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.
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 )
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
Example 11. Applying the Simpson’s 3/8 rule evaluate the integral
Z 0.2
f (x)dx
−0.6
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
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
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.
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.
π
usign the Simpson’s 1/3 rule with h = 12
.
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.
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.