Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

Chapter19

Applied numerical methods 19

Uploaded by

uskang00
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Chapter19

Applied numerical methods 19

Uploaded by

uskang00
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Numerical Analysis: Part Five

Chapter 19: Numerical Integration Formulas

Prof. Sung Jin Yoo

School of Electrical and Electronics Engineering


Chung-Ang University

Numerical analysis Chapter 19


19. Numerical Integration Formulas – Integration

 Integration:
 f x dx
b
I a

is the total value, or summation, of f(x) dx over the range from a to b:

Numerical analysis Chapter 19


19. Numerical Integration Formulas – Newton-Cotes Formulas

 Newton-Cotes Formulas
• The Newton-Cotes formulas are the most common numerical integration
schemes.
• Generally, they are based on replacing a complicated function or
tabulated data with a polynomial that is easy to integrate:

 f x dx   f x dx
b b
I a a n

where fn(x) is an nth order interpolating polynomial.


• The integrating function can be polynomials for any order - for example,
(a) straight lines or (b) parabolas.
• The integral can be approximated in one step or in a series of steps to
improve accuracy.

Numerical analysis Chapter 19


19. Numerical Integration Formulas – The Trapezoidal Rule

 The Trapezoidal Rule


• Trapezoidal rule
~ a straight-line approximation for
the function:
I   f n  x  dx
b

b f b  f  a  
I    f (a)   x  a   dx
a
 ba 
f  a   f b
I  b  a 
2
(width)  (average height)

Numerical analysis Chapter 19


19. Numerical Integration Formulas – The Trapezoidal Rule

 Error of the Trapezoidal Rule


• An estimate for the local truncation
error of a single application of the
trapezoidal rule is: b

1 1
ò f ¢¢ (x )d x
Et = - f (x )(b - a )  Ea = - (b - a )
3 3
¢¢ a

12 12 b -a
where is somewhere between a
and b.
• Error can thus be reduced by
breaking the curve into parts.

Ex19.1)

Numerical analysis Chapter 19


19. Numerical Integration Formulas – The Trapezoidal Rule

 Composite Trapezoidal Rule


• Assuming n+1 data points are evenly
spaced, there will be n intervals over
which to integrate.
• The total integral can be calculated by
integrating each subinterval and then
adding them together:
I   f n  x  dx   f n  x  dx   f n  x  dx     f n  x  dx
xn x1 x2 xn

x0 x0 x1 xn1

f  x0   f  x1  f  x1   f  x2  f  xn 1   f  xn 
I h h   h
2 2 2
h n 1
 ba
I   f  x0   2 f  xi   f  xn   (h  )
2 i 1  n
• Error for the composite trapezoidal rule
n

b  a 
3
n  f   i
b  a 
3

Et 
12n3
 f   
i 1
 By f ''  i 1

n
, Ea 
12n 2
f ''

Numerical analysis Chapter 19


19. Numerical Integration Formulas – The Trapezoidal Rule

 Composite Trapezoidal Rule (cont.)


Ex 19.2)

 The error is inversely related to the square of n.


So, doubling the number of segments quarters the error.
Numerical analysis Chapter 19
19. Numerical Integration Formulas – Simpson’s Rules

 Simpson’s Rules
• One drawback of the trapezoidal rule is that the error is related to the
second derivative of the function.
• More complicated approximation formulas can improve the accuracy for
curves - these include using (a) 2nd and (b) 3rd order polynomials.
• The formulas that result from taking the integrals under these
polynomials are called Simpson’s rules.

Numerical analysis Chapter 19


19. Numerical Integration Formulas – Simpson’s Rules
* Lagrange polynomial interpolation for nnpoints
n x  xj
 Simpson’s 1/3 Rule fn -1 (x i ) = å Li (x ) f (x i ) where Li x  
i =1 j1 xi  x j
• Simpson’s 1/3 rule corresponds to using second-order polynomials. ji

Using the Lagrange form for a quadratic fit of three points:

fn x 
x  x1  x  x2  f x  x  x0  x  x2  f x  x  x0  x  x1  f x
     
x0  x1  x0  x2  0 x1  x0  x1  x2  1 x2  x0  x2  x1  2
• Integration over the three points simplifies to:
I   f n  x  dx
x2

x0

 x  x1   x  x2  f x   x  x0   x  x2  f x   x  x0   x  x1  f x dx
     
x2

x0
 x0  x1   x0  x2  0  x1  x0   x1  x2  1  x2  x0   x2  x1  2
h ba
I  f  x0   4 f  x1   f  x2   (h  )
3 2

• The local truncation error of a single application of Simpson’s 1/3 rule


 b  a  f (4) 
5
1
Et   h5 f (4)    By h  (b  a ) / 2, Et    
90 2880
Numerical analysis Chapter 19
19. Numerical Integration Formulas – Simpson’s Rules

 Composite Simpson’s 1/3 Rule


• Simpson’s 1/3 rule can be used
on a set of subintervals.
• There must be an odd number of
points and an even number of
segments.
• Because of the heavy weighting of
the internal points, the formula is a
little more complicated than for the
trapezoidal rule:
I   f n  x  dx   f n  x  dx   f n  x  dx     f n  x  dx
xn x2 x4 xn

x0 x0 x2 xn2

h h h
I  f  x0   4 f  x1   f  x2     f  x2   4 f  x3   f  x4       f  xn  2   4 f  xn 1   f  xn  
3 3 3
 n 1 n2
 • An error estimate
 f x  4
 f  xi   2  f  x j   f  xn  
 b  a 
5
 0
i 1 j 2
 E   f (4)
 
I  (b  a ) 
a
i , odd j , even
180n 4
3n
Numerical analysis Chapter 19 Ex 19.4)
19. Numerical Integration Formulas – Simpson’s Rules
* Lagrange polynomial interpolation for nnpoints *
n x  xj
 Simpson’s 3/8 Rule fn -1 (x i ) = å Li (x ) f (x i ) where Li x  
i =1 j1
xi  x j
• Simpson’s 3/8 rule corresponds to ji

using third-order polynomials to fit four


points. Integration over the four points
simplifies to:
x3
I = ò fn (x ) dx
x0

3h é
I = ê f (x 0 ) + 3 f (x 1 ) + 3 f (x 2 ) + f (x 3 )ùú
8 ë û
where h = (b - a ) / 3

• Simpson’s 3/8 rule is generally used in


concert with Simpson’s 1/3 rule when
the number of segments is odd.

Ex 19.5)

Numerical analysis Chapter 19


19. Numerical Integration Formulas
– Integration with Unequal Segments
 Integration with Unequal Segments
• Previous formulas were simplified based on equispaced data points -
though this is not always the case.
• The trapezoidal rule may be used with data containing unequal
segments:
I   f n  x  dx   f n  x  dx   f n  x  dx     f n  x  dx
xn x1 x2 xn

x0 x0 x1 xn1

f  x0   f  x1  f  x1   f  x2  f  xn 1   f  xn 
I  h1  h2    hn
2 2 2
where hi : the width of segment
Ex 19.6)

Numerical analysis Chapter 19


19. Numerical Integration Formulas
– Integration with Unequal Segments
• MATLAB Functions
• MATLAB has built-in functions to evaluate integrals based on the
trapezoidal rule
• z = trapz(y)
z = trapz(x, y)
produces the integral of y with respect to x. If x is omitted, the program
assumes h=1.

Numerical analysis Chapter 19


19. Numerical Integration Formulas
– Integration with Unequal Segments
• MATLAB Functions (cont.)
• z = cumtrapz(y)
z = cumtrapz(x, y)
produces the cumulative integral of y with respect to x. If x is omitted, the
program assumes h=1.
Ex 19.7) Measurements of velocity at series of discrete unequally spaced times
during free fall. Incorporate some random error by rounding the velocities to the
nearest integer. Then use cumtrapz to determine the distance fallen and compare
the results to the analytical solution.

Numerical analysis Chapter 19

You might also like