0% found this document useful (0 votes)
515 views

Lecture09 - Numerical Integration (I)

The document discusses numerical integration techniques. It introduces the Trapezoidal Rule and Simpson's 1/3 Rule for approximating the area under a curve. The Trapezoidal Rule uses linear interpolation to estimate the integral, while Simpson's Rule uses quadratic interpolation. The document also covers the multiple application versions of these rules, which subdivide the interval into smaller segments to improve accuracy. Examples are provided to demonstrate calculating integrals using these numerical integration formulas and estimating the errors.

Uploaded by

Na2ry
Copyright
© Attribution Non-Commercial (BY-NC)
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)
515 views

Lecture09 - Numerical Integration (I)

The document discusses numerical integration techniques. It introduces the Trapezoidal Rule and Simpson's 1/3 Rule for approximating the area under a curve. The Trapezoidal Rule uses linear interpolation to estimate the integral, while Simpson's Rule uses quadratic interpolation. The document also covers the multiple application versions of these rules, which subdivide the interval into smaller segments to improve accuracy. Examples are provided to demonstrate calculating integrals using these numerical integration formulas and estimating the errors.

Uploaded by

Na2ry
Copyright
© Attribution Non-Commercial (BY-NC)
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
You are on page 1/ 25

MTH2212 – Computational Methods and

Statistics

Numerical Differentiation and Integration

Lecture 9:
Numerical Integration (I)
Objectives

 Introduction
 Trapezoidal Rule
 Multiple-Application Trapezoidal Rule
 Simpson’s 1/3 Rule
 Multiple-Application Simpson’s 1/3 Rule

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 2


Integration – Graphical representation

 The integral is the area under the curve

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 3


Integration – Engineering applications

 How to take complicated integrals and approximate the


area under the curve
 Integration needed for analyzing irregularly shaped lines,
areas, volumes
 Examples:

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 4


Newton-Cotes Integration Formulas

 The Newton-Cotes formulas are the most common numerical


integration schemes.
 This involves the replacement of a complicated function or
tabulated data with an approximating function that is easy
to integrate.
b b
I  a f ( x)dx  a f n ( x)dx

 Where fn(x) is a polynomial of order n

f n ( x)  a0  a1 x  a2 x 2  ...  an 1 x n1  an x n

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 5


Newton-Cotes Integration Formulas

 Closed and open forms


 Closed: data points at the beginning and end of the limits of integration are
known
 Open: integration limits that extend beyond the range of data

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 6


Trapezoidal Rule

 The Trapezoidal rule is the first of the Newton-Cotes closed


integration formulas, corresponding to the case where the
polynomial is first order i.e. n = 1
b b
I  a f ( x)dx  a f1 ( x)dx
 f1(x) is expressed using linear interpolation formula
f (b)  f (a )
f1 ( x)  f (a)  ( x  a)
ba
 The area under the straight line is an estimate of the integral
of f1(x): b f (b)  f (a ) 
I  a  f (a)  ( x  a ) dx
 ba 
Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 7
Trapezoidal Rule

 The result of this integration is

f (a )  f (b)
I  (b  a) Trapezoidal rule
2

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 8


Trapezoidal Rule

f (a )  f (b)
I  (b  a )
2

Area of a trapezoid = Width X Average Height

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 9


Error of the Trapezoidal Rule

 Truncation error is expressed as:


1
Et   (b  a )3 f ' ' ()
12
 An approximation of the second derivative is given by
b

f ' ' ( )  f ''


a
f ' ' ( x)dx
ba
 Approximate error estimate is then:
1
Ea   (b  a )3 f ' '
12

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 10


Example 1

Use Trapezoidal Rule to integrate numerically the following


function:
f ( x)  0.2  25 x  200 x 2  675x 3  900x 4  400 x 5

from a = 0 to b = 0.8

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 11


Example 1 - Solution

 Evaluate f(a) and f(b)


f (0)  0.2
f (0.8)  0.232
 Evaluate the integral
0.2  0.232
I  (0.8  0)  0.1728
2
 Approximate error estimate
0.8

f ' ' ( x) 

0
(400  4050 x  10800 x 2  8000 x 3 )dx
 60
0.8  0
1 1
Ea   f ' ' ( x )(b  a ) 3   (60)(0.8  0) 3  2.56
12 12
Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 12
Example 1 - Solution

 True value of the integral


is 1.640533

 Et = 1.640533 – 0.1728
= 1.467733  εt = 89.5%

 Ea = 2.56

 Discrepancy between Et
and Ea due to the fact that
f̅’’(x) is not an accurate
approximation of f’’(ξ) for
an interval of this size.

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 13


Multiple-Application or Composite Trapezoidal Rule

 Divide integration interval from a to b into n segments of


equal width  improve the accuracy of the trapezoidal rule
 The total integral can be represented as
x1 x2 xn
I  x f ( x)dx  x f ( x)dx  ...  x f ( x)dx
0 1 n 1

 Substituting the trapezoidal rule for each integral, we get


f ( x0 )  f ( x1 ) f ( x1 )  f ( x2 ) f ( xn1 )  f ( xn )
I h h  ...  h
2 2 2
 By grouping terms, we have
h n 1 
I   f ( x0 )  2 f ( xi )  f ( xn )
2 i 1 
Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 14
Multiple-Application Trapezoidal Rule

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 15


Error of Multiple-Application Trapezoidal Rule

 Truncation error is obtained by summing the individual error for each


segment 3 n
(b  a )
Et  
12n3
 f ' ' ()
i 1
 By estimating the average value of f̅ ’’(x) for the entire interval
n
 f ' ' ( ) n

f '' i 1  f ' ' (  )  nf ' '


i 1
n
 Approximate error estimate for multiple-application of trapezoidal rule
is then: 3
(b  a )
Ea   2
f ''
12n
 As you double the number of segments error is quartered

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 16


Example 2

Apply two segments in the trapezoidal rule to estimate the


integral of:
f ( x )  0.2  25 x  200 x 2  675 x 3  900 x 4  400 x 5

from a = 0 to b = 0.8

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 17


Example 2 - Solution

0.8  0
 We have n = 2  h  0.4
2

f (0)  0.2 f (0.4)  2.456 f (0.8)  0.232

 Evaluate the integral


0.2  2(2.456)  0.232
I  0.8  1.0688
4
 True and Approximate error estimate
Et = 1.640533 – 1.0688 = 0.571733

( 0. 8  0 ) 3
Ea   2
( 60)  0.64
12(2)

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 18


Simpson’s 1/3 Rule

 It corresponds to the case where n = 2 i.e. a polynomial of


second order:
b b
I  a f ( x)dx  a f 2 ( x)dx

 Let a = x0 and b = x2 and f2(x) a second order Lagrange


polynomial, then
x2  ( x  x1 )( x  x2 ) ( x  x0 )( x  x2 )
I  x  f ( x0 )  f ( x1 )
0
 ( x0  x1 )( x0  x2 ) ( x1  x0 )( x1  x2 )
( x  x0 )( x  x1 ) 
 f ( x2 ) dx
( x2  x0 )( x2  x1 ) 

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 19


Simpson’s 1/3 Rule

 After integration, we have:


h where b  a
I   f ( x0 )  4 f ( x1 )  f ( x2 ) h
3 2

 Estimated truncation error


b

( 4)
5
(b  a ) ( 4) ( 4) ( 4)
f ( x)dx
Ea   f f ( )  f  a
2880 ba

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 20


Example 3

Evaluate the integral of:


f ( x)  0.2  25 x  200 x 2  675x 3  900 x 4  400 x 5
from a = 0 to b = 0.8 using Simpson’s 1/3 rule.
Compute the truncation errors Et and Ea

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 21


Example 3 - Solution

Evaluate the integral with h = (b-a)/2 = 0.4


h 0.4
I   f ( x0 )  4 f ( x1 )  f ( x2 )   0.2  4( 2.456 )  0.232  1.367467
3 3
True truncation error

Et = 1.640533 – 1.367467 = 0.2730667  εt = 16.6%


Approximate truncation error
0.8
0 f ( 4) ( x)dx
f ( 4) ( x)  21600  48000 x  f ( 4) ( x)   2400
0.8  0
5 5
(b  a) ( 4) (0.8)
Ea   f ( x)   ( 2400)  0.2730667
2880 2880

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 22


Multiple-Application of Simpson’s 1/3 Rule

 Just as the trapezoidal rule,


Simpson’s 1/3 rule can be
improved by dividing the
integration interval into n
segments of equal width

 The total integral can then be


represented by

h n 1 n2  (b  a)5 ( 4)
I   f ( x0 )  4  f ( xi )  2  f ( xi )  f ( xn ) Ea   4
f
3 i 1,3,5,... j  2, 4, 6,...  180n

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 23


Example 4

Use n = 4 to evaluate the integral of:


f ( x)  0.2  25 x  200 x 2  675x 3  900 x 4  400 x 5
from a = 0 to b = 0.8 using Simpson’s 1/3 rule.
Compute the truncation errors Et and Ea

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 24


Example 4 – Solution

 The integral using composite simpson’s 1/3 rule

h = (0.8-0)/4 = 0.2

f(0)=0.2 f(0.2)=1.288 f(0.4)=2.456 f(0.6)=3.464 f(0.8)=0.232


0.2
I  0.2  4(1.288)  2.456  0.2  2.456  4(3.464)  0.232
3 3
 1.623466  εt = 1.0%
Et = 1.640533 – 1.623466 = 0.017067
 Approximate truncation error
(b  a )5 ( 4) (0.8)5
Ea   4
f  4
(2400)  0.017067
180n 180(4)

Dr. M. Hrairi MTH2212 - Computational Methods and Statistics 25

You might also like