# Newton's Method

## Learning Project Summary

[edit | edit source]**Project Code: Newton's Method****School: Computer Science****Department: Scientific Computing**

## Content Summary

[edit | edit source]This learning project offers learning activities to Newton's Method. In this course, students will learn how to solve problems of the type using the Newton’s Method, also called the Newton-Raphson iteration.

## Derivation of the Newton's Method

[edit | edit source]In Newton’s method, we must first assume that the function is differentiable, i.e. that function has a definite slope at each point. Hence at any point, we can calculate the tangent, which is a fairly good approximation to the curve at that point. Alternatively, we can see that linear function

is quite close to function near point , and at , the functions and give the same value. Hence, we take it that the solution to the problem will give a fairly good approximation to the problem.

The zero of can be easily found:

This can be done repeatedly to produce points with the following equation:

```
```

An alternative way of viewing Newton’s method is as follows: we let be our approximation to the problem , then we try to solve for the correction *h* such that

```
```

If is well-behaved function, we can then write the Taylor series at as

```
```

By dropping all but the first two terms of the series, we can achieve an approximation of *h* through the equation

```
```

Solving for *h*, we then achieve our next approximation to the root of with the equation

```
```

Repeating this process results in the recursive definition of Newton’s Method

```
```

The success of Newton’s method depends on whether the following equation holds:
where r is the root of .

## Code

[edit | edit source]The following is an example of a function that can be written using MATLAB to perform Newton's Method on any given mathematical function .

```
function x = Newton(f, fp, x, nmax, e)
% f is an inline function which we apply Newton's method on
% fp is an inline function that is the derivative of function f
% x is the initial guess of the root
% nmax is the total number of iterations done
% e is the error used to control convergence
fprintf('x(0) = %10g \n', x)
for n = 1:nmax
d = f(x)/fp(x);
x = x - d;
fprintf('x(%i) = %10g \n', n, x)
if abs(d) < e
fprintf('Converged! \n')
return
end
end
```

## Example

[edit | edit source]We try to locate the root of the equation with initial starting point = 3. Note also that the derivative of the above function is

Then we do the following:

```
declare our function f
f = inline('x^3 - 2*x^2 + x - 3');
% declare the derivative of function f
fp = inline('3*x^2 - 4*x + 1');
% declare total number of iterations to be undertaken
nmax = 10;
% declare value of initial starting point
x = 3.0;
% declare amount of error allowed
e = 1.0e-15;
% carry out iteration using function above
x = Newton(f,fp,x,nmax,e)
% results are as follows:
x(0) = 3
x(1) = 2.4375
x(2) = 2.21303
x(3) = 2.17555
x(4) = 2.17456
x(5) = 2.17456
x(6) = 2.17456
x(7) = 2.17456
Converged!
x =
2.174559410292980
```

## Problems and Restrictions of Newton's Method

[edit | edit source]Firstly, and most obviously, Newton's Method can only be applied with functions that are differentiable. This can be seen straight from the formula, where f’(x) is a necessary part of the iterative function.

Secondly, the starting point must be chosen carefully, and it is best chosen with an approximate idea of the graph of the function in mind. If chosen wrongly, one of the following three situations could happen:

- Runaway: In which Newton’s Method leads away from the root instead of towards the root; the solution diverges rather than converges.
- Flat Spot: In which the derivative of the graph at the starting point is 0, and thus the next iterative point occurs at infinity and cannot be used.
- Cycle: In which the solutions cycle between two points, and never converges to the root.

## Convergence

[edit | edit source]Newton's method is said to converge quadratically to the root r, if r is a simple root, i.e. . This means that the errors obey the inequality.

Using the Taylor Series, we see that there exists some point between and such that

```
```

Dividing the last equation throughout by , we get

```
```

Substituting the equation used in Newton's Method, we get

```
```

Thus

```
```

## Exercises

[edit | edit source]- Locate the root of nearest using Newton's method.
- Two of the four zeros of are positive. Find them by Newton's method, correct to two significant figures.

## References

[edit | edit source][1] Cheney, Ward and Kincaid, David. __Numerical Mathematics and Computing__. 6th Edition. United States: Thomson Brooks/Cole, 2008.

## Active Participants

[edit | edit source]Active participants in this Learning Group