mecn 3500 inter - bayamon lecture 6 numerical methods for engineering mecn 3500 professor: dr. omar...

20
MECN 3500 MECN 3500 Inter - Bayamon Inter - Bayamon Lecture Lecture 6 6 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: dwight-quinn

Post on 17-Jan-2016

233 views

Category:

Documents


2 download

TRANSCRIPT

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

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

Lecture 6Lecture 6MEC

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-54-5

System of Linear EquationsSystem of Linear Equations

Least Square Curve FittingLeast Square Curve Fitting

Polynomial Interpolation Polynomial Interpolation

Numerical IntegrationNumerical Integration

Ordinary Differential Equations Ordinary Differential Equations

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Engineering PracticeEngineering Practice

Roots of EquationsRoots of Equations

33

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

To understand the open methods to find To understand the open methods to find the root of equations.the root of equations.

44

Course ObjectivesCourse Objectives

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

For the bracketing methods in previous For the bracketing methods in previous chapter, the root is located within an interval chapter, the root is located within an interval prescribed by a prescribed by a lower and an upper boundlower and an upper bound. . Repeated application of theses methods always Repeated application of theses methods always results in closer estimates of the true value of results in closer estimates of the true value of the root.the root.

These methods are said to be These methods are said to be convergentconvergent because they move closer to the truth as the because they move closer to the truth as the computation progresses.computation progresses.

In contrast In contrast Open Methods Open Methods described in this described in this chapter are based on formulas that require chapter are based on formulas that require only a single starting value of x or two starting only a single starting value of x or two starting values that values that do not necessarily bracket the rootdo not necessarily bracket the root..

They They some time diverge some time diverge or move away from the or move away from the true root as the computation progresses.true root as the computation progresses.

When the When the open methods convergeopen methods converge, they usually , they usually do so much do so much more quickly than the bracketing more quickly than the bracketing methodsmethods..

55

IntroductionIntroduction

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Simple Fixed-Point Iteration: Simple Fixed-Point Iteration: As mentioned As mentioned previously, open methods employ a previously, open methods employ a formula to predict the root. Such a formula formula to predict the root. Such a formula can be developed for simple fixed-point can be developed for simple fixed-point iteration (or, as it is also called, one-point iteration (or, as it is also called, one-point iteration or successive substitution) by iteration or successive substitution) by rearranging the function f(x)=0 so that x is rearranging the function f(x)=0 so that x is on the left-hand side of the equation: on the left-hand side of the equation:

66

Open MethodsOpen Methods

%x

xx

)x(gx

)x(gx)x(f

i

iia

ii

100

0

1

1

1

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

77

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Example 6.1 - Fixed-Point IterationExample 6.1 - Fixed-Point Iteration Problem StatementProblem Statement. Use the fixed-point iteration to . Use the fixed-point iteration to

locate the root of f(x)=elocate the root of f(x)=e-x-x-x.-x. SolutionSolution: The function can be separated directly and : The function can be separated directly and

expressed of the formexpressed of the form Starting with an initial guess of xStarting with an initial guess of x00=0,=0,

88

Open MethodsOpen Methods

ixi ex 1

i xi εa(%) εt(%)

0 0 100

1 1.000000 100.0 76.3

2 0.367879 171.8 35.1

3 0.692201 46.9 22.1

4 0.500473 38.3 11.8

5 0.606244 17.4 6.89

6 0.545396 11.2 3.83

7 0.579612 5.90 2.20

8 0.560115 3.48 1.24

9 0.571143 1.93 0.705

10 0.564879 1.11 0.399

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on Open MethodsOpen Methods

x=g(x) can be expressed as x=g(x) can be expressed as a pair of equations:a pair of equations:

yy11=x=x

yy22=g(x)(component =g(x)(component equations)equations)

Plot them separatelyPlot them separately

99

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

The Newton-Raphson Method: The Newton-Raphson Method: Perhaps the Perhaps the most widely used of all root-locating formulas most widely used of all root-locating formulas in the Netwton-Raphson. If the initial guess at in the Netwton-Raphson. If the initial guess at the root is xthe root is xii, a tangent can be extended from , a tangent can be extended from the point [xthe point [xii,f(x,f(xii)]. The point where this tangent )]. The point where this tangent crosses the x axis usually represents an crosses the x axis usually represents an improved estimate of the root.improved estimate of the root.

1010

Open MethodsOpen Methods

)(

)(

)(0

g,Rearrangin

0)f(x when xof value theisroot The!2

)()()()(

1

1

1i1i

32

1

i

iii

iiii

iiii

xf

xfxx

xx)(xf)f(x

xOx

xfxxfxfxf

Newton-Raphson formula

Solve for

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on Open MethodsOpen Methods

1111

A convenient method for functions whose A convenient method for functions whose derivatives can be evaluated analytically. It derivatives can be evaluated analytically. It may not be convenient for functions whose may not be convenient for functions whose derivatives cannot be evaluated analytically.derivatives cannot be evaluated analytically.

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

1212

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Example 6.3 – Newton-Raphson MethodExample 6.3 – Newton-Raphson Method Problem StatementProblem Statement. Use the Newton-Raphson . Use the Newton-Raphson

Method to estimate the root of f(x)=eMethod to estimate the root of f(x)=e-x-x-x, -x, employing an initial guess of xemploying an initial guess of x00=0=0

SolutionSolution: The first derivative of the function : The first derivative of the function can be evaluated ascan be evaluated as

Which can be substituted in the Newton-Which can be substituted in the Newton-Raphson MethodRaphson Method

1313

Open MethodsOpen Methods

1 xex'f

11

i

i

xi

x

ii e

xexx

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Starting with an initial guess of xStarting with an initial guess of x00=0, this =0, this iterative equation can be applied to compute iterative equation can be applied to compute

1414

Open MethodsOpen Methods

i xi εt(%)

0 0 100

1 0.500000000 11.8

2 0.566311003 0.147

3 0.567143165 0.0000220

4 0.567143290 <10-8

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on Open MethodsOpen Methods

The Secant Method:The Secant Method: A potential problem in A potential problem in implementing the Newton-Raphson Method implementing the Newton-Raphson Method is the evaluation of the derivative.is the evaluation of the derivative.

A slight variation of Newton’s method for A slight variation of Newton’s method for functions whose derivatives are difficult to functions whose derivatives are difficult to evaluate. For these cases the derivative evaluate. For these cases the derivative can be approximated by a backward finite can be approximated by a backward finite divided difference.divided difference.

1515

)x(f)x(f

xx)x(fxx

xx

)x(f)x(f)x(f

ii

iiiii

ii

iii

1

11

1

1

Formula for the Secant Method

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on Open MethodsOpen Methods

• Requires two initial Requires two initial estimates of x , e.g, estimates of x , e.g, xxoo, x, x11. However, . However, because f(x) is not because f(x) is not required to change required to change signs between signs between estimates, it is not estimates, it is not classified as a classified as a “bracketing” method.“bracketing” method.

• The secant method The secant method has the same has the same properties as properties as Newton’s method. Newton’s method. Convergence is not Convergence is not guaranteed for all xguaranteed for all xoo, , f(x).f(x).

1616

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

1717

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Example 6.6 – The Secant MethodExample 6.6 – The Secant Method Problem StatementProblem Statement. Use the Secant Method to . Use the Secant Method to

estimate the root of f(x)=eestimate the root of f(x)=e-x-x-x. Start with initial -x. Start with initial estimates of xestimates of x-1-1=0 x=0 x00=1.0.=1.0.

SolutionSolution: Recall that the true root is 0.56714329: Recall that the true root is 0.56714329 First Iteration:First Iteration:

Second Iteration:Second Iteration:

1818

Open MethodsOpen Methods

%...

.x

.xfx

.xfx

t 086127006321201

106321201

6321201

0000010

1

00

11

%....

...x

.xf.x

.xfx

t 580563840070810632120

6127001070810612700

070810612700

6321201

2

11

00

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

Third Iteration:Third Iteration:

1919

Open MethodsOpen Methods

%....

....x

.xf.x

.xf.x

t 00480567170005180070810

563840612700563840563840

0051805638400

070810612700

2

22

11

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

Lecture 6Lecture 6MEC

N 3

500 I

nte

r -

Bayam

on

MEC

N 3

500 I

nte

r -

Bayam

on

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

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

2020