316
COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES
6.5 TRAPEZOIDAL RULE
Putting n =1 in equation (2) and taking the curve y = f(x) through (x
0
, y
0
) and (x
0
, y
0
) as a polynomial
of degree one so that differences of order higher than one vanish, we get
()()
0
0
00 010 01
1
() 2
22 2
xh
x
hh
fxdx hy y y y y y y
+
=+∆= +−=+
∫
Similarly, for the next sub interval
()
00
,2,
xhx h
++
we get
()
00
00
2
12 1
(1)
( ) ( ) ( )
22
xnh
xh
nn
xh x n h
hh
f x dx y y f x dx y y
+
+
−
++−
=+ = +
∫∫
Adding the above integrals, we get
()
0
0
012 1
() 2( )
2
xnh
nn
x
h
f x dx y y y y y
+
−
=+++++
∫
which is known as Trapezoidal rule.
6.6 SIMPSON’S ONE-THIRD RULE
Putting n = 2 in equation (2 ) and taking the curve through
00 11
(,),(,)
xy xy
and
22
(,)
xy
as a
polynomial of degree two so that differences of order higher than two vanish, we get
0
0
2
2
00 0
1
() 2
6
xh
x
fxdx hy y y
+
=+∆+∆
∫
()
010210 012
2
66 (2 ) (4 )
63
hh
yyyyyy yyy
=+−+−−=++
Similarly,
()
0
0
4
234
2
( ) 4 ,
3
xh
xh
h
fxdx y y y
+
+
=++
∫
0
0
21
(2)
() ( 4 )
3
xnh
nnn
xnh
h
fxdx y y y
+
−−
+−
=++
∫
Adding the above integrals, we get
()( )
0
0
0131242
() 4 2( )
3
xnh
nn n
x
h
fxdx y y y y y y y y
+
−−
= + + + ++ + + ++
∫
which is known as Simpson’s one-third rule.
Note: Using the formula, the given interval of integration must be divided into an even number of sub-
intervals.
NUMERICAL DIFFERENTIATION AND INTEGRATION
317
6.7 SIMPSON’S THREE-EIGHT RULE
Putting n = 3 in equation (2) and taking the curve through (x
0
, y
0
), (x
1
, y
1
), (x
2
, y
2
) and (x
3
, y
3
) as a
polynomial of degree three so that differences of order higher than three vanish, we get
0
0
3
23
00 0 0
33 1
() 3
24 8
xh
x
fxdx hy y y y
+
=+∆+∆+∆
∫
()( )
0 10 2 10 3 2 10
3
812 6 2 (33 )
8
h
y yy yyy yyyy
=+−+−++−+−
()
0123
3
33
8
h
yyyy
=+++
Similarly,
()
0
0
6
3456
3
3
( ) 3 3 ,
8
xh
xh
h
fxdx y y y y
+
+
=+++
∫
0
0
6
321
(3)
3
() ( 3 3 )
8
xh
nnnn
xnh
h
fxdx y y y y
+
−−−
+−
=+++
∫
Adding the above integrals, we get
0
0
0) 1245 2 1 36 3
3
( ) [( 3( ) 2( )]
8
xnh
nnnn
x
h
fxdx y y y y y y y y y y y
+
−− −
=+++++++++++
∫
which is known as Simpson’s three-eighth rule.
Note: Using this formula, the given interval of integration must be divided into sub-intervals whose
number n is a multiple of 3.
6.8 BOOLE’S RULE
Putting n = 4 in equation (2) and neglecting all differences of order higher than four, we get
0
0
4
4
23 4
00 0 0 0
0
(1)(1)(2)(1)(2)(3)
()
2! 3! 4!
xh
x
rr rr r rr r r
fxdx h y r y y y y dr
+
−−−−−−
= +∆+ ∆+ ∆+ ∆
∫∫
(By Newton’s forward interpolation formula)
4
4
2432
23
0
00 0 0
0
(2 3) ( 2) 3 11
43
212 24 5234!
y
nnn nn nnn
hy y y y n
∆
−−
=+∆+ −∆+ ∆+−+−
23 4
0000 0
52 7
42
3390
hyyyy y
= +∆+∆+∆+∆
01234
2
(7 32 12 32 7 )
45
h
yyyyy=++++
Similarly,
08
04
45678
2
( ) (7 32 12 32 7 )
45
h
h
x
x
h
fxdx y y y y y
+
+
=++++
∫
and so on.
318
COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES
Adding all these integrals from x
0
to x
0
+ nh, where n is a multiple of 4, we get
0
0
012345678
2
( ) (7 32 12 32 14 32 12 32 14 )
45
xnh
x
h
fxdx yyyyyyyyy
+
= ++++++++
∫
This is known as Boole’s rule.
Note: Using Boole’s rule, the number of sub-intervals should be taken as a multiple of 4.
6.9 WEDDLE’S RULE
Putting n = 6 in equation (2) and neglecting all differences of order higher than six, we get
0
0
6
6
23
00 0 0
0
(1) (1)(2)
()
2! 3!
xh
x
rr rr r
fxdx h y ry y y
+
−−−
=+∆+ ∆+ ∆
∫∫
45
00
(1)(2)(3) (1)(2)(3)(4)
4! 5!
rrrr rrrrr
yy
−−− −−−−
+∆+ ∆
6
0
( 1)( 2)( 3)( 4)( 5)
6!
rr r r r r
ydr
−−−−−
+∆
232 4
2323
00 0 0
11
2232 64
rrr r
hry y y r r y
=+∆+−∆+−+∆
54 3 6 4 3
24 5 25
00
1311 1 3550
3212
24 5 2 3 120 6 4 3
rr r r r r
ry r ry
+−+−∆+ −+−+∆
78 4 3
52
6
6
0
0
1 5 225 274
17 60
720 7 2 4 3
rr r r
rry
+−+−+−∆
=
63
9
2
4
41
20
11
20
41
840
00
2
0
3
0
4
0
5
0
6
0
hy y y y y y y
++ + + + +
L
N
M
O
Q
P
∆∆ ∆ ∆ ∆ ∆
2345 6
00 0 0 0 0 0
641
20 60 90 80 41 11
20 42
h
yy y y y y y
= +∆+∆+∆+∆+∆+∆
()( )( )
010 210 3210
3
20 60 90 2 80 3 3
10
h
yyy yyy yyyy
=+−+−++−+−
43210 54 3 210
41(464 )11(510105 )
yyyyy yy y yyy+ −+−++ −+−+−
65 4 3 210
( 6 15 20 15 6 )]
yy y y yyy+−+−+−+
3
41
42
1
≈
L
N
M
O
Q
P
()
0
12 34 56
3
565
10
h
yyyyyyy
= + ++ ++ +
NUMERICAL DIFFERENTIATION AND INTEGRATION
319
Similarly,
()
()
0
0
12
6 7 8 9 10 11 12
6
3
56 5
10
xh
xh
h
fxdx y y y y y y y
+
+
=++++++
∫
0
0
654321
(6)
3
() ( 5 6 5 )
10
xnh
nnynnnn
xnh
h
fxdxyyyyyyy
+
−−−−−−
+−
=++++++
∫
Adding the above integrals, we get
0
0
0 1 2 3 4 5 6 7 8 9 10 11 12
3
() ( 5 6 5 2 5 6 5 2 )
10
xnh
x
h
fxdx yyyyyyyyyyy y y
+
= + ++ ++ + + ++ + + + +
∫
which is known as Weddle’s rule. Here n must be a multiple of 6.
Example 1. Use Trapezoidal rule to evaluate
1
0
1
.
1
dx
x+
∫
Sol. Let h = 0.125 and y = f(x) =
1
1 x+
, then the values of y are given for the arguments which
are obtained by dividing the interval [0,1] into eight equal parts are given below:
x 0 0.125 0.250 0.375 0.5 0.625 0.750 0.875 1.0
1
1
y
x
=
+
1.0 0.8889 0.8000 0.7273 0.6667 0.6154 0.5714 0.5333 0.5
y
0
y
1
y
2
y
3
y
4
y
5
y
6
y
7
y
8
Now by Trapezoidal rule
1
0 1234567 8
0
1
[2( )]
12
h
dx y yyyyyyy y
x
= + ++++++ +
+
∫
0.125
[1 2(0.8889 0.800 0.7273 0.6667 0.6154 0.5714 0.5333) 0.5]
2
= + ++++++ +
0.125
[1.5 2(4.803)]
2
=+
=
0.125
2
[11.106] = 0.69413. Ans.
Example 2. Evaluate
1
2
0
1
dx
x+
∫
using
(i) Simpson’s
1
3
rule taking
1
4
h =
(ii) Simpson’s
3
8
rule taking
1
6
h =
(iii) Weddle’s rule taking
1
6
h =
Hence compute an approximate value of π in each case.
320
COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. (i) The values of
2
1
()
1
fx
x
=
+
at
123
0, , , ,1
444
x =
are given below:
()
01234
11 3
01
42 4
16
1 0.8 0.64 0.5
17
x
fx
yyy y y
By Simpon’s
1
3
rule
()
1
04 13 2
2
0
[4()2]
3
1
dx h
yy yy y
x
=++++
+
∫
{}
116
(1 0.5) 4 .64 2(0.8) 0.78539215
12 17
=++++ =
Also,
1
11
2
0
0
tan tan 1
4
1
dx
x
x
−−
π
===
+
∫
∴
0.785392156 3.1415686
4
π
=⇒π≈
. Ans.
(ii) The values of
2
1
()
1
fx
x
=
+
at x = 0,
12345
,,,,,1
66666
are given below:
()
0123456
12345
0 1
66666
36 9 4 9 36 1
1
37 10 5 13 61 2
x
fx
yyyyyyy
By Simpson’s
3
8
rule
[]
1
06 1245 3
2
0
3
()3( )2
8
1
dx h
yy yyyy y
x
=++++++
+
∫
=
3
1
6
8
1
1
2
3
36
37
9
10
9
13
36
61
2
4
5
F
H
I
K
+
F
H
G
I
K
J
++++
R
S
T
U
V
W
+
F
H
G
I
K
J
L
N
M
O
Q
P
= 0.785395862
Also,
1
2
0
4
1
dx
x
π
=
+
∫
∴
0.785395862
4
π
=
⇒
π = 3.141583. Ans.
NUMERICAL DIFFERENTIATION AND INTEGRATION
321
(iii) By Weddle’s rule
()
1
0123456
2
0
3
565
10
1
dx h
yyyyyyy
x
=++++++
+
∫
1
3
36949361
6
15 6 5
10 37 10 5 13 61 2
= + ++ ++ +
= 0.785399611
Since
1
2
0
4
1
dx
x
π
=
+
∫
∴
0.785399611
4
π
=
⇒
π = 3.141598
Example 3. Evaluate
6
2
0
1
dx
x+
∫
by using
(i) Trapezoidal Rule
(ii) Simpson’s one-third rule
(iii) Simpson’s three-eighth rule
(iv) Weddle’s rule.
Sol. Divide the interval (0, 6) into six parts each of width h = 1.
The value of
2
1
()
1
fx
x
=
+
are given below:
x 01 2 3 4 5 6
f(x) 1 0.5 0.2 0.1
1
17
1
26
1
37
y
0
y
1
y
2
y
3
y
4
y
5
y
6
(i) By Trapezoidal rule,
6
06 12345
2
0
[( ) 2( )]
2
1
dx h
yy yyyyy
x
= + + ++++
+
∫
11 11
120.50.20.1
237 1726
=++++++
= 1.410798581. Ans.
(ii) By Simpson’s one-third rule,
()( )
6
06 135 24
2
0
[4 2()]
3
1
dx h
yy yyy yy
x
=++++++
+
∫
11 1 1
140.50.120.2
337 26 17
=++ ++++
= 1.366173413. Ans.
322
COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES
(iii) By Simpson’s three-eighth rule,
6
06 1245 3
2
0
3
[( ) 3( ) 2 ]
8
1
dx h
yy yyyy y
x
=++++++
+
∫
=
31 11
1 3 0.5 0.2 2(0.1)
837 1726
++ ++++
= 1.357080836. Ans.
(iv) By Weddle’s rule,
6
0123456
2
0
3
(5 6 5 )
10
1
dx h
yyyyyyy
x
=++++++
+
∫
3111
1 5(0.5) 0.2 6(0.1) 5
10 17 26 37
=+ ++ ++ +
1.373447475.=
Ans.
Example 4. Using Simpson’s one-third rule, find
6
2
0
(1 )
dx
x+
∫
. (B. Tech. 2002)
Sol. Divide the interval [0,6] into 6 equal parts with
60
6
h
−
=
= 1. The values of
2
1
(1 )
y
x
=
+
at
each points of sub-divisions are given by
x 01 2 3 4 5 6
2
1
(1 )
y
x
=
+
1 0.25 0.11111 0.0625 0.04 0.02778 0.02041
y
0
y
1
y
2
y
3
y
4
y
5
y
6
By Simpson’s one-third rule, we get
[]
6
0 135 24 6
2
0
4( ) 2( )
3
(1 )
dx h
y yyy yy y
x
=++++++
+
∫
=
[]
1
1 4(0.25 0.0625 0.02778) 2(0.11111 0.04) 0.02041
3
+++ + ++
=
[]
1
1.02041 4(0.34028) 2(0.15111)
3
++
=
[]
11
1.02041 1.36112 0.30222 (2.68375)
33
++
= 0.89458. Ans.
Example 5. Evaluate
4
2
0
1
dx
x
x+
∫
using Boole’s rule taking
(i) h = 1 (ii) h = 0.5
Compare the rusults with the actual value and indicate the error in both.
NUMERICAL DIFFERENTIATION AND INTEGRATION
323
Sol. (i) Dividing the given interval into 4 equal subintervals (i.e. h = 1), the table is as below:
x 01234
y 1
1
2
1
5
1
10
1
17
y
0
y
|
y
2
y
3
y
4
Using Boole’s rule,
1
4
0234
0
2
(7 32 12 32 7 )
45
h
ydx y y y y y=++++
∫
=
21
45
71 32
1
2
12
1
5
32
1
10
7
1
17
()
()+
F
H
I
K
+
F
H
I
K
+
F
H
I
K
+
F
H
I
K
L
N
M
O
Q
P
= 1.289412 (approx.)
∴
4
2
0
1.289412.
1
dx
x
=
+
∫
Ans.
(ii) Dividing the given interval into 8 equal subintervals (i.e. h = 0.5), the table is as below:
x 0 0.5 1 1.5 2 2.5 3 3.5 4
y 1.0 0.8 0.5
4
13
0.2
4
29
0.1
4
53
1
17
y
0
y
1
y
2
y
3
y
4
y
5
y
6
y
7
y
8
Using Boole’s rule,
[]
4
012345678
0
2
7321232143212327
45
h
ydx y y y y y y y y y
=++++++++
∫
=
() () ()
14441
7(1) 32(8) 12(5) 32 7 .2 7 .2 32 12 .1 32 7
45 13 29 53 17
+++ +++ + + +
= 1.326373
∴
dx
x1
2
0
4
+
z
= 1.326373
But the actual value is
()
0
4
4
11
2
0
tan tan (4) 1.325818
1
dx
x
x
−−
===
+
∫
Error in I result =
1.325818 1.289412
100 2.746%
1.325818
−
×=
Error in II result =
1.325818 1.326373
100 0.0419%
1.325818
−
×=−
324
COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 6. Evaluate the integral
6
3
0
1
dx
x+
∫
by using Weddle’s rule.
Sol. Divide the interval [0,6] into 6 equal parts each of width
60
1
6
h
−
==
. The value of
3
1
1
y
x
=
+
at each points of sub-divisions are given below:
x 0123456
y 1.0000 0.5000 0.1111 0.0357 0.0153 0.0079 0.0046
y
0
y
1
y
2
y
3
y
4
y
5
y
6
By Weddle’s Rule, we get
[]
6
0152436
3
0
3
5( ) 6
10
1
dx h
yyyyyyy
x
=++++++
+
∫
[]
3
1.0000 5(0.5000 0.0079) 0.1111 0.0153 6(0.357) 0.0046
10
=++++++
()()
3
1.131 5 0.5079 6 0.0357
10
=+ +
[]
3
1.131 2.5395 0.2142
10
=++
3
(3.8847) 1.1654.
10
==
Ans.
Example 7. Evaluate the integral
3
1.5
0
1
x
x
dx
e
−
∫
by using Weddle’s rule.
Sol. Dividing the interval [0, 1, 5] into 6 equal parts of each of width
1.5 0
0.25
6
h
−
==
and the
values of
3
1
x
x
y
e
=
−
at each points of sub-interval are given by
x 0 0.25 0.50 0.75 1.00 1.25 1.50
y 0 0.0549 0.1927 0.3777 0.5820 0.7843 0.9694
y
0
y
1
y
2
y
3
y
4
y
5
y
6
Now by Weddle’s rule, we get
[]
3
1.5
0152436
0
3
5( ) 6
10
1
x
xh
dx y y y y y y y
e
=++++++
−
∫
[]
3(0.25
0 5(0.0549 0.7843) 0.1927 0.5820 0.9694 6(0.3777)
10
= + + ++++
= 0.075[1.7441 + 5(0.8392) +6(0.3777)]
NUMERICAL DIFFERENTIATION AND INTEGRATION
325
= 0.075[1.7441 + 4.196 + 2.2662] = 0.075(8.2063)
= 0.6155. Ans.
Example 8. Evaluate the integral
5.2
4
log ,
xdx
∫
using Weddle’s rule.
Sol. Divide the interval [4, 5.2] into 6 equal sub-interval of each width
5.2 4
0.2
6
−
==
and
values of y = log x are given below:
x 4.0 4.2 4.4 4.6 4.8 5.0 5.2
y 1.3862 1.4350 1.4816 1.5261 1.5686 1.6094 1.6486
y
0
y
1
y
2
y
3
y
4
y
5
y
6
By Weddle’s Rule, we get
5.2
0152436
4
3
log [ 5( ) 6 ]
10
h
xdx y y y y y y y= + + +++ +
∫
3(0.2)
[1.3862 5(1.4350 1.6094) 1.4816 1.5686 6(1.5261) 1.6486]
10
=++++++
0.6
[1.3862 5(3.0444) 1.4816 1.5686 6(1.526) 1.6486]
10
= + +++ +
0.6
[6.085 5(3.0444) 6(1.5261)]
10
=++
0.6
[6.085 15.222 9.1566]
10
=++
==
0.6
(30.4636) 1.8278
10
Ans.
Example 9. A river is 80 m wide. The depth y of the river at a distance ‘x’ from one bank is given by the
following table:
x
01020304050607080
y
0 4 7 9 12 15 14 8 3
Find the approximate area of cross section of the river using
(i) Boole’s rule.
(ii) Simpson’s one-third rule.
Sol. The required area of the cross-section of the river.
80
0
ydx=
∫
(1)
Here no. of sub intervals is 8
(i) Boole’s rule,
[]
= ++++++++
∫
80
012345678
0
2
7321232143212327
45
h
ydx yyyyyyyyy