Sei sulla pagina 1di 30

Teach A Level Maths

Vol. 2: A2 Core Modules

19: Newton-Raphson
Iteration

Christine Crisp

Newton-Raphson Iteration
It isnt always possible to find iterative formulae of
the type

x n 1 g ( x n )

that will find the solution of every equation.


Another iterative method that is useful is called the
Newton-Raphson method.

Newton-Raphson Iteration
Suppose we want to find an approximate solution to
the equation

f ( x) 0

To see how the method works, well sketch y f ( x )


using f ( x ) x 3 x 1 .
The root
lies between
1 and 2.
Well zoom in
near

y f ( x)

Newton-Raphson Iteration

y f ( x)

x2

x1

x0

Suppose our first estimate is given by x 0 2 .


We draw the tangent to the curve at x 0
The point where the tangent meets the x-axis we
call x1 .
Repeating . . .
Each point x1 , x 2 , . . . is closer to .

Newton-Raphson Iteration
To carry out the iteration we need to find the points
where the tangents meet the x-axis.

( x 0 , y 0 )x
y0

y f ( x)

x 0 x1
x1
The grad. of the tangent

x0

the change in y
the change in x

y0
dy

at x 0
dx
x 0 x1

Newton-Raphson Iteration
We have dy

y0
and we need to find
.
at x 0
x1
dx
x 0 x1
dy
Using y 0 and
at x 0 in the formula isnt very
dx
convenient, so, since y f ( x ) we have
y0
dy
y0 f ( x0 )
and
at x 0
f / ( x0 )
dx
x 0 x1
Then,
f ( x0 )
/
f ( x0 )
x 0 x1
f ( x0 )
f ( x0 )
Rearranging:
x 0 x1 /
x1 x 0 /
f ( x0 )
f ( x0 )

Newton-Raphson Iteration
So,

x1 x 0

f ( x0 )
f / ( x0 )

We just need to alter the subscripts to find

x 2 x1
Generalising gives

x n 1 x n

x2 :

f ( x1 )
f / ( x1 )
f ( xn )
f / ( xn )

We dont need a diagram to use this formula but


we must know how to differentiate f ( x ) .
Convergence is often very fast.

Newton-Raphson Iteration
e.g. Use the Newton-Raphson method with x 0 2
to find the root of the equation

x3 x 1 0

correct to 4 d.p.
Solution:

Differentiate:

x n 1 x n

f ( x) x 3 x 1

Let

f / ( x) 3 x 2 1

f ( xn )
/

f ( xn )

x n 1 x n

( x n x n 1)
2

( 3 x n 1)

Using a calculator we need: 2, ENTER


(ANS 3 ANS 1)
Then,
ANS
( 3ANS 2 1)
x 1 6180 ( 4 d.p.)

Newton-Raphson Iteration
SUMMARY
To use the Newton-Raphson method to estimate a
root of an equation:
rearrange the equation into the form f ( x ) 0
differentiate f ( x ) to find f / ( x )
substitute f ( x ) and f / ( x ) into the formula

x n 1 x n

f ( xn )
f / ( xn )

choose a suitable starting value for


use a calculator to iterate

x0

Tip: It saves a lot of errors if, before you type the


formula into your calculator, you write the formula
with ANS replacing every x.

Exercise

Newton-Raphson Iteration

1. (a) Use the Newton-Raphson method to estimate


the root of the following equation to 6 d.p.
using the starting value given:
3

x 2x 2 0 ;

x0 1

(b) What happens if you use x 0 0 ?

(c) Use your calculator or a graph plotter to


3
2
sketch the graph of y x 2 x 2 .
(d) What is special about the graph at x 0 0
and why does it explain the answer to (b) ?
2. Use the Newton-Raphson method to estimate one
root of 3 cos x 1 x to 4 d.p. using x 0 2

Newton-Raphson Iteration
(a)

x3 2x2 2 0 ;

x0 1

Solution: Let f ( x ) x 3 2 x 2 2

x n 1 x n

x0 1 ,

f ( x) 3 x 4 x
f ( xn )
f / ( xn )
3
2
( x n 2 x n 2)
x n 1 x n
2
(3 x n 4 x n )
(ANS 3 2ANS 2 2)
ANS
( 3ANS 2 4ANS)

x1 0 857143 , x 2 0 839545 , . . .
x 0 839287 ( 6 d.p. )

Newton-Raphson Iteration
3

x n 1 x n

( x n 2 x n 2)
2

(3 x n 4 x n )

(b) What happens if you use x 0 0 ?


(c)

The iteration fails immediately.


3

y x 2x 2

At x = 0, there is a
stationary point.
At a stationary point
f / ( x ) 0 so in the
formula we are
dividing by 0.

We also notice that the tangent never meets


the x-axis.

Newton-Raphson Iteration
2. Use the Newton-Raphson method to estimate one
root of 3 cos x 1 x to 4 d.p. using x 0 2
Solution:
Let
f ( x ) 3 cos x 1 x

f ( x ) 3 sin x 1

( 3 cos x n 1 x n )
x n 1 x n /
x n 1 x n
( 3 sin x n 1)
f ( xn )
( 3 cos ANS 1 ANS )
x n1 ANS
( 3 sin ANS 1)
x 0 2,
Radians!
x1 1 8562, x 2 1 8624
x 1 8624 ( 4 d.p. )
f ( xn )

Newton-Raphson Iteration
The Newton-Raphson method will fail if

f ( x) 0

i.e. at a stationary point

It will also sometimes fail to give the expected root


if the initial value is close to a stationary point.
Can you draw a graph to show what could happen in
this case?
This is one example.

Newton-Raphson Iteration

y x3 2x2 5x 1

x0
With

x 0 1 9
x 1 576

the iteration gives the root

instead of the closer root

x 0 187

Newton-Raphson Iteration

The following slides contain repeats of


information on earlier slides, shown without
colour, so that they can be printed and
photocopied.
For most purposes the slides can be printed
as Handouts with up to 6 slides per sheet.

Newton-Raphson Iteration
It isnt always possible to find iterative formulae of
the type

x n 1 g ( x n )

that will find the solution of every equation.


Another iterative method that is useful is called the
Newton-Raphson method.

Newton-Raphson Iteration
SUMMARY
To use the Newton-Raphson method to estimate a
root of an equation:
rearrange the equation into the form f ( x ) 0
differentiate

f ( x ) to find f / ( x )
substitute f ( x ) and f / ( x ) into the formula
choose a suitable starting value for

x0

use a calculator to iterate


Tip: It saves a lot of errors if, before you type the
formula into your calculator, you write the formula
with ANS replacing every x.

Newton-Raphson Iteration
e.g. Use the Newton-Raphson method with x 0 2
to find the root of the equation

x3 x 1 0

correct to 4 d.p.
Solution:

Differentiate:

x n 1 x n

f ( x) x 3 x 1

Let

f / ( x) 3 x 2 1

f ( xn )
/

f ( xn )

x n 1 x n

xn xn 1
2

3 xn 1

Using a calculator we need: 2, ENTER


ANS 3 ANS 1
Then,
ANS
3ANS 2 1
x 1 6180 ( 4 d.p.)

Newton-Raphson Iteration
The Newton-Raphson method will fail if

f ( x) 0

i.e. at a stationary point

It will also sometimes fail if the initial value is


close to a stationary point.

Guess:

2.44948979592

f xn
f 2.44948979592

.00000013016

xn 1 xn
Newtons Method:
f xn
Amazingly close to zero!
This is Newtons Method of finding roots. It is an example
of an algorithm (a specific set of computational steps.)
It is sometimes called the Newton-Raphson method
This is a recursive algorithm because a set of steps are
repeated with the previous answer put in the next
repetition. Each repetition is called an iteration.

3
Find where y x x crosses y 1 .

1 x3 x

0
1

xn
1
1.5

0 x3 x 1 f x x3 x 1

f xn
1
.875

f xn
xn 1 xn
f xn

f xn
2

1
1
1.5
2

5.75

.875
1.5
1.3478261
5.75

2 1.3478261 .1006822 4.4499055

1.3252004

f x 3x 2 1

1.3252004

1.3252004 1.0020584

There are some limitations to Newtons method:

Looking for this root.

Bad guess.

Wrong root found

Failure to converge

Advantages and Drawbacks of


Newton Raphson Method
http://numericalmethods.eng.usf.edu

http://numericalmethods.eng.us
f.edu

24

Advantages
Converges fast (quadratic convergence), if it
converges.
Requires only one guess

http://numericalmethods.eng.us
f.edu

25

Drawbacks
1.

Divergence at inflection points


Selection of the initial guess or an iteration value of the root
f x
that is close to the inflection point of the function
may
start diverging away from the root in ther Newton-Raphson
method.
3

For example, to find the root of the


equation
.

f x x 1 0.512 0

xi 1 xi

The Newton-Raphson method reduces to

3
i

1 0.512
2
3 xi 1

Table 1 shows the iterated values of the root of


x the
1 equation.
The root starts to diverge at Iteration 6 because the previous
estimatexof
is close to the inflection point of
.
00.92589
.2.
Eventually after 12

http://numericalmethods.eng.us
f.edu iterations the root converges
more

to the

26

Drawbacks Division by Zero


2. Division by zero
For the equation

f x x 3 0.03 x 2 2.4 10 6 0
the Newton-Raphson method
reduces to
xi3 0.03 xi2 2.4 10 6
xi 1 xi
3xi2 0.06 xi

For x0 0 or x0 0.02 , the


denominator will equal zero.

Figure 9 Pitfall of division by


zero
or near a zero
number

http://numericalmethods.eng.us
f.edu

27

Drawbacks Oscillations near local


maximum and minimum
3. Oscillations near local maximum and minimum
Results obtained from the Newton-Raphson method may
oscillate about the local maximum or minimum without
converging on a root but converging on the local maximum or
minimum.
Eventually, it may lead to division by a number close to zero
and may diverge.
2
For example for f x x 2 0 the equation has no real
roots.
http://numericalmethods.eng.us
f.edu

28

Drawbacks Oscillations near local


maximum and minimum
Table 3 Oscillations near local maxima
and mimima in Newton-Raphson method.
Iteration
Number

xi

0
1
2
3
4
5
6
7
8
9

1.0000
0.5
1.75
0.30357
3.1423
1.2529
0.17166
5.7395
2.6955
0.97678

f xi a %
3.00
2.25
5.063
2.092
11.874
3.570
2.029
34.942
9.266
2.954

300.00
128.571
476.47
109.66
150.80
829.88
102.99
112.93
175.96

Figure 10 Oscillations around local


2
minima for f x x 2 .

http://numericalmethods.eng.us
f.edu

29

Drawbacks Root Jumping


4. Root Jumping
In some cases where the functionf x is oscillating and has a
number of roots, one may choose an initial guess close to a root.
However, the guesses may jump and converge to some other root.

f(x)

For example

f x sin x 0

0.5

Choose

x0 2.4 7.539822

It will converge to x
instead of

1.5

-2

-0.06307

0.5499

4.461

7.539822

10

-0.5

-1

-1.5

x 2 6.2831853 Figure 11 Root jumping from

intended
location of root for
http://numericalmethods.eng.us f x sin
30
. x0
f.edu

Potrebbero piacerti anche