MECN 3500 Lecture 5 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo...
-
Upload
willa-fisher -
Category
Documents
-
view
225 -
download
0
Transcript of MECN 3500 Lecture 5 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo...
MEC
N 3
500
MEC
N 3
500
LectureLecture
55Numerical 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
Lecture 5Lecture 5MEC
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 33
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
Lecture 5Lecture 5MEC
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
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
To understand the use of Taylor Series in To understand the use of Taylor Series in the study of numerical methods.the study of numerical methods.
44
Course ObjectivesCourse Objectives
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
Years ago, you learned to use the quadratic Years ago, you learned to use the quadratic formulaformula
The values calculated with the previous The values calculated with the previous equation are called the “equation are called the “rootsroots” of f(x). They ” of f(x). They represent the values of x that make f(x) equal represent the values of x that make f(x) equal to zero. For this reason, roots are sometimes to zero. For this reason, roots are sometimes called the called the zeroszeros of the equation. of the equation.
There are many other functions for which the There are many other functions for which the roots cannot be determined so easily. roots cannot be determined so easily.
55
IntroductionIntroduction
a2
ac4bbx0cbxax)x(f
22
?x0xxsin
?x0fexdxcxbxax 2345
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
66
IntroductionIntroduction
Nonlinear Equation Solvers
Bracketing Graphical Open Methods
BisectionFalse Position (Regula-Falsi)
Newton Raphson
Secant
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
This chapter on roots of equations deals This chapter on roots of equations deals with methods that exploit the fact that a with methods that exploit the fact that a function typically changes sign in the function typically changes sign in the vicinity of a root.vicinity of a root.
These techniques are called These techniques are called Bracketing Bracketing Methods (Or, two point methods for finding Methods (Or, two point methods for finding roots) roots) because two initial guesses for the because two initial guesses for the root are required. root are required.
As the name implies, these guesses must As the name implies, these guesses must “bracket”, or be on either side of, the root.“bracket”, or be on either side of, the root.
Previous to discuss the techniques Previous to discuss the techniques Bisection and False-Position, we will briefly Bisection and False-Position, we will briefly discuss the discuss the Graphical MethodGraphical Method..
77
Bracketing MethodsBracketing Methods
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
Graphical Methods: Graphical Methods: A simple method for A simple method for obtaining an estimate the root of the obtaining an estimate the root of the equation f(x)=0 is to make a plot of the equation f(x)=0 is to make a plot of the function and observe where it crosses the x function and observe where it crosses the x axis. This point, which represents the x axis. This point, which represents the x value for which f(x)=0, provides a rough value for which f(x)=0, provides a rough approximation of the root.approximation of the root.
Example 5.1- The Graphical Approach:Example 5.1- The Graphical Approach: Problem StatementProblem Statement. Use the graphical . Use the graphical
approach to determine the drag coefficient approach to determine the drag coefficient c needed for a parachutist of mass m=68 c needed for a parachutist of mass m=68 kg to have a velocity of 40 m/s after free-kg to have a velocity of 40 m/s after free-falling for time t=10s. Note: The falling for time t=10s. Note: The acceleration due to gravity is 9.8 /sacceleration due to gravity is 9.8 /s22..
SolutionSolution. This problem can be solved by . This problem can be solved by determining the root of parachutist determining the root of parachutist equation using the parameters t=10, equation using the parameters t=10, g=9.8, v=40 and m=68.1g=9.8, v=40 and m=68.1
88
Bracketing MethodsBracketing Methods
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
(1)(1)
(2)(2)
99
Bracketing MethodsBracketing Methods
t)m/c(ec
gm)t(v 1
10)1.68/c(e1c
)1.68(8.940
40e1c
38.667)c(f
40e1c
)1.68(8.9)c(f
40e1c
)1.68(8.90
c146843.0
10)1.68/c(
10)1.68/c(
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on Bracketing MethodsBracketing Methods
Various values of c can Various values of c can be substituted into the be substituted into the right-hand side of this right-hand side of this equation to compute equation to compute values shows in the values shows in the table and resulting in table and resulting in the curve that crosses the curve that crosses the c axis between 12 the c axis between 12 and 16.and 16.
Visual inspection of the Visual inspection of the plot provides a rough plot provides a rough estimate of the root of estimate of the root of 14.7514.75. .
Substituting this value Substituting this value in to equation in to equation (2)(2) we we get f(14.75)=0.059, get f(14.75)=0.059, which is close to zero.which is close to zero.
In order to check the In order to check the root, substituting it into root, substituting it into equation equation (1) (1) v=40.059, v=40.059, which is close to 40m/s.which is close to 40m/s.
1010
c f(c)
4 34.115
8 17.653
12 6.067
16 -2.269
20 -8.401
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on Bracketing MethodsBracketing Methods
1111
Graphical techniques Graphical techniques are of limited are of limited practical value practical value because they are not because they are not precise. However, precise. However, graphical methods graphical methods can be utilized to can be utilized to obtain the rough obtain the rough estimates of roots. estimates of roots. These estimates can These estimates can be employed as be employed as starting guesses for starting guesses for numerical methods.numerical methods.
No answer (No root)
Nice case (one root)
Oops!! (two roots!!)
Three roots( Might work for a while!!)
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on Bracketing MethodsBracketing Methods
1212
Two roots( Might work for a while!!)
Discontinuous function. Need special method
Progressive Enlargement
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
The Bisection Method: The Bisection Method: When applying the When applying the graphical technique you have observed graphical technique you have observed that f(x) changed sign on opposite side of that f(x) changed sign on opposite side of the root. In general if f(x) is real and the root. In general if f(x) is real and continuum in the interval from xcontinuum in the interval from xll to x to xuu and and f(xf(xll) and f(x) and f(xuu) have apposite signs, that is) have apposite signs, that is
Then there is at least one real root Then there is at least one real root between xbetween xll and x and xuu..
The methods that capitalize on this The methods that capitalize on this observation by locating an interval where observation by locating an interval where the function change sign are called the function change sign are called Incremental Search MethodsIncremental Search Methods..
1313
Bracketing MethodsBracketing Methods
0)x(f).x(f ul
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
The Bisection method also called binary The Bisection method also called binary chopping, interval halving, is one type of chopping, interval halving, is one type of incremental search method in which the incremental search method in which the interval interval is always divided in halfis always divided in half..
If a function changes sign over an interval, If a function changes sign over an interval, the function value at the midpoint is the function value at the midpoint is evaluated.evaluated.
The location of the root is then determined The location of the root is then determined as lying at the midpoint of the subinterval as lying at the midpoint of the subinterval within which the sign change occurs.within which the sign change occurs.
The process is repeated to obtain refined The process is repeated to obtain refined estimates.estimates.
A simple algorithm for the bisection A simple algorithm for the bisection calculation is listed as follow:calculation is listed as follow:
1414
Bracketing MethodsBracketing Methods
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
For the arbitrary equation of one variable, f(x)=0For the arbitrary equation of one variable, f(x)=0
1.1. Pick xPick xll and x and xuu such that they bound the root of such that they bound the root of interest, check if f(xinterest, check if f(xll).f(x).f(xuu) <0.) <0.
2.2. Estimate the root by evaluating xEstimate the root by evaluating xr =r =(x(xll+x+xuu)/2)/2
3.3. Find the pairFind the pair If f(xIf f(xll). f[(x). f[(xll+x+xuu)/2]<0, root lies in the lower )/2]<0, root lies in the lower
interval, then xinterval, then xuu=(x=(xll+x+xuu)/2 and go to step 2.)/2 and go to step 2.
If f(xIf f(xll). f[(x). f[(xll+x+xuu)/2]>0, root lies in the upper )/2]>0, root lies in the upper interval, then xinterval, then xll= [(x= [(xll+x+xuu)/2, go to step 2.)/2, go to step 2.
If f(xIf f(xll). f[(x). f[(xll+x+xuu)/2]=0, then root is (x)/2]=0, then root is (xll+x+xuu)/2 )/2 and terminate.and terminate.
4.4. Compare eCompare ess with e with eaa
5.5. If eIf ess<e<eaa, stop. Otherwise repeat the process., stop. Otherwise repeat the process.
1515
Bracketing MethodsBracketing Methods
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
1616
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
Example 5.3- Bisection Method:Example 5.3- Bisection Method: Problem StatementProblem Statement. Use the bisection to solve . Use the bisection to solve
the same problem approached graphically in the same problem approached graphically in Example 5.1.Example 5.1.
SolutionSolution. The first step in bisection is to guess . The first step in bisection is to guess two values (12 and 16) of the unknown (in the two values (12 and 16) of the unknown (in the present problem, c) that give values for f(c) present problem, c) that give values for f(c) with different signs. The initial estimate of the with different signs. The initial estimate of the root root xxrr lies at the midpoint of the interval lies at the midpoint of the interval
Next we compute the product of the function Next we compute the product of the function value at the lower bound and at the midpoint:value at the lower bound and at the midpoint:
1717
Bracketing MethodsBracketing Methods
142
1612x r
517.9)569.1(067.6)14(f)12(f
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
Which value is greater than zero, and hence no Which value is greater than zero, and hence no sign change occurs between the lower bound sign change occurs between the lower bound and the midpoint. Consequently, the root must and the midpoint. Consequently, the root must be located between 14 and 16. Therefore, we be located between 14 and 16. Therefore, we create a new interval by redefining the lower create a new interval by redefining the lower bound as 14 and determining a revised root bound as 14 and determining a revised root estimate as:estimate as:
Compute the product of the function value at Compute the product of the function value at the lower bound and at the midpointthe lower bound and at the midpoint
1818
Bracketing MethodsBracketing Methods
152
1614x r
666.0)425.0(569.1)15(f)14(f
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
Therefore, the root is between 14 and 15. The Therefore, the root is between 14 and 15. The upper bound is redefined as 15, and the root upper bound is redefined as 15, and the root estimate for the third iteration is calculated asestimate for the third iteration is calculated as
The method can be repeated until the result is The method can be repeated until the result is accurate enough to satisfy your needs.accurate enough to satisfy your needs.
1919
Bracketing MethodsBracketing Methods
5.142
1514x r
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
2020
Bracketing MethodsBracketing Methods
Bisection Method
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
Termination Criteria and Error Estimates:Termination Criteria and Error Estimates:
Error Estimation Example 5.3, for Error Estimation Example 5.3, for εεss=0.5%=0.5%
2121
Bracketing MethodsBracketing Methods
%100x
xxnewr
oldr
newr
a
Iteration Xl Xu Xr εa(%) εt(%)
1 12 16 14 5.279
2 14 16 15 6.667 1.487
3 14 15 14.5 3.448 1.896
4 14.5 15 14.75 1.695 0.204
5 14.75 15 14.875 0.840 0.641
6 14.75 14.875 14.8125 0.422 0.219
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
The False-Position Method: The False-Position Method: Although bisection Although bisection is a perfectly valid technique for determining is a perfectly valid technique for determining roots, its roots, its “brute-force“brute-force” approach is relatively ” approach is relatively inefficient. False position is an alternative inefficient. False position is an alternative based on a graphical insight.based on a graphical insight.
This method that exploits this graphical insight This method that exploits this graphical insight is to joint is to joint f(xf(xll) and f(x) and f(xuu) by a ) by a straight linestraight line. The . The fact that the replacement of the curve by a fact that the replacement of the curve by a straight line gives a “false position” of the root straight line gives a “false position” of the root is the origin of the name, method of false is the origin of the name, method of false position, or in latin, regula falsi. It is also called position, or in latin, regula falsi. It is also called the the linear interpolation methodlinear interpolation method..
Using similar triangles, the intersection of the Using similar triangles, the intersection of the straight line with the x axis can be estimated straight line with the x axis can be estimated asas
2222
Bracketing MethodsBracketing Methods
ur
u
lr
l
xx
)x(f
xx
)x(f
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on Bracketing MethodsBracketing Methods
Which can be Which can be solved forsolved for
This is the false-This is the false-position formula. position formula. The value of xThe value of xrr replaces replaces whichever of the whichever of the two initial two initial guesses, xguesses, xll or x or xuu, , yields a function yields a function value with the value with the same sign as f(xsame sign as f(xrr))
2323
)x(f)x(f
xx)x(fxx
ul
uluur
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on Bracketing MethodsBracketing Methods
In this way, the values of xIn this way, the values of xll and x and xuu always bracket always bracket the true root. The process is repeated until the the true root. The process is repeated until the root is estimated adequately. root is estimated adequately.
The algorithm is presented as follow:The algorithm is presented as follow:
1.1. Find a pair of values of x, xFind a pair of values of x, xll and x and xuu such that such that ffll=f(x=f(xll) <0 and f) <0 and fuu=f(x=f(xuu) >0.) >0.
2.2. Estimate the value of the root xEstimate the value of the root xrr and evaluate and evaluate f(xf(xrr).).
3.3. Use the new point to replace one of the original Use the new point to replace one of the original points, keeping the two points on opposite sides points, keeping the two points on opposite sides of the x axis.of the x axis.
If f(xIf f(xrr)<0 then x)<0 then xll=x=xrr == > == > ffll=f(x=f(xrr))
If f(xIf f(xrr)>0 then x)>0 then xuu=x=xrr == > == > ffuu=f(x=f(xrr))
If f(xIf f(xrr)=0 then you have found the root and )=0 then you have found the root and need go no further!need go no further!
2424
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on Bracketing MethodsBracketing Methods
4.4. See if the new xSee if the new xll and x and xuu are close enough for are close enough for convergence to be declared. If they are not go convergence to be declared. If they are not go back to step 2.back to step 2.
2525
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
2626
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on Bracketing MethodsBracketing Methods
Example 5.5- False Position:Example 5.5- False Position: Problem StatementProblem Statement. Use the false-position . Use the false-position
method to determine the root of the same method to determine the root of the same equation investigated in example 5.1.equation investigated in example 5.1.
SolutionSolution. As in example 5.3, initiate the . As in example 5.3, initiate the computation with guesses of computation with guesses of xxll=12 and =12 and xxuu=16. =16.
First IterationFirst Iteration::
Which has a true relative error of 0.89 percent.Which has a true relative error of 0.89 percent.
2727
9113.14
2688.20699.6
16122688.216
2688.2)(16
0699.6)(12
r
uu
ll
x
xfx
xfx
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on Bracketing MethodsBracketing Methods
Second IterationSecond Iteration::
Therefore, the root lies in the first interval, Therefore, the root lies in the first interval, and xand xrr becomes the upper limit for the next becomes the upper limit for the next iteration, xiteration, xuu=14.9113:=14.9113:
Which has true and approximate relative Which has true and approximate relative error of 0.09 and 0.79 percent.error of 0.09 and 0.79 percent.
2828
5426.1)x(f)x(f rl
7942.14
2543.00699.6
9113.14122543.09113.14x
2543.0)x(f9113.14x
0699.6)x(f12x
r
uu
ll
Lecture 5Lecture 5MEC
N 3
500 I
nte
r -
Bayam
on
MEC
N 3
500 I
nte
r -
Bayam
on
Homework4 Homework4 www.bc.inter.edu/facultad/omeza
Omar E. Meza Castillo Ph.D.Omar E. Meza Castillo Ph.D.
2929