22
MECN 3500 MECN 3500 Inter - Bayamon Inter - Bayamon Lecture Lecture 1 1 1 1 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

MECN 3500 Inter - Bayamon Lecture 11111111 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo [email protected]

Embed Size (px)

Citation preview

Page 1: MECN 3500 Inter - Bayamon Lecture 11111111 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

1111

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 11111111 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 11Lecture 11MEC

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

Numerical DerivationNumerical Derivation 1111

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

Lecture 11Lecture 11MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Derivation FormulasDerivation Formulas

Numerical DerivationNumerical Derivation

33

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

Lecture 11Lecture 11MEC

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 11111111 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 11Lecture 11

•We like to estimate the value of We like to estimate the value of f f '('(xx) for a ) for a given function given function ff((xx).).

•The derivative represents the rate of change The derivative represents the rate of change of a dependent variable with respect to an of a dependent variable with respect to an independent variable.independent variable.

•The difference approximation isThe difference approximation is

•If If xx is allowed to approach zero, the is allowed to approach zero, the difference becomes a derivative:difference becomes a derivative:

x

xfxxf

dx

dy

x

xfxxf

x

y

ii

x

ii

)()(lim

)()(

0

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

Lecture 11Lecture 11

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

Lecture 11Lecture 11

Numerical DifferentiationNumerical Differentiation

•The Taylor series expansion of The Taylor series expansion of ff((xx) about ) about xxii is is

•From this:From this:

•This formula is called the This formula is called the first forward divided first forward divided difference difference formula and the error is of order formula and the error is of order OO((hh).).

h

xfxf

xx

xfxfxf

xxxfxfxf

ii

ii

iii

iiiii

)()()()()(

))(()()(

1

1

1

11

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

Lecture 11Lecture 11

•Or equivalently, the Taylor series expansion of Or equivalently, the Taylor series expansion of ff((xx) ) about about xxii can be written as can be written as

•From this:From this:

•This formula is called the This formula is called the first backward divided first backward divided difference difference formula and the error is of order formula and the error is of order OO((hh).).

h

xfxf

xx

xfxfxf

xxxfxfxf

ii

ii

iii

iiiii

)()()()()(

))(()()(

1

1

1

11

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

Lecture 11Lecture 11

•A third way to approximate the first derivative is to A third way to approximate the first derivative is to subtract the backward from the forward Taylor series subtract the backward from the forward Taylor series expansions:expansions:

•This yields toThis yields to

•This formula is called the This formula is called the centered divided centered divided difference difference formula and the error is of order formula and the error is of order OO((hh22).).

h

xfxfxf

hxfxfxf

hxfxfxf

hxfxfxf

iii

iii

iii

iii

2

)()()(

)(2)()(

_________________________

)()()(

)()()(

11

11

1

1

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

Lecture 11Lecture 11MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Forward

Backward

Centered

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

Lecture 11Lecture 11

•The forward Taylor series expansion for The forward Taylor series expansion for ff((xxii+2+2) in ) in terms of terms of ff((xxii) is) is

•Combine equations:Combine equations:

212

21

22

22

)()()(2)(

_______________________________________

2

)()()()(2

)2(2

)()2)(()()(

)2(2

)()2)(()()(

hxfxfxfxf

hxf

hxfxfxf

hxf

hxfxfxf

hxf

hxfxfxf

iiii

iiii

iiii

iiii

Finite Difference Approximation of Higher Finite Difference Approximation of Higher DerivativesDerivatives

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

Lecture 11Lecture 11

•Solve for Solve for f f ''(''(xxii):):

•This formula is called the This formula is called the second forward finite second forward finite divided differencedivided difference and the error of order and the error of order OO((hh).).

•The The second backward finite divided difference second backward finite divided difference which has an error of order which has an error of order OO((hh) is) is

221

212

)()(2)()(

)()(2)()(

h

xfxfxfxf

h

xfxfxfxf

iiii

iiii

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

Lecture 11Lecture 11

•The The second centered finite divided difference second centered finite divided difference which which has an error of order has an error of order OO((hh22) is) is

211 )()(2)(

)(h

xfxfxfxf iiii

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

Lecture 11Lecture 11

•High accurate estimates can be obtained by High accurate estimates can be obtained by retaining more terms of the Taylor series.retaining more terms of the Taylor series.

hxf

h

xfxfxf

hxf

xxxfxfxf

iiii

iiiiii

2

)('')()()(

2

)(''))(()()(

1

211

•The forward Taylor series expansion is:The forward Taylor series expansion is:

•From this, we can writeFrom this, we can write

High-Accuracy Differentiation FormulasHigh-Accuracy Differentiation Formulas

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

Lecture 11Lecture 11

•Substitute the second derivative approximation Substitute the second derivative approximation into the formula to yield:into the formula to yield:

•By collecting terms:By collecting terms:

•Inclusion of the 2Inclusion of the 2ndnd derivative term has improved derivative term has improved the accuracy to the accuracy to OO((hh22).).

•This is the This is the forward divided difference formula forward divided difference formula for for the first derivative.the first derivative.

h

xfxfxfxf

hhxfxfxf

h

xfxfxf

iiii

iii

iii

2

)(3)(4)()(

2

)()(2)()()(

)(

12

212

1

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

Lecture 11Lecture 11MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Forward FormulasForward Formulas

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

Lecture 11Lecture 11MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Backward FormulasBackward Formulas

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

Lecture 11Lecture 11MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Centered FormulasCentered Formulas

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

Lecture 11Lecture 11MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

1919

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

Lecture 11Lecture 11

ExampleExample

Estimate Estimate f f '(1) for '(1) for ff((xx) = ) = eexx + + xx using the centered formula using the centered formula of of OO((hh44) with ) with hh = 0.25. = 0.25.

SolutionSolution

5.15.012

25.125.01

1

75.025.01

5.05.012

12

)()(8)(8)()(

2

1

1

2

2112

hxx

hxx

x

hxx

hxx

h

xfxfxfxfxf

ii

ii

i

ii

ii

iiiii

•From Table 23.3:From Table 23.3:

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

Lecture 11Lecture 11

717.33

)149.2()867.2(8)740.4(8982.5

)25.0(12

)5.0()75.0(8)25.1(8)5.1()(

ffff

xf i

•In substituting the values:In substituting the values:

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

Lecture 11Lecture 11MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

www.bc.inter.edu/facultad/omeza

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

2222