0% found this document useful (0 votes)
186 views43 pages

Simpson's Rule for Numerical Integration

The document discusses Simpson's 3/8 rule for numerical integration. It provides two methods for deriving the Simpson 3/8 formula. The formula approximates the integral of a function f(x) over an interval [a,b] as (b-a)/8 * [f(a) + 3f(x1) + 3f(x2) + f(b)], where x1 and x2 are points dividing the interval into three equal parts. An example calculates the integral of a function from 8 to 30 using this rule.

Uploaded by

Shubham Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
186 views43 pages

Simpson's Rule for Numerical Integration

The document discusses Simpson's 3/8 rule for numerical integration. It provides two methods for deriving the Simpson 3/8 formula. The formula approximates the integral of a function f(x) over an interval [a,b] as (b-a)/8 * [f(a) + 3f(x1) + 3f(x2) + f(b)], where x1 and x2 are points dividing the interval into three equal parts. An example calculates the integral of a function from 8 to 30 using this rule.

Uploaded by

Shubham Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

Numerical Methods

Part: Simpson 3
8 Rule For
Integration.
 

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 3 8 Rule


For Integration.
 
Major: All Engineering Majors

Authors: Duc Nguyen

http://numericalmethods.eng.usf.edu
Numerical Methods for STEM undergraduates

04/01/22 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   f ( x)dx (1)
a
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) fi (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
fi ( x)  f 2 ( x), defined as:

2
f 2 ( x)  a0  a1x  a2 x (2)

7 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 fi ( x )  f 3 ( x )
defined as f ( x)  a  a x  a x 2  a x 3 
3 0 1 2 3

 a0  
a  
 1  (3)
 1, x, x , x   
2 3

a
 2 
a3  
8 which can also be symbolically represented in Figure 1.
Method 1
The unknown coefficients a0 , a1 , a2 and a3 (in Eq. (3))
can be obtained by substituting 4 known coordinate
data points x0 , f x0 , x1 , f x1 , x2 , f x2  and x3 , f x3 
into Eq. (3), as following
f ( x0 )  a0  a1x0  a2 x02  a3 x02 

f ( x1 )  a0  a1x1  a2 x12  a3 x12 
 (4)
f ( x2 )  a0  a1x2  a2 x22  a3 x22 
2 2
9
f ( x3 )  a0  a1x3  a2 x3 http://numericalmethods.eng.usf.edu
a3 x3 
Eq. (4) can be expressed in matrix notation as
1 x0 x02 x03  a0   f x0 
 3   a   f x 
1 x1 x12 x1   1   1 

3  a   f x 
(5)
1 x2 x22 x2  2   2 
 3   a   f x 
1 x3 x32 x3   3   3 

The above Eq. (5) can be symbolically represented as


 
A44 a41  f 41 (6)

10 http://numericalmethods.eng.usf.edu
Thus, a0 
a  
  1
a     A  f
1
(7)
a2 
a3 

Substituting Eq. (7) into Eq. (3), one gets



 2 3

f3 x   1, x, x , x  A1
f (8)

11 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  2a a  2b  (9)
x2  a  2h  a  
3 3 

3b  3a 
x3  a  3h  a  b 
3
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

f 3 x  
x  x1 x  x2 x  x3   f x   x  x0 x  x2 x  x3   f x 
x0  x1 x0  x2 x0  x3  0
x1  x0 x1  x2 x1  x3  1


 x  x0 x  x1 x  x3 
 f x3  
 x  x0 x  x1 x  x2 
 f x3 
x2  x0 x2  x1 x2  x3  x3  x0 x3  x1 x3  x2 
(10)
13 http://numericalmethods.eng.usf.edu
3
Simpsons 8 Rule For
Integration
Thus, Eq. (1) can be calculated as (See Eqs. 8, 10 for
Method 1 and Method 2, respectively):
b b
I   f x dx   f3 x dx
a a
Integrating the right-hand-side of the above
equations, one obtains

I  b  a 
 f x0   3 f x1   3 f x2   f x3  (11)
8
14 http://numericalmethods.eng.usf.edu
ba
Since h  hence b  a  3h , and the above
3
equation becomes:
3h
I    f x0   3 f x1   3 f x2   f x3  (12)
8
The error introduced by the Simpson 3/8 rule can be
derived as [Ref. 1]:
5
(b  a)
Et    f   , where a  b (13)
6480
15 http://numericalmethods.eng.usf.edu
Example 1 (Single Simpson 3 8 rule)
Compute
b 30
  140,000  
I   2000 ln   9.8 x dx,
a 8   140,000  2100x  
by using a single segment Simpson 3 8 rule
Solution
In this example:
b  a 30  8
h   7.3333
3 3
16 http://numericalmethods.eng.usf.edu
 140000 
x0  8  f x0   2000 ln   9.8  8  177.2667
 140000  2100  8 

 x1  x0  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
 x2  x0  2h  8  2(7.3333)  22.6666

  140000 
f
 2  x   2000 ln    9.8  22.6666  608.8976
  140000  2100  22.6666 

 x3  x0  3h  8  3(7.3333)  30

  140000 
f
 3  x   2000 ln    9.8  30  901.6740
  140000  2100  30 

18 http://numericalmethods.eng.usf.edu
Applying Eq. (12), one has:
3
I   7.3333  177.2667  3  372.4629  3  608.8976  901.6740
8
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
ba
h (14)
3
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 b
I   f x dx   f3 x dx
a a

x3 x6 xn b
I  f3 x dx   f3 x dx  ........   f3 x dx (15)
x0  a x3 x n 3

21 http://numericalmethods.eng.usf.edu
Substituting Simpson 3 8 rule (See Eq. 12) into
Eq. (15), one gets

3h  f x0   3 f x1   3 f x2   f x3   f x3   3 f x4   3 f x5   f x6 


I  
8  .....  f xn 3   3 f xn  2   3 f xn 1   f xn  
(16)

3h  n2 n 1 n 3 
I   f x0   3  f xi   3  f xi   2  f xi   f xn 
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
  140,000  
Compute I   2000 ln   9.8 x dx,
a 8   140,000  2100x  
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):
30  8
h  3.6666
6
x0 , f x0   8,177.2667
x1, f x1  11.6666,270.4104; where x1  x0  h  8  3.6666
 11 .6666
x2 , f x2  15.3333,372.4629; where x2  x0  2h  15.3333
x3 , f x3  19,484.7455; where x3  x0  3h  19
24 http://numericalmethods.eng.usf.edu
x4 , f x4  22.6666,608.8976; where x4  x0  4h  22.6666

x5 , f x5  26.3333,746.9870; where x5  x0  5h  26.3333

x6 , f x6   30,901.6740; where x6  x0  6h  30

25 http://numericalmethods.eng.usf.edu
Applying Eq. (17), one obtains:
3  n24 n 1 5 n  3 3 
I  3.6666177.2667  3  f xi   3  f xi   2  f xi   901.6740
8  i 1, 4,.. i  2,5,.. i  3,6,.. 

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
1 3
Example 3 (Mixed, multiple segments Simpson 3 and 8
rules)
b  30
  140,000  
Compute I   2000 ln   9.8 x dx,
a 8   140,000  2100x  
using Simpson 1/3 rule (with n1  4 small segments), and
Simpson 3/8 rule (with n2  3 small segments).
Solution:
In this example, one has:
ba ba 30  8
h    3.1429
27
n n1  n2 4  3 http://numericalmethods.eng.usf.edu
x0  a  8 
x1  x0  1h  8  3.1429  11 .1429 

x2  x0  2h  8  23.1429   14.2857  Simpson 1 rule
3
x3  x0  3h  8  33.1429   17.4286 

x4  x0  4h  8  43.1429   20.5714
x5  x0  5h  8  53.1429  23.7143
x6  x0  6h  8  63.1429  26.8571
x7  x0  7 h  8  73.1429  30
28 http://numericalmethods.eng.usf.edu
 140,000 
 
f x0  8  2000 ln   9.8  8  177.2667
 140,000  2100  8 
Similarly: f x1  11.1429  256.5863
f x2   342.3241
f x3   435.2749
f x4   536.3909
f x5   646.8260
f x6   767.9978
29
f x7   901.6740 http://numericalmethods.eng.usf.edu
For multiple segments n1  first 4 segments 
using Simpson 1 rule, one obtains (See Eq. 19):
3

 h  
n1 1 3 n1  2  2
 
I1    f x0   4  f xi   2  f xi   f xn1 
 3  i 1,3,... i  2,... 
 3.1429 
I1   177.2667  4256.5863  435.2749  2342.3241  536.3909
 3 
I1  4364.1197

30 http://numericalmethods.eng.usf.edu
For multiple segments n2  last 3 segments 
using Simpson 3/8 rule, one obtains (See Eq. 17):
 3h 
n2  2 1 n2 1 2 n2  3 0 
 
I 2    f x0   3  f xi   3  f xi   2  f xi   f xn1 
 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  I1  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
Et 
b  a 5
 f   (18)
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
I1    f x0   4 f x1   f x2   f x2   4 f x3   f x4   .....  f xn  2   4 f xn 1   f xn 
3
 h  n 1 n2 
I 2    f x0   4  f xi   2  f xi   f xn  (19)
 3  i 1,3,... i  2, 4,6... 

33 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
n2 = number of small, “h” segments, in conjunction with
Simpson 3/8 rule.
Notes:
n1 = a multiple of 2 (any even numbers)

n2 = a multiple of 3 (can be certain odd, or even


numbers)

36 http://numericalmethods.eng.usf.edu
Step 2
x0  a
Compute n  n1  n2
x1  a  1h
ba
h x2  a  2h
n
.
.
xi  a  ih
.
.
xn  a  nh  b
37 http://numericalmethods.eng.usf.edu
Step 3
Compute “multiple segments” Simpson 1/3 rule (See
Eq. 19)

 h  
n1 1 n1  2
I1    f x0   4  f xi   2  f xi   f xn 
 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)
 3h  
n2  2 n2 1 n2  3
I 2    f x0   3  f xi   3  f xi   2  f xi   f xn2   
 8  i 1, 4, 7... i  2,5,8... i  3, 6,9,... 
(17, repeated)
Step 5
I  I1  I 2 (20)
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

You might also like