0% found this document useful (0 votes)
53 views40 pages

Numerical Differentiation and Integration

Chapter 8 covers numerical differentiation and integration, detailing methods for calculating derivatives and integrals from tabulated data. It discusses various interpolation formulas, including Newton's forward and backward formulas, as well as Lagrange's and Gaussian integration methods. The chapter also addresses potential errors in numerical methods and provides examples for practical application.

Uploaded by

shahisagar2016
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views40 pages

Numerical Differentiation and Integration

Chapter 8 covers numerical differentiation and integration, detailing methods for calculating derivatives and integrals from tabulated data. It discusses various interpolation formulas, including Newton's forward and backward formulas, as well as Lagrange's and Gaussian integration methods. The chapter also addresses potential errors in numerical methods and provides examples for practical application.

Uploaded by

shahisagar2016
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

CHAPTER

8
NUMERICAL DIFFERENTIATION
AND INTEGRATION

Chapter Objectives
O Numerical differentiation
O Formulae for derivatives
O Maxima and minima of a tabulated function
O Numerical integration
O Quadrature formulae
O Errors in quadrature formulae
O Romberg’s method
O Euler-Maclaurin formula
O Method of undetermined coefficients
O Gaussian integration
O Numerical double integration
O Objective type of questions

8.1 Numerical Differentiation


It is the process of calculating the value of the derivative of a
function at some assigned value of x from the given set of values
(xi, yi). To compute dy/dx, we first replace the exact relation y  f(x)
by the best interpolating polynomial y  (x) and then differentiate
the latter as many times as we desire. The choice of the interpola-
tion formula to be used, will depend on the assigned value of x at
which dy/dx is desired.
340 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

If the values of x are equispaced and dy/dx is required near the begin-
ning of the table, we employ Newton’s forward formula. If it is required
near the end of the table, we use Newton’s backward formula. For values
near the middle of the table, dy/dx is calculated by means of Stirling’s or
Bessel’s formula. If the values of x are not equispaced, we use Lagrange’s
formula or Newton’s divided difference formula to represent the function.
Hence corresponding to each of the interpolation formulae, we can de-
rive a formula for finding the derivative.

Obs. While using these formulae, it must be observed that the


NOTE table of values defines the function at these points only and
does not completely define the function and the function may
not be differentiable at all. As such, the process of numerical
differentiation should be used only if the tabulated values
are such that the differences of some order are constants.
Otherwise, errors are bound to creep in which go on increasing
as derivatives of higher order are found. This is due to the
fact that the difference between f(x) and the approximating
polynomial (x) may be small at the data points but f (x) – (x)
may be large.

8.2 Formulae for Derivatives


Consider the function y  f(x) which is tabulated for the values xi( x0 
ih), i  0, 1, 2, ... n.
Derivatives using Newton’s forward difference formula
Newton’s forward interpolation formula (p. 274) is
p(p  1) 2 p(p  1)(p  2) 3
y  y0  py0   y0   y0 
2! 3!
Differentiating both sides w.r.t. p, we have
dy 2 p 1 2 3 p2  6 p  2 3
 y0   y0   y0 
dp 2! 3!
( x  x0 )
Since p
h
dp 1
Therefore 
dx h
NUMERICAL DIFFERENTIATION AND INTEGRATION • 341

dy dy dp 1 2 p 1 2 3 p2  6 p  2 3
Now     y0   y0   y0
ds dp dx h 2! 3!
4 p3  18 p2  22 p  6 4 
  y0  (1)
4! 
At x  x0, p  0. Hence putting p  0,
 dy  1 1 2 1 3 1 4 1 5 1 6 
    y0   y0   y0   y0   y0   y0  (2)
 dx x0 h 2 3 4 5 6 

Again differentiating (1) w.r.t. x, we get


d 2 y d  dy dp
  
dx2 dp dp dx

1 2 6p 6 3 12 p2  36 p2  36 p  22 4 1
  2 y0   y0   y0 
h 2! 3! 4! h
Putting p  0, we obtain
 d2 y  1  11 5 137 6 

 dx2  h2  2 y0  3 y0   4 y0   5 y0   y0  (3)
   12 6 180 

 d3 y  1  3 
Similarly 
 dx3  h3  3 y0   4 y0 
   2 
Otherwise: We know that 1    E  ehD
1 1 1
 hD  log(1  )   2  3   4 
2 3 4
1 1 2 1 3 1 4 
or D         
h 2 3 4 
2
1 1 1 1  1 11 
and D  2   2  3   4   2  2  3   4 
2
h  2 3 4  h  12 
1 3 3 4 
and D3  
2
   
h 2 
Now applying the above identities to y0, we get
 dy  1 1 2 1 3 1 1 1 
Dy0 i.e.,    y0    y0  y0   4 y0   5 y0  6 y0 
 dx x0 h 2 3 4 5 6 
342 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

 d2 y  1  11 5 137 6 

 dx2  h2  2 y0  3 y0   4 y0   5 y0   y0 
   12 6 180 

 d3 y  1  3 
and 
 dx3  h3  2 y0   4 y0 
   2 
which are the same as (2), (3), and (4), respectively.
Derivatives using Newton’s backward difference formula
Newton’s backward interpolation formula (p. 274) is
p(p  1) 2 p(p  1)(p  2) 3
y  yn  pyn   yn   yn 
2! 3!
Differentiating both sides w.r.t. p, we get
dy 2 p 1 2 3 p2  6 p  2 3
 yn   yn   yn 
dp 2! 3!
x  xn dp 1
Since p  , therefore. 
h dx h
 3 
Now dy  dy  dp  1 y  2 p  1 2 y  3 p  6 p  2 3 y  (5)
n n n
dx dp dx h 2! 3! 
At x  xn, p  0. Hence putting p  0, we get
 dy  1 1 2 1 3 1 4 1 5 1 6 
    yn   yn   yn   yn   yn   yn  (6)
 dx xn h 2 3 4 5 6 

Again differentiating (5) w.r.t. x, we have


d2 y d  dy  dp
2
  
dx dp dx dx3
1 2 6p 6 3 6 p2  18 p  11 4 
 2   yn   yn   yn 
h  3! 12 
Putting p  0, we obtain
 d2 y  1  11 5 137 6 

 dx2  h2  2 yn  3 yn   4 yn   5 yn   yn  (7)
   12 6 180 
 d3 y  1 3 
Similarly,  3 
   3  3 yn   4 yn  (8)
 dx xn h  2 
NUMERICAL DIFFERENTIATION AND INTEGRATION • 345

Derivatives using unequally spaced values of argument


(i) Lagranges’s interpolation formula is
( x  x1 )( x  x2 )( x  xn )
f ( x)  f ( x0 )
( x0  x1 )( x0  x2 )( x0  xn )
( x  x0 )( x  x2 )( x  xn )
 f ( x1 ) 
( x1  x0 )( x1  x2 )( x1  x n )
Differentiating both sides w.r.t. x, we get f (x).
(ii) Newton’s divided difference formula is
f  x   f ( x0 )  ( x – x0 )f ( x0 )  ( x – x0 )( x – x1 )2 f ( x0 )
( x – x0 )( x – x1 )( x – x2 )3 f ( x0 ) 
Differentiating both sides w.r.t. x, we obtain
f  x   f ( x0) [2 x – ( x0  x1 )] 2 f ( x0 ) [3 x2 – 2 x( x0  x1  x2 )
( x0 x1  x1 x2  x2 x3 )] 3 f ( x0 ) 

EXAMPLE 8.1
Given that
x: 1.0 1.1 1.2 1.3 1.4 1.5 1.6
y: 7.989 8.403 8.781 9.129 9.451 9.750 10.031
2
dy
find and d y at (a) x  1.1 (b) x  1.6.
dx dx2
Solution:
(a) The difference table is:
x y  2 3 4 5 6
1.0 7.989
0.414
1.1 8.403 – 0.036
0.378 0.006
1.2 8.781 – 0.030 – 0.002
0.348 0.004 0.001
1.3 9.129 – 0.026 – 0.001 0.002
0.322 0.003 0.003
1.4 9.451 – 0.023 0.002
346 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

x y  2 3 4 5 6
0.299 0.005
1.5 9.750 – 0.018
0.281
1.6 10.031
We have
 dy  1 1 2 1 3 1 4 1 5 1 6 
    y0   y0   y0   y0   y0   y0  (i)
 dx x 0 h 2 3 4 5 6 

 d2 y  1 2 11 5 137 6 
and 
 dx2   h2   y0  3 y0   4 y0   5 y0   y0  (ii)
 x 0  12 6 180 

Here h  0.1, x0  1.1, y0  0.378, 2y0  – 0.03 etc.


Substituting these values in (i) and (ii), we get
 dy  1  1 1 1 1 
   0.378  (0.03)  (0.004)  (0.001)  (0.003) 3.952
 dx  0.1 2 3 4 5 
 d y
2
1  11 5 
 2
  2
0.03  (0.004)  (0.001)  (0.003)3.74
 dx  (0.1)  12 6 

(b) We use the above difference table and the backward difference op-
erator  instead of .
 dy  1 1 2 1 3 1 5 1 6 
    yn   yn   yn   yn   yn  (i)
 dx x n
h 2 3 5 6 

 d2 y  1 2 11 5 137 6 
and 
 dx2   h2   yn  3 yn   4 yn   5 yn   yn  (ii)
 xn  12 6 180 

Here h  0.1, xn  1.6, yn  0.281, 2yn  – 0.018 etc.


Putting these values in (i) and (ii), we get
 dy  1 1 1 1
    
0.281  (0.018)  (0.05)  (0.002)
 dx 1.6 0.1 2 3 4
1 1 
 (0.003)  (0.002)  2.75
5 6 
NUMERICAL DIFFERENTIATION AND INTEGRATION • 347

 d2 y  1  11 5

 dx2   (0.1)2 
0.018  0.005  12 (0.002)  6 (0.003)
 1.6
137 
 (0.002) 0.715.
180 

EXAMPLE 8.2
The following data gives the velocity of a particle for twenty seconds
at an interval of five seconds. Find the initial acceleration using the entire
data:
Time t (sec): 0 5 10 15 20
Velocity v(m/sec): 0 3 14 69 228
Solution:
The difference table is:
t v v 2 v 3 v 4 v
0 0
3
5 3 8
11 36
10 14 44 24
55 60
15 69 104
159
20 228
 dv 
An initial acceleration i.e., at t  0 is required, we use Newton’s
 dt 
forward formula:
 dv  1 1 1 1 
    v0  2 v0  3 v0   4 v0 
 dt t0 h 2 3 4 
 dv  1 1 1 1 
     3  (8)  (36)  (24)
 dt t0 5 1 3 4 
1
 (3  4  12  6)  1
5
Hence the initial acceleration is 1 m/sec2.
348 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

EXAMPLE 8.3
Find the value of cos (1.74) from the following table:
x: 1.7 1.74 1.78 1.82 1.86
sin x: 0.9916 0.9857 0.9781 0.9691 0.9584
Solution:
Let y  f (x)  sin x. so that f (x)  cos x.
The difference table is
x y y 2y 3y 4y
1.7 0.9916
– 0.0059
1.74 0.9857 – 0.0017
– 0.0076 0.0003
1.78 0.9781 – 0.0014 – 0.0006
– 0.0090 – 0.0003
1.82 0.9691 – 0.0017
– 0.0107
1.84 0.9584
Since we require f (1.74), we use Newton’s forward formula
dy 1 1 1 1 
  y0  2 y0  3 y0   4 y0  (i)
dx h 2 3 4 
Here h  0.04, x0  1.7, y0  – 0.0059, 2y0  – 0.0017 etc.
Substituting these values in (i), we get
 dy  1  1 1 1 
    0.0059  (0.0017)  (0.003)  (0.0006)
 dx 1.74 0.04  2 3 4 
1
 (0.007)  0.175
0.04
Hence cos (1.74)  0.175

EXAMPLE 8.4
A slider in a machine moves along a fixed straight rod. Its distance x cm.
along the rod is given below for various values of the time t seconds. Find
the velocity of the slider and its acceleration when t  0.3 second.
356 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

2. Find the first, second and third derivatives of f(x) at x  1.5 if


x: 1.5 2.0 2.5 3.0 3.5 4.0
f(x): 3.375 7.000 13.625 24.000 38.875 59.000
3. Find the first and second derivatives of the function tabulated below, at
the point x  1.1:
x: 1.0 1.2 1.4 1.6 1.8 2.0
f(x): 0 0.128 0.544 1.296 2.432 4.00
4. Given the following table of values of x and y
x: 1.00 1.05 1.10 1.15 1.20 1.25 1.30
y: 1.000 1.025 1.049 1.072 1.095 1.118 1.140
dy d2 y
find and 2 at (a) x  1.05. (b) x  1.25 (c) x  1.15.
dx dx
5. For the following values of x and y, find the first derivative at x  4.
x: 1 2 4 8 10
y: 0 1 5 21 27
6. Find the derivative of f(x) at x  0.4 from the following table:
x: 0.1 0.2 0.3 0.4
f(x): 1.10517 1.22140 1.34986 1.49182
7. From the following table, find the values of dy/dx and d2y/dx2 at x  2.03.
x: 1.96 1.98 2.00 2.02 2.04
y: 0.7825 0.7739 0.7651 0. 7563 0.7473
8. Given sin 0°  0.000, sin 10°  0.1736, sin 20°  0.3420, sin 30°  0.5000,
sin 40°  0.6428,
(a) find the value of sin 23°,
(b) find the numerical value of cos x at x  10°
(c) find the numerical value of d2y/dx2 at x  20° for y  sin x.

9. The population of a certain town is given below. Find the rate of growth
of the population in 1961 from the following table
Year: 1931 1941 1951 1961 1971
Population: 40.62 60.80 71.95 103.56 132.68
(in thousands)
NUMERICAL DIFFERENTIATION AND INTEGRATION • 357

Estimate the population in the years 1976 and 2003. Also find the rate of
growth of population in 1991.
10. The following data gives corresponding values of pressure and specific
volume of a superheated steam.
v: 2 4 6 8 10
p: 105 42.7 25.3 16. 7 13
Find the rate of change of
(i) pressure with respect to volume when v  2,
(ii) volume with respect to pressure when p  105.

11. The table below reveals the velocity v of a body during the specified
time t find its acceleration at t  1.1?
t: 1.0 1.1 1.2 1.3 1.4
v: 43.1 47.7 52.1 56.4 60.8
12. The following table gives the velocity v of a particle at time t. Find its
acceleration at t  2.
t: 0 2 4 6 8 10 12
v: 4 6 16 34 60 94 131
13. A rod is rotating in a plane. The following table gives the angle  (radi-
ans) through which the rod has turned for various values of the time t
second.
t: 0 0.2 0.4 0.6 0.8 1.0 1.2
: 0 0.12 0.49 1.12 2.02 3.20 4.67
Calculate the angular velocity and the angular acceleration of the rod,
when t  0.6 second.
14. Find dy/dx at x  1 from the following table by constructing a central
difference table:
x: 0.7 0.8 0.9 1.0 1.1 1.2 1.3
y: 0.644218 0.717356 0 0.783327 0.841471 0.891207 0.932039 0.963558
15. Find the value of f (x) at x  0.04 from the following table using Bessel’s
formula.
x: 0.01 0.02 0.03 0.04 0.05 0.06
f(x): 0.1023 0.1047 0.1071 0.1096 0.1122 0.1148
358 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

16. If y  f(x) and yn denotes f(x0  nh), prove that, if powers of h above h6
are neglected.
 dy  3 1 1 
   (y  y1 )  (y2  y2 )  (y3  y3 ).
 dx x0 4h
 1 5 45 
[HINT: Differentiate Stiling’s formula w.r.t. x, and put x  0]

17. Find the value of f (8) from the table given below:
x: 6 7 9 12
f (x): 1.556 1.690 1.908 2.158
18. Given the following pairs of values of x and y:
x: 1 2 4 8 10
y: 0 1 5 21 27
Determine numerically dy/dx at x  4.

19. Find f  (6) from the following data:


x: 0 2 3 4 7 8
f (x): 4 26 58 112 466 922
20. Find the maximum and minimum value of y from the following table:
x: 0 1 2 3 4 5
y: 0 0.25 0 2.25 16 56.25
21. Using the following data, find x for which y is minimum and find this
value of y.
x: 0.60 0.65 0.70 0.75
y: 0.6221 0.6155 0.6138 0.6170
22. Find the value of x for which f (x) is maximum, using the table
x: 9 10 11 12 13 14
f (x): 1330 1340 1320 1250 1120 930
Also find the maximum value of f (x).

8.4 Numerical Integration


The process of evaluating a definite integral from a set of tabulated val-
ues of the integrand f(x) is called numerical integration. This process when
applied to a function of a single variable, is known as quadrature.
NUMERICAL DIFFERENTIATION AND INTEGRATION • 359

The problem of numerical integration, like that of numerical differen-


tiation, is solved by representing f(x) by an interpolation formula and then
integrating it between the given limits. In this way, we can derive quadra-
ture formulae for approximate integration of a function defined by a set of
numerical values only.

8.5 Newton-Cotes Quadrature Formula


b
Let I  a
f ( x)dx

where f(x) takes the values y0, y1, y2,  yn for x  x0, x1, x2,  xn.
Let us divide the interval (a, b) into n sub-intervals of width h so that
x0  a, x1  x0  h, x2  x0  2h,  .xn  x0  nh  b. Then

y = f(x)

y0 y1 y2 yn

0 x0 x0 + h x0 +2h x0 +nh X
FIGURE 8.1
x0nh n
I  x0
f ( x)dx  h  0
f ( x0  rh)dr, Putting x  x0  rh, dx  hdr
n r(r  1) 2 r(r  1)(r  2) 3
h  0
[y0  r y0 
2!
 y0 
3!
 y0

r(r  1)(r  2)(r  3) 4 r(r  1)(r  20(r  3)(r  4) 5


  y0   y0
4! 5!
r(r  1)(r  2)(r  3)(r  4)(r  5) 6 
  y0 dr
6! 
[by Newton’s forward interpolation formula]
Integrating term by term, we obtain
x0 nh  n n(2 n  3) 2 n(n  2)2 3
 x0
f ( x)dx  nh y0  y0 
 2 12
 y0 
24
 y0
360 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

 n4 3n3 11n2  4 y0
    3 n
5 2 3  4!
 n5 34 n3 50 n2  5 y0
  2 n4    12 n  (1)
 6 4 3  5!
 n6 15n5 225n3 274 n2 6 y0 
   17 n4    60 n 
7 6 4 3  6! 
This is known as Newton-Cotes quadrature formula. From this gen-
eral formula, we deduce the following important quadrature rules by taking
n  1, 2, 3, 
I. Trapezoidal rule. Putting n  1 in (1) and taking the curve through
(x0, y0) and (x1, y1) as a straight line (Figure 8.2) i.e., a polynomial of first
order so that differences of order higher than first become zero, we get

y0 y1

0 x0 x1 x2 x3 xn x
FIGURE 8.2

x0 h  1  h
 x0
f ( x)dx  h y0  y0  (y0  y1 )
 2  2
x0 2 h  1  h
Similarly  f ( x)dx  h y1  y1  (y1  y2 )
x0 h  2  2
.....................................................................
x0 nh h

x0 ( n1)
f ( x)dx  (yn1  yn)
2
Adding these n integrals, we obtain
x0 nh h
 x0
f ( x)dx  [(y0  yn )  2(y1  y2   yn-1 )]
2
(2)

This is known as the trapezoidal rule.

Obs. The area of each strip (trapezium) is found separately.


NOTE Then the area under the curve and the ordinates at x0 and xn is
approximately equal to the sum of the areas of the n trapeziums.
NUMERICAL DIFFERENTIATION AND INTEGRATION • 361

II. Simpson’s one-third rule. Putting n  2 in (1) above and taking the
curve through (x0, y0), (x1, y1), and (x2, y2) as a parabola (Figure 8.3), i.e., a
polynomial of the second order so that differences of order higher than the
second vanish, we get

y0 y1 y2
0 x0 x1 x2 x3 xn x
FIGURE 8.3
x0 2 h 1 h
 x0
f ( x)dx  2h(y0  y0  2 y0 )  (y0  4 y1  y2 )
6 3
x0 4 h h
Similarly  f ( x)dx  (y2  4 y3  y4 )
x0 2 h 3
...............................................................
x0 nh h
 x0 ( n2) h
f ( x)dx  (yn2  4 yn1  yn ), n being even.
3
Adding all these integrals, we have when n is even
x 0 +nh h
 x0
f(x)dx= [(y 0 +y n )+4(y 1 +y 3 +…+y n-1 )+2(y 2 +y 4 +…y n-2 )]
3
(3)

This is known as the Simpson’s one-third rule or simply Simpson’s rule


and is most commonly used.

Obs. While applying (3), the given interval must be divided


NOTE into an even number of equal subintervals, since we find the
area of two strips at a time.

III. Simpson’s three-eighth rule. Putting n  3 in (1) above and taking


the curve through (xi, yi): i  0, 1, 2, 3 as a polynomial of the third order
(Figure 8.4) so that differences above the third order vanish, we get

y
y0 y1 y3
y2

0 x0 x1 x2 x3 xn x
FIGURE 8.4

x0 3 h  3 3 1 
x0
f ( x)dx  3h y0  y0  2 y0  3 y0 
 2 4 8 
362 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

3h
 (y  3 y1  3 y2  y3 )
8 0
Similarly,
x0 5 h 3h
 x0 3 h
f ( x)dx  (y  3 y4  3 y5  y6 ) and so on.
8 3
Adding all such expressions from x0 to x0  nh, where n is a multiple of
3, we obtain
x0 nh 3h
 x0
f ( x)dx  [(y0  yn )  3(y1  y2  y4  y5   yn1 )
8
(4)
2(y3  y6   yn3 )]

NOTE Obs. While applying (4), the number of sub-intervals should be


taken as a multiple of 3.

IV. Boole’s rule. Putting n  4 in (1) above and taking the curve (xi, yi),
i  0, 1, 2, 3, 4 as a polynomial of the fourth order (Figure 8.5) and neglect-
ing all differences above the fourth, we obtain

y
y1 y3
y0 y2 y4
0 x0 x1 x2 x3 x4 x
FIGURE 8.5
x0 4 h  5 2 7 
 x0
f ( x)dx  4h y0  2y0  2 y0  3 y0   4 y0 
 3 3 90 
2h
(7 y  32 y1  12 y2  32 y33  7 y4 )
45 0
x0 8 h 2h
0

Similarly x 4 h f ( x)dx  (7 y4  32 y5  12 y6  32 y7  7 y8 ) and so on.
45
Adding all these integrals from x0 to x0  nh, where n is a multiple of 4,
we get
2h
x0 nh f ( x)dx  (7 y  32 y1  12 y2  32 y3  14 y4  32 y5 (5)
 x0
45 0
12 y6  32 y7  14 y8 
This is known as Boole’s rule.

Obs. While applying (5), the number of sub-intervals should be


NOTE taken as a multiple of 4.
NUMERICAL DIFFERENTIATION AND INTEGRATION • 363

V. Weddle’s rule. Putting n  6 in (1) above and neglecting all differ-


ences above the sixth, we obtain
x0 6 h  9 123 4
x0
f ( x)dx  6h y0  3y0  2 y0  43 y0 
 2 60
 y0

11 1 41 6 
  5 x0    y0 
20 6 140 
41 6 3
If we replace  y0 by 6 y0 , the error made will be negligible.
140 10
x0 6 h 3h
  x0
f ( x)dx  (y  5 y1  y2  6 y3  y4  5 y5  y6 )
10 0
Similarly
x0 12 h 3h
 x0 6 h
f ( x)dx  (y  5 y7  y8  6 y9  y10  5 y11  y12 ) and so on.
10 6
Adding all these integrals from x0 to x0  nh, where n is a multiple of 6,
we get
x0 nh 3h
 x0
f ( x)dx  (y0  5 y1  y2  6 y3  y4  5 y5  2 y6  5 y7  y8 ) (6)
10
This is known as Weddle’s rule.

Obs. While applying (6), the number of sub-intervals should


NOTE be taken as a multiple of 6. Weddle’s rule is generally more
accurate than any of the others. Of the two Simpson rules, the
1/3 rule is better.

EXAMPLE 8.10
dx 6
Evaluate 
0 1  x2
by using

(i) Trapezoidal rule,


(ii) Simpson’s 1/3 rule,
(iii) Simpson’s 3/8 rule,
(iv) Weddle’s rule and compare the results with its actual value.
Solution:
Divide the interval (0, 6) into six parts each of width h  1. The values
1
of f ( x)  are given below:
1  x2
364 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

x 0 1 2 3 4 5 6
f(x) 1 0.5 0.2 0.1 0.0588 0.0385 0.027
y y0 y1 y2 y3 y4 y5 y6
(i) By Trapezoidal rule,
dx h
 [(y0  y6 )  2(y1  y2  y3  y4  y5 )]
6 1  x2 2
 0 1
 [(1  0.027)  2(0.5  0.2  0.1  0.0588  0.0385)]  1.4108.
2
(ii) By Simpson’s 1/3 rule,
6 dx h
 0 1 x 2
 [(y0  y6 )  4(y1  y 3  y5 )  2(y2  y4
3
1
 [(1  0.027)  4(0.5  0.1  0.0385)  2(0.2  0.0588)]  1.3662.
3
(iii) By Simpson’s 3/8 rule,
6 dx 3h
 0 1 x 2
 [(y0  y6 )  3(y 1  y2  y4  y5 )  2 y3 ]
8
3
 [(1  0.027)  3(0.5  0.2  0.0588  0.0385)  2(0.1)]  1.3571
8
(iv) By Weddle’s rule,
6 dx 3h
 0 1  x2
 [y0  5 y1  y2  6 y3  y4  5 y5  y6 ]
10
 0.3[1  5(0.5)  0.2  6(0.1)  0.0588  5(0.0385)  0.027]  1.3735
dx
6
Also 
0 1  x2
 tan1 x 60  tan1 6  1.4056

This shows that the value of the integral found by Weddle’s rule is the
nearest to the actual value followed by its value given by Simpson’s 1/3 rule.

EXAMPLE 8.11
1 x2
Evaluate the integral  3
dx using Simpson’s 1/3 rule. Compare
the error with the exact value.1  x
0

Solution:
Let us divide the interval (0, 1) into 4 equal parts so that h  0.25.
2
Taking y  x , we have
(1  x3 )
NUMERICAL DIFFERENTIATION AND INTEGRATION • 365

x: 0 0.25 0.50 0.75 1.00


y: 0 0.06153 0.22222 0.39560 0.5
y0 y1 y2 y3 y4
By Simpson’s 1/3 rule, we have
x2
1 h
 0 1 x 3
dx  [(y0  y4 )  2(y2 )  4(y1  y3 )]
3
0.25
 [(0  0.5)  2(0.22222)  4(0.06153  0.3956)]
3
0.25
 [0.5  0.44444  1.82852]  0.23108
3
1
x2 1 1 1
Also 
0 1  x3
dx  log(1  x3 )  log e2  0.23108
3 0 3
Thus the error  0.23108 – 0.23105  – 0.00003.

EXAMPLE 8.12
2
Use the Trapezoidal rule to estimate the integral  0
ex2 dx taking the
number 10 intervals.
Solution:
Let y  ex2 , h  0.2 and n  10.
The values of x and y are as follows:
x: 0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0
y: 1 1.0408 1.1735 1.4333 1.8964 2.1782 4.2206 7.0993 12.9358 25.5337 54.5981
y0 y1 y2 y3 y4 y5 y6 y7 y8 y9 y10

By the Trapezoidal rule, we have


1 h
0
e x 2 dx  [(y0  y10 )  2(y1  y2  y3  y4  y5  y6  y7  y8  y9 )]
2
0.2
 [(1  54.5981)  2(1.0408  1.1735  1.8964  2.1782
2
4.2206  7.0993  12.9358  25.5337)]
2

2
Hence e x dx  17.0621.
0
366 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

EXAMPLE 8.13
0.6
Use Simpson’s 1/3rd rule to find 0
ex 2 dx by taking seven ordinates.
Solution:
Divide the interval (0, 0.6) into six parts each of width h  0.1. The val-
2
ues of y  f  x   e– x are given below:
x 0 0.1 0.2 0.3 0.4 0.5 0.6
2
x 0 0.01 0.04 0.09 0.16 0.25 0.36
y 1 0.9900 0.9608 0.9139 0.8521 0.7788 0.6977
y0 y1 y2 y3 y4 y5 y6

By Simpson’s 1/3rd rule, we have


2 h
ex dx  [(y0  y6 )  4(y1  y3  y5 )  2(y2  y4 )]
3
0.6 0.1
 0

3
[(1  0.6977)  4(0.99  0.9139  0.7788)  2(0.9608  0.8521)]
0.1 0.1
 [1.6977  10.7308  3.6258]  (16.0543)  0.5351.
3 3

EXAMPLE 8.14
1.4
Compute the value of 0.2
(sin x  log x  e x )dx using Simpson’s 3/8
rule.
Solution:
Let y  sin x – loge x  ex and h  0.2, n  6.
The values of y are as given below:
x: 0.2 0.4 0.6 0.8 1.0 1.2 1.4
y: 3.0295 2.7975 2.8976 3.1660 3.5597 4.0698 4.4042
y0 y1 y2 y3 y4 y5 y6
By Simpson’s 3/8 rule, we have
1.4 3h

0.2
ydx 
8
[(y0  y6 )  2(y3 )  3(y1  y2  y4  y5 )]
3
 (0.2)[7.7336  2(3.1660)  3(13.3247)]  4.053
8
NUMERICAL DIFFERENTIATION AND INTEGRATION • 367

1.4
Hence  0.2
(sin x  log e x  e x )dx  4.053.

Obs. Applications of Simpson’s rule. If the various ordinates


NOTE in Section 8.5 represent equispaced cross-sectional areas, then
Simpson’s rule gives the volume of the solid. As such, Simpson’s
rule is very useful to civil engineers for calculating the amount
of earth that must be moved to fill a depression or make a dam.
Similarly if the ordinates denote velocities at equal intervals
of time, the Simpson’s rule gives the distance travelled. The
following Examples illustrate these applications.

EXAMPLE 8.15
The velocity v(km/min) of a moped which starts from rest, is given at
fixed intervals of time t (min) as follows:
t: 2 4 6 8 10 12 14 16 18 20
v: 10 18 25 29 32 20 11 5 2 0
Estimate approximately the distance covered in twenty minutes.
Solution:
ds
If s (km) be the distance covered in t (min), then v
dt
20 h

20
s t0 
0

v dt  [ X  4.0  2.E], by Simpson’s rule
3
Here h  2, v0  0, v1  10, v2  18, v3  25 etc.
 X  v0  v10  0  0  0
O  v1  v3  v5  v7  v9  10  25  32  11  2  80
E  v2  v4  v6  v8  18  29  20  5  72
2
Hence the required distance  s 20
t0  (0  4  80  2  72)  309.33 km.
3

EXAMPLE 8.16
The velocity v of a particle at distance s from a point on its linear path
is given by the following table:
s (m): 0 2.5 5.0 7.5 10.0 12.5 15.0 17.5 20.0
v (m/sec): 16 19 21 22 20 17 13 11 9
368 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

Estimate the time taken by the particle to traverse the distance of 20


meter, using Boole’s rule.
Solution:
ds
If t sec be the time taken to traverse a distance s (m) then v
dt
dr 1
or   y (say),
ds v
20
then
s20
t s0  
0
yds
Here h  2.5 and n  8.
1 1 1 1 1
Also y0  ,y  ,y  ,y  ,y  ,
16 1 19 2 4 3 22 4 20
1 1 1 1
y5  , y6  y7  , y8  .
17 13 11 9
 By Boole’s Rules, we have
20 2h
s20
t s0   0
yds  [7 y  32 y1  312 y2  14 y3  32 y5  12 y6  32 y7  14 y8 ]
45 0
2(2.5)  1  1 1 1 1 1
  7  32  12  32  14  32 
45   16   19   21   22   20   17 
1 1  1 
12  32  14 
3  11   9 
1
 (12.11776)  1.35
9
Hence the required time  1.35 sec.

EXAMPLE 8.17
A solid of revolution is formed by rotating about the x-axis, the area
between the x-axis, the lines x  0 and x  1 and a curve through the points
with the following co-ordinates:
x: 0.00 0.25 0.50 0.75 1.00
y: 1.0000 0.9896 0.9589 0.9089 0.8415
Estimate the volume of the solid formed using Simpson’s rule.
NUMERICAL DIFFERENTIATION AND INTEGRATION • 369

Solution:
Here h  0.25, y0  1, y1  0.9896, y2  0.9589 etc.
 Required volume of the solid generated
1 h
  0
y2 dx   [(y0 2  y4 2 )  4(y12  y32 )  2 y2 2 ]
3
0.25 
 [{1  0.8415)2 }  4{(0.9896)2  (0.9089)2 }  2(0.9589)2 ]
3
0.25  3.1416
 [1.7081  7.2216  1.839]
3
 0.2618(10.7687)  2.8192.
Exercises 8.2
1
1. Use trapezoidal rule to evaluate 
0
x3 dx considering five sub-intervals.
1 dx
2. Evaluate 0 
1 x
applying
(i) Trapezoidal rule
(ii) Simpson’s 1/3 rule
(iii) Simpson’s 3/8 rule.
1 dx using
3. Evaluate  0 1  x2
(i) Trapezoidal rule taking h  1/4.
(ii) Simpson’s 1/3rd rule taking h  1/4.
(iii) Simpson’s 3/8th rule taking h  1/6.
(iv) Weddle’s rule taking h  1/6.
Hence compute an approximate value of  in each case.

4. Find an approximate value of loge 5 by calculating to four decimal


5 dx dividing the range into ten
places, by Simpson’s 1/3 rule,
0 4x  5

equal parts.
4
5. Evaluate  0
e x dx by Simpson’s rule, given that

e  2.72, e2  7.39, e3  20.09, e4  54.6


and compare it with the actual value.
6 ex
6. Find 0 1 x
dx using Simpson’s 1/3 rule.
370 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

2
7. Evaluate  0
ex 2 dx, using Simpson’s rule. (Take h  0.25)

8. Evaluate using Simpson’s 1/3 rule,



(i)  0
sin x dx, taking eleven ordinates.
 /2
(ii)  cos  d , taking nine ordinates.
0

9. Evaluate by Simpson’s 3/8 rule:


9 dx
(i) 0 
1  x3
 /2
(ii)  0
sin x dx
 /2
(iii)  0
esin x dx


(iv)  0
(1  3 cos2  ) d , using six ordinates

10. Given that


x: 4.0 4.2 4.4 4.6 4.8 5.0 5.2
log x: 1.3863 1.4351 1.4816 1.5261 1.5686 1.6094 1.6487
5.2
evaluate  4
log xdx by

(a) Trapezoidal rule


(b) Simpson’s 1/3 rule,
(c) Simpson’s 3/8 rule,
(d) Weddle’s rule.
Also find the error in each case.
 /2
11. Use Boole’s five point formula to compute  0
(sin x) / dx .
12. The table below shows the temperature f (t) as a function of time:
t: 1 2 3 4 5 6 7
f (t): 81 75 80 83 78 70 60
1 7
Using Simpson’s
3
rule to estimate  1
f (t)dt.
NUMERICAL DIFFERENTIATION AND INTEGRATION • 371

13. A curve is drawn to pass through the points given by the following table:
x: 1 1.5 2 2.5 3 3.5 4
y: 2 2.4 2.7 2.8 3 2.6 2.1
Estimate the area bounded by the curve, x-axis and the lines x  1, x  4.
14. A river is 80 feet wide. The depth d in feet at a distance x feet. from one
bank is given by the following table:
x: 0 10 20 30 40 50 60 70 80
y: 0 4 7 9 12 15 14 8 3
15. Find approximately the area of the cross-section.
A curve is drawn to pass through the points given by the following table:
x: 1 1.5 2 2.5 3 3.5 4
y: 2 2.4 2.7 2.8 3 2.6 2.1
Using Weddle’s rule, estimate the area bounded by the curve, the x-axis,
and the lines x  1, x  4.
16. A curve is given by the table:
x: 0 1 2 3 4 5 6
y: 0 2 2.5 2.3 2 1. 7 1. 5

The x-coordinate of the C.G. of the area bounded


6
by the curve, the end
ordinates, and the x-axis is given by Ax 
0

xydx, where A is the area.
Find x by using Simpson’s rule.
17. A body is in the form of a solid of revolution. The diameter D in cms of
its sections at distances x cm. from one end are given below. Estimate
the volume of the solid.
x: 0 2.5 5.0 7.5 10.0 12.5 15.0
D: 5 5.5 6.0 6.75 6.25 5.5 4.0
18. The velocity v of a particle at distance s from a point on its path is given
by the table:
s ft: 0 10 20 30 40 50 60
v ft/sec: 47 58 64 65 61 52 38
Estimate the time taken to travel sixty feet by using Simpson’s 1/3 rule.
Compare the result with Simpson’s 3/8 rule.
372 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

19. The following table gives the velocity v of a particle at time t:


t (seconds): 0 2 4 6 8 10 12
v (m/sec.): 4 6 16 34 60 94 136
Find the distance moved by the particle in twelve seconds and also the
acceleration at t  2 sec.
20. A rocket is launched from the ground. Its acceleration is registered
during the first eighty seconds and is given in the table below. Using
Simpson’s 1/3 rule, find the velocity of the rocket at t  80 seconds.
t (sec): 0 10 20 30 40 50 60 70 80
f (cm/sec2): 30 31.63 33.34 35.47 37.75 40.33 43.25 46.69 50.67
21. A reservoir discharging water through sluices at a depth h below the
water surface has a surface area A for various values of h as given below:
h (ft.): 10 11 12 13 14
A (sq. ft.): 950 1070 1200 1350 1530
If t denotes time in minutes, the rate of fall of the surface is given by
dh/dt  – 48 h/A.
Estimate the time taken for the water level to fall from fourteen to ten
feet above the sluices.

8.6 Errors in Quadrature Formulae


The error in the quadrature formulae is given by
b b
E  a
ydx   a
P( x)dx
where P(x) is the polynomial representing the function y  f(x), in the in-
terval [a, b].
Error in Trapezoidal rule. Expanding y  f(x) around x  x0 by Taylor’s
series, we get
( x  x0 )2 
y  y0  ( x  x0 )y0  y0 
2! (1)
2
x0 h x0 h ( x  x0 ) 
  x0
y dx  
x0
[y0  ( x  x0 )y0 
2!
y0 ]dx (2)

h2 h3
 y0 h  y0  y0 
2! 3!
NUMERICAL DIFFERENTIATION AND INTEGRATION • 373

1
Also A1  area of the first trapezium in the interval [ x0 , x1 ]  h(y0  y1 ) (3)
2
2
h
Putting x  x0  h and y  y1 in (1), we get y1  y0  hy0  y0 
2!
Substituting this value of y1 in (3), we get
1  h2 
A1  h y0  y0  hy0  y0  (4)
2  2! 
h2  h3
 hy0  y0  y  
2 22! 0
x1
 Error in the interval [ x0 , x1]  x0
ydx  A1 [(2) – (4)]

1 1 3  h3
  h y0   y0 
3! 2.2! 12
h3 
i.e., Principal part of the error in [ x0 , x1 ]  y
12 0
h3 
Hence the total error E  [y  y1   yn1 ]
12 0
Assuming that y( X) is the largest of the n quantities y0, y1, yn1 we
obtain
nh3 (b  a)h2
E  y( X)  y( X) [ nh  b – a ...(5)
12 12
Hence the error in the trapezoidal rule is of the order h2.
Error in Simpson’s 1/3 rule. Expanding y = f(x) around x  x0 by Taylor’s
series, we get (1).
 Over the first doubt strip, we get
x2 x0 2 h  ( x  x0 )2  
x0
ydx  
x0
 y0  ( x  x0 )y0 
 2!
y0 dx

(6)

4h2  8h3  16h 4  32h 5 iv


 2hy0  y  y  y  y 
2! 0 3! 0 4! 0 5! 0
Also A1  area over the first doubt strip by Simpson’s 1/3 rule
1
 h(y0  4 y1  y2 ) (7)
3
374 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

Putting x  x0  h and y  y1 in (1), we get


h2 h3
y1  y0  hy0  y  y0 
2! 3!
Again putting x  x0  2h and y  y2 in (1), we have
4h2  8h3 
y2  y0  2hy0  y  y 
2! 0 3! 0
Substituting these values of y1 and y2 in (7), we get
h  h2 
A1   y0  4 y0  hy0  y0  y0
3  2! 
 4h2  8h3  
 2hy0  y0  y0 
 2! 3! 

4h3  2h2  5h 5 iv


 2hy0  2h2 y0  y  y  y 
3 0 3 0 18 0 (8)
 Error in the interval [x0, x2]
x2 4 5 
 
x0
ydx  A1   h 5 y0 iv 
 5 18 
[(6) – (8)]

i.e., Principal part of the error in [x0, x2]


4 5 h5
  h 5 y0 iv  y0 iv
 15 18  90

h 5 iv
Similarly principal part of the error in [ x2 , x4 ]  y and so on.
90 2
h 5 iv
Hence the total error E  [y  y2 iv   yiv 2(n  1)]
90 0
Assuming the yiv(X) is the largest of y0iv, y2iv, ..., yiv2n–2, we get
nh 5 iv (b  a)h 4 iv
E  y0 ( X)  y ( X) [ 2nh  b – a ...(9)]
90 180
i.e., the error in Simpson’s 1/3 -rule is of the order h4.
Error in Simpson’s 3/8 rule. Proceeding as above, here the principal part
of the error in the interval [x0, x3]
3h 5 iv
 y (10)
80
NUMERICAL DIFFERENTIATION AND INTEGRATION • 375

Error in Boole’s rule. In this case, the principal part of the error in the
interval
8h7 iv
[x0, x4]  y (11)
945
Error in Weddle’s rule. In this case, principle part of the error in the
interval
h7
[x0, x6]  y iv (12)
140 0

8.7 Romberg’s Method


In Section 8.5, we have derived approximate quadrature formulae with
the help of finite differences method. Romberg’s method provides a simple
modification to these quadrature formulae for finding their better approxi-
mations. As an illustration, let us improve upon the value of the integral
b
I  a
f ( x)dx,

by the Trapezoidal rule. If I1, I2 are the values of I with sub-intervals of


width h1, h2 and E1, E2 their corresponding errors, respectively, then
(b  a)h12 (b  a)2 h2 2
E1  y( X), E2  y( X)
12 12
Since y( X) is also the largest value of y( x), we can reasonably assume that
y( X) and y( X) are very nearly equal.

E1 h12 E1 h2
  or  2 1 2 (1)
E2 h22 E2  E1 h2  h1

Now since I  I1  E1  I2  E2 ,
 E2 – E1  I1 – I2 (2)
From (1) and (2), we have
h12
E1  (I1  I2 )
h2 2  h12

h12 I1 h2 2  I2 h12
Hence I  I1  E1  I1  (I1  I2 ) i.e., I  (3)
h2 2  h12 h2 2  h12
which is a better approximation of I.
376 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

1
To evaluate I systematically, we take h1  h and h2  h
2
I1 (h / 2)2  I2 h2 2 4I2  I1
so that (3) gives I  
(h / 2)2  h2 3
1
i.e., I(h, h / 2)  [4I(h / 2)  I(h)] (4)
3
Now we use the trapezoidal rule several times successively halving h
and apply (4) to each pair of values as per the following scheme:
I(h)
I(h, h/2)
I(h/2) I(h, h/2, h/4)
I(h/2, h/4) I(h, h/2, h/4, h/8)
I(h/4) I(h/2, h/4, h/8)
I(h/4, h/8)
I(h/8)
The computation is continued until successive values are close to each oth-
er. This method is called Richardson’s deferred approach to the limit and
its systematic refinement is called Romberg’s method.

EXAMPLE 8.18
dx 1
Evaluate 
1 x0
correct to three decimal places using Romberg’s

method. Hence find the value of loge 2.


Solution:
Taking h  0.5, 0.25, and 0.125 successively, let us evaluate the given inte-
gral by the Trapezoidal rule.
(i) When h  0.5, the values of y  (1  x)–1 are:
x: 0 0.5 1
y: 1 0.6666 0.5
0.5
 I (1  0.5  2  0.6666)  0.7083.
2
(ii) When h  0.25, the values of y  (1  x)–1 are:
x: 0 0.25 0.5 0.75 1
y: 1 0.8 0.6666 0.5714 0.5
NUMERICAL DIFFERENTIATION AND INTEGRATION • 377

0.25
 I [(1  0.5)  2(0.8  0.666  0.5714)]  0.697
2
(iii) When h  0.125, the values of y  (1  x)–1 are:
x: 0 0.125 0.25 0.375 0.5 0.625 0.75 0.875 1
y: 1 0.8889 0.8 0. 7272 0.6667 0.6153 0.5714 0.5333 0.5

0.125
I [(1  0.5)  2(0.8889  0.8  0.7272  0.6667
 2
0.6513  0.5714  0.5333)]
 0.6941
Using Romberg’s formulae, we obtain
1 1
I(h, h / 2)  [4I(h / 2)  I(h)]  [4  0.697  0.7083]  0.6932
3 3
1 1
I(h / 2, h / 4)  [4I(h / 4)  I(h / 2)]  [4  0.6941  0.697]  0.6931
3 3
1
I(h, h / 2, h / 4)  [4I(h / 2, h / 4)  I(h, h / 2)]  0.6931
3
1 dx
Hence the value of the integral 
0 1 x
 0.693 (i)

dx
1
Also 
0 1 x
1
 log(1  x) 0  log 2 (ii)

Hence from (i) and (ii), we have


loge 2  0.693.

EXAMPLE 8.19
1 dx correct to four decimal
Use Romberg’s method to compute  0 1  x2
places.
Solution:
We take h  0.5, 0.25 and 0.125 successively and evaluate the given
integral using the Trapezoidal rule.
(i) When h  0.5, the values of y  (1  x2)–1 are
x: 0 0.5 1.0
y: 1 0.8 0.5
378 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

 0.5
I [1  2  0.8  0.5)  0.775
2
(ii) When h  0.25, the values of y  (1  x2)–1 are
x: 0 0.25 0.5 0.75 1.0
y: 1 0.9412 0.8 0.64 0.5
0.25
I [1  2(0.9412  0.8  0.64)  0.5]  0.7828
2
(iii) When h  0.125, we find that I  0.7848
Thus we have
I(h)  0.7750, I(h/2)  0.7828, I(h/4)  0.7848
Now using (4) above, we obtain
1 1
I(h, h / 2)  [4I(h / 2)  I(h)]  (3.1312  0.775)  0.7854
3 3
1 1
I(h / 2, h / 4)  [(4I(h / 4)  I(h / 2)]  (3.1392  0.7828)  0.7855
3 2
1 1
I(h, h / 2, h / 4)  [4I(h / 2, h / 4)  I(h, h / 2)]  (3.142  0.7854)  0.7855
3 3
 The table of these values is
0.7750
0.7854
0.7828 0.7855
0.7855
0.7848
Hence the value of the integral  0.7855.

EXAMPLE 8.20
0.5  x 
Evaluate the integral  0
 dx using Romberg’s method, correct
 sin x 
to three decimal places.
Solution:
Taking h  0.25, 0.125, 0.0625 successively, let us evaluate the given
integral by using Simpson’s 1/3 rule.
NUMERICAL DIFFERENTIATION AND INTEGRATION • 379

x
(i) When h  0.25, the values of y  are
sin x
x: 0 0.25 0.5
y: 1 1.0105 1.0429
y0 y1 y2

 By Simpson’s rule,
h 0.25
I  [(y0  y2 )  4 y1 ]  [(1  1.0429)  1.0105]
3 3
 0.5071

(ii) When h  0.125, the values of y are


x: 0 0.125 0.25 0.375 0.5
y: 1 1.0026 1.0105 1.1003 1.0429
y0 y1 y2 y3 y4
 By Simpson’s rule
h
I  [(y 0  y4 )  4(y 1  y3 )  2 y2 ]
3
0.125
 [(1  1.0429)  4(1.0026  1.1003)  2(1.0105)]
3
 0.5198
(iii) When h  0.0625, the values of y are
x: 0 0.0625 0.125 0.1875 0.25 0.3125 0.1875 0.4375 0.5
y: 1 0.0006 1.0026 1.0059 1.0157 1.0165 1.1003 1.0326 1.0429
y0 y1 y2 y3 y4 y5 y6 y7 y8
 By Simpson’s rule:
h
I  [(y0  y8 )  4(y1  y3  y5  y7 )  2(y2  y4  y6 )]
3
0.0625
 [(1  1.0429)  4(1.0006  1.0059  1.0165  1.0326
3
2(1.0026  1.0105  1.1003)]
 0.510253
380 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

Using Romberg’s formulae, we obtain


h 1  h  
I(h, )   4I  I(h) 0.5241
2 3  2  
h h 1  h   h 
I( , )   4I  I  0.5070
2 4 3  4   2 
h h 1  h h   h 
I(h. , )   4I ,  I h,  0.5013
2 4 3  2 4   2 
0.5 x 
Hence  0
 dx  0.501
 sin x 

8.8 Euler-Maclaurin Formula


Taking F(x)  f(x), we define the inverse operator –1 as
F(x)  –1 f(x) (1)
Now F(x1) – F(x0)  F(x0)  f(x0)
Similarly, F(x2) – F(x1)  f(x1)
.....................................
F(xn) – F(xn–1)  f(xn–1)
Adding all these, we get
n1
F( xn )  F( x0 )   f (x ) i
(2)
i0

where x0, x1, ....., xn are the (n  1) equispaced values of x with differ-
ence h.
From (1), we have
F( x)  1 f ( x)  (E  1)1 f ( x)  (ehD  1)1 f ( x) [ E = ehD]
1
 h 2 D2 h 3 D3  
1  hD    1  f ( x)
 2! 3!  
1
 hD h2 D2
1

 (hD) 1    f ( x)
 2! 3!  (3)
1  hD h2 D2 h 4 D4 
 D11     f ( x)
h  32 12 720 
1 1 h h3

h
 f ( x)dx 
2
f ( x) 
12
f ( x) 
720
f ( x) 
NUMERICAL DIFFERENTIATION AND INTEGRATION • 385

To solve these equations, we shift the origin to x0 and take x0  0.


 The above equations reduce to
2
a–1  a0  a1  2h, – a–1  a1  0 and a1  a1  h
3
1 4
Solving these, we get a1  h  a1 , a0  h
3 3
x0 h h
Hence  x0 h
ydx  (y1  4 y0  y1 ) which is Simpson’s rule.
3
(9)

8.10 Gaussian Integration


b
So far the formulae derived for evaluation of  a
f ( x)dx, required the
values of the function at equally spaced points of the interval. Gauss derived
a formula which uses the same number of functional values but with differ-
ent spacing and yields better accuracy.
Gauss formula is expressed as
n
1

1
f ( x)dx  w1 f ( x1 )  w2 f ( x2 )   wn f ( xn )   w f (x )i i (1)
i1

where wi and xi are called the weights and abscissae, respectively. The ab-
scissae and weights are symmetrical with respect to the middle point of the
interval. There being 2n unknowns in (1), 2n relations between them are
necessary so that the formula is exact for all polynomials of degree not ex-
ceeding 2n – 1. Thus we consider

f ( x)  c0  c1 x  c2 x   c2 n1 x2 n1 (2)


Then (1) gives
1 1

1
f ( x)dx   1
(c0  c1 x  c2 x   c2 n1 x2 n1 )dx (3)
2 2
 2 c0  c2  c4 
3 5
Putting x  xi in (2), we get
f ( xi )  c0  c1 xi  c2 x2i  c3 x3i   c2 n1 x2i n1
386 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

Substituting these values on the right hand side of (1), we obtain


1
 1
f ( x)dx  w1(c0  c1 x1  c2 x12  c3 x13  c2 n1 x12 n1
  w2(c0  c1 x2  c2 x22  c3 x23  ....  c2n – 1 x22n – 1)
  w3(c0  c1 x3  c2 x32  c3 x33  ....  c2n – 1 x32n – 1)
  ...............................................................................
  wn(c0  c1 xn  c2 xn2  c3 xn3  ....  c2n – 1 xn2n – 1)
  c0 (w1  w2  w3    wn)  c1 (w1x1  w2 x2  w3 x3    wn xn)
  c (w x 2  w x 2  w x 2    w x 2)
2 1 1 2 2 3 3 n n

 ...................................................................
 c2n – 1 (w1x12n – 1  w2 x22n – 1  w3 x32n – 1    wn xn2n – 1) (4)
But the equations (3) and (4) are identical for all values of ci, hence
comparing coefficients of ci , we obtain 2n equations in 2n unknowns wi and
xi (i  1, 2, ......, n).
w1  w2  w3   wn  2

w1 x1  w2 x2  w3 x3   wn xn  0
2 (5)
w1 x12  w2 x2 2  w3 x32   wn xn2  
3
.............................................................................
2 n1 
w1 x1  w2 x2 2 n1  w3 x32 n1   wn xn2 n1  0
The solution of the above equations is extremely complicated. It can
however, be shown that xi are the zeros of the (n  1)th Legendre polyno-
mial.
Gauss formula for n = 2 is
1
 1
f ( x)dx  w1 f ( x1 )  w2 f ( x2 )
Then the equations (5) become
w1  w2  2
w1 x1  w2 x2  0
2
w1 x12  w2 x2 2 
3
w1 x13  w2 x2 3  0
Solving these equations, we obtain
w1  w2  1, x1  – 1/3 and x2  1/3.
NUMERICAL DIFFERENTIATION AND INTEGRATION • 387

Thus Gauss formula for n  2 is


1
 1
f ( x)dx  f (1 3)  f (1 / 3) (6)
which gives the correct value of the integral of f(x) in the range (– 1, 1)
for any function up to third order. Equation (6) is also known as Gauss-
Legendre formula.
Gauss formula for n = 3 is
1 8 5  3   3 

1 9
f (0)   f   f  
f ( x)dx 
9  5   5 
(7)

which is exact for polynomials upto degree 5.


The abscissae xi and the weights wi in (1) are tabulated for different
values of n. The following table lists the abscissae and weights for values of
n from 2 to 5.
TABLE 8.1 Gauss integration: Abscissae and Weights
N xi wi
2 – 0.57735 1.0000
0.57735 1.0000
3 – 0.7746 0 0.55555
0.00000 0.88889
0.77460 0.55555
4 – 0.86114 0.34785
– 0.33998 0.65214
0.33998 0.65214
0.86114 0.34785
5 – 0.90618 0.23693
– 0.53847 0.47863
0.00000 0.56889
0.53847 0.47863
0.90618 0.23693
Gauss formula imposes a restriction on the limits of integration to be from
– 1 to 1.
b

In general, the limits of the integral a f ( x)dx are changed to – 1 to 1
by means of the transformation
1 1 (8)
x  (b  1) u  (b  a)
2 2
388 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

EXAMPLE 8.23
dx 1
Evaluate

1 1  x 2
using Gauss formula for n  2 and n  3.
Solution:
(i) Gauss formula for n  2 is
1 dx  1   1  1
I  1 1  x 2
 f   f   where f ( x) 
 3  3 1  x2
1 1 3 3
I  2
 2
   1.5.
1  (1 3) 1  (1 / 3) 4 4
(ii) Gauss formula for n  3 is

8 5  3   3  1
I f (0)   f   f   where f ( x) 
9 9  5   5  1  x2

8 5 5 5  8 50
Thus I  (1)       1.5833 .
9 9 8 8  9 72

EXAMPLE 8.24
1 dx
Using the three-point Gaussian quadrature formula, evaluate
 0 1 x
Solution:
We first change the limits (0, 1) to – 1 to 1 by (8) above, so that
1 1 1
x  (1  0) u (1  0)  ( u  1).
2 2 2
1
1 dx 1
du 1 du
 I  0 
1 x
  1
2
1
 1 u3
1  ( u  1)
2
Gauss-formula for n  3 is
8 5  3  3 1
I  f (0)  f   f   where f ( x) 
9 9  5  5 1  x2


8 1  5  1 1 

Thus I      
9 3  9 
 (3 / 5)  3 (3 / 5)  3 

NUMERICAL DIFFERENTIATION AND INTEGRATION • 389

8 25
   0.29629  0.39682  0.6931
27 63
Otherwise (using the table):
1
I  w1 f ( u1 )  w2 f ( u2 )  w3 f ( u3 ) where f ( ui ) 
ui  3
Using the abscissae and weights corresponding to n  3 in the above table,
we obtain
1 1 1
I (0.555)  (0.8889)  (0.555)
3  0.7746 30 3  0.7746
1
 0.4497  0.5555  (0.8889)  0.2649  0.5555  0.6931.
3

EXAMPLE 8.25
2 x2  2 x  1
Evaluate  0 1  ( x  1)4
dx by the Gaussian three-point formula.
Solution:
Changing the limits of integration 0 to 2 to – 1 to 1 by
1 1 20 20
x  (b  a) u  (b  a)  u  u 1
2 2 2 2
2 x2  2 x  1 ( u  1)2  2( u  1)  1
1
 I  0 1  ( x  1)4
dx  
1 1  ( u  1  u)4
du [ dx  du]

u2  4 u  4
1 1
 1 ( u  2)4  1
du   1
f ( u)du

u2i  4 ui  4
 w1 f ( u1 )  w2 f ( u2 )  w3 f ( u3 ) where f ( ui ) 
( ui  2)4  1
4 4
Now f (0)  4

2 1 17
 3  ( (3 / 5)  2)2 15016
f     0.4614
 5  [ (3 / 5)  2]  1 3.2548
4

 3 (3 / 5)  2 7.6984
f   4
  0.1277
 5  [ (3 / 5)  2]  1 60.2652
390 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE

Using the three-point Gaussian formula, we have


1 8 5  3   3 
I
1

f ( u)du  f (0)  f   f  
9 9  5   5 

8 4  5
   [0.4614  0.1277]  0.5365
9 17  9
Solution:
Changing the limits of integration (0.2 to 1.5) to (– 1, 1) by
1 1 1 1
x  (b  a) u  (b  a)  (1.5  0.2) u  (1.5  0.2)
2 2 2 2
 0.65 u  0.85
1.5 1 1
  
2
 I ex dx  0.65 e(0.65 u0.85)2 du  0.65 f ( u)du
0.2 1 1

so that f(u)  e−(0.65u  0.85)2


Now f(0)  e−[0.65(0)  0.85]2 0.4855,
2
f ( 3 / 5)  f (0.7746)  e[0.65(0.7746)0.85]  0.8869
2
f ( 3 / 5)  f (0.7746)  e[0.65(0.7746)0.85]  0.1601.
Using the Gauss three-point formula, we have

I  f ( u)du  f (0)[ f ( 3 / 5)  f ( 3 / 5)]


5 5
 (0.4855)  [0.8869  0.1601]  0.4316  0.5187  1.0133
9 9
1.5

2
Hence ex dx  0.65(1.0133)  0.65865.
0.2

Exercises 8.3

1. Obtain an estimate of the number of sub-intervals that should be cho-


2
sen so as to guarantee that the error committed in evaluating
1
dx/ x by 
trapezoidal rule is less than 0.001.
2. Evaluate 2 dx using the Romberg’s method. Hence obtain an ap-

0 x2  4

proximate value of .
NUMERICAL DIFFERENTIATION AND INTEGRATION • 391

5.2
3. Apply Romberg’s method to evaluate  4
log x dx, given that
x: 4.0 4.2 4.4 4.6 4.8 5.0 5.2
loge x: 1.3863 1.4351 1.4816 1.526 1.5686 1.6094 1.6486.
 /2
4. Using the Euler-Maclaurin formula, find the value of 
0
sin x dx cor-
rect to five decimal places.
5. Using the Euler-Maclaurin formula, prove that
n n 2
n(n  1)(2 n  1) n(n  1)
(a)  x  2
6
(b)  3
x 
 2 

1 1

6. Apply the Euler-Maclaurin formula, to evaluate


1 1 1 1
(a)    
400 402 404 500
1 1 1 1
(b) 2
 2
 2
 
(201) (203) (205) (299)2
h
7. Assuming that  0
y( x)dx  h(a0 y0  a1 y1 )  h2 (b0 y0  b1 y1) derive the
quadrature formula, using the method of undetermined coefficients.
8. Using the Gaussian two-point formula compute
n 2
2 n(n  1)
(a)  2
x 2
e dx (b)  3
x 
 2 

1
9. Using three point Gaussian quadrature formula, evaluate:
51 2 1
(a) (i) 
2 x
dx (b) 1 1  x3
dx .

10. Evaluate the following, integrals, using the Gauss three-point formula:
5 4
(a)
2
4
 (1  x 4 )dx (b) 3
 2 x2 
dx 
1
11. Using the four point Gauss formula, compute  0
xdx correct to four
decimal places.

You might also like