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

Lecture 15_Chapter_19_numerical integratio formuals(1)

The document discusses numerical integration methods, particularly focusing on Newton-Cotes formulas, including the trapezoidal rule and Simpson's rules. It outlines the implementation of these methods, their errors, and how to apply them to both equally and unequally spaced data using MATLAB. Additionally, it provides examples and MATLAB code for performing numerical integration and multiple integrals.

Uploaded by

kan nelson
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 views26 pages

Lecture 15_Chapter_19_numerical integratio formuals(1)

The document discusses numerical integration methods, particularly focusing on Newton-Cotes formulas, including the trapezoidal rule and Simpson's rules. It outlines the implementation of these methods, their errors, and how to apply them to both equally and unequally spaced data using MATLAB. Additionally, it provides examples and MATLAB code for performing numerical integration and multiple integrals.

Uploaded by

kan nelson
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
You are on page 1/ 26

Applied Numerical Methods

with MATLAB®
for Engineers and Scientists
4th Edition
Steven C. Chapra

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University and


Prof. Steve Chapra, Tufts University

©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.

Knowing how to use the trapezoidal rule to


integrate unequally spaced data.

Understanding the difference between open


and closed integration formulas.

©McGraw-Hill Education.
• Integration
Integration:

is the total value, or summation, of f(x) dx over the range


from a to b:

©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:

where fn(x) is an nth order interpolating


polynomial.

©McGraw-Hill Education.
• Newton-Cotes Examples
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.

©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:

where is somewhere between a


and b.

This formula indicates that the error


is dependent upon the curvature of
the actual function as well as the
distance between the points.

Error can thus be reduced by


breaking the curve into parts.

©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:

Integration over the three points simplifies to:

©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:

where again is somewhere between a and b.


This formula indicates that the error is dependent upon the
fourth-derivative of the actual function as well as the
distance between the points.
Note that the error is dependent on the fifth power of the
step size (rather than the third for the trapezoidal rule).
Error can thus be reduced by breaking the curve into parts.

©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:

Simpson’s 3/8 rule is generally


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

©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.

As in Simpson’s 1/3 and 3/8 rule, the even-


segment-odd-point formulas have truncation errors
that are the same order as formulas adding one
more point. For this reason, the even-segment-odd-
point formulas are usually the methods of
preference.
©McGraw-Hill Education.
• 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:

©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)

produces the integral of y with respect to x. If x is omitted,


the program assumes h = 1.

©McGraw-Hill Education.
• MATLAB Example

Unit Spacing Non Unit Spacing

Y=[ 1 4 9 16 25] X = 0:pi/100:pi;


Q = trapz(Y) Y = sin(X);
Q = trapz(X,Y)

©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

fun = @(x) exp(-x.^2).*log(x).^2;


q = integral(fun,0,Inf)

©McGraw-Hill Education.
• MATLAB Example
.

Calculate I using
integral2 command :

©McGraw-Hill Education.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy