Lecture 15_Chapter_19_numerical integratio formuals(1)
Lecture 15_Chapter_19_numerical integratio formuals(1)
with MATLAB®
for Engineers and Scientists
4th Edition
Steven C. Chapra
©McGraw-Hill Education. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education.
Part 5
Chapter 19
Numerical Integration
Formulas
©McGraw-Hill Education. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education.
• Chapter Objectives, 1
Recognizing that Newton-Cotes integration formulas are
based on the strategy of replacing a complicated
function or tabulated data with a polynomial that is easy
to integrate.
Knowing how to implement the following single
application Newton-Cotes formulas:
• Trapezoidal rule
• Simpson’s 1/3 rule
• Simpson’s 3/8 rule
Knowing how to implement the following composite
Newton-Cotes formulas:
• Trapezoidal rule
• Simpson’s 3/8 rule
©McGraw-Hill Education.
• Chapter Objectives, 2
Recognizing that even-segment-odd-point
formulas like Simpson’s 1/3 rule achieve
higher than expected accuracy.
©McGraw-Hill Education.
• Integration
Integration:
©McGraw-Hill Education.
• 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:
©McGraw-Hill Education.
• Newton-Cotes Examples
The integrating function
can be polynomials for
any order—for example,
(a) straight lines or (b)
parabolas.
©McGraw-Hill Education.
• The Trapezoidal Rule
The trapezoidal rule is the
first of the Newton-Cotes
closed integration formulas;
it uses a straight-line
approximation for the
function:
©McGraw-Hill Education.
• Error of the Trapezoidal Rule
An estimate for the local truncation
error of a single application of the
trapezoidal rule is:
©McGraw-Hill Education.
• 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:
©McGraw-Hill Education.
• MATLAB Program
©McGraw-Hill Education.
• 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.
©McGraw-Hill Education.
• Simpson’s 1/3 Rule
Simpson’s 1/3 rule corresponds to using
second-order polynomials. Using the
Lagrange form for a quadratic fit of three
points:
©McGraw-Hill Education.
• Error of Simpson’s 1/3 Rule
An estimate for the local truncation error of a single
application of Simpson’s 1/3 rule is:
©McGraw-Hill Education.
• Composite Simpson’s 1/3 Rule
Simpson’s 1/3 rule can be used on a
set of subintervals in much the same
way the trapezoidal rule was, except
there must be an odd number of points.
Because of the heavy weighting of the
internal points, the formula is a little
more complicated than for the
trapezoidal rule:
©McGraw-Hill Education.
• Simpson’s 3/8 Rule
Simpson’s 3/8 rule corresponds
to using third-order polynomials
to fit four points. Integration over
the four points simplifies to:
©McGraw-Hill Education.
• Higher-Order Formulas
Higher-order Newton-Cotes formulas may also be
used—in general, the higher the order of the
polynomial used, the higher the derivative of the
function in the error estimate and the higher the
power of the step size.
©McGraw-Hill Education.
• Integration Code for Unequal
Segments
©McGraw-Hill Education.
• MATLAB Functions
MATLAB has built-in functions to evaluate integrals
based on the trapezoidal rule
z = trapz(y)
z = trapz(x, y)
©McGraw-Hill Education.
• MATLAB Example
©McGraw-Hill Education.
• MATLAB Example
Matrix Integral
X = [1 ;2;.;5 ;7 ;10]
Y = [5.2 4.8 4.9 5.1; 7.7 7.0 6.5 6.8; 9.6 10.5 10.5 9.0; 13.2 14.5 13.8 15.2]
©McGraw-Hill Education.
• Multiple Integrals
Multiple integrals can be
determined numerically by first
integrating in one dimension,
then a second, and so on for
all dimensions of the problem.
©McGraw-Hill Education.
• MATLAB Example
Multiple Integral
©McGraw-Hill Education.
• MATLAB Example
.
Function Integral
©McGraw-Hill Education.
• MATLAB Example
.
Calculate I using
integral2 command :
©McGraw-Hill Education.