SPCE-DCCN Numerical Integration Trapezoidal and Simpson’s rule
Numerical Integration
b b
Introduction: To Evaluate I = ydx = f ( x)dx
a a
Divide the interval a, b into n equal sub-intervals
a = x0 , x1 , x1, x2 , x2 , x3 xn−1, xn = b where xi − xi −1 = h (fixed)
Let y0 , y1 , y2 , , yn be the values of the function y = f ( x) at equidistance points
a = x0 , x1 , x2 , , xn = b respectively.
Here we shall evaluate integral numerically using following three methods
Method 1: Trapezoidal Rule
xn
h
ydx = 2 ( y
x0
0 + yn ) + 2 ( y1 + y2 + y3 + y4 + + yn −1 )
Method 2: Simpson’s One Third Rule
Integral can be evaluated using Simpson’s One Third Rule, if the number of sub-intervals is
EVEN. That is number of ordinates should be ODD.
xn
h
ydx = 3 ( y
x0
0 + yn ) + 2 ( y2 + y4 + y6 + yn −2 ) + 4 ( y1 + y3 + y5 + + yn −1 )
Method 3: Simpson’s Three Eighth Rule
Integral can be evaluated using Simpson’s Three Eighth Rule, if the number of sub-intervals is
MULTIPLE OF THREE.
xn
3h
ydx = ( y0 + yn ) + 2 ( y3 + y6 + y9 + yn −3 ) + 3 ( y1 + y2 + y4 + y5 + + yn −2 + yn −1 )
x0
8
Note: To Evaluate integral using all three methods, number of sub-intervals
should be multiple of SIX.
© 2020-SEAM by Prof. Satishkumar Barot Page 1
SPCE-DCCN Numerical Integration Trapezoidal and Simpson’s rule
(9.1) Examples
1
1
1. Evaluate 1 + x dx using Trapezoidal rule with h = 0.2 . Hence determine the value of
0
2
1 rd
x2 1
2. Evaluate dx using Simpson’s rule with h = 0.25. Hence find the value of
0
1 + x3 3
log 2 .
3. Use the Trapezoidal rule and Simpson’s one third rule with 5 ordinates to find an
2
1
approximate value for the integral 1 + dx
1
x
4. Use the Trapezoidal rule and Simpson’s one third rule with 5 ordinates to find an
6
1
approximate value for the integral dx
4 3− x
1.4
1
5. Evaluate 1 2 + log e x
dx , using Trapezoidal and Simpson’s one-third rule with n = 4
1
1 1
6. Evaluate 0 x +14
dx , using Trapezoidal and Simpson’s one-third rule with h =
4
7
1
7. Evaluate 1 x 3
+1
dx , using Trapezoidal, Simpson’s one-third and Simpson’s three eighth
rule with n = 6
© 2020-SEAM by Prof. Satishkumar Barot Page 2
SPCE-DCCN Numerical Integration Trapezoidal and Simpson’s rule
1
1
Example 9.1.1: Evaluate 1 + x dx using Trapezoidal rule with h = 0.2 . Hence determine the
0
2
value of .
1 1− 0
Solution: Here y = . Given that h = 0.2 . Number of sub-intervals n = =5
1+ x 2
0.2
Dividing the interval 0,1 into 5 sub-intervals, each of width h = 0.2 .
x x0 = 0 x1 = 0.2 x2 = 0.4 x3 = 0.6 x4 = 0.8 x5 = 1
y y0 = 1 y1 = 0.96153 y2 = 0.86206 y3 = 0.73529 y4 = 0.60975 y5 = 0.5
By Trapezoidal rule
x5
h
ydx = 2 ( y
x0
0 + y5 ) + 2 ( y1 + y2 + y3 + y4 )
1
1 0.2
dx = (1 + 0.5 ) + 2 ( 0.96153 + 0.86206 + 0.73529 + 0.60975 )
0
1 + x 2
2
= 0.78371
To find the value of , we integrate directely and compare the answers.
1
1
1+ x
1
2
dx = tan −1 x = tan −1 (1) − tan −1 (0) = − − − − − −(2)
0
0 4
From (1) and (2)
= 0.78372
4
= 4 ( 0.78372 ) = 3.13488
© 2020-SEAM by Prof. Satishkumar Barot Page 3
SPCE-DCCN Numerical Integration Trapezoidal and Simpson’s rule
1 rd
x2 1
Example 9.1.2: Evaluate dx using Simpson’s rule with h = 0.25 . Hence find the
0
1 + x3 3
value of log 2 .
x2 2 −1
Solution: Here y = . Given that Width of sub-intervals h = = 0.25
1+ x 3
4
1− 0
Number of sub-interval n = = 0.25
4
Dividing the interval 0, 1 into 4 sub-intervals, each of width h = 0.25 .
x x0 = 0 x1 = 0.25 x2 = 0.50 x3 = 0.75 x4 = 1.0
y y0 = 0 y1 = 0.06153 y2 = 0.22222 y3 = 0.39560 y4 = 0.5
By Simpson's One Third Rule,
x4
h
ydx = 3 ( y
x0
0 + y4 ) + 2 ( y2 ) + 4 ( y1 + y3 )
1
x2 0.25
dx = ( 0 + 0.5 ) + 2 ( 0.22222 ) + 4 ( 0.06153 + 0.39560 )
0
1 + x 3
3
= 0.23108 − − − − − − − −(1)
To find the value of log 2
x 0 1
Put 1 + x 3 = t 3 x 2 dx = dt
t 1 2
1 1
1 2
x2
dx = dt
0
1+ x 3
1
t 3
1
= log t 1
2
3
1 1
= log 2 − log1 = log 2 − − − − − −(2)
3 3
From (1) and (2)
1
log 2 = 0.23108
3
log 2 = 3 0.23108 = 0.69324
© 2020-SEAM by Prof. Satishkumar Barot Page 4
SPCE-DCCN Numerical Integration Trapezoidal and Simpson’s rule
Example 9.1.3: Use the Trapezoidal rule and Simpson’s one third rule with 5 ordinates to find
2
1
an approximate value for the integral 1 1 + dx
x
1
Solution: Here y = 1 + . Five ordinates means 4 sub-intervals. n = 4 .
x
2 −1
Width of sub-intervals h = = 0.25
4
Dividing the interval 1, 2 into 4 sub-intervals, each of width h = 0.25 .
x x0 = 1 x1 = 1.25 x2 = 1.50 x3 = 1.75 x4 = 2.0
y y0 = 1.41421 y1 = 1.34164 y2 = 1.29099 y3 = 1.25356 y4 = 1.22474
By Trapezoidal rule
x4
h
ydx = 2 ( y
x0
0 + y4 ) + 2 ( y1 + y2 + y3 )
2
1 0.25
1 + dx = (1.41421 + 1.22474 ) + 2 (1.34164 + 1.29099 + 1.25356 )
1
x 2
= 1.30141
By Simpson's One Third Rule,
x4
h
ydx = 3 ( y
x0
0 + y4 ) + 2 ( y2 ) + 4 ( y1 + y3 )
2
1 0.25
1 + dx = (1.41421 + 1.22474 ) + 2 (1.29099 ) + 4 (1.34164 + 1.25356 )
1
x 3
= 1.30014
© 2020-SEAM by Prof. Satishkumar Barot Page 5
SPCE-DCCN Numerical Integration Trapezoidal and Simpson’s rule
Example 9.1.4: Use the Trapezoidal rule and Simpson’s one third rule with 5 ordinates to find
6
1
an approximate value for the integral 4 3 − x
dx
1
Solution: Here y = . Five ordinates means 4 sub-intervals. n = 4 .
3− x
6−4
Width of sub-intervals h = = 0.5
4
Dividing the interval 1, 2 into 4 sub-intervals, each of width h = 0.25 .
x x0 = 4 x1 = 4.5 x2 = 5 x3 = 5.5 x4 = 6
y y0 = 1 y1 = 1.138071 y2 = 1.30901 y3 = 1.52720 y4 = 1.81649
By Trapezoidal rule
x4
h
ydx = 2 ( y
x0
0 + y4 ) + 2 ( y1 + y2 + y3 )
6
1 0.5
dx = (1 + 1.81649 ) + 2 (1.138071 + 1.30901 + 1.52720 )
4 3− x 2
= 2.69126
By Simpson's One Third Rule,
x4
h
ydx = 3 ( y
x0
0 + y4 ) + 2 ( y2 ) + 4 ( y1 + y3 )
6
1 0.5
dx = (1 + 1.81649 ) + 2 (1.30901) + 4 (1.138071 + 1.52720 )
4 3 − x 3
= 2.68259
© 2020-SEAM by Prof. Satishkumar Barot Page 6
SPCE-DCCN Numerical Integration Trapezoidal and Simpson’s rule
1.4
1
Example 9.1.5: Evaluate 1 2 + log e x
dx , using Trapezoidal and Simpson’s one-third rule with
n=4
1
Solution: Here y = . Number of sub-intervals n = 4 .
2 + log e x
1.4 − 1
Width of sub-intervals h = = 0.1
4
Dividing the interval 1, 1.4 into 4 sub-intervals, each of width h = 0.1 .
x x0 = 1 x1 = 1.1 x2 = 1.2 x3 = 1.3 x4 = 1.4
y y0 = 0.5 y1 = 0.47725 y2 = 0.45822 y3 = 0.44201 y4 = 0.42799
By Trapezoidal rule
x4
h
ydx = 2 ( y
x0
0 + y4 ) + 2 ( y1 + y2 + y3 )
1.4
1 0.1
dx = ( 0.5 + 0.42799 ) + 2 ( 0.47725 + 0.45822 + 0.44201)
1
2 + log e x 2
= 0.18414
By Simpson's One Third Rule,
x4
h
ydx = 3 ( y
x0
0 + y4 ) + 2 ( y2 ) + 4 ( y1 + y3 )
1.4
1 0.1
dx = ( 0.5 + 0.42799 ) + 2 ( 0.45822 ) + 4 ( 0.47725 + 0.44201)
1
2 + log e x 3
= 0.18404
© 2020-SEAM by Prof. Satishkumar Barot Page 7
SPCE-DCCN Numerical Integration Trapezoidal and Simpson’s rule
1
1
Example 9.1.6: Evaluate 0 x4 + 1
dx , using Trapezoidal and Simpson’s one-third rule with
1
h=
4
1 1
Solution: Here y = . Given that h = = 0.25 .
x +1
4 4
1− 0
Number of sub-intervals n = =4
0.25
Dividing the interval 0,1 into 4 sub-intervals, each of width h = 0.25 .
x x0 = 0 x1 = 0.25 x2 = 0.50 x3 = 0.75 x4 = 1.0
y y0 = 1 y1 = 0.99805 y2 = 0.97014 y3 = 0.87157 y4 = 0.70710
By Trapezoidal rule
x4
h
ydx = 2 ( y
x0
0 + y4 ) + 2 ( y1 + y2 + y3 )
1
1 0.25
dx = (1 + 0.70710 ) + 2 ( 0.99805 + 0.97014 + 0.87157 )
0 x +14 2
= 0.92332
By Simpson's One Third Rule,
x4
h
ydx = 3 ( y
x0
0 + y4 ) + 2 ( y2 ) + 4 ( y1 + y3 )
1
1 0.25
dx = (1 + 0.70710 ) + 2 ( 0.97014 ) + 4 ( 0.99805 + 0.87157 )
0 x4 + 1 3
= 0.92715
© 2020-SEAM by Prof. Satishkumar Barot Page 8
SPCE-DCCN Numerical Integration Trapezoidal and Simpson’s rule
7
1
Example 9.1.7: Evaluate 1 x 3
+1
dx , using Trapezoidal, Simpson’s one-third rule and
Simpson’s three-eighth rule with n = 6 .
1
Solution: Here y = . Given that number of sub-intervals n = 6 .
x +1
3
7 −1
Width of the sub-intervals h = =1
6
Dividing the interval 7,1 into 6 sub-intervals, each of width h = 1 .
x x0 = 1 x1 = 2 x2 = 3 x3 = 4 x4 = 5 x5 = 6 x6 = 7
y y0 = 0.5 y1 = 0.11111 y2 = 0.03571 y3 = 0.01538 y4 = 0.00793 y5 = 0.00460 y6 = 0.00290
By Trapezoidal rule
x6
h
ydx = 2 ( y
x0
0 + y6 ) + 2 ( y1 + y2 + y3 + y4 + y5 )
7
1 1
dx = ( 0.5 + 0.00290 ) + 2 ( 0.11111 + 0.03571 + 0.01538 + 0.00793 + 0.00460 )
1
x +1
3
2
= 0.42618
By Simpson's One Third Rule,
x6
h
ydx = 3 ( y
x0
0 + y6 ) + 2 ( y2 + y4 ) + 4 ( y1 + y3 + y5 )
7
1 1
dx = ( 0.5 + 0.00290 ) + 2 ( 0.03571 + 0.00793 ) + 4 ( 0.11111 + 0.01538 + 0.00460 )
1
x +1
3
3
= 0.37151
By Simpson's Three Eighth Rule,
x6
3h
ydx = ( y0 + yn ) + 2 ( y3 + y6 + y9 + yn −3 ) + 3 ( y1 + y2 + y4 + y5 + + yn − 2 + yn −1 )
x0
8
3
= _________________________________________________________________
8
= ______
© 2020-SEAM by Prof. Satishkumar Barot Page 9