Lecture2 - Roots of Equations - 26feb2024 - NK - v1
Lecture2 - Roots of Equations - 26feb2024 - NK - v1
Lecture2 - Roots of Equations - 26feb2024 - NK - v1
COMPUTATIONAL METHODS IN
ENGINEERING
Part 2 – Roots of Equation
The desired value of c is the value that makes f(c) = 0. Numerical methods
provide a way to determine this value.
Graphical Approaches
Use the graphical approach to determine the drag
coefficient c needed for a parachutist of mass m = 68.1 kg
to have a velocity of 40 m/s after freefalling for time t =
10 s.
f (c) =
gm
c
( )
1 − e − ( c m )t − v
Graphical Approaches
Two initial guesses for the root are
required. These guesses must “bracket”
or be on either side of the root.
If one root of a real and continuous
function, f(x)=0, is bounded by values
x = xl and x = xu then if,
f ( xl ) f ( xu ) 0
The progressive
enlargement of
f(x) = sin 10x + cos 3x
by the computer.
Such interactive
graphics permit the
analyst to determine
that two distinct roots
exist between x = 4.2
and x = 4.3.
Graphical Depiction of the Bisection Method
Graphical Depiction of the Bisection Method
Bisection Method
For the arbitrary equation of one variable, f(x) = 0.
1. Pick xl and xu such that they bound the root of interest, check if
f(xl) × f(xu) < 0.
after six iterations εa finally falls below εs = 0.5%, and the computation can be
terminated
Evaluation of Bisection Method
When Bisection method fails to find roots?
• After 1 iteration. L1 = L0 2
• After 2 iterations. L2 = L0 4
• After k iterations. Lk = L0 2k
Lk
a 100% a s
n
s x
= 10−4
100%
−4 2
10 = k 2k = 2 104 k 14.3 = 15
2
The False-Position Method (Regula-Falsi)
If a real root is bounded
by xl and xu of f(x) = 0,
then we can approximate
the solution by doing a
linear interpolation
between the points.
xl fu − xu fl
xr =
fu − fl
If f ( xr ) 0 then xl = xr f l = f ( xr )
If f ( xr ) 0 then xu = xr f u = f ( xr )
xi+1 = g(xi)
Notice that the true percent relative error for each iteration is roughly proportional (by a factor of
about 0.5 to 0.6) to the error from the previous iteration. This property, called linear convergence, is
characteristic of fixed-point iteration
Simple Fixed-point Iteration 1
f ( x) = 0 g ( x) = x
xk = g ( xk −1 ) x0 given, k = 1, 2, ...
Ei +1 = g’ ( ) Ei
If g’ ( ) 1
▪ converges
If g’ ( ) 1
▪ diverges
If g’ ( ) = 1
▪ infinite
Conclusion
Fixed-point iteration converges if,
▪ Solve for,
f ( xi )
xi +1 = xi − ▪ Newton-Raphson formula
f ( xi )
Newton-Raphson Method
A convenient method
for functions whose
derivatives can be
evaluated analytically.
It may not be
convenient for
functions whose
derivatives cannot be
evaluated analytically.
Newton-Raphson Method
Use the Newton-Raphson method to estimate the root of f(x) = e−x − x,
employing an initial guess of x0 = 0.
Newton-Raphson Method
That is, the error is roughly proportional to the square of the previous
error
Four cases where Newton-Raphson exhibits poor
convergence
Aside from slow convergence due to the nature of the
function, other difficulties can arise
xi − xi −1
xi +1 = xi − f ( xi ) i = 1, 2,3,
f ( xi ) − f ( xi −1 )
The Secant Method
Requires two initial estimates
of x , for example, x0, x1.
However, because f(x) is not
required to change signs
between estimates, it is not
classified as a “bracketing”
method.
The secant method has the
same properties as Newton’s
method. Convergence is not
guaranteed for all initial
guesses and functions, f(x).
The Secant Method
The similarity Between Secant and False Position
The critical difference is how the initial values is replaced by the new
estimate. Recall that in the false-position method the latest estimate
of the root replaces whichever of the original values yielded a function
value with the same sign as f(xr).
Consequently, the two estimates always bracket the root. Therefore,
for all practical purposes, the method always converges because the
root is kept within the bracket.
u ( xi )
▪ Then find xi + 1 −
u ( xi )
Systems of Nonlinear Equations
x 2 + xy = 10
y + 3xy 2 = 57
u ( x, y ) = x 2 + xy − 10 = 0
v ( x, y ) = y + 3xy 2 − 57 = 0
ui ui
ui +1 = ui + ( x1i +1 − x1i ) + ( yi +1 − yi )
x y
vi vi
vi +1 = vi + ( x1i +1 − x1i ) + ( yi +1 − yi )
x y
• The root of the equation occurs at the value of x and y
where ui+1 and vi+1 equal to zero.
Multi-dimensional Newton-Raphson 2
vi ui
ui − vi
y y
xi +1 = xi −
ui vi ui vi
−
x y y x
Matlab Applications - Bisection
bisect
This function uses the method of bisection to compute the root of f(x) = 0 that is known to lie
in the interval (x1,x2).
By setting filter = 1, we force the routine to check whether the magnitude of f(x) decreases
with each interval halving.
If it does not, the “root” may not be a root at all, but a singularity, in which case root = NaN is
returned. Since this feature is not always desirable, the default value is filter = 0.
Matlab Applications - Bisection
Matlab Applications - Bisection
Matlab Applications – Incremental Search
The function rootsearch looks for a zero of the function f(x) in the interval (a,b).
Once a zero is detected, rootsearch returns its bounds (x1,x2) to the calling program. If a
root was not detected, x1 = x2 = NaN is returned (in MATLAB NaN stands for “not a number”).
After the first root (the root closest to a) has been bracketed, rootsearch can be called again
with a replaced by x2 in order to find the next root. This can be repeated as long as
rootsearch detects a root.
Matlab Applications – Incremental Search
Matlab Applications – Newton Raphson
Matlab Applications – Newton Raphson