Numerical Methods Part: Simpson Rule For Integration. .
Transcript of Numerical Methods Part: Simpson Rule For Integration. .
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.
Chapter 07.08: Simpson Rule For Integration.
Major: All Engineering Majors
Authors: Duc Nguyen
http://numericalmethods.eng.usf.edu
Numerical Methods for STEM undergraduateshttp://
numericalmethods.eng.usf.edu 504/20/23
Lecture # 1
83
Most (if not all) of the developed formulas for integration is based on a simple concept of replacing a given (oftently complicated) function by a simpler function (usually a polynomial function) where represents the order of the polynomial function.6
IntroductionThe main objective in this chapter is to develop appropriated formulas for obtaining the integral expressed in the following form:
b
a
dxxfI )(
where is a given function.)(xf
)(xf)(xfi i
(1)
http://numericalmethods.eng.usf.edu7
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 )(xfwith the 2nd –order (or quadratic) polynomial function
)()( 2 xfxfi , defined as:
22102 )( xaxaaxf (2)
which can also be symbolically represented in Figure 1.8
In a similar fashion, Simpson rule for integration can be derived by replacing the given function )(xfwith the 3rd-order (or cubic) polynomial (passing through 4 known data points) function )()( 3 xfxfi
defined as
3
2
1
0
32
33
22103
,,,1
)(
a
a
a
a
xxx
xaxaxaaxf
(3)
83
http://numericalmethods.eng.usf.edu9
Method 1The unknown coefficients (in Eq. (3)) can be obtained by substituting 4 known coordinate data points
3210 ,, aandaaa
33221100 ,,,,,, xfxandxfxxfxxfxinto Eq. (3), as following
233
2323103
223
2222102
213
2121101
203
2020100
)(
)(
)(
)(
xaxaxaaxf
xaxaxaaxf
xaxaxaaxf
xaxaxaaxf
(4)
http://numericalmethods.eng.usf.edu10
Eq. (4) can be expressed in matrix notation as
3
2
1
0
3
2
1
0
33
233
32
222
31
211
30
200
1
1
1
1
xf
xf
xf
xf
a
a
a
a
xxx
xxx
xxx
xxx
The above Eq. (5) can be symbolically represented as
141444 faA
(5)
(6)
http://numericalmethods.eng.usf.edu11
Thus,
fA
a
a
a
a
a
1
3
2
1
0
Substituting Eq. (7) into Eq. (3), one gets
fAxxxxf
1323 ,,,1
(7)
(8)
http://numericalmethods.eng.usf.edu12
Remarks As indicated in Figure 1, one has
bab
ahax
baabahax
baabahax
ax
3
333
3
2
3
222
3
2
3
3
2
1
0
With the help from MATLAB [2], the unknown vector (shown in Eq. 7) can be solved. a
(9)
http://numericalmethods.eng.usf.edu13
Method 2Using Lagrange interpolation, the cubic polynomial function that passes through 4 data points xfi 3(see Figure 1) can be explicitly given as
3231303
2103
321202
310
1312101
3200
302010
3213
xfxxxxxx
xxxxxxxf
xxxxxx
xxxxxx
xfxxxxxx
xxxxxxxf
xxxxxx
xxxxxxxf
(10)
http://numericalmethods.eng.usf.edu14
Simpsons Rule For Integration
Thus, Eq. (1) can be calculated as (See Eqs. 8, 10 for Method 1 and Method 2, respectively):
b
a
b
a
dxxfdxxfI 3
Integrating the right-hand-side of the above equations, one obtains
8
33 3210 xfxfxfxfabI
(11)
83
http://numericalmethods.eng.usf.edu15
Since hence , and the above3
abh
equation becomes:
3210 338
3xfxfxfxf
hI
The error introduced by the Simpson 3/8 rule can be derived as [Ref. 1]:
fab
Et
6480
)( 5
, where ba
hab 3
(13)
(12)
http://numericalmethods.eng.usf.edu16
Example 1 (Single Simpson rule)
Compute
30
8
,8.92100000,140
000,140ln2000
b
a
dxxx
I
by using a single segment Simpson ruleSolutionIn this example:
3333.73
830
3
abh
83
83
http://numericalmethods.eng.usf.edu17
2667.17788.982100140000
140000ln20008 00
xfx
4629.3723333.158.93333.152100140000
140000ln2000
3333.153333.78
1
01
xf
hxx
http://numericalmethods.eng.usf.edu18
8976.6086666.228.96666.222100140000
140000ln2000
6666.22)3333.7(282
2
02
xf
hxx
6740.901308.9302100140000
140000ln2000
30)3333.7(383
3
03
xf
hxx
http://numericalmethods.eng.usf.edu19
Applying Eq. (12), one has:
3104.11063
6740.9018976.60834629.37232667.1773333.78
3
I
I
The “exact” answer can be computed as
34.11061exactI
http://numericalmethods.eng.usf.edu20
3. Multiple Segments for Simpson Rule
Using = number of equal (small) segments, the width can be defined as
3
abh
Notes: = multiple of 3 = number of small segments
""n""h
(14)
n ""h
83
http://numericalmethods.eng.usf.edu21
b
a
b
a
dxxfdxxfI 3
bx
x
x
x
x
ax
n
n
dxxfdxxfdxxfI3
6
3
3
0
333 ........
The integral, shown in Eq. (1), can be expressed as
(15)
http://numericalmethods.eng.usf.edu22
Substituting Simpson rule (See Eq. 12) into Eq. (15), one gets
nnnn xfxfxfxf
xfxfxfxfxfxfxfxfhI
123
65433210
33.....
3333
8
3
n
n
ii
n
ii
n
ii xfxfxfxfxf
hI
3
,..9,6,3
1
,..8,5,2
2
,..7,4,10 233
8
3
(16)
(17)
83
http://numericalmethods.eng.usf.edu23
Example 2 (Multiple segments Simpson rule)
Compute
30
8
,8.92100000,140
000,140ln2000
b
a
dxxx
I
using Simple multiple segments rule, with number (of ) segments = = 6 (which corresponds to 2 “big” segments).
""h n
83
83
http://numericalmethods.eng.usf.edu24
SolutionIn this example, one has (see Eq. 14):
6666.36
830
h
2667.177,8, 00 xfx
6666.11
6666.38;4104.270,6666.11, 0111
hxxwherexfx
3333.152;4629.372,3333.15, 0222 hxxwherexfx
193;7455.484,19, 0333 hxxwherexfx
http://numericalmethods.eng.usf.edu25
6666.224;8976.608,6666.22, 0444 hxxwherexfx
3333.265;9870.746,3333.26, 0555 hxxwherexfx
306;6740.901,30, 0666 hxxwherexfx
http://numericalmethods.eng.usf.edu26
Applying Eq. (17), one obtains:
6740.9012332667.1776666.3
8
3 33
,..6,3
51
,..5,2
42
,..4,1
n
ii
n
ii
n
ii xfxfxfI
6740.9017455.4842
9870.7464629.37238976.6084104.27032667.1773750.1I
4696.601,11I
http://numericalmethods.eng.usf.edu27
Example 3 (Mixed, multiple segments Simpson and rules)
Compute
30
8
,8.92100000,140
000,140ln2000
b
a
dxxx
I
using Simpson 1/3 rule (with 4 small segments), and Simpson 3/8 rule (with 3 small segments).
Solution:In this example, one has:
1429.334
830
21
nn
ab
n
abh
83
31
1n2n
http://numericalmethods.eng.usf.edu28
ruleSimpson
hxx
hxx
hxx
hxx
ax
31
5714.201429.3484
4286.171429.3383
2857.141429.3282
1429.111429.381
8
04
03
02
01
0
301429.3787
8571.261429.3686
7143.231429.3585
07
06
05
hxx
hxx
hxx
http://numericalmethods.eng.usf.edu29
2667.17788.982100000,140
000,140ln200080
xf
Similarly: 6740.901
9978.767
8260.646
3909.536
2749.435
3241.342
5863.2561429.11
7
6
5
4
3
2
1
xf
xf
xf
xf
xf
xf
xf
http://numericalmethods.eng.usf.edu30
For multiple segments segmentsfirstn 41 using Simpson rule, one obtains (See Eq. 19):
1197.4364
3909.5363241.34222749.4355863.25642667.1773
1429.3
243
1
1
22
,...2
31
,...3,101 1
11
I
I
xfxfxfxfh
I n
n
ii
n
ii
31
http://numericalmethods.eng.usf.edu31
For multiple segments
using Simpson 3/8 rule, one obtains (See Eq. 17):
segmentslastn 32
2748.6697
2749.435!3241.34235863.25632667.1771429.38
3
2338
3
2
2
03
,...6,3
21
,...2
12
,...3,102 1
222
I
skipI
xfxfxfxfxfh
I n
n
ii
n
ii
n
ii
The mixed (combined) Simpson 1/3 and 3/8 rules give:
3946.061,11
2748.66971197.436421
I
III
http://numericalmethods.eng.usf.edu32
Remarks:(a) Comparing the truncated error of Simpson 1/3 rule
fab
Et
2880
5
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).
(18)
http://numericalmethods.eng.usf.edu33
(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).
n
n
ii
n
ii
nnn
xfxfxfxfh
I
xfxfxfxfxfxfxfxfxfh
I
2
...6,4,2
1
,...3,102
124322101
243
4.....443
(19)
http://numericalmethods.eng.usf.edu34
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).
http://numericalmethods.eng.usf.edu35
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 integral limits
= number of small, “h” segments, in conjunction with Simpson 1/3 rule.1n
4. Computer Algorithm For Mixed Simpson 1/3 and 3/8
rule For Integration
),(xf ,"," ba
http://numericalmethods.eng.usf.edu36
= number of small, “h” segments, in conjunction with Simpson 3/8 rule.2n
Notes:
= a multiple of 2 (any even numbers)1n
= a multiple of 3 (can be certain odd, or even numbers)2n
http://numericalmethods.eng.usf.edu37
Step 2
Compute 21 nnn
n
abh
bnhax
ihax
hax
hax
ax
n
i
.
.
.
.
2
1
2
1
0
http://numericalmethods.eng.usf.edu38
Step 3
Compute “multiple segments” Simpson 1/3 rule (See Eq. 19)
n
n
ii
n
ii xfxfxfxf
hI
2
...6,4,2
1
,...3,101
11
243
(19, repeated)
http://numericalmethods.eng.usf.edu39
Step 4
Compute “multiple segments” Simpson 3/8 rule (See Eq. 17)
2
222 3
,...9,6,3
1
...8,5,2
2
...7,4,102 233
8
3n
n
ii
n
ii
n
ii xfxfxfxfxf
hI
Step 5
21 III and print out the final approximated answer for I.
(17, repeated)
(20)
This instructional power point brought to you byNumerical Methods for STEM undergraduatehttp://numericalmethods.eng.usf.eduCommitted to bringing numerical methods to the undergraduate
Acknowledgement
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.