5.2.1 Simpson's Rule
5.2.1 Simpson's Rule
f ( x) dx
( x) dx
ab ab
, f
2
2
2
2
2
2
Chapter 5
ab
2
abf (a) b f (a )
2
a0
2
a 2ab b 2
ab
ab
af (a ) 4af
3af (b) 3bf (a ) 4bf
bf (b)
2
2
a1
a 2 2ab b 2
ab
2 f (a) 2 f
f (b)
2
a2
2
2
a 2ab b
a 2 f (b) abf (b) 4abf
Then
b
( x) dx
a 0 a1 x a 2 x 2 dx
a
x2
x3
a 0 x a1
a2
2
3 a
b2 a2
b3 a 3
a 0 (b a ) a1
a2
2
3
( x) dx
ba
ab
f (a) 4 f
f (b)
6
2
Since for Simpsons 1/3rd Rule, the interval a, b is broken into 2 segments, the
segment width
h
ba
2
f ( x )dx 3
a b
f (b)
2
f (a ) 4 f
Since the above form has 1/3 in its formula, it is also called Simpsons 1/3rd Rule.
Simpsons Rule
Example 1:
Human vision has the remarkable ability to infer 3D shapes from 2D images. The
intriguing question is: can we replicate some of these abilities on a computer?
Yes, it can be done and to do this, integration of vector fields is required. The
following integral needs to integrated.
100
f ( x )dx
0
where
f(x) 0 , 0 x 30
9.1688 10 6 x 3 2.7961 10 3 x 2 2.8487 10 1 x 9.6778, 30 x 172
0, 172 x 200
ba
ab
I
f (a) 4 f
f (b)
a)
6
2
c)
a0
b 100
ab
50
2
f(x) 0 , 0 x 30
9.1688 10 6 x 3 2.7961 10 3 x 2 2.8487 10 1 x 9.6778, 30 x 172
0, 172 x 200
f (0) 0
f (100) 9.1688 10 6 (100) 3 2.7961 10 3 (100) 2 2.8487 10 1 (100) 9.6778
0.017
f (50) 9.1688 10 6 (50) 3 2.7961 10 3 (50) 2 2.8487 10 1 (50) 9.6778
Chapter 5
1.2784
ba
ab
I
f (a ) 4 f
f (b)
6
2
100 0
100
0 4(1.2784) (0.017)
6
84.94667
b) The exact value of the above integral is found using Maple for calculating the
true error and relative true error.
100
f ( x)dx
0
60.7926
60.7926 (84.94667)
24.1540
, would then be
True Error
100
True Value
60.7926 (84.94667)
100
60.7926
39.73%
a, b into n segments and apply Simpsons 1/3rd Rule repeatedly over every
Simpsons Rule
ba
.
n
f ( x)dx
f ( x)dx
x0
where
x0 a
xn b
x2
f ( x)dx
f ( x)dx
x0
x4
f ( x)dx ......
x2
xn 2
xn 4
f ( x )dx
xn
f ( x)dx
xn 2
f ( x )dx ( x
f ( x0 ) 4 f ( x1 ) f ( x 2 )
f ( x 2 ) 4 f ( x3 ) f ( x 4 )
( x4 x2 )
...
6
6
x0 )
f ( x n 4 ) 4 f ( x n 3 ) f ( x n 2 )
f ( x n 2 ) 4 f ( x n 1 ) f ( x n )
( x n x n 2 )
6
6
( x n2 xn 4 )
Since
x i xi 2 2h
i 2, 4, ..., n
then
b
f ( x0 ) 4 f ( x1 ) f ( x 2 )
f ( x 2 ) 4 f ( x3 ) f ( x 4 )
2h
...
6
6
f ( x )dx 2h
a
f ( x n 4 ) 4 f ( x n 3 ) f ( x n 2 )
f ( x n 2 ) 4 f ( x n 1 ) f ( x n )
2h
6
6
2h
h
f ( x0 ) 4 f ( x1 ) f ( x3 ) ... f ( xn1 ) 2 f ( x2 ) f ( x4 ) ... f ( xn2 ) f ( x n )
3
Chapter 5
n 1
n2
n1
n 2
h
ba
f ( x0 ) 4 f ( xi ) 2 f ( xi ) f ( xn ) f ( x)dx f ( x0 ) 4 f ( xi ) 2 f ( xi ) f ( xn )
3
3n
i 1
i 2
i 1
i2
a
i odd
i even
i odd
i even
H.W: Draw a flow chart to calculate the integral of the function f(x) from a to b
using n equal intervals by Simpson Rule.
Example 2:
Human vision has the remarkable ability to infer 3D shapes from 2D images. The
intriguing question is: can we replicate some of these abilities on a computer?
Yes, it can be done and to do this, integration of vector fields is required. The
following integral needs to integrated.
100
f ( x )dx
0
where
f(x) 0 , 0 x 30
9.1688 10 6 x 3 2.7961 10 3 x 2 2.8487 10 1 x 9.6778, 30 x 172
0, 172 x 200
a) Use four segment Simpsons 1/3rd Rule to find the value of the integral.
b) Find the true error, Et for part (a).
c) Find the absolute relative true error for part (a).
Solution:
a) Using
I
n 1
n 2
ba
f ( x 0 ) 4 f ( x i ) 2 f ( x i ) f ( x n )
3n
i 1
i 2
i odd
i even
n4
a0
b 100
Simpsons Rule
ba
n
100 0
25
f(x) 0 , 0 x 30
9.1688 10 6 x 3 2.7961 10 3 x 2 2.8487 10 1 x 9.6778, 30 x 172
0, 172 x 200
So
f ( x 0 ) f ( 0)
f (0) 0
f ( x1 ) f (0 25) f (25)
f ( 25) 0
1.2784
f ( x3 ) f (50 25) f (75)
f (75) 9.1688 10 6 (75) 3 2.7961 10 3 (75) 2 2.8487 10 1 (75) 9.6778
0.17252
f ( x 4 ) f ( y n ) f ( 270)
f (100) 9.1688 10 6 (100) 3 2.7961 10 3 (100) 2 2.8487 10 1 (100) 9.6778
0.017
n 1
n 2
ba
f ( x 0 ) 4 f ( x i ) 2 f ( x i ) f ( x n )
3n
i 1
i 2
i odd
i even
Chapter 5
2
100 0 3
f (0) 4 f ( xi ) 2 f (xi ) f (100)
3(4)
i1
i2
iodd ieven
100
f (0) 4 f ( x1 ) 4 f ( x3 ) 2 f ( x 2 ) f (100)
12
25
26.91667
b) The exact value of the above integral is found using Maple for calculating the
true error and relative true error.
100
f ( x)dx
0
60.7926
60.7926 (26.91667)
33.8759
, would then be
True Error
100
True Value
60.7926 ( 26.91667)
100
60.7926
55.723%
Table 1: Values of Simpsons 1/3rd Rule for Example 2 with multiple segments
Approximate Value
Et
84.94667
-24.154
39.731%
26.91667
33.875
55.723%
Simpsons Rule
66.6063
-5.8137
9.5632%
62.3177
-1.5251
2.5088%