mecn 3500 inter - bayamon lecture 10101010 numerical methods for engineering mecn 3500 professor:...

30
MECN 3500 MECN 3500 Inter - Bayamon Inter - Bayamon Lecture Lecture 1 1 0 0 Numerical Methods for Engineering Numerical Methods for Engineering MECN 3500 MECN 3500 Professor: Dr. Omar E. Meza Castillo Professor: Dr. Omar E. Meza Castillo [email protected] http://www.bc.inter.edu/facultad/omeza Department of Mechanical Engineering Department of Mechanical Engineering Inter American University of Puerto Rico Inter American University of Puerto Rico Bayamon Campus Bayamon Campus

Upload: clarissa-melton

Post on 26-Dec-2015

232 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

LectureLecture

1100

Numerical Methods for EngineeringNumerical Methods for Engineering MECN 3500 MECN 3500

Professor: Dr. Omar E. Meza CastilloProfessor: Dr. Omar E. Meza [email protected]

http://www.bc.inter.edu/facultad/omeza

Department of Mechanical EngineeringDepartment of Mechanical Engineering

Inter American University of Puerto RicoInter American University of Puerto Rico

Bayamon CampusBayamon Campus

Page 2: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

22

Tentative Lectures ScheduleTentative Lectures Schedule

TopicTopic LectureLecture

Mathematical Modeling and Engineering Problem SolvingMathematical Modeling and Engineering Problem Solving 11

Introduction to MatlabIntroduction to Matlab 22

Numerical ErrorNumerical Error 33

Root FindingRoot Finding 4-5-64-5-6

System of Linear EquationsSystem of Linear Equations 7-87-8

Least Square Curve FittingLeast Square Curve Fitting 99

Numerical IntegrationNumerical Integration 1010

Ordinary Differential Equations Ordinary Differential Equations

Page 3: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Newton-Cotes Integration FormulasNewton-Cotes Integration Formulas

Numerical IntegrationNumerical Integration

33

Page 4: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

To solve numerical problems and To solve numerical problems and appreciate their applications for appreciate their applications for engineering problem solving.engineering problem solving.

44

Course ObjectivesCourse Objectives

Page 5: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

badxxfb

a and between curve under the area )(

b

a

dxxf

dxxf

)( :nintegratio Definite •

)( :nintegratio Indefinite •

IntroductionIntroduction

Page 6: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

They are based on the strategy of replacing a complicated function or tabulated data with an approximating function that is easier to integrate:

b

a n

b

adxxfdxxfI )()(

where fn(x) is a polynomial of degree n.

f1(x)f2(x)

Page 7: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Piecewise functions can be used also to approximate the integral.

3 piecewise linear functions to approximate f(x) between a and b.

Page 8: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Two forms of the Newton-Cotes formulas:

Closed Forms: the data points at the beginning and end of the limits of integration are known.

Open Forms: integration limits extend beyond the range of the data.

Page 9: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on The Trapezoidal RuleThe Trapezoidal Rule

2

)()()(

)()( 1

bfafab

dxxfdxxfIb

a

b

a

The integral is approximated by a line:

Page 10: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Statement: Use the trapezoidal rule to estimate

Example 21.1 Example 21.1

8.0

0

5432 400900675200252.0 dxxxxxx

%5.89

1728.02

232.02.08.0

2

)8.0()0()08.0(

2

)()()(

t

ff

bfafabI

Solution:

Page 11: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

One way to improve the accuracy of the trapezoidal rule is to divide the integration interval from a to b into a number of segments and apply the method to each segment.

The areas of individual segments can then be added to yield the integral for the entire interval.

The Multiple-Application Trapezoidal RuleThe Multiple-Application Trapezoidal Rule

Page 12: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Page 13: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Page 14: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

n

n

x

x

x

x

x

x

dxxfdxxfdxxfI1

2

1

1

0

)()()(

2

)()(

2

)()(

2

)()( 12110 nn xfxfh

xfxfh

xfxfhI

n

xfxfxfabxfxfxf

hI

n

n

ii

n

n

ii 2

)()(2)()()()(2)(

2

1

101

10

The total integral is

Substituting the trapezoidal rule for each integral:

Grouping terms:

Page 15: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

1515

Page 16: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Statement: Use the multiple-application trapezoidal rule for n = 2 to estimate

Example 21.1 Example 21.1

8.0

0

5432 400900675200252.0 dxxxxxx

%9.34

0688.14

232.0)456.2(22.08.0

4

)8.0()4.0(2)0()08.0(

)2(2

)()(2)()( 210

t

fff

xfxfxfabI

Solution:

Page 17: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Page 18: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on Computer Algorithms for the Trapezoidal RuleComputer Algorithms for the Trapezoidal Rule

Page 19: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

More accurate estimate of an integral is obtained if a high-order polynomial is used to connect the points.

The formulas that result from taking the integrals under such polynomials are called Simpson’s rules.

Simpson’s RulesSimpson’s Rules

Page 20: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

This rule results when a second-order interpolating polynomial is used.

2

where)()(4)(3

)())((

))((

)())((

))(()(

))((

))((

,and Let

)()(

210

21202

10

12101

200

2010

21

20

2

2

0

abhxfxfxf

hI

dxxfxxxx

xxxx

xfxxxx

xxxxxf

xxxx

xxxxI

xbxa

dxxfdxxfI

x

x

b

a

b

a

•After integration,

Simpson’s 1/3 RuleSimpson’s 1/3 Rule

Page 21: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

2121

Page 22: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Statement: Single Application of Simpson’s 1/3 Rule

5432 400900675200252.0)( xxxxxxf

From a=0 to b=0.8. recall that the exact integral is 1.640533

%6.16,2730667.0367467.1640533.1where

367467.16

232.0)456.2(42.08.0

ttE

I

Which is approximately 5 times more accurate than for a single application of the trapezoidal rule (Example 21.1)

Example 21.4 Example 21.4

Solution:

Page 23: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

This rule results when a third-order interpolating polynomial is used.

3

where)()(3)(3)(8

3

,yields This

)()(

3210

3

abhxfxfxfxf

hI

dxxfdxxfIb

a

b

a

Simpson’s 8/3 RuleSimpson’s 8/3 Rule

Page 24: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

2424

Page 25: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Statement: Single Application of Simpson’s 3/8 rule to integrate

5432 400900675200252.0)( xxxxxxf

From a=0 to b=0.8.

Simpson’s rule 3/8 requires four equally spaced points:

232.0)8.0(,487177.3)5333.0(,432724.1)2667.0(,2.0)0( ffff

%4.7,1213630.0519170.1640533.1where

519170.18

232.0)487177.3432724.1(32.08.0

ttE

I

Example 21.6 Example 21.6

Solution:

Page 26: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Statement: Estimate the cross section area of the stream.

Case StudiesCase Studies

Page 27: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

•Consider this example

Page 28: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

•Trapezoidal rule (h = 4):

•Trapezoidal rule (h = 2):

2

2

m 2.6320

0)8.24.36.3464428.1(20)020(

m 6.5310

0)4.3442(20)020(

I

I

Page 29: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Integration with Matlab

•Use quad for functions.

SoftwareSoftware

Page 30: MECN 3500 Inter - Bayamon Lecture 10101010 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 10Lecture 10MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Homework8 Homework8 www.bc.inter.edu/facultad/omeza

Omar E. Meza Castillo Ph.D.Omar E. Meza Castillo Ph.D.

3030