Beruflich Dokumente
Kultur Dokumente
ROOTS FINDING
Nabil R. Nassif and Dolly K. Fayad
October 2008
Introduction
(1)
|rn rn1 |
|rn0 rn0 1 |
tol and
> tol , n < n0 .
|rn0 |
|rn |
The remainder f (rn ) can also be used to set a criterion since f (r) = limn f (rn ) = 0.
Thus, one may use a relative evaluation of the remainder for a second stopping criterion,
specifically, get the first element rn0 of the sequence {rn } satisfying:
(3)
|f (rn )|
|f (rn0 )|
tol and
> tol n < n0 .
|f (r0 )|
|f (r0 )|
There are basically two approaches to locate the roots of a function. The first one seeks to
analyze its behavior, analytically or through plotting its graph, while the second method
transforms the problem of roots finding into a fixed point problem. We illustrate these
methods through some specific examples.
Example 1 Locate the roots of the function f (x) = ex sin(x).
1. Analyzing the behavior of the function
Since for x < 0, ex > 1 and given that | sin(x)| 1, x, then f (x) > 0 for x < 0.
Furthermore f (0) = 1. This implies that all the roots of the function lie in the interval
(0, ). Studying the variation of the function f (x) is done by studying the sign of its
derivative.
2. A fixed point problem
Solving the problem f (r) = 0 can be made equivalent to solving g1 (r) = g2 (r), r
becoming the fixed-point for the 2 functions g1 (x) = ex and g2 (x) = sin x.
Hence we plot on the same graph the 2 distinct functions g1 and g2 , Obviously these
2 functions intersect at an infinite number of points. Hence one concludes that the
function f (x) has an infinite number of roots.
The bisection method is a procedure that halves the interval where the root r is expected
to lie, until one achieves the desired accuracy.
- At the 1st step in this process, we have located an interval (a, b) satisfying properties
(a), (b) and (c).
, and compute y = f (r). It
- Next we construct the midpoint of this interval r = a+b
2
can happen fortuitously that f (r) = 0. If so, the objective of this algorithm has been
fulfilled. In the usual case y 6= 0 and either yf (a) < 0 or yf (a) > 0. If yf (a) < 0 , we
can be sure that a root of f lies exists in the interval (a, r). Consequently, we store the
value of r in b and y in f (b). If yf (a) > 0, we can be sure that a root of f lies exists in
the interval (r, b). Consequently, we store the value of r in a and y in f (a). In either
case, the situation at the end of this step is just like at the beginning except that the
final interval (a, b) is half large as the initial one.
- This process can be repeated until the interval is satisfactorily small. (stopping
criteria)
- At the end, the best estimate of the root would be r =
interval obtained through this procedure.
a+b
,
2
if y*fa<0
b=r(n);fb=y;
else
if y*fa>=0
a=r(n);fa=y;
end
S=(abs(b-a)/ab);
end
%If n>=kmax, reconsider the values allocated to the parameters: a, b, S, kmax
if n>=kmax display "error no convergence";
else
r=r(n);
end
In summary, for finding the zero of a given continuous function in an interval (a, b), k
steps of the bisection method involves generating a sequence of intervals: {(an , bn ):n=0,...,k},
such that:
1. a0 = a, b0 = b,
2. bn an =
bn1 an1
2
ba
,
2n
n 1,
The method achieves the desired accuracy, whenever (an , bn ) is sufficiently small, i.e whenever
n reaches k such that:
(5)
bk1 ak1
b1 a1
1
b 0 a0
b k ak
tol <
< ...
= <
= 1.
ba
ba
ba
2
ba
bk ak
ba
>
From 2., we can estimate the least number of iterations required to reach the relative precision tol = 12 101p , p being the number of decimal figures that are fixed by the user. Thus,
the integer k in (5), verifies:
1
1
1
(6)
101p < k1 .
k
2
2
2
Applying the natural logarithm function on (6), yields:
k ln(2) (1 p) ln(10) ln(2) < (k 1) ln(2),
5
k (p 1)
ln(10)
+ 1 > k 1,
ln(2)
ln(10)
+ 1e.
ln(2)
bk ak
,
ba
a measure of
Iterations k
8
15
21
31
48
Iterate
5.000000 101
....
5.888672 101
5.885009 101
5.886230 101
5.885010 101
5.885620 101
5.885315 101
5.885468 101
5.885391 101
5.885353 101
5.885334 101
5.885324 101
5.885329 101
Iterate
1.500000 100
1.750000 101
....
1.618164 101
1.617676 101
1.617920 101
1.618042 101
1.617981 101
1.618011 101
1.618027 101
1.618034 101
1.618031 101
1.618032 101
1.618033 101
1.618034 101
In conclusion, the bisection method, whenever a root has been located, is a globally, multi-step,
linearly convergent method since:
- The choice of (a, b) does not affect the process of convergence.
- The method is a multi-step method since at each step 2 points ak and bk are needed.
(rk = F (ak1 , bk1 ))
- We qualify this method to be a linear method relative to the iterated intervals, since
|bk ak | = C|bk1 ak1 |, where C = 1/2 for all k. Note that definition 2 of the order
of convergence is difficult to prove and apply literally for the bisection method.
Newtons Method
In Newtons method, referred to as the tangent method, it is assumed at once that the
function f is differentiable. At a certain point (r0 , f (r0 )) on the graph of f there is a tangent,
which is a rather good approximation to the curve in the vicinity of that point.
Analytically, it means that the equation of the tangent i.e. the linear function:
y = f 0 (r0 )(r r0 ) + f (r0 )
is close to the given function f near r0 . At r0 the 2 functions y and f agree.
We take the zero of the tangent y as an approximation to the zero of the curve.
7
The zero
of y is easily found:
r1 = r0
f (r0 )
f 0 (r0 )
Thus, starting with the point r0 (which we may interpret as a 1st approximation to the root
sought), we pass to a new point r1 obtained from the preceding formula. Naturally, the
process can be repeated or iterated to produce a sequence of points:
(8)
rn+1 = rn
f (rn )
f 0 (rn )
Under favorable conditions, the sequence of points will approach a zero of f , say r.
To summarize, Newtons method consists in obtaining the sequence {rn }, recursively, with
(rn+1 , 0) being the intersection with the x-axis of the tangent to the curve y = f (x) at the
point (rn , f (rn )).
Clearly, Newtons method is a one-step iteration rn+1 = g(rn ), with the iteration function g(x) given by:
f (x)
(9)
g(x) = x 0 .
f (x)
Note that the function g(x) verifies the following properties:
1. r = g(r), i.e. r is a fixed point to the function g (since f (r) = 0).
2. The definition of g and the consequent generation of the sequence {rn } necessitates the
existence of an interval (, ), such that: r (, ) and f 0 (x) 6= 0 for allx (, ).
This can be achieved through finding a sufficiently small interval (, ) where f 0 (r) 6=
0, and f 0 (x) continuous in that interval (i.e. f C 1 ).
3. If in addition to (2), one assumes that f (x) is continuous on (, ) (i.e. f C 2 ), then
(x)f (x)
0
one also verifies that: g 0 (x) = f(f
0 (r))2 , and consequently: g (r) = 0.
8
These properties on the function f , added to the above properties (a), (b) and (c) (imposed
in the introduction) are sufficient to prove the following result:
Theorem 1 If the function f (x) verifies properties (a), (b) and (c) and furthermore is such
that f C 2 with f 0 (r) 6= 0, then there exists an interval (, ), such that r (, ) and the
iteration
f (rn )
= g(rn ), n 0,
rn+1 = rn 0
f (rn )
is such that: r0 (, ), rn (, ) and limn rn = r.
This theorem reflects the locally convergent character of Newtons method: convergence
is assured whenever the initial choice r0 is close to the root r.
On the other hand, under the sufficient conditions of this theorem, one also shows that the
convergence is quadratic as follows:
Theorem 2 Under the conditions of Theorem 1, the convergence of Newtons method is
maxx(,) |f (x)|
, such that:
quadratic, i.e., there exists a constant C = 12 minx(,)
|f 0 (x)|
|r rn+1 | C|r rn |2 .
Proof. Using Taylors expansion of f (r) about rn , one has:
0 = f (r) = f (rn ) + (r rn )f 0 (rn ) +
(r rn )2
f (cn ), cn = rn + t(r rn ), t (0, 1).
2
f (rn )
(r rn )2 f (cn )
=
r
+
,
f 0 (rn )
2
f 0 (rn )
and therefore:
(10)
rn+1 r = (r rn )2
f (cn )
.
2f 0 (rn )
Thus, one can assert that in general, Newtons algorithm is a locally and quadratically convergent method. When a root r of a function f (x) is located in an interval
(a, b), the first step is to insure finding a sub-interval (, ) (a, b) containing r, in which
f 0 (x) 6= 0 x (, ). The existence of such interval is validated by the continuity of f 0 (x)
and the assumption that f 0 (r) 6= 0. A rule of thumb would be to select r0 after 1(or 2)
application(s) of the bisection method. Such a step would make sure the initial condition r0
is close to r and thus f 0 (r0 ) 6= 0.
In the following version of Newtons method, the initial choice is being selected after one
bisection iteration. Note that Newtons method requires the availability of the first derivative
f 0 (x) of f (x). This is the price to pay in order to get a quadratic convergence.
9
Obviously, Newtons method is not applicable when the initial choice of the iteration r0 is
selected from the whole interval (0, 2). For example if r0 is chosen in the interval (1.5, 2),
the generated sequence {rn } may not fall in the interval (0, 2) and thus fails to converge,
as is shown in the following table resulting from the application of Newtons algorithm with
r0 = 1.75.
10
Iteration
0
1
2
3
4
...
Iterate
1.75
1.8291987102
1.8206468102
1.8221346102
1.8221237102
...
Obviously, the convergence is taking place to a root that is not in the interval (0, 2). On the
other hand, one application of the bisection method would start the iteration with r0 = 1,
leading to the following effciently convergent process.
Iteration
0
1
2
3
4
5
6
Iterate
1.0
4.785277889803116101
5.841570194114709101
5.885251122073911101
5.885327439585476101
5.885327439818611101
5.885327439818611101
Obviously, about 5 iterations would provide 10 significant figures, a sixth one leading to 16
figures, i.e. a more than a double precision answer.
f (x + h) f (x)
f (rn )
where f 0 (x) = lim
0
h0
f (rn )
h
One drawback of Newtons method is the necessary availability of the derivative f 0 (x). In
case such function is difficult to program, an alternative would be to replace in (8), f 0 (rn ) by
(rn1 )
the divided difference f [rn , rn1 ] = f (rrnn)f
. This would suggest obtaining rn+1 using the
rn1
secant to the curve y = f (x) passing through the points (rn1 , f (rn1 )) and (rn , f (rn )). The
intersection of this secant line with the x axis would provide the (n + 1)-iterate secant
method algorithm.
11
(12)
rn+1 = rn
f (rn )
f (rn )(rn rn1 )
rn
,n 2
f [rn , rn1 ]
f (rn ) f (rn1 )
The secant method is a two-step method of the form rn+1 = g(rn , rn1 ), its processing
requiring selection of r0 and r1 . Of course, if the method is succeeding, the points rn will be
approaching a zero of f , so f (rn ) will be converging to zero.
If a root r of the function f is located in the interval (a, b), one would suggest applying twice
the bisection method in order to implement (12) as follows:
%Input f, a, b,TOL, kMAX
%Find the first 2 approximations by the " Bisection rule"
r(0) ; r(1);
k=1;RelErr =1;
while RelErr >TOL & k<=kMAX
d=(f(r(k))-f(r(k-1))/r(k)-r(k-1));
r(k+1)=r(k)-f(r(k)/d;
RelErr = Abs[r(k+1)-r(k)]/ Abs[r(k);
k=k+1;
end
The advantages of the secant method relative to the tangent method are that (after
the first step) only one function evaluation is required per step (in contrast
to Newtons iteration which requires 2) and that it is almost as rapidly convergent.
It can be shown that under the same assumptions as those of theorem 2, the basic
secant method is superlinear and has a local character of convergence.
Theorem 3 If the function f (x) verifies properties (a), (b) and (c), and furthermore is such that f C 2 with f 0 (r) 6= 0, there exists a constant C such
that:
5
1
+
(13)
1.62
|r rn | c|r rn1 | , =
2
12
f (rn )
1
f (c)
= r + (r rn )(r rn1 )
f [rn , rn1 ]
2
f [rn , rn1 ]
Since f [rn , rn1 ] = f 0 (c1 ), then under the same assumptions as those of theorem 2, one
concludes that:
|r rn | C|r rn1 ||r rn2 |
From this inequality and using Fibonacci sequences one proves the required result.
13
Example 5 Find the roots of f (x) = sin x ex in the interval (0, 2) using the Secants
method.
This process gives the following results:
Iteration
0
1
2
3
4
5
6
7
8
Iterate
1.0
-0.57669074041
0.73322180627
0.63480346897
0.58558226622
0.58858855795
0.58853280981
0.58853274398
0.58853274398
14
PROBLEMS
Bisection Method
1. Find where the graphs of y = 3x and y = ex intersect by finding roots of ex 3x = 0
correct to four decimal digits.
2. Give a graphical demonstration that the equation tanx = x has infinitely many roots.
Determine one root precisely and another approximately by using a graph.
3. By graphical methods, locate approximations to all roots of the nonlinear equations
ln(x + 1) + tan(2x) = 0.
4. Prove the following inequality: |r rn |
b0 a0
2n+1
if rn =
an +bn
2
5. If a = 0.1 and b = 1.0, how many steps of the bisection method are needed to determine
the root with an error of at most 12 108 ?
6. Find all the roots of the function f (x) = cosx cos3x.
7. Find the root or roots of ln[(1 + x)/(1 x2 )] = 0.
8. If the bisection method generates intervals [a0 , b0 ], [a1 , b1 ], and so on, is the inequality
true for the root r that is being calculated? Give proofs or counterexemples.
(a) |r an | 2|r bn |
(b) |r bn | 2n1 (b0 a0 )
9. If the bisection method is applied with starting interval [a, a + 1] and a 2m , where
m 0, what is the correct number of steps to compute the root with full machine
precision in the Fs system ?
Newtons and Secant Methods
1. Verify that when Newtons method is used to compute
x2 = R), the sequence of iterates is defined by
1
R
xn+1 =
xn +
2
xn
2. (Continuation) Show that if the sequence {xn } is defined as in the preceding problem,
then
2
2
xn R
2
xn+1 R =
2xn
Interpret this equation in terms of quadratic convergence.
15
3. Write Newtons method in simplified form for determining the reciprocal of a positive
number. Show the local character of convergence of the method by choosing different
values of the first iterate.
4. Write Newtons method in simplified form for determining the reciprocal of
the square
root of a positive number. Perform two iterations to approximate 1/ 5, starting
with x0 = 1 and x0 = 1.
5. Two of the four roots of x4 + 2x3 7x2 + 3 are positive. Find them by Newtons
method, correct to two significant figures.
6. The equation x Rx1 = 0 has x = R1/2 for its solution. Establish Newtons
iterative scheme, in simplified form, for this situation. Carry out five steps for R = 25
and x0 = 1.
7. Compute ln2. Use Newtons method applied to the equation ex = 2
8. Define a sequence xn+1 = xn tanxn with x0 = 3. What is limn xn ?
9. Each of the following functions has 3 R as a zero for any positive real number R.
Determine the formulas for Newtons method for each and any necessary restrictions
on the choice for x0 .
(a) a(x) = x3 R
(b) b(x) = 1/x3 1/R
(c) c(x) = x2 R/x
(d) d(x) = x R/x2
(e) e(x) = 1 R/x3
(f) f (x) = 1/x x2 /R
(g) g(x) = 1/x2 x/R
(h) h(x) = 1 x3 /R
10. If Newtons method is used on f (x) = x3 x + 1 starting wit x0 = 1, what will x1 be?
11. Locate the root of f (x) = ex cosx that is nearest /2.
12. If Newtons method is used on f (x) = x5 x3 + 3 and if xn = 1, what is xn+1 ?
Establish this relation by applying Newtons method to some f (x). Beginning with
x0 = 0.2, compute the reciprocal of 4 correct to six decimal digits or more by this rule.
Tabulate the error at each step and observe the quadratic convergence.
Establish this and explain why it is inferior to the standard equation in a computer
program.
17
References
[1] BURDEN, R., FAIRES D., Numerical Analysis. 7th edition. Brooks, Cole. 2001
[2] CHENEY, W., KINCAID D., Numerical Mathematics and Computing. 4th edition.
Brooks, Cole 1999.
[3] ISAACSON, E., KELLER H.B, Analysis of Numerical Methods. 4th edition. Wiley
1966.
18