Introduction to Fourier Series

advertisement
Numerical Methods
Part: Simpson
Integration.
3
8
Rule For
http://numericalmethods.eng.usf.edu
For more details on this topic


Go to http://numericalmethods.eng.usf.edu
Click on Keyword
You are free


to Share – to copy, distribute, display and
perform the work
to Remix – to make derivative works
Under the following conditions



Attribution — You must attribute the work in
the manner specified by the author or licensor
(but not in any way that suggests that they
endorse you or your use of the work).
Noncommercial — You may not use this work
for commercial purposes.
Share Alike — If you alter, transform, or build
upon this work, you may distribute the resulting
work only under the same or similar license to
this one.
Lecture # 1
Chapter 07.08: Simpson
For Integration.
3
8
Rule
Major: All Engineering Majors
Authors: Duc Nguyen
http://numericalmethods.eng.usf.edu
Numerical Methods for STEM undergraduates
4/6/2015
http://numericalmethods.eng.usf.edu
5
Introduction
The main objective in this chapter is to develop
appropriated formulas for obtaining
the integral
expressed in the following form:
b
I 

a
f ( x ) dx
(1)
where f ( x ) is a given function.
Most (if not all) of the developed formulas for integration
is based on a simple concept of replacing a given
(oftently complicated) function f ( x ) by a simpler
function (usually a polynomial function) f i ( x ) where i
6 represents the order of the polynomial function.
In the previous chapter, it has been explained and
illustrated that Simpsons 1/3 rule for integration can
be derived by replacing the given function f ( x )
with the 2nd –order (or quadratic) polynomial function
f i ( x )  f 2 ( x ) , defined as:
f 2 ( x )  a 0  a1 x  a 2 x
7
2
(2)
http://numericalmethods.eng.usf.edu
In a similar fashion, Simpson 3 8 rule for integration
can be derived by replacing the given function f ( x )
with the 3rd-order (or cubic) polynomial (passing
through 4 known data points) function f i ( x )  f 3 ( x )
defined as f ( x )  a  a x  a x 2  a x 3 
3
0

1
 1, x , x , x
8
2
2
3

a0 
 
 a1 
 
a2 
a3 
 
3







(3)
which can also be symbolically represented in Figure 1.
Method 1
The unknown coefficients a 0 , a1 , a 2 and a 3 (in Eq. (3))
can be obtained by substituting 4 known coordinate
data points x 0 , f  x 0 , x1 , f  x1 , x 2 , f  x 2  and x 3 , f  x 3 
into Eq. (3), as following
9
2
2
f ( x 0 )  a 0  a1 x 0  a 2 x 0  a 3 x 0 

2
2
f ( x1 )  a 0  a1 x1  a 2 x1  a 3 x1 
(4)

2
2
f ( x 2 )  a 0  a1 x 2  a 2 x 2  a 3 x 2 
2
2 
f ( x 3 )  a 0  a1 x 3  a 2 x 3 http://numericalmethods.eng.usf.edu
a 3 x3 
Eq. (4) can be expressed in matrix notation as
1

1
1

1
2
x0
x0
x1
x1
x2
2
x2
2
x3
x3
2
3
x 0   a 0   f  x 0 
 

3


a
f
x
x1   1  
1 


3
x 2  a 2   f  x 2 

3 
x 3   a 3   f  x 3  
(5)
The above Eq. (5) can be symbolically represented as


(6)
 A 4  4 a 4 1  f 4 1
10
http://numericalmethods.eng.usf.edu
Thus,
 a0 
 

  a1 
1
a     A  f
a2 
 a 3 
(7)
Substituting Eq. (7) into Eq. (3), one gets

f 3  x   1, x , x , x
11
2
3
  A 
1

 f
(8)
http://numericalmethods.eng.usf.edu
Remarks
As indicated in Figure 1, one has
x0  a


b  a 2a  b

x1  a  h  a 

3
3


2b  2 a a  2b 
x2  a  2 h  a 


3
3

3b  3 a

x3  a  3 h  a 
b

3
(9)
With
 the help from MATLAB [2], the unknown vector
a (shown in Eq. 7) can be solved.
12
http://numericalmethods.eng.usf.edu
Method 2
Using Lagrange interpolation, the cubic polynomial
function f
 x  that passes through 4 data points
i3
(see Figure 1) can be explicitly given as
f3  x  
x 
x1  x  x 2  x  x 3 
 f  x0  
x 
x 0  x  x 2  x  x 3 
 f  x1 
 x 0  x1  x 0  x 2  x 0  x 3 
 x1  x 0  x1  x 2  x1  x 3 
 x  x 0  x  x1  x  x 3 
 x  x 0  x  x1  x  x 2 

 f  x3  
 f  x3 
 x 2  x 0  x 2  x1  x 2  x 3 
 x 3  x 0  x 3  x1  x 3  x 2 
(10)
13
http://numericalmethods.eng.usf.edu
Simpsons 8 Rule For
Integration
3
Thus, Eq. (1) can be calculated as (See Eqs. 8, 10 for
Method 1 and Method 2, respectively):
b
I 
 f  x dx
a
b


f 3  x dx
a
Integrating the right-hand-side
equations, one obtains
I  b  a  
14
of
the
above
 f  x 0   3 f  x1   3 f  x 2   f  x3 
(11)
8
http://numericalmethods.eng.usf.edu
Since h 
ba
3
hence b  a  3 h , and the above
equation becomes:
3h
I 
  f  x 0   3 f  x1   3 f  x 2   f  x 3 
(12)
8
The error introduced by the Simpson 3/8 rule can be
derived as [Ref. 1]:
Et  
15
(b  a )
6480
5
 f 
 , where a    b
(13)
http://numericalmethods.eng.usf.edu
Example 1 (Single Simpson 3 8 rule)
Compute
b  30
I 

a 8


140 , 000


  9 . 8 x  dx ,
 2000 ln 
 140 , 000  2100 x 


by using a single segment Simpson 3 8 rule
Solution
In this example:
h
16
ba
3

30  8
3
 7 . 3333
http://numericalmethods.eng.usf.edu
140000


x 0  8  f  x 0   2000 ln 
  9 . 8  8  177 . 2667
 140000  2100  8 
 x1  x 0  h  8  7 . 3333  15 . 3333

140000



 f  x1   2000 ln  140000  2100  15 . 3333   9 . 8  15 . 3333  372 . 4629



17
http://numericalmethods.eng.usf.edu
 x 2  x 0  2 h  8  2 ( 7 . 3333 )  22 . 6666

140000





f
x

2000
ln

  9 . 8  22 . 6666  608 . 8976
2

 140000  2100  22 . 6666 

 x 3  x 0  3 h  8  3 ( 7 . 3333 )  30

140000





f
x

2000
ln

  9 . 8  30  901 . 6740
3

 140000  2100  30 

18
http://numericalmethods.eng.usf.edu
Applying Eq. (12), one has:
I 
3
8
 7 . 3333  177 . 2667  3  372 . 4629  3  608 . 8976  901 . 6740
I  11063 . 3104
The “exact” answer can be computed as
I exact  11061 . 34
19
http://numericalmethods.eng.usf.edu

3. Multiple Segments for
Simpson 3 8 Rule
Using " n " = number of equal (small) segments, the
width " h " can be defined as
h
ba
3
(14)
Notes:
n = multiple of 3 = number of small " h " segments
20
http://numericalmethods.eng.usf.edu
The integral, shown in Eq. (1), can be expressed as
b
I 
 f  x dx
a
x3
I 

f 3  x dx 
x0  a
21
b


f 3  x dx
a
x6

x3
f 3  x dx  ........ 
xn b

f 3  x dx
(15)
xn3
http://numericalmethods.eng.usf.edu
Substituting Simpson 3 8 rule (See Eq. 12) into
Eq. (15), one gets
3 h  f  x 0   3 f  x1   3 f  x 2   f  x 3   f  x 3   3 f  x 4   3 f  x 5   f  x 6 
I 


8   .....  f  x n  3   3 f  x n  2   3 f  x n  1   f  x n 

(16)
n2
n 1
n3

3h 
I 
 f  x 0   3  f  x i   3  f  x i   2  f  x i   f  x n 
8 
i  1, 4 , 7 ,..
i  2 , 5 , 8 ,..
i  3 , 6 , 9 ,..

(17)
22
http://numericalmethods.eng.usf.edu
Example 2 (Multiple segments Simpson 3 8 rule)
b  30
Compute I  
a 8


140 , 000


  9 . 8 x  dx ,
 2000 ln 
 140 , 000  2100 x 


3
using Simple 8 multiple segments rule, with number
(of " h " ) segments = n = 6 (which corresponds to 2
“big” segments).
23
http://numericalmethods.eng.usf.edu
Solution
In this example, one has (see Eq. 14):
h
30  8
 3 . 6666
6
x 0 , f  x 0   8 ,177 . 2667 
x1 , f  x1   11 . 6666
, 270 . 4104 ; where x1  x 0  h  8  3 . 6666
 11 . 6666
x 2 , f  x 2   15 . 3333 ,372 . 4629 ; where
x 3 , f  x 3   19 , 484 . 7455 ; where
24
x 2  x 0  2 h  15 . 3333
x 3  x 0  3 h  19
http://numericalmethods.eng.usf.edu
x 4 , f  x 4   22 . 6666
, 608 . 8976 ; where x 4  x 0  4 h  22 . 6666
x 5 , f  x 5   26 . 3333 , 746 . 9870 ; where
x 6 , f  x 6   30 ,901 . 6740 ; where
25
x 5  x 0  5 h  26 . 3333
x 6  x 0  6 h  30
http://numericalmethods.eng.usf.edu
Applying Eq. (17), one obtains:
n24
n 1  5
n 33


I  3 . 6666 177 . 2667  3  f  x i   3  f  x i   2  f  x i   901 . 6740 
8
i  1, 4 ,..
i  2 , 5 ,..
i  3 , 6 ,..


3
177 . 2667  3  270 . 4104  608 . 8976   3 372 . 4629  746 . 9870 
I  1 . 3750 



  2 484 . 7455  901 . 6740

I  11 , 601 . 4696
26
http://numericalmethods.eng.usf.edu
3
1
Example 3 (Mixed, multiple segments Simpson 3 and 8
rules)
b  30
Compute I  
a 8


140 , 000


  9 . 8 x  dx ,
 2000 ln 
 140 , 000  2100 x 


using Simpson 1/3 rule (with n1  4 small segments), and
Simpson 3/8 rule (with n 2  3 small segments).
Solution:
In this example, one has:
h
27
ba
n

ba
n1  n 2

30  8
4  3 
 3 . 1429
http://numericalmethods.eng.usf.edu
x0  a  8


x1  x 0  1h  8  3 . 1429  11 . 1429


x 2  x 0  2 h  8  2 3 . 1429   14 . 2857  Simpson
x 3  x 0  3 h  8  3 3 . 1429   17 . 4286 

x 4  x 0  4 h  8  4 3 . 1429   20 . 5714 
x 5  x 0  5 h  8  5 3 . 1429   23 . 7143
x 6  x 0  6 h  8  6 3 . 1429
x 7  x 0  7 h  8  7 3 . 1429
28
1
3
rule
  26 . 8571
  30
http://numericalmethods.eng.usf.edu
140 , 000


f  x 0  8   2000 ln 
  9 . 8  8  177 . 2667
 140 , 000  2100  8 
Similarly:
f  x1  11 . 1429
  256 . 5863
f  x 2   342 . 3241
f  x 3   435 . 2749
f  x 4   536 . 3909
f  x 5   646 . 8260
f  x 6   767 . 9978
29
f  x 7   901 . 6740
http://numericalmethods.eng.usf.edu
For multiple segments  n 1  first 4 segments 
using Simpson 1 rule, one obtains (See Eq. 19):
3
n1  1  3
n1  2  2

 h 
I1     f  x 0   4  f  xi   2  f  xi   f x n 
1
 3 
i  1, 3 ,...
i  2 ,...

 
 3 . 1429 
I1  
 177 . 2667  4  256 . 5863  435 . 2749
3


  2 342 . 3241   536 . 3909 
I 1  4364 . 1197
30
http://numericalmethods.eng.usf.edu
For multiple segments  n 2  last 3 segments 
using Simpson 3/8 rule, one obtains (See Eq. 17):
n 2  2 1
n 2 1 2
n2 3 0

 3h  
I2  
  f  x 0   3  f  x i   3  f  x i   2  f  x i   f x n1 
 8 
i  1, 3 ,...
i  2 ,...
i  3 , 6 ,...

 
3

I 2    3 . 1429  177 . 2667  3  256 . 5863   3 342 . 3241    skip !  435 . 2749
8


I 2  6697 . 2748
The mixed (combined) Simpson 1/3 and 3/8 rules give:
I  I 1  I 2  4364 . 1197  6697 . 2748
I  11 , 061 . 3946
31
http://numericalmethods.eng.usf.edu
Remarks:
(a) Comparing the truncated error of Simpson 1/3 rule
5
b  a 
(18)
Et  
 f  
2880
With Simple 3/8 rule (See Eq. 13), the latter seems to
offer slightly more accurate answer than the former.
However, the cost associated with Simpson 3/8 rule
(using 3rd order polynomial function) is significant
higher than the one associated with Simpson 1/3 rule
(using 2nd order polynomial function).
32
http://numericalmethods.eng.usf.edu
(b) The number of multiple segments that can be used
in the conjunction with Simpson 1/3 rule is 2,4,6,8,..
(any even numbers).
h
I 1     f  x 0   4 f  x1   f  x 2   f  x 2   4 f  x 3   f  x 4   .....  f  x n  2   4 f  x n  1   f  x n 
3
n 1
n2

 h 
I 2     f  x 0   4  f  x i   2  f  x i   f  x n 
 3 
i  1, 3 ,...
i  2 , 4 , 6 ...

33
(19)
http://numericalmethods.eng.usf.edu
However, Simpson 3/8 rule can be used with the
number of segments equal to 3,6,9,12,.. (can be
either certain odd or even numbers).
(c) If the user wishes to use, say 7 segments, then the
mixed Simpson 1/3 rule (for the first 4 segments),
and Simpson 3/8 rule (for the last 3 segments).
34
http://numericalmethods.eng.usf.edu
4. Computer Algorithm For Mixed Simpson
1/3 and 3/8
rule For Integration
Based on the earlier discussions on (Single and Multiple
segments) Simpson 1/3 and 3/8 rules, the following
“pseudo” step-by-step mixed Simpson rules can be given
as
Step 1 User’s input information, such as
Given function f ( x ), integral limits " a , b " ,
n1= number of small, “h” segments, in conjunction with
Simpson 1/3 rule.
35
http://numericalmethods.eng.usf.edu
n 2 = number of small, “h” segments, in conjunction with
Simpson 3/8 rule.
Notes:
n1 = a multiple of 2 (any even numbers)
n 2 = a multiple of 3 (can be certain odd, or even
numbers)
36
http://numericalmethods.eng.usf.edu
Step 2
Compute n  n1  n 2
h
ba
x0  a
x1  a  1h
x2  a  2 h
n
.
.
x i  a  ih
.
.
37
x n  a  nh  b
http://numericalmethods.eng.usf.edu
Step 3
Compute “multiple segments” Simpson 1/3 rule (See
Eq. 19)
n1  1
n1  2

 h 
I 1     f  x 0   4  f  x i   2  f  x i   f  x n 
 3 
i  1, 3 ,...
i  2 , 4 , 6 ...

(19, repeated)
38
http://numericalmethods.eng.usf.edu
Step 4
Compute “multiple segments” Simpson 3/8 rule (See
Eq. 17)
n2  2
n 2 1
n2  3

 3h  
I2  
  f  x 0   3  f  xi   3  f  xi   2  f  xi   f x n 2 
 8 
i  1, 4 , 7 ...
i  2 , 5 , 8 ...
i  3 , 6 , 9 ,...

 
(17, repeated)
Step 5
(20)
I  I1  I 2
and print out the final approximated answer for I.
39
http://numericalmethods.eng.usf.edu
THE END
http://numericalmethods.eng.usf.edu
Acknowledgement
This instructional power point brought to you by
Numerical Methods for STEM undergraduate
http://numericalmethods.eng.usf.edu
Committed to bringing numerical methods to the
undergraduate
For instructional videos on other topics, go to
http://numericalmethods.eng.usf.edu/videos/
This material is based upon work supported by the National
Science Foundation under Grant # 0717624. Any opinions,
findings, and conclusions or recommendations expressed in
this material are those of the author(s) and do not necessarily
reflect the views of the National Science Foundation.
The End - Really
Download