Numerical Methods for Finding Roots
Numerical Methods for Finding Roots
Unity University
Department of Civil Engineering
Chapter-2
ROOTS OF EQUATIONS
By: Feysel N.
(MSc-Geotechnical Engineering & Geo-hazard)
Introduction 2
Bracketing Methods
1) Bisection method
2) False-Position method
Introduction 9
I. Graphical method
• Graphical method involves plotting the equation over the range of
interest and observing where it crosses the x axis. This point,
which represents the x value for which f(x)=0, provides a rough
approximation of the root.
• Graphing calculators, spreadsheet apps like Excel & software like
Matlab and Mathcad have the capability to plot a function simply
by defining the function and specifying the range of interest.
• Graphical interpretations are important tools for understanding
the properties of the functions and anticipating the pitfalls of the
numerical methods.
• Figure 2.2a-2.2f in the following slide shows a number of ways in
which roots can occur (or be absent) in an interval specified by a
lower bound xl and an upper bound xu.
Bounding the root 12
I. Graphical method
• Fig. 2.2a & 2.2c show that if
f(xl) and f(xu) have the same
sign, there are either no
roots or an even number of
roots in the interval.
• Fig. 2.2b & 2.2d show that
if f(xl) and f(xu) have
opposite sign, there are an
odd number of roots in the
interval
• Although these generalizations are usually true, there are cases
where they do not hold. For example, functions that are tangential
to the x axis (Fig. 2.2e) and discontinuous functions (Fig. 2.2f) can
violate these principles.
Bounding the root 13
I. Graphical method
• When a function is tangential to the x axis but
do not cross it at the root, it will have double
or quadruple…(even multiple roots) roots at
that point.
• An example of a function that is tangential to
the x axis is f(x)=x3-8x2+20x-16 (which can be
written as f(x)=(x-2)(x-2)(x-4)) and its roots
are x=2 and x=4. Notice that x=2 is a multiple
(double) root.
Bounding the root 14
Procedure
Step-1: Choose lower xl and upper xu guesses for the root such that
the function changes sign over the interval. This can be checked by
ensuring that f(xl)*f(xu)<0.
௫ ା௫ೠ
Step-2: Estimate the root xr using ଶ
Step-3: Make the following evaluations to determine the interval in
which the root lies:
(a) If f(xl)*f(xr)<0, the root lies in the lower subinterval.
Therefore, set xl =xl & xu =xr and return to step-2.
(b) If f(xl)*f(xr)>0, the root lies in the upper subinterval.
Therefore, set xl =xr & xu =xu and return to step-2.
(c) If f(xl)*f(xr)=0, the root equals xr and terminate the iteration.
1) Bisection method 17
Where xrnew is the root for the present iteration and xrold is the root
from the previous iteration.
• Since the interval is always halved at each iteration, the above
equations can be written as; xu xl xu xl
a 100% Ea
xu xl 2
• Because each succeeding iteration halves the error, the relative
error for the present iteration will be half of the error from the
previous iteration.
1) Bisection method 18
Advantages
• The root is bracketed (i.e., trapped) within the bounds of the
interval, so the method is guaranteed to converge.
• Another benefit of the bisection method is that the number of
iterations required to attain a tolerable error E can be computed
before starting the iterations using;
log( xuinit xlinit ) log E
n
log 2
Where xuinit and xlinit are the initial guesses of xu and xl.
Disadvantages
• The major disadvantage of the bisection method is that the
solution converges slowly (it can take a large number of iterations).
1) Bisection method 19
xr
Advantages
• The false position method generally converges more rapidly than
the bisection method.
Disadvantages
• Its one-sided. That is, as iterations are proceeding, one of the
bracketing points will tend to stay fixed. This can lead to poor
convergence, particularly for functions with significant curvature
as shown in the figure below.
2) False-Position method 23
Disadvantages
Figure:- Plot of f(x)=x10−1, illustrating slow
convergence of false-position method. the
curve violates the basis upon which false
position was based—that is, if f(xl) is much
closer to zero than f(xu), then the root is
closer to xl than to xu. But in this case, the
opposite is true.
• One way to mitigate the “one-sided” nature
of false position is when one of the bounds
is stuck, the function value at the stagnant
bound can be divided in half. This is called
the modified false-position method.
2) False-Position method 24
Algorithm for
Modified False-Position
25
Open Methods
1) Fixed-point iteration method
2) Newton-Raphson method
3) Secant method
Introduction 26
Advantage
• Once you figure out the function g(x); the iteration is so simple,
you can even do it on a calculator (see next slide on how to this).
Disadvantage
• It is not a reliable method & is not recommended for computer use.
Algorithm for Fixed-point iteration
1) Fixed-point iteration method 32
SOLUTION
Manipulating the function using the x4 term;
x4 2 x 5 0
x4 2 x 5
x (2 x 5)1/4
g ( x) (2 x 5)1/4
Since the power (¼) is even, it will always give a positive result. Note
that the term in the bracket must be >0 (i.e. x must be ≥ -2.5).
⸫ Let us try x0 = 1
Do the following on your calculator
1) Press 1 and then =
2) Type (2ANS+5)^0.25
3) Press = (this gives you the value of x1 = 1.626576562)
1) Fixed-point iteration method 34
…SOLUTION
1) Fixed-point iteration method 35
…SOLUTION
Pressing = sign afterwards displays values of x1,2,3… as shown
⸫ The root in the interval [1,2] is
x = 1.702706371
• You will get the same final result if you
try x0=2, x0=0, x0=-1 or x0=-2
1) Fixed-point iteration method 36
…SOLUTION
Manipulating the function using the x1 term;
Since the power (1) is odd, it can either give a +ve or -ve result.
Let us try x0 = -1
Do the following on your calculator
1) Press -1 and then =
2) Type (ANS^4 – 5)÷2
3) Press = (this gives you the value of x1 = -2)
1) Fixed-point iteration method 37
…SOLUTION
Pressing = sign afterwards displays values of x1,2,3… as shown
• As can be seen, the values get
increasing and we get “Math ERROR”
message. Hence g(x) diverges at this
point (Monotone Divergence).
• You will get the same pattern if you try
x0=-2, x0=0, x0=1 or x0=2.
• Therefore, we have to manipulate the
function in other way as shown in the
next slide.
1) Fixed-point iteration method 38
…SOLUTION
Manipulate the function as follows;
Since the power (1) is odd, it can either give a +ve or -ve result.
Let us try x0 = -1
Do the following on your calculator
1) Press -1 and then =
2) Type 5÷(ANS3 – 2)
3) Press = (this gives you the value of x1 = -1.666666667)
1) Fixed-point iteration method 39
…SOLUTION
Pressing = sign afterwards displays values of x1,2,3… as shown
• As can be seen, the values get alternating.
Hence the iteration with this g(x) has
gone into an infinite loop without
convergence (Oscillating Divergence).
• You will get the same pattern if you try
x0=-2, x0=0, x0=1 or x0=2
• Therefore, we have to manipulate the
function in other way as shown in the
next slide.
1) Fixed-point iteration method 40
…SOLUTION
Manipulate the function as follows;
Since the power (1/3) is odd, it can either give a +ve or -ve result.
Let us try x0 = -1
Do the following on your calculator
ଵ
DO NOT write the power as
1) Press -1 and then = ଷ
0.333. If you do, you will get a
2) Type (5ANS2 ÷ (ANS3−2))^(1÷3) Math ERROR message.
1) Fixed-point iteration method 41
…SOLUTION
3) Press = (this gives you the value of x1 = -1.185631101)
Pressing = sign afterwards displays values of x1,2,3… as shown
⸫ The root in the interval [-1,-2] is
x = -1.255937548
You will get the same final result if
you try x0=1 or x0=-2 but with
different accuracy.
If you try x0=2 will get the same final
result after 29 iterations.
2) Newton-Raphson method 42
Disadvantages
• In some cases, if a poor initial estimate is used, the procedure may
converge slowly or it may converge to an alternate solution.
• If an inflection point [i.e., f ’’(x)=0] occurs in the vicinity of a root,
it can send the method far away from the root as shown below.
Notice that iterations beginning at x0 progressively diverge from
the root. A better initial estimate can eliminate this problem.
2) Newton-Raphson method 45
Disadvantages
• If a local maximum or minimum occurs in the vicinity of a root, it
may cause oscillations in the solution as shown below.
• The oscillations may persist, or as in the figure below, a near-zero
slope is reached, and so the solution is sent far from the area of
interest. A better initial estimate can eliminate this problem.
2) Newton-Raphson method 46
Disadvantages
• In some cases where the function f(x) has a number of roots, an
initial guess that is close to one root can jump to a location several
roots away (the guess may jump and converge to some other root)
as shown below. This tendency to move away from the area of
interest is because near-zero slopes are encountered.
2) Newton-Raphson method 47
Disadvantages
• Obviously, a zero slope [f ’(x)=0] is truly a disaster because it
causes division by zero in the Newton-Raphson formula.
Graphically (see the Figure below), it means that the solution
shoots off horizontally and never hits the x axis.