Upload
la-makina
View
217
Download
0
Embed Size (px)
Citation preview
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
1/25
Numerical Methods Applied to Mechatronics
Lecture No 4
Escuela de Ingeniera Mecatrnica
Universidad Nacional de Trujillo
NON-LINEAR EQUATIONS ROOTS
Dr. Jorge A. Olortegui Yume Ph.D.
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
2/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.2
ROOTS PROBLEMS
Functionf can be written as:f(x)=0
particular x satisfying equality is a root
These problems often occur when a design
problem presents an implicit equation for a
required parameter.
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
3/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.3
GRAPHICAL METHODS
Plot of the function and observewhere it crosses thex-axis.
Graphing can also indicate whereroots may be and where some root-
finding methods may fail:
a) Same sign, no roots
b) Different sign, one root
c) Same sign, two roots
d) Different sign, three roots
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
4/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.4
BRACKETING METHODS
Make 2 initial guesses that bracket the root
Brackets: 2 guessesxlandxufulfillingf(xl)f(xu) < 0
[ ]xl xu
f(xu)
f(xl)
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
5/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.5
Incremental Search Methods
Disadvantages:
BRACKETING METHODS
If spacing are too far
apart, brackets may
be missed due tocapturing an even
number of roots
within two points.
Cannot find bracketscontaining even-
multiplicity roots
Tests the value of function at evenly spaced intervals to
find brackets by function sign change.
Good Practice: Plot the function along with the algorithm
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
6/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.6
Incremental Search MethodsBRACKETING METHODS
Example: Matlab program
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
7/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.7
The Bisection Method
BRACKETING METHODSIncremental Search Methods
a variation of the incremental
search methodthe interval
is always divided in half.
If a function changes sign over
an interval, the function value
at the midpoint is evaluated.
The location of the root is then
determined as lying within the
subinterval where the sign
change occurs.
The absolute error is reduced
by a factor of 2 for each
iteration.
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
8/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.8
Bisection Method Errors
BRACKETING METHODSIncremental Search Methods
The absolute error of the bisection method is solelydependent on the absolute error at the start of the
process (the space between the two guesses) and the
number of iterations:
The required number of iterations to obtain a particular
absolute error can be calculated based on the initialguesses:
Ean x
0
2n
nlog2x 0
Ea,d
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
9/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.9
BRACKETING METHODSIncremental Search MethodsThe Bisection Method
Example: Matlab program
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
10/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.10
BRACKETING METHODSThe False Position Method
It determines the nextguess not by splitting the
bracket in half but byconnecting the endpointswith a straight line and
determining the locationof the intercept of thestraight line (xr).
The value ofxrthenreplaces whichever of the
two initial guesses yieldsa function value with thesame sign asf(xr).
xr xu f(xu)(xlxu)
f(xl) f(xu)
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
11/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.11
BRACKETING METHODS
Bisection vs False Position
Bisection does not take intoaccount the shape of the
function; this can be good
or bad depending on thefunction!
Bad: f(x)x10 1
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
12/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.12
BRACKETING METHODSThe False Position Method
Homework: Write a general purpose Matlab program for the
False position method
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
13/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.13
OPEN METHODS
Open methodsdiffer from bracketing methods, in
that open methods require:
1 starting value or
2 starting values (not necessarily bracketing a
root).
Open methods may diverge as the computation
progresses, butwhen they do converge, they
usually do so much faster than bracketing methods.
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
14/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.14
OPEN METHODS
GRAPHICAL COMPARISON OF METHODSa) Bracketing method
b) Diverging open method
c) Converging open method
Note speed!
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
15/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.15
OPEN METHODS
SIMPLE FIXED-POINT METHOD
Rearrangef(x)=0 to the form
Use g(x)to predict a new value ofx- that is,
Approximate error : a xi1x i
xi1100%
xgx
ii
xgx 1
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
16/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.16
OPEN METHODSSIMPLE FIXED-POINT METHODExample: Solve for the roots of f(x)=e-x-x
Solution:
1. Rearrange
2. Start with a guess for x0. For this case x0 =0
3. Use the iteration formula
4. Continue until some tolerance is reached
xgx x=e-x
i xi g(xi)=e-xi |a| %
0 0.0000 1.0000
1 1.0000 0.3679 100.000
2 0.3679 0.6922 171.828
3 0.6922 0.5005 46.854
4 0.5005 0.6062 38.309
5 0.6062 0.5454 17.436
ii xgx 1
a xi1x i
xi1100%
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
17/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.17
OPEN METHODSSIMPLE FIXED-POINT METHODExample: Solve for the roots of f(x)=e-x-x
Solution:
xgx
567143.0x
00x
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
18/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.18
OPEN METHODSSIMPLE FIXED-POINT METHODExample: Solve for the roots of f(x)=e-x-x
Solution:
00x
10 xg
101
xgx
3679.01 xg
3679.012
xgx
6922.02 xg
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
19/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.19
OPEN METHODSSIMPLE FIXED-POINT METHODConvergence:
Requires :
a) Convergent, 0 g(x) 1
d) Divergent, g(x)
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
20/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.20
OPEN METHODSSIMPLE FIXED-POINT METHODConvergence:
Requires :
a) Convergent, 0 g(x) 1
d) Divergent, g(x)
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
21/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.21
OPEN METHODS
NEWTON-RAPHSON METHOD
Based on forming the tangent line to thef(x) curve at
some guessx, then following the tangent line to where it
crosses thex-axis.
f'(x i) f(xi)0
x ix i1
x i1x i
f(x i)
f'(x i)
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
22/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.22
OPEN METHODS
NEWTON-RAPHSON METHOD
Pros and Cons
Pro: The error of the i+1thiteration is
roughly proportional to the square of
the error of the ithiteration - this is
called quadratic convergence
Con: Some functions show slow or
poor convergence
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
23/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.23
OPEN METHODSNEWTON-RAPHSON METHOD Matlab Code
O O S
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
24/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.24
OPEN METHODS
SECANT METHOD
Newton-Raphson method problem:
Evaluation of the derivative - may be difficult or
inconvenient to evaluate.
Then, the derivative can be approximated by abackward finite divided difference:
f'
(x i) f(x
i1) f(x
i
)
x i1xi
OPEN METHODS
8/10/2019 (4)ROOTS_NON_LINEAR_EQNS.pdf
25/25
Non-Linear Equations Roots Dr. Jorge A. Olortegui Yume Ph.D.25
OPEN METHODS
SECANT METHOD (contd)
Substitution of this approximation for thederivative to the Newton-Raphson method
equation gives:
Note - this method requires twoinitial estimatesofxbut does notrequire an analytical expression
of the derivative.
xi1xi f(xi) xi1x i
f(xi1) f(xi)