Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

SOLVING NONLINEAR EQUATIONS Part 2

Chapter 3

Newton’s &
Secant
Methods
At the end of this chapter, students should be able to:
 Derive Newton’s and Secant methods graphically and algebraically
 Apply Newton’s and Secant methods for solving non-linear equations
 Determine the rate of convergence of different root finding methods

3.1 Introduction

In Chapter 2, the Bisection method has been discussed for solving non-linear
equations. Based on the examples given, we conclude that if the existence of a
root is guaranteed then the method always converge to the required root. Even
though the Bisection method is perhaps a simple method, its approach is
relatively inefficient due to slow convergence rate. In contrast, the Newton’s and
Secant methods to be discussed in this chapter are generally more
computationally efficient.

31
SOLVING NONLINEAR EQUATIONS Part 2

3.2 Newton’s Method

Newton’s method is also called the Newton-Raphson iteration (attributed to Sir


Isaac Newton (1643-1727) and Joseph Raphson (1648-1715)). Being one of the
most widely used method of root finding, the procedure attempt to find a solution
of the equation f ( x )  0 where f (x ) is a function of one variable, continuous and
differentiable.

In Newton’s method, approximation is done by using tangential lines. The


solution process begins with choosing a value as the first estimate of the solution
(normally obtained from graphing). This initial value is often called the “initial
guess”. The second estimate is obtained by using the tangent line of f (x ) at the

initial value. The third estimate is obtained by using the tangent line of f (x ) at the
second estimate. The process goes on and on until desired accuracy is achieved.

Geometric Derivation
y y  f (x )

L0

Actual
root r
x
x2 x1 x0

Figure 3.1

Let us consider a differentiable function f (x ) and the problem of finding the

solution for the equation f ( x )  0 . Say, for instance, one root is known to lie

between the values x  a and x  b . Newton’s method of approximating this


root calls for an initial guess x 0 to be made. The line L0 tangent to the graph

of y  f (x ) at ( x 0 , f(x0 ) ) is then constructed. By finding the x-intercept x1 of L0 ,

32
SOLVING NONLINEAR EQUATIONS Part 2

we obtain a second approximation of the root. Newton’s famous observation is


simply that for many functions the second approximation x1 is better than the

first, x 0 .

If the procedure is then repeated by finding the line L1 tangent to the graph of f at

( x1 , f(x1 ) ), the x-intercept of L1 (say x2 ) provides an even closer approximation

to the actual root than x1 . The procedure is repeated again and again, until an
approximation of sufficiently high accuracy is obtained.
We can obtain a simple equation for obtaining the (n + 1) th approximation, xn 1 ,

from the nth approximation, xn by considering Figure 3.2.

y y  f (x )

Ln

Ln1

Actual
root r
x
xn1 xn

Figure 3.2

Since the slope of line Ln tangent to the graph of y  f (x ) at ( xn , f(xn ) ) is given

by the derivative f ' (xn ) , the equation for Ln can be written as:

y - f(xn )  f' (xn )x - xn  (1)

To find xn 1 , the x-intercept of Ln , we set y  0 and solve for x in equation (1).


We obtain:
f ( xn )
x  xn  f ' (xn ) ≠ 0
f ' ( xn ) ;

Hence, we have the approximation scheme for Newton’s method where x  xn 1 :

f ( xn )
xn 1  xn  , f ' (xn ) ≠ 0
f ' ( xn )

33
SOLVING NONLINEAR EQUATIONS Part 2

Algebraic Derivation
Newton’s method can also be derived based upon the Taylor’s polynomial.
Suppose that the function f (x ) is twice continuously differentiable on the interval

[a, b]. Let xn  [a, b] be an approximation of the true root r such that

f ' (xn ) ≠ 0 and xn - r is ‘small’. Consider the second-degree Taylor’s

polynomial for f(x), expanded about xn

(r - xn )2
f(x)  f(xn )  (r - xn )f ' (xn )  f " ( ) (1)
2
where  in between x and xn . Since f (r )  0 , with x  r , gives

(r - xn )2
0  f(xn )  (r - xn )f ' (xn )  f(  )
2
2
Since xn - r is assumed to be small, xn - r is even smaller, and if this

quantity is assumed to be negligible, then


0  f(xn )  (r - xn )f ' (xn )
Solving for r in this equation gives:
f ( xn )
r  xn 
f ' ( xn )
Thus, the Newton’s formula for (n+1)th iteration is,
f(xn )
xn 1  xn - for n = 0,1, 2, …
f ' (xn )

Theorem
Assume that f  C 2 [a, b] and there exists a number r  [a, b] , where f (r )  0 .

If f ' (r )  0 , then there exists a   0 such that the sequence  rk 


k 0 defined by

the iteration
f(rn )
rn 1  rn - for n = 0, 1, 2, …
f ' (rn )

will converge for any initial approximation r0  [r - , r  ] .

34
SOLVING NONLINEAR EQUATIONS Part 2

Steps : Newton’s method

 Identify the function f (x )


 Compute the derivative f ' ( x )
 Identify initial value x 0
 Evaluate f (x ) and f ' ( x ) at x 0
 Apply Newton’s formula for the next root estimate
f ( xn )
xn 1  xn 
f ' ( xn )
 Repeat until desired iterations/accuracy

Figure 3.3 Flowchart for the Newton’s Method

Example 1

For the x - cosx  0 , use the Newton’s method with three iterations to find a
solution to the equation given x0  1.4 . What can be said about the accuracy
of the estimated value (root)?

Solution

 Identify the function f (x )

f ( x )  x - cosx
 Compute the derivative f ' ( x )

35
SOLVING NONLINEAR EQUATIONS Part 2

1
f '(x)   sinx
2 x
 Identify initial value x 0

x0  1.4
 Evaluate f (x ) and f ' ( x ) at x 0 (angles in radian mode)

f (1.4)  1.0132

f ' (1.4)  1.4080


 Apply Newton’s method
f ( x0 )
x1  x0 
f ' ( x0 )

1.0132
x1  1.4 
1.4080
 0.6804

Repeat until desired iterations/accuracy


1
n xn f ( x )  x - cosx f ' (x)   sinx
2 x
0 1.4 1.0132 1.4080
1 0.6804 0.0475 1.2353
2 0.6419 0.0002 1.2228
3 0.6417

Hence after three iterations, the estimated root is 0.642 (accurate to 3 decimal
places).

Example 2

f ( x )  e x  x  2 has one real root in [0, 1]. Estimate the root accurate to 3
decimal places by Newton’s method.

Solution
 Identify the function f (x )

f (x)  ex  x  2  0

36
SOLVING NONLINEAR EQUATIONS Part 2

 Compute the derivative f ' ( x )

f '(x)  ex  1
 Identify initial value x 0

x0  0.5

 Evaluate f (x ) and f ' ( x ) at x 0

f (0.5)  0.1487 f ' (0.5)  2.6487


 Apply Newton’s method
f ( x0 )
x1  x0 
f ' ( x0 )

0.1487
x1  0 .5 
2.6487
 0.4439
Repeat until desired iterations/accuracy

n xn f ( x)  e x  x  2 f ' ( x)  e x  1 3D
0 0.5 0.1487 2.6487
1 0.4439 0.0026 2.5587 ~ 0.444
2 0.4429 0.0000 2.5571 ~ 0.443
3 0.4429 ~ 0.443

Hence, the root estimate accurate to 3D is 0.443.

Example 3

Apply Newton’s method with x 0  1 to find the zero of h( x )  x 3  x  1 to 3


significant digits. Calculate the percentage relative error for each of the
iteration.

Solution
Given

h( x )  x 3  x  1
hence,

h' ( x )  3x 2  1

37
SOLVING NONLINEAR EQUATIONS Part 2

Let the initial value be x0  1 , then

f ( x0 )
x1  x 0 
f ' ( x0 )
1
 1 
2
 1.5

n xn f (x ) f ' (x) 3 SD
0 -1 1 2
1 -1.5 -0.8750 5.7500 ~ -1.35
2 -1.3478 -0.1007 4.4499 ~ - 1.33
3 -1.3252 -0.0021 4.2685 ~ -1.32
4 -1.3247 0.0000 4.2646 ~ -1.32
5 -1.3247

In Chapter 1 we define percentage relative error as

x-x
%  x 100% , x ≠ 0 .
x

In iterative method of solving a non-linear equation, the most recent estimate is


the best estimate and hence is used to represent the true value (since the true
value is not available).
Considering the estimated root after the first iteration, the computed percentage
error is

x-x
x 100
x
(-1.5) - (-1)
 x 100
 1.5
 0.33

iteration xn xn+1 %
1 -1 -1.5 0.33
2 -1.5 -1.3478 11.29
3 -1.3478 -1.3252 1.71
4 -1.3252 -1.3247 0.04
5 -1.3247 -1.3247 0

38
SOLVING NONLINEAR EQUATIONS Part 2

Example 4

Determine the formula for Newton’s method to approximate 3 a .

Solution
 Identify the function f (x )

The problem is to determine the root x  3 a , which can be rewrite as

x3  a
then f (x)  x 3  a
3
x a 0
 Compute the derivative f ' ( x )

f ' ( x )  3x 2
 Identify initial value;
xn

 Evaluate f (x ) and f ' ( x ) at x n

f ( xn )  xn 3  a f ' ( xn )  3xn2

 Apply Newton’s method


x3  a
x n 1  x n  n
3 x n2
x a
 xn  n 
3 3 x n2

Warm up exercise
Let x 3 - 2x - 5  0 where 2 ≤ r ≤ 3 .
(i) Identify the function f(x).
(ii) Compute the derivative f’(x).
(iii) Identify initial value x 0 .
(iv) Evaluate f(x) and f’(x) at x 0 .
(v) Apply Newton’s formula to determine the next root estimate
f ( x0 )
x1  x0 
f ' ( x0 )
(vi) Continue until the third iteration and determine the root estimate.

39
SOLVING NONLINEAR EQUATIONS Part 2

CASES OF FAILURE
When the approximations produced by Newton’s method approach the desired
zero, we say that the method converges to that zero. Depending on the initial
approximation and the function, Newton’s method may not converge to the
desired zero.

Some of these cases are:

(a) f ' (x0 ) is too small

y y = f(x)

x0
X1
Figure 3.4

(b) f ' (x) increases too rapidly

y y = f(x)

x1 x
x0
Figure 3.5

40
SOLVING NONLINEAR EQUATIONS Part 2

(c) x 0 is too far from r


y = f(x)
y

x1 x0
r x

Figure 3.6

(d) two roots are close together

x
r1 x0 r2 x1

y = f(x)
Figure 3.7

(e) Iterations move away from zero rather than converging or simply oscillate
between two or more distinct approximations.

x2
r1 xo r2 x
x1
y = f(x)
x3

Figure 3.8

41
SOLVING NONLINEAR EQUATIONS Part 2

When using Newton’s method, consideration must be given to the proper choice
of starting point or initial value. Usually, one must have some insights as to the
shape of the function. Many times a rough graph is adequate, but in other cases
step-by-step evaluation of the function at various points may be necessary to
locate the root. Often the Bisection method is used initially to obtain a starting
point, and Newton’s method is used to improve the precision.

3.3 Secant Method


A potential problem in implementing the Newton’s method is the evaluation of
derivative. Although it may not be a problem to evaluate derivatives of
polynomials, there are certain functions whose derivatives may be extremely
difficult or tedious to evaluate. We next consider a procedure that converges
almost as fast as Newton’s method. This method mimics Newton’s method but
avoids the evaluation of derivatives. Recall that Newton’s iteration defines xn 1

in terms of xn by the formula

f(xn )
xn 1  xn - (1)
f ' (xn )

In the secant method we replace f ' (xn ) in formula (1) by an approximation that
is easily computed. Since the derivative is defined by
f(xn  h) - f(xn )
f ' (xn )  lim
h →0 h
for small h, we can say
f(x  h) - f(x)
f ' (x) ≈
h
in particular, if x  xn and h  xn  xn 1 , we have

f(xn ) - f(xn -1 )
f ' (xn ) ≈ (2)
xn - xn -1

When this is used in equation (1), the result defines the secant method:
 x - xn -1 
xn 1  xn - f(xn ) n  n  1, 2, 3,... (3)
 f(xn ) - f(xn -1 ) 

42
SOLVING NONLINEAR EQUATIONS Part 2

Clearly xn 1 in secant method depends on two previous elements of the

sequence. So as a start, two points (i.e. xo and x1 ) must be provided.

Steps : Secant Method

 Identify the function f(x)


 Identify two initial values xo and x1
 Evaluate f(x0) and f(x1)
 Apply Secant formula for the next root estimate
 x - xn -1 
o xn 1  xn - f(xn ) n 
 f(xn ) - f(xn -1 ) 
 Repeat until desired iterations/accuracy

Example 5
One of the solutions for the equation e x  3 x 2 lies in the interval [-0.6, -0.4].
If the Secant method is used to find this root with xo   0.6 and x1   0.4 ,

what are x2 and x3 ?

Solution
 Identify the function : f(x)
ex  3 x2

e x  3x 2  0  f ( x )  e x  3x 2

 Identify two initial values xo and x1

xo  0.6 and x1  0.4


 Evaluate f(x0) and f(x1)
f (0.6)  0.5312 and f (0.4)  0.1903
 Apply Secant formula for the next root estimate
 x - xn -1 
xn 1  xn - f(xn ) n 
 f(xn ) - f(xn -1 ) 

43
SOLVING NONLINEAR EQUATIONS Part 2

 x - x0 
x2  x1 - f(x1 ) 1 
 f(x1 ) - f(x0 ) 
 ( 0.4)  ( 0.6) 
 ( 0.4)  (0.1903) 
 0.1903  ( 0.5312) 
 0.4528
 Repeat until desired iterations/accuracy
x2  0.4528
 f ( x 2 )  f ( 0.4528)  0.0208

 x - x1 
x3  x2 - f(x2 ) 2 
 f(x2 ) - f(x1 ) 
 ( 0.4528)  ( 0.4) 
 ( 0.4528)  (0.0208) 
 0.0208  (0.1903) 
 0.4593

Example 6
Let f ( x )  ln x  x  2 . Use the Secant method to estimate the root of f
accurate to 1 decimal place if x0 = 0.1 and x1 = 0.25.

Solution

 Identify the function : f(x)


f ( x )  ln x  x  2

 Identify two initial values x o and x1

xo  0.1 and x1  0.25


 Evaluate f(x0) and f(x1)
f (0.1)  0.4026 and f (0.25)  0.3637
 Apply Secant formula for the next root estimate
 x - xn -1 
xn 1  xn - f(xn ) n 
 f(xn ) - f(xn -1 ) 

44
SOLVING NONLINEAR EQUATIONS Part 2

 x - x0 
x2  x1 - f(x1 ) 1 
 f(x1 ) - f(x0 ) 
 (0.25)  (0.1) 
 0.25  (0.3637) 
 0.3637  ( 0.4026) 
 0.1788  0.2 (1D )
 Repeat until desired iterations/accuracy
 x - x1 
x3  x2 - f(x2 ) 2 
 f(x2 ) - f(x1 ) 

 (0.1788)  (0.25) 
x3  0.1788  (0.0997) 
 0.0997  (0.3637) 
 0.1519  0.2 (1D )

Hence, the root accurate to 1D is 0.2

Example 7

Let f ( x )  x  cos x . Use the Secant method to estimate the root of f(x)
accurate to 2 significant digits if x0 = 0 and x1 = 1.

Solution

f ( x )  x  cos x
xo  0 and x1  1

root 2 SD
n xn-1 xn f(xn-1) f(xn)
xn+1
0 0 1 -1.0000 0.4597 0.6851 ~ 0.69
1 1 0.6851 0.4597 0.0533 0.6438 ~ 0.64
2 0.6851 0.6438 0.0533 0.0025 0.6417 ~ 0.64

Hence, the root is accurate to 2SD is 0.64.

Example 8
3
Determine an approximate value for 95 accurate to 3 decimal places.

45
SOLVING NONLINEAR EQUATIONS Part 2

Solution

x  3 95
x 3  95
x 3  95  0

 f ( x )  x 3  95
xo  4 and x1  5

n xn xn+1 f(xn) f(xn+1) root


0 4 5 -31.0000 30.0000 4.5082
1 5 4.5082 30.0000 -3.3761 4.5579
2 4.5082 4.5579 -3.3761 -0.3093 4.5630
3 4.55794 4.5630 -0.3093 0.0037 4.5629
4 4.56296 4.5629 0.0037 0.0000 4.5629 3 DP

Hence, the root accurate to 3 decimal places is 4.563.

Warm up exercise

1. By graphical, bisection, Newton’s and secant methods, find


the largest root correct to three decimal places of
x 3  3x 2  1 . Calculate the percentage of error for each of
the iteration..
3
2. Calculate an approximate value for 4 4 accurate to 2
significant digits.

46
SOLVING NONLINEAR EQUATIONS Part 2

Exercise 3

1. Show that x3 – x – 2 = 0 has a root between 1 and 2. Using the Newton’s method
and initial point 1.5, find this root accurate to two decimal places.

2. Using the Newton’s method, solve x + ln x = 3, given that the root is close to 2.
Obtain the root correct to two decimal places.

3. Use the Newton’s method to approximate the zero of f(x) = 1 – x – x2 with initial
guess of 0.5. Give your answers accurate to 2 significant digits.

4. Apply the Newton’s method to find the solution of x 3  6x  16  0 with x0  0 and


determine the root accurate to three correct decimals. Calculate the percentage
of relative error for each of the iteration.

5. Use the Newton’s method with two iterations to find the point in the right half-
plane where the graphs of f(x)  2x 3 and g(x) = 5x + 1 intersects.

6. Use the Newton’s method to find the zero of f(x) = (x – 2)1/3 with the initial guess
x = 3. What happens? Why?

7. Using the Secant method for f(x) = x5 + x3 + 3, find x2 if x0 = 0 and x1 = 1.

8. Find a solution to the equation x 3  x  1 that is near x0 = 1.5 and x1=1.8.


Perform three iterations.

9. Approximate the cube root of 757 given initial values 8.9 and 9.

10. Solve 2cos x = ex with accuracy 10 4 using


a) Newton’s method with x0 = 1.
 
b) Secant method with p0 = and p1 = .
4 2
For each of the iteration, calculate the percent relative error.

47
SOLVING NONLINEAR EQUATIONS Part 2

11. Discuss the situations where by Newton’s method and secant method fail.

12. Show that the Newton’s formula for finding the reciprocal of A is
xn 1  xn ( 2  Axn ) .

13. Approximate the roots of h(x) = 2x3 − 4x − 2. How many real roots does h have?

48
SOLVING NONLINEAR EQUATIONS Part 2

1. 1.52

2. 2.21

3. 0.62

4. 1.7592

5. 1.6729
6. Case of failure

7. -1.5

8. 1.3247

9. 9.1138

10. a) 0.540
b)

11.

12.

13. -1, -0.59, 1.61

49
SOLVING NONLINEAR EQUATIONS Part 2

1. Graphically, show that x3 + 6x – 16 = 0 has only one real root in the interval
(1, 2).

2. Using graphs, determine the number of roots of


1 x
a) ln 0
1 x2

b) 2x = tan x in the interval [0,3]

3. Determine the number of iterations needed to approximate the root of the


following equations if the bisection method is used with the given desired error. If
the number of iterations is less than 10, find the approximate root.

a) x5 – 3x + 2 = 0 a = 0.5 b = 0.9 Ed  0.5 x 10-2

b) 10 – x – log x = 0 a=7 b = 10 Ed  0.5

c) 1 + x2 – x3 = 0 a=1 b=3 Ed  0.5 x 10-2

4. If a = 0.1 and b = 1.0, how many iterations of the bisection method are needed to
determine the root with an error of at most 0.5 x 10-8.

50

You might also like