Está en la página 1de 19

CHAPTER II

ROOTS FINDING
Nabil R. Nassif and Dolly K. Fayad
October 2008

Introduction

Let f be a real-valued function of a real variable admitting a specific regularity, i.e., f


C k , k 1. We seek to find the roots of this function f , defined as follows:
Definition 1 The set of roots R of the function f (x) is defined as:
R = {r R : f (r) = 0}.
Given some computational tolerance tol = 12 101m , m = 1, 2, ..., our objective is to compute
one or more roots of f , within such tolerance tol . Specifically, for any r R, we seek an
approximation ra to r, (ra r), such that:
|r ra |
tol .
|r|

(1)

(We say then, that ra approximates r up to m decimal places)


The search for a particular root of a function requires two steps.
1. Locate the root, i.e. seek an interval (a, b), such that:
(a) r (a, b).
(b) f (a) f (b) < 0.
(c) x [a, b], x 6= r, f (x) 6= 0.

2. Generate a sequential process leading to a sequence r1 . ..., rn , .. converging to r. The


generation of this sequence is usually done through an iteration procedure (or function
g), rn = g(rn1 , ..., rnk ). In case k = 1, the method is said to be a one-step method,
the initial state of the sequence being determined by the only choice of r0 . Otherwise,
it is a multi-step method of order k, then its initial state is determined by the choice
of r0 , .., rk1 .

Definition 2 Order of Convergence of a Method


If there exists two constants c and , independent from n, such that:
|rn r| c|rn1 r| ,
the method is said to have an -order of convergence.
The order of convergence of a method measures the rate at which the sequence {rn } generated by the numerical method converges to the root r. If = 1 the convergence is linear,
while if > 1, the convergence is superlinear. In particular, if = 2 the convergence is
said to be quadratic. (Note that since we are dealing with small differences, the greatest
is, the more accurate is the method.)
Definition 3 Global convergence vs Local convergence
If the sequence {rn } generated by the numerical method converges for any choice of the
initial state, the method is said to be globally convergent. Otherwise, it is said to be
locally convergent.
Definition 4 Stopping criteria
Let {rn } be a converging sequence generated by some numerical method. When implemented,
the process will be stopped and leads to an approximation to the root r, as soon as the 1st
computed element rn0 of {rn } satisfies the following:
(2)

|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 )|

Note also that by using the Mean-Value Theorem one has:


0 = f (r) = f (rn ) + (r rn )f 0 (cn ), where cn = r + (rn r), (0, 1).
Thus if f 0 is available (referring also to (2)), a more sophisticated stopping criterion would
be:
|f (rn0 )|
|f (rn )|
(4)
tol and
> tol n < n0 .
0
|rn0 f (rn0 )|
|rn0 f 0 (rn0 )|

How to locate the roots of a function

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.

Example 2 Locate the roots of the quadratic polynomial p(x) = x4 x3 x 1


Let g1 (x) = x4 x3 and g2 (x) = x + 1. Obviously, in this case the function f has 2 roots,
one in the interval (1, 0) and the second in the interval (1, 2).

The Bisection Method

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

We describe the Bisection Method through the following algorithm:


%Input a, b, f(a), f(b)
% kmax is the maximum acceptable number of iterations
% tol is the desired relative precision
fa=f(a);fb=f(b);
ab=abs(b-a);n=0;S=1;
while S>tol & n<kmax
n=n+1;r(n)=(a+b)/2;y=f(r(n));
4

where (a, b) is the last

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,

3. r (an , bn ), n (with an < r < bn , n).


The midpoints of these intervals r1 , r2 . ..., rn , .. form a sequence of approximations to the
n1
. Obviously, the last two properties imply that the two sequences
root, namely rn = an1 +b
2
that are being generated by the bisection method, i.e.{an } and {bn } converge both to the
root r:
lim an = lim bn = r.
n

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

The parameter kmax is used as a programming safeguard. If k exceeds kmax with


tol, the written algorithm imbeds an error.

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

from which one concludes that:


k ln(2) (p 1) ln(10) + ln(2) > (k 1) ln(2),
leading to:
(7)

k (p 1)

ln(10)
+ 1 > k 1,
ln(2)

i.e., solving these inequalities gives:


k = d(p 1)

ln(10)
+ 1e.
ln(2)

Note that such k is independent of a and b, since it estimates the ratio


the (relative) reduction of the size of the interval (ak , bk ) containing r.
precision p
3
5
7
10
15

bk ak
,
ba

a measure of

Iterations k
8
15
21
31
48

Obviously the method is slowly convergent!


In applying the bisection method algorithm for the above 2 examples, one gets the following
results:
1. f (x) = ex sin(x). Search for the root in the interval [0, 1].
Tolerance: 0.5 105 (6 significant figures rounded).
Iteration
1
...
10
11
12
13
14
15
16
17
18
19
20
21
6

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

2. f (x) = x4 x3 x 1. Search for the root in the interval [0, 3].


Tolerance: 0.5 105 (6 significant figures rounded).
Iteration
1
2
...
10
11
12
13
14
15
16
17
18
19
20
21

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

Obviously, this identity leads to:


rn+1 = g(rn ) = rn

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

%Input f, df, a, b,TOL, kMAX


%Find the first approximation by the Bisection rule"
r(1)=(a+b)/2;k=1;RelErr =1;
while RelErr >TOL & k<=kMAX
F=f(r(k)); DF=df(r(k));
r(k+1)=r(k)-F/DF;
RelErr = Abs[r(k+1)-r(k)]/ Abs[r(k);
k=k+1;
end
There are cases where the convergence of the method is not affected by the choice of the
initial condition whereby Newtons method converges unconditionally.
Example 3 The square root function

Assume a > 0. We seek an approximation to r = a.


Clearly, such r is the unique positive root of f (x) = x2 a. In such case, one shows that
Newtons iteration:
f (rn )
1
a
rn+1 = rn 0
(11)
(rn + ),
f (rn )
2
rn

converges to a for any initial choice of r0 > 0.


(We can easily check this property on the graph).
Example 4 Find the roots of f (x) = sin(x) ex in the interval (0, 2), using Newtons
method.

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.

The Secant Method

Recall that Newtons iteration satisfies formula (8):


rn+1 = rn

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

Proof. Using Taylors expansion formula, the following identity holds:


1
0 = f (r) = f (rn ) + f [rn , rn1 ](r rn ) + (r rn )(r rn1 )f (c)
2
from which one deduces:
rn

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

i.e. 2 more iterations than Newtons method.

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

R (by solving the equation

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 ?

13. To determine x = 3 R, we can solve the equation x3 = R by Newtons method. Write


the loop that carries out this process, starting from the initial approximation x0 = R.
14. The reciprocal of a number R can be computed without division by the iterative
formula
xn+1 = xn (2 xn R)
16

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.

15. Newtons method for finding R is




1
R
xn+1 =
xn +
2
xn

Perform three iterations of this


scheme for computing 2, starting with x0 = 1, and
of the bisection method for 2, starting with interval [1, 2]. How many iterations are
needed for each method in order to obtain 106 accuracy?
16. The iteration formula xn+1 = xn (cosxn )(sinxn ) + Rcos2 xn where R is a positive
constant, was obtained by applying Newtons method to some function f (x). What is
f (x) ? What can this formula be used for ?
17. Determine the formula for Newtons method for finding a root of the function f (x) =
x e/x. What is the behavior of the iterates ?
18. Consider the following procedures:
(a) xn+1 = 31 (2xn R/x2n
(b) xn+1 = 12 xn + 1/xn
Do they converge for x different from 0 ? If so, to what values ?
19. Calculate an approximate value for 43/4 using one step of the secant method with
x0 = 3andx1 = 2.
20. If we use the secant method on f (x) = x3 2x + 2starting with x0 = 0and x1 = 1,what
is x2 ?
21. If the secant method is used onf (x) = x5 + x3 + 3,and if xn2 = 0andxn1 = 1, what
is xn ?
22. If xn+1 = xn + (2 exn )(xn xn1 )/(exn exn1 )with x0 == 0and x1 = 1, what is xn ?
23. Using the bisection method, Newtons method and the secant method, find the largest
positive root correct to 3decimal places of x3 5x+3 = 0. All the roots are in [3, +3].
24. The formula for the secant method can also be written
xn+1 =

xn1 f (xn ) xn f (xn1 )


f (xn ) f (xn1 )

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

También podría gustarte