Professional Documents
Culture Documents
Chapter 2 ROOT - OP PDF
Chapter 2 ROOT - OP PDF
Chapter 2 ROOT - OP PDF
There are two classes of numerical methods to determine the roots of the equation.
In this section, we are trying to determine solutions (or roots) of a function using
numerical methods. A function may be of a single independent variable or multi-
independent variables.
Finding the roots of the equations means that we want to solve for the values of x or both x
and y of the above equations when they are equal to zero.
f(x) = 0
f(x, y) = 0.
1
Roots of a Function Applied Numerical Methods For Engineers 2-2
This is a simple method to get an estimate of the root of the equation f(x) = 0. The function
f(x) is plotted against x and the location(s) where it crosses the x axis (i.e. f(x) = 0)
provides a rough approximation of the root(s).
Spreadsheet and other computational tools such as Lotus 1-2-3, MATLAB, MathCAD,
DERIVE, and etc may used for this purpose. Figure 2.2-1 shows a MATLAB program that
plots the function f(x) = x2 - 4x- 3 for a given range of x from 0 to 8.
%
% MATLAB Program 2.1-1: Plotting Graph
%
x = 0:0.1:8;
y = x.^2 - 4*x - 3;
plot(x,y); xlabel(‘x’); ylabel(‘f(x)’);
20
15
10
f(x)
5
0
-5
-10
0 1 2 3 4 5 6 7 8
x
Remark: 1. Graphical method only provides rough estimates of the roots ( i.e. not
accurate).
2. These estimates can be used as initial guesses for advanced numerical
methods.
2
Applied Numerical Methods For Engineers Roots of a Function 2-3
1. If f(xu ) and f(xl ) has opposite signs, there is an odd number of roots in the interval.
2. If f(xu ) and f(xl ) has same signs, there is either no root or an even number of roots.
f ( x) f ( x)
three roots
xl xl
x
xu x xu
f ( x) f ( x)
x
xl xu x xl xu
3
Roots of a Function Applied Numerical Methods For Engineers 2-4
(i) when the functions are tangential to the x axis such as f(x) = (x - 3)(x - 2)(x - 2)
= 0 as shown in figure 2.2-2(a) and
For the function f(x) = (x - 5)(x - 5)(x - 1) = 0, the root x = 5 is called the multiple root.
The procedures for a function with multiple roots will be discussed in section 2.4.
xl
x xl
xu x
xu
4
Applied Numerical Methods For Engineers Roots of a Function 2-5
a Bisection Method
From the graphical method, we found that when a function f(x) is continuous and real in the
interval from xl to xu , and f(xl ) and f(xu ) have opposite signs, that is
f ( xl ) f ( xu ) 0 (2.2-1)
Steps:
1. Guess or select an interval [xl, xu] that contains the
root: f(xl )f(xu ) < o.
f(x) xl xu
2. Estimate the root xr: xr (2.2-2)
real root
2
3. Evaluate the products :
Convergence Criterion. Since the process of finding the roots of the equation is
iterative, it is important to specify a convergence criterion s ( or a tolerance) in order to
terminate the iterations.
xrk 1 xrk
a 100% (2.2-3)
xrk 1
where
xrk 1 xrnew and xrk xrold
Example 2.2-1: Using Bisection method to find the root of the equation.
f(x) = x3 - x2 - 10x - 8 = 0
5
Roots of a Function Applied Numerical Methods For Engineers 2-6
Therefore, the root is x = 4.004 which is pretty close to the true value of 4.0.
xu xl
Remark: 1. After n steps of bisection, the interval will have the size of .
2n
2. The method will always converge on the root, provided that only one
root lies in the interval.
6
Applied Numerical Methods For Engineers Roots of a Function 2-7
MATLAB Results:
>>
iteration xl xu Solution(xr) f(xr) ea
1 3.7500 5.0000 4.3750 12.8496 100.0000
2 3.7500 4.3750 4.0625 1.9182 7.6923
3 3.7500 4.0625 3.9063 -2.7166 4.0000
4 3.9063 4.0625 3.9844 -0.4661 1.9608
5 3.9844 4.0625 4.0234 0.7092 0.9709
6 3.9844 4.0234 4.0039 0.1174 0.4878
The approximate solution is x = 4.003906
>>
b False-Position Method
Unlike the bisection method, the false-position method takes into account the magnitudes
of the function at the lower and upper bounds, f(xl ) and f(xu ). For example, if f(xl ) is
closer to zero than f(xu ) then xl is likely to be closer to the root xr than xu is. This results
in an improved estimate of the root. It is also called linear interpolation method.
f ( xl ) f ( xu )
xr xr xl xr xu
xl xu x
Compute xr, and replace it with whichever of the initial guesses, xl or xu , that has a
function of the same sign as f(xr ). In this way the interval [xl , xu ] always bracket the true
root. The process is repeated until the root converge.
The steps for this method are similar to that of the bisection method with eq.(2.2-4)
replacing eq.(2.2-2) in Step 2. The stopping criterion is also the same as before.
7
Roots of a Function Applied Numerical Methods For Engineers 2-8
Example 2.2-2: Using false-position method to find the root of the equation.
Problem Statement: Using the false-position method, find the root of the 3rd-order
polynomial
f(x) = x3 - x2 - 10x - 8 = 0
In this example, we need only 3 iterations as compared to 6 iterations for the bisection
method.
In general, the false-position method converges faster than the bisection and that a is
not always greater than t for this method.
Remark: There are cases when the bisection is a better approach than the false-
position method.
8
Applied Numerical Methods For Engineers Roots of a Function 2-9
Worksheet 2.2-1: Using bisection and false-position method to find the root.
Problem Statement: Use both the bisection and false-position method to find the root of
the function
f(x) = x4 - 2 = 0
Bisection method:
iteration xl xr xu f(xl ) f(xr ) f(xu ) Et
i
1
2
3
4
5
6
7
8
Comments:
False-position method:
iteration xl xr xu f(xl ) f(xr ) f(xu ) Et
i
Comments:
9
Roots of a Function Applied Numerical Methods For Engineers 2-10
1. It is not always the case that xr is better estimate than the mid-point. There are cases
when the size of the interval decreases slowly than in the bisection method. (Refer
example 4.7, p.141 of the textbook).
2. The size of the interval containing the root doesn’t, in general, approach zero. This is
because, in the neighborhood of the root, most functions are strictly concave or convex
and this results in only one of the end-points approaching the root while the other remains
fixed. Consequently, the size of the interval is of little use as a bound on the error in the
approximation or as a tolerance for terminating the iterations.
2. Use an incremental search at the beginning of the computer programs. Starting at one
end of the region of interest and then making function evaluations at small increments
across the region. Note where the change of sign occurs. Use the bound as an initial
guess of the interval. However, it can very time-consuming if the interval is too small. On
the other hand, if the interval is too large - some closely spaced roots might be missed.
3. Experience and understanding of the problem background might help in locating all the
roots of the functions.
f(x)
x
xl x
xu
10
Applied Numerical Methods For Engineers Roots of a Function 2-11
Open methods are based on a single starting point or two points that do not have to
bracket a root. Some of them require an evaluation of the first derivative of the functions.
Sometimes, the open methods diverge from the root. But when they do converge, they do
so more quickly than the bracketing methods.
This is done by rearranging the function f(x) = 0 so that x is on the left side of the
equation,
x = g(x) (2.3-1)
For example,
f(x) = x3 + x2 + x - 4 = 0 => x = 4 - x2 - x3 or x 4 x x 3
f ( x ) 1 x xe x = 0
Eq.(2.3-1) gives us a formula to predict the value of x as a function of x i.e. it can be used
to estimate the new value xi+1 knowing or having an initial guess xi (an old value).
11
Roots of a Function Applied Numerical Methods For Engineers 2-12
xi 1 xi
a 100% < s (2.3-3)
xi 1
This formula has a linear convergence. Figure 2.3-1 shows graphical depiction of the
procedures.
f(x)
root
x
xi
f(x) f(x)
x xi x
xi
(a) oscillation divergence (b) staircase divergence
12
Applied Numerical Methods For Engineers Roots of a Function 2-13
Example 2.3-1: Use the one-point iteration method to find the root of the function
x
f ( x) e 4 (2 x) 1 0
with initial guess x = 0 until the approximate percent relative error is less than 0.1%.
Solution: x
Rearranging f(x): x 2 e4
xk
or x k 1 2 e 4
0
For k = 0 x0 = 0, x1 2 e 4 = 2 - 1 = 1
iteration xk xk+1 a %
k
0 0 1 100
1 1 0.715975 39.66
2 0.715975 0.803987 10.94
3 0.803987 0.777379 3.42
4 0.777379 0.785485 1.03
5 0.785485 0.783021 0.31
6 0.783021 0.783771 0.09
Since a is less than 0.1%, we stop the iteration. The root is 0.783771.
13
Roots of a Function Applied Numerical Methods For Engineers 2-14
Worksheet 2.3-1: Use the one-point iteration method to find the root of the function
f ( x ) 0.5x 3 3x 2 0.5x 3 0
with initial guess (i) x = 0 and (ii) x = 5.0 with an accuracy to 2 d.ps.
Solution: 3
Rearranging f(x): (a) x x 3 6x 2 6 (b) x
0.5 3x 0.5x 2
(i) Using the form as in (a) for k = 0, 1, 2, 3, ...
iteration xk xk+1 a %
k
0 0 6
1 6 6
2 6 6
Comments:
14
Applied Numerical Methods For Engineers Roots of a Function 2-15
Worksheet 2.3-2: Use the one-point iteration method to find the root of the function
ex
f ( x) x 2 120 0 (x=6.372153)
1 x
with initial guess (i) x = 0 and (ii) x = 6.0 with an accuracy to 2 d.ps.
Solution: ex
Rearranging f(x): (a) x 120
(1 x )
1 x
or (b) x [e x 2 (1 x ) 120]
120
e0
(a) For k = 0 (i) x0 = 0, x1 120 = 10.90871
(1 0)
Repeat the above procedure for k = 1, 2,
iteration xk xk+1 a %
k
0 0 10.90871 100
1 10.90871 -6.32311E24 100
2 -6.32311E24 -6.32311E24 0
???
1 0
(ii) x0 = 0, x1 [e (0) 2 (1 0) 120] = -0.99167
120
Note: The one-point iteration method is not applicable to this function. Therefore,
alternative methods must be employed.
15
Roots of a Function Applied Numerical Methods For Engineers 2-16
b Newton-Raphson Method
This is the most widely used technique to find the root of the equations. It is an efficient
method if the first derivative of the function f’(x) is available or easy to get. From the
TSE (after truncating terms beyond the first derivative term), it can be shown that the
value of xi+1 in terms of xi is given as
f ( xi )
Newton-Raphson formula: xi 1 xi (2.3-4)
f '( xi )
Note that this method requires the evaluation of the function and its first derivative at an
old point xi which sometimes can be very difficult. Figure 2.3-3 illustrates the Newton-
Raphson method.
f(x)
root
x
xi xi+1
16
Applied Numerical Methods For Engineers Roots of a Function 2-17
It can also be shown that the true error expression, Et, for the truncated TSE, in the form
f ''( xi ) 2
E t ,i 1 E t ,i (2.3-5)
2 f '( xi )
which shows that the error is proportional to the square of the previous error. This type of
error behavior is called quadratic convergence i.e. the convergence is quadratic or
second-order.
Problem Statement: Use the Newton-Raphson method to find the root of the function
x
f ( x) e 4 (2 x) 1 0
until the approximation error is less than 0.1%. Use x = 0 as initial guess.
Solution:
x
4
x2
First derivative: f '( x ) e 1
4
iteration
i xi f(xi ) f’(xi ) xi+1 a %
0 0.0 1.0 -1.5 0.666667 -
1 0.666667 0.128642 -1.128642 0.780646 14.600
2 0.780646 0.003164 -1.073493 0.783594 0.376
3 0.783594 0.000002 -1.072096 0.783596 0.0002
17
Roots of a Function Applied Numerical Methods For Engineers 2-18
Remark:
1. If the function f(x) is linear, eq.(2.3-4) provides an exact solution on the
first trial; however, if f(x) is nonlinear, the formula is valid only over small
ranges of x.
Disadvantages:
18
Applied Numerical Methods For Engineers Roots of a Function 2-19
c Secant Method
Secant method is very useful when f’(x) is either unavailable or costly to evaluate. It
requires two initial approximations which don’t have to bracket the root. The estimate of
the root, xi+1 , is given in terms of xi and xi-1 as
( xi 1 xi )
Secant formula: xi 1 xi f ( xi ) (2.3-6)
f ( xi 1 ) f ( xi )
Note: a secant to a curve is the straight line passing through two points on the curve. This
formula is similar to the false-position method but the interval does not have to bracket a
root. Thus, this method may diverge.
f(x)
root
x
xi-1 xi xi+1
1.62....
f ''( xi )
Et ,i 1 Et1,.i62... (2.3-7)
2 f '( xi )
which shows that the error is proportional to the power of 1.62... of the previous error
which is slightly less than the Newton-Raphson method.
19
Roots of a Function Applied Numerical Methods For Engineers 2-20
Problem Statement: Use the secant method to find the root of the function
x
f ( x) e 4 (2 x) 1 0
until the relative error is less than 0.1%. Use x = 0 and x = 1.0 as initial guesses.
Solution:
iteratio
n xi-1 xi f(xi-1) f(xi) xi+1 a %
i
1 0 1.0 1.0 -0.221199 0.818867 -
2 1.0 0.818867 -0.221199 -0.037521 0.781866 4.73
3 0.818867 0.781866 -0.037521 0.001855 0.783609 0.22
4 0.781866 0.783609 0.001855 0.000014 0.783596 0.0016
Remark: 1. If the function f(x) is linear, eq.(2.3-6) provides an exact solution on the
first trial; however, if f(x) is nonlinear, the formula is valid only over small
ranges of x.
When the occasion arises that you have to choose between the Newton-Raphson
method and the secant method, the following rule is provided by Jeeves (1958):
If the effort required to evaluate f’(x) is less than 43% of the effort required to evaluate
f(x), then Newton-Raphson method is more efficient, otherwise, choose the secant
method.
20
Applied Numerical Methods For Engineers Roots of a Function 2-21
A multiple root corresponds to a point where a function is tangent to the x axis at that
point. For example, the following polynomials have, respectively, double and triple roots,
Remark: In general, a function with odd multiple roots crosses the x axis, whereas,
a function with even multiple roots do not cross the x axis.
f(x) f(x)
x
1 2 3
x -3
xl c xu
(a) double root (b) double root
6 6
4 4
2 2
0 0
-2 -2
-4
-4
0 1 2 3 4 0 1 2 3 4
21
Roots of a Function Applied Numerical Methods For Engineers 2-22
Consequently, multiple roots pose several limitations for the numerical methods
discussed early. There are two possible difficulties:
1. For a function with even multiple roots, the function does not change
sign over the interval. Thus, it eliminates the use of the reliable
bracketing methods.
2. At the multiple roots, both f(x) and f’(x) are zero or approach zero. This
poses problems for both Newton-Raphson and secant methods.
The potential problem with the methods discussed earlier is that when there exists
multiple roots. For example, if the number of roots at a point is even, the function does
not change sign at the root. In this case, the bracketing method is inapplicable.
In addition, the value of the function and its first derivative is also zero at the root. This
would make Newton-Raphson and secant method impossible. To overcome these
problems, a modified Newton-Raphson method is introduced. This method is based on
the fact that f(x) will always reach zero before f’(x).
Introducing the new function g(x) as the ratio of the function and its first derivative as
f ( x)
g( x) (2.4-1)
f '( x )
Using quotient rule for the derivative,
g( x)
xi 1 xi (2.4-3)
g '( x )
22
Applied Numerical Methods For Engineers Roots of a Function 2-23
f ( xi ) f '( xi )
Modified Newton-Raphson formula: xi 1 xi (2.4-4)
[ f '( xi )]2 f ( xi ) f ''( xi )
Note that in eq.(2.4-4), the denominator will not be zero even if f’(x) is zero. Therefore,
the formula is said to be more stable.
Example 2.4-1: Modified Newton-Raphson method to find the root of the equation.
Problem Statement: Use the modified Newton-Raphson method to find the root of the
following polynomial function
f(x) = x3 - 7x2 + 8x +16 = 0
until the relative error is less than 0.05%. Use (i) x = 0 and (ii) x = 2.0 as initial guess.
20
10
-1 0
-2 0
-2 -1 0 1 2 3 4 5 6
23
Roots of a Function Applied Numerical Methods For Engineers 2-24
iteration
i xi f(xi ) f’(xi) f’’(xi) xi+1 a %
1 0.0 16.0 8.0 -14.0 -0.444444 -
2 -0.444441 0.9739371 14.81476 -16.666667 -0.848485 47.619
3 -0.848485 3.5617892 22.03857 -19.090909 -0.990253 14.316
4 -0.990253 0.2427162 24.80534 -19.941520 -0.999962 0.970
5 -0.999962 0.0009502 24.99924 -19.999772 -1.000000 0.004
Note: f’(x) does not approach zero, so x = 1.0 is not a multiple root.
iteration
i xi f(xi ) f’(xi) f’’(xi) xi+1 a %
1 2.0 12.0 -8.0 -2.0 3.090909 -
2 3.090909 3.380917 -6.611570 4.545455 3.879518 20.327
3 3.879518 0.070831 -1.161272 9.277108 3.998476 2.975
4 3.998476 0.000012 -0.015230 9.990858 3.999999 0.038
24
Applied Numerical Methods For Engineers Roots of a Function 2-25
Worksheet 2.4-1: Modified Newton-Raphson method to find the root of the equation .
Problem Statement: Use the modified Newton-Raphson method to find the root of the
following polynomial function
f(x) = 0.2x3 - x2 + 1.4x +0.6 = 0
until the relative error is less than 0.05%. Use (i) x = 0 and (ii) x = 5.0 as initial guess.
Comment:
Comment:
25