0% found this document useful (0 votes)
10 views37 pages

Numerical Integration Techniques Explained

Uploaded by

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

Numerical Integration Techniques Explained

Uploaded by

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

Numerical Methods in

Engineering (ME 381)


3 Credit, 3 Periods/Week

Lecture 22 1
Numerical Integration

Lecture 22 2
Numerical Integration
What is Integration?
 Numerical integration is the approximate computation of an integral
using numerical techniques.
 The integration points and weights depend on the specific method used and the
accuracy required from the approximation. An important part of the analysis of
any numerical integration method is to study the behavior of the approximation
error as a function of the number of integral evaluations.
b

 f ( x )dx
The process of measuring
a
y
f(x)
the area under a function
plotted on a graph.
b
I   f ( x )dx
a
Where:
f(x) is the integrand
a= lower limit of integration
b= upper limit of integration a b
3 x
Lecture 22
Newton-Cotes Methods

 In Newton-Cote Methods, the function is approximated by a polynomial


of order n.
 Computing the integral of a polynomial is easy.


a
b
f ( x)dx  
a
b
a 0  a1 x  ...  a n x 
n
dx
b (b 2  a 2 ) (b n 1  a n 1 )

a
f ( x)dx a0 (b  a)  a1
2
 ...  an
n 1
4 Lecture 22
Simpson’s 3/8 Rule

In the previous chapter, it has been explained and illustrated


that Simpson’s 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:

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

5 Lecture 22
Simpson’s 3/8 Rule
In a similar fashion, Simpson’s 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 ( x)  f ( x)
i 3
defined as:
f 3 ( x)  a0  a1 x  a2 x 2  a3 x 3 

a0  
a  
 (3)
 2

3  1
 1, x, x , x   
a 
 2 
a3  

which can also be symbolically represented in Figure 1.


Lecture 22
6
Simpson’s 3/8 Rule
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 x2  a3 x2 
2 2

2
f ( x3 )  a0  a1x3  a2 x3  a3 x3 
2

7 Lecture 22
Simpson’s 3/8 Rule

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)

8 Lecture 22
Simpson’s 3/8 Rule

Thus, a0 
a  
  1
a      A  f
1
(7)
a2 
a3 

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

f x   1, x, x , x  A 1

3
2 3
f (8)

9 Lecture 22
Simpson’s 3/8 Rule
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, the unknown vector
a (shown in Eq. 7) can be solved.
10 Lecture 22
Simpson’s 3/8 Rule
Method 2
Using Lagrange interpolation, the cubic polynomial function
fi 3 x  that passes through 4 data points
(see Figure 1) can be explicitly given as

f3  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)

11 Lecture 22
Simpsons 3 8 Rule For
Integration
Thus, Eq. (1) can be calculated as Note:
(See Eqs. 8, 10 for Method 1 and b
I   f 2 ( x )dx
Method 2, respectively): a

  a0  a1 x  a 2 x 2 dx
b

b b a

I   f  x dx   f3  x dx  x2 x3 
b

 a0 x  a1  a2 
a a  2 3 a

b2  a2 b3  a3
Integrating the right-hand-side of  a0 ( b  a )  a1  a2
the above equations, one obtains 2 3

I  b  a  
 f x0   3 f x1   3 f x2   f x3  (11)
8

12 Lecture 22
Simpson’s 3/8 Rule
Since
ba hence b  a  3h, and the above equation becomes:
h
3
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]:
(b  a)5
Et    
 f   , where a  b (13)

13
6480 Lecture 22
Simpson’s 3/8 Rule

Example 1 (Single Simpson 3 Rule)


8
Compute
b  30
  140 ,000  
I   2000 ln    9.8 x dx,
a 8   140 ,000  2100 x  
by using a single segment Simpson 3 rule
8
Solution
In this example:
b  a 30  8
h   7.3333
3 3

14 Lecture 22
Simpson’s 3/8 Rule
 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
 1  x   2000 ln    9.8  15.3333  372.4629
  140000  2100  15.3333 
 x2  x0  2h  8  2(7.3333)  22.6666

  140000 
 f  x2   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 
Lecture 22
15
Simpson’s 3/8 Rule
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

16 Lecture 22
3. Multiple Segments for
Simpson 3 Rule
8
Using "n" = number of equal (small) segments, the
width"h" can be defined as
ba
h (14)
Notes: 3
n = multiple of 3 = number of small "h" segments
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)
17 x0  a x3 Lecture 22 x n 3
Simpson’s 3/8 Rule
Substituting Simpson 3 rule (See Eq. 12) into Eq. (15), one
gets 8

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  (17)
8  i 1, 4,7,.. i  2,5,8,.. i 3,6,9,.. 

18 Lecture 22
Simpson’s 3/8 Rule
Example 2 (Multiple segments Simpson 3 rule)
8
b  30
Compute
  140 ,000  
I   2000 ln    9.8 x dx,
a 8   140 ,000  2100 x  
3
using Simple 8 multiple segments rule, with number
(of "h" ) segments = n = 6 (which corresponds to 2 “big”
segments).

19 Lecture 22
Solution Simpson’s 3/8 Rule
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
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
Lecture 22
20
Simpson’s 3/8 Rule

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

21 Lecture 22
Simpson’s 3/8 Rule

Example 3 (Mixed, multiple segments Simpson 1 and 3


rules) 3 8
b  30
  140 ,000  
Compute I   2000 ln    9.8 x dx,
a 8   140 ,000  2100 x  
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
n n1  n2 4  3

22 Lecture 22
Simpson’s 3/8 Rule

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  7h  8  73.1429  30

23 Lecture 22
Simpson’s 3/8 Rule

 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
f  x7   901.6740

24 Lecture 22
Simpson’s 3/8 Rule
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

25 Lecture 22
Simpson’s 3/8 Rule
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

26 Lecture 22
Simpson’s 3/8 Rule
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).

27 Lecture 22
Simpson’s 3/8 Rule
(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... 
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).

28 Lecture 22
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.
29 Lecture 22
Simpson’s 3/8 Rule
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)

30 Lecture 22
Simpson’s 3/8 Rule
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

31 Lecture 22
Simpson’s 3/8 Rule
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)

32 Lecture 22
Simpson’s 3/8 Rule
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
(20)
I  I1  I 2
and print out the final approximated answer for I.

33 Lecture 22
Weddle’s Rule

Lecture 22 34
Lecture 22 35
36
Lecture 22
Self Assessment
Practice Examples of
Vedamuirthy and Vasistha

37
Lecture 22

You might also like