Simpson’s 1/3 Rule of Integration rd

Download Report

Transcript Simpson’s 1/3 Rule of Integration rd

Simpson’s 1/3rd Rule of
Integration
Chemical Engineering Majors
Authors: Autar Kaw, Charlie Barker
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
5/27/2016
http://numericalmethods.eng.usf.edu
1
rd
1/3
Simpson’s
Rule of
Integration
http://numericalmethods.eng.usf.edu
What is Integration?
b
Integration
The process of measuring
the area under a curve.
 f ( x )dx
y
a
f(x)
b
I   f ( x )dx
a
Where:
f(x) is the integrand
a= lower limit of integration
b= upper limit of integration
3
a
b
x
http://numericalmethods.eng.usf.edu
Simpson’s 1/3rd Rule
4
http://numericalmethods.eng.usf.edu
Basis of Simpson’s 1/3rd Rule
Trapezoidal rule was based on approximating the integrand by a first
order polynomial, and then integrating the polynomial in the interval of
integration. Simpson’s 1/3rd rule is an extension of Trapezoidal rule
where the integrand is approximated by a second order polynomial.
Hence
b
b
a
a
I   f ( x )dx   f 2 ( x )dx
Where
f2( x )
is a second order polynomial.
f 2 ( x )  a0  a1 x  a2 x 2
5
http://numericalmethods.eng.usf.edu
Basis of Simpson’s 1/3rd Rule
Choose
 a  b  a  b 
( a , f ( a )), 
,f
 ,
 2 
 2
and
( b , f ( b ))
as the three points of the function to evaluate a0, a1 and a2.
f ( a )  f 2 ( a )  a 0  a1 a  a 2 a 2
a  b
a  b
a  b
a  b
f
  f2 
  a0  a1 
  a2 

 2 
 2 
 2 
 2 
2
f ( b )  f 2 ( b )  a0  a1b  a 2 b 2
6
http://numericalmethods.eng.usf.edu
Basis of Simpson’s 1/3rd Rule
Solving the previous equations for a0, a1 and a2 give
a  b
2
a f ( b )  abf ( b )  4abf 
  abf ( a )  b f ( a )
 2 
a0 
a 2  2ab  b 2
a  b
a  b
af ( a )  4af 
  3af ( b )  3bf ( a )  4bf 
  bf ( b )
2 
2 


a1  
a 2  2ab  b 2


a  b
2 f ( a )  2 f 

f
(
b
)


 2 


a2 
a 2  2ab  b 2
2
7
http://numericalmethods.eng.usf.edu
Basis of Simpson’s 1/3rd Rule
Then
b
I   f 2 ( x )dx
a
b
  a0  a1 x  a2 x 2 dx
a
b

x
x 
 a0 x  a1  a 2 
2
3 a

2
3
b2  a2
b3  a3
 a0 ( b  a )  a1
 a2
2
3
8
http://numericalmethods.eng.usf.edu
Basis of Simpson’s 1/3rd Rule
Substituting values of a0, a1, a 2 give
b
 f 2 ( x )dx 
a
ba

a  b
f
(
a
)

4
f

f
(
b
)




6 
 2 
Since for Simpson’s 1/3rd Rule, the interval [a, b] is broken
into 2 segments, the segment width
h
9
ba
2
http://numericalmethods.eng.usf.edu
Basis of Simpson’s 1/3rd Rule
Hence
h

a  b
f
(
x
)
dx

f
(
a
)

4
f

f
(
b
)


 2


3
 2 
a
b
Because the above form has 1/3 in its formula, it is called Simpson’s 1/3rd Rule.
10
http://numericalmethods.eng.usf.edu
Example 1
In an attempt to understand the mechanism of the
depolarization process in a fuel cell, an electro-kinetic model for mixed
oxygen-methanol current on platinum was developed in the laboratory
at FAMU. A very simplified model of the reaction developed suggests
a functional relation in an integral form. To find the time required for
50% of the oxygen to be consumed, the time, T (s) is given by
 6.73x  4.3025  10 7

T  
1.2210 6 
2.316  10 11 x

0.6110 6
a)
b)
c)
11

dx

Use Simpson’s 1/3rd Rule to find the time required for 50% of the
oxygen to be consumed.
Find the true error, E t for part (a).

Find the absolute relative true error, a for part (a).
http://numericalmethods.eng.usf.edu
Solution
a)
 6.73x  4.3025  10 7

T  
1.2210 6 
2.316  10 11 x

0.6110 6

dx

 6.73x  4.3025  10 7 
f ( x)   

2.316  10 11 x



 b  a 
 ab
T 
  f (a)  4 f 
  f (b)
 6 
 2 

 0.61  10 6  1.22  10 6 
 f (1.22  10 6 )  4 f (0.915  10 6 )  f (0.61  10 6 )
 
6



  0.61106 
  3.05811011  4(3.1089 1011 )  3.2104 1011
 
6





 190160s
12
http://numericalmethods.eng.usf.edu
Solution (cont)
b) The exact value of the above integral is
 6.73x  4.3025  10 7

T  
11
1.2210 6 
2
.
316

10
x

0.6110 6

dx

 1.90140 105 s
True Error
Et  True Value  Approximate Value
 1.90140 105  190160
 24.100
13
http://numericalmethods.eng.usf.edu
Solution (cont)
c.) Absolute relative true error,
t 

True Error
 100
True Value
 24.100
 100
1.90140  105
 0.012675%
14
http://numericalmethods.eng.usf.edu
Multiple Segment Simpson’s
1/3rd Rule
15
http://numericalmethods.eng.usf.edu
Multiple Segment Simpson’s 1/3rd
Rule
Just like in multiple segment Trapezoidal Rule, one can subdivide the interval
[a, b] into n segments and apply Simpson’s 1/3rd Rule repeatedly over
every two segments. Note that n needs to be even. Divide interval
[a, b] into equal segments, hence the segment width
ba
h
n
b
xn
a
x0
 f ( x )dx   f ( x )dx
where
x0  a
16
xn  b
http://numericalmethods.eng.usf.edu
Multiple Segment Simpson’s 1/3rd
Rule
f(x)
b
x2
x4
a
x0
x2
 f ( x )dx   f ( x )dx   f ( x )dx  .....
. . .
xn  2
xn
xn  4
xn  2
....   f ( x )dx   f ( x )dx
x
x0
x2
xn-2
xn
Apply Simpson’s 1/3rd Rule over each interval,
 f ( x0 )  4 f ( x1 )  f ( x2 )
f
(
x
)
dx

(
x

x
)
 ...

2
0 

6


a
b
 f ( x2 )  4 f ( x3 )  f ( x4 )
 ( x4  x2 )
 ...

6


17
http://numericalmethods.eng.usf.edu
Multiple Segment Simpson’s 1/3rd
Rule
 f ( xn4 )  4 f ( xn3 )  f ( xn2 )
...  ( xn2  xn4 )
 ...

6


 f ( xn2 )  4 f ( xn1 )  f ( xn )
 ( xn  xn2 )

6

Since
xi  xi  2  2 h
18
i  2, 4, ..., n
http://numericalmethods.eng.usf.edu
Multiple Segment Simpson’s 1/3rd
Rule
Then
 f ( x0 )  4 f ( x1 )  f ( x2 )
 ...
 f ( x )dx  2h 

6


a
b
 f ( x2 )  4 f ( x3 )  f ( x4 )
 2h 
 ...

6


 f ( xn4 )  4 f ( xn3 )  f ( xn2 )
 2h 
 ...

6


 f ( xn2 )  4 f ( xn1 )  f ( xn )
 2h 

6

19
http://numericalmethods.eng.usf.edu
Multiple Segment Simpson’s 1/3rd
Rule
b
h
 f ( x )dx  3  f ( x0 )  4 f ( x1 )  f ( x3 )  ...  f ( xn1 )  ...
a
...  2 f ( x2 )  f ( x4 )  ...  f ( xn2 )  f ( xn )}]


n

1
n

2
h
  f ( x 0 )  4  f ( xi )  2  f ( xi )  f ( x n ) 

3
i 1
i 2
i  odd
i  even




n

1
n

2
ba

f ( x 0 )  4  f ( xi )  2  f ( xi )  f ( x n ) 

3n 
i 1
i 2
i odd
i even


20
http://numericalmethods.eng.usf.edu
Example 2
In an attempt to understand the mechanism of the
depolarization process in a fuel cell, an electro-kinetic model for
mixed oxygen-methanol current on platinum was developed in
the laboratory at FAMU. A very simplified model of the reaction
developed suggests a functional relation in an integral form. To
find the time required for 50% of the oxygen to be consumed,
the time, T (s) is given by
 6.73x  4.3025  10 7

T  
1.2210 6 
2.316  10 11 x

0.6110 6
a)
b)
c)
21

dx

Use 4-segment Simpson’s 1/3rd Rule to find the time required for 50%
of the oxygen to be consumed.
Find the true error, E t for part (a).

Find the absolute relative true error, a for part (a).
http://numericalmethods.eng.usf.edu
Solution
a) Using n segment Simpson’s 1/3rd Rule,
ba
h
n
So
0.61  10 6  1.22  10 6

4
 0.15250  10 6
f ( x0 )  f (1.22  10 6 )
f ( x1 )  f (1.22  10 6  0.15250  10 6 )  f (1.0675  10 6 )
f ( x2 )  f (1.0675  10 6  0.15250  10 6 )  f (0.915  10 6 )
f ( x3 )  f (0.915  10 6  0.15250  10 6 )  f (0.76250  10 6 )
f ( x4 )  f (0.61106 )
22
http://numericalmethods.eng.usf.edu
Solution (cont.)


n 1
n2
ba 
T
f ( x0 )  4  f ( xi )  2  f ( xi )  f ( xn )

3n 
i 1
i 2


i  odd
i  even

3
2
0.6110 6  1.22 10 6 
6

f 1.22 10  4  f xi   2  f xi   f 0.6110 6

34
i 1
i 2

i  odd
i  even




 0.61106

f 1.22 106  4 f x1   4 f x3   2 f x2   f 0.61106
12
23








http://numericalmethods.eng.usf.edu
Solution (cont.)
cont.

 0.61  10 6

f (1.22  10 6 )  4 f (1.0675  10 6 )  4 f (0.76250  10 6 )  2 f (0.915  10 6 )  f (0.61  10 6 )
12

 0.61  10 6

 3.0582  1011  4(3.0799  1011 )  4(3.1495  1011 )  2(3.1089  1011 )  3.2104  1011
12


 190140s
24
http://numericalmethods.eng.usf.edu
Solution (cont.)
b)
In this case, the true error is
Et  True Value  Approximate Value
 1.90140 105  190140
 1.9838
c)
The absolute relative true error
t 

True Error
 100
True Value
 1.9838
 100
5
1.90140  10
 0.0010434%
25
http://numericalmethods.eng.usf.edu
Solution (cont.)
Table. Values of Simpson’s 1/3rd Rule for
Example 2 with multiple segments
26
n
Approximate Value
Et
t %
2
4
6
8
10
190160
190140
190140
190140
190140
−24.100
−1.9838
0.42010
0.13655
0.056663
0.012675%
0.0010434%
2.2094×10−4%
7.1815×10−5%
2.9802×10−5%
http://numericalmethods.eng.usf.edu
Error in the Multiple Segment
Simpson’s 1/3rd Rule
The true error in a single application of Simpson’s 1/3rd Rule is given as
(b  a) 5 ( 4)
Et  
f (), a    b
2880
In Multiple Segment Simpson’s 1/3rd Rule, the error is the sum of the errors
in each application of Simpson’s 1/3rd Rule. The error in n segment Simpson’s
1/3rd Rule is given by
27
h5 ( 4 )
( x2  x0 )5 ( 4 )
E1  
f ( 1 )   f ( 1 ), x0  1  x2
90
2880
h5 ( 4 )
( x4  x2 )5 ( 4 )
E2  
f (  2 )   f (  2 ), x2   2  x4
90
2880
http://numericalmethods.eng.usf.edu
Error in the Multiple Segment
Simpson’s 1/3rd Rule
Ei  
( x2i  x2( i 1 ) )5
2880
f
(4)
5
h
(  i )   f ( 4 ) (  i ), x2( i 1 )   i  x2i
90
.
.
.
5

( xn 2  xn  4 )5 ( 4 ) 
h
En  
f   n    f ( 4 )   n  , x n 4   n  x n 2
1
 1 
2880
1
90
 2 1 
2
2
 2 
5
  , x   x
( xn  xn  2 )5 4  
h
( 4)
n2
n
n


En  
f n   
f   n 
2
2880
90
 2
2
 2
28
http://numericalmethods.eng.usf.edu
Error in the Multiple Segment
Simpson’s 1/3rd Rule
Hence, the total error in Multiple Segment Simpson’s 1/3rd Rule is
n
2
Et   Ei  
i 1
n
5
h 2
f
( 4)
90 i 1
n
2

29
( i )
f
(b  a ) 5
( 4)
i 1
90n 4

n
(b  a) 5 2
90n 5
( 4)
f
( i )

i 1
( i )
n
http://numericalmethods.eng.usf.edu
Error in the Multiple Segment
Simpson’s 1/3rd Rule
n
2
The term
f
( 4)
i 1
( i )
is an approximate average value of
n
f ( 4) ( x), a  x  b
Hence
(b  a) 5 ( 4)
Et  
f
4
90n
n
2
where
f
30
( 4)
f
 i 1
( 4)
n
( i )
http://numericalmethods.eng.usf.edu
Additional Resources
For all resources on this topic such as digital audiovisual
lectures, primers, textbook chapters, multiple-choice
tests, worksheets in MATLAB, MATHEMATICA, MathCad
and MAPLE, blogs, related physical problems, please
visit
http://numericalmethods.eng.usf.edu/topics/simpsons_
13rd_rule.html
THE END
http://numericalmethods.eng.usf.edu