# Newton's Method
## Learning Project Summary

* Project Code: Newton's Method
* School: Computer Science
* Department: Scientific Computing

## Content Summary

This learning project offers learning activities to Newton's Method. In this course, students will learn how to solve problems of the type$f(x)=0\,$ using the Newton’s Method, also called the Newton-Raphson iteration.

## Derivation of the Newton's Method

In Newton’s method, we must first assume that the function is differentiable, i.e. that function$f\,$ has a definite slope at each point. Hence at any point$(x_{0},f(x_{0}))\,$, we can calculate the tangent$f'\!(x_{0})\,$, which is a fairly good approximation to the curve at that point. Alternatively, we can see that linear function
$l(x)=f'\!(x_{0})(x-x_{0})+f(x_{0})$
is quite close to function$f\,$ near point $x_{0}\,$, and at $x_{0}\,$, the functions $l\,$ and$f\,$ give the same value. Hence, we take it that the solution to the problem $l(x)=0\,$ will give a fairly good approximation to the problem$f(x)=0\,$.
The zero of $l(x)\,$ 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 $x_{0}\,$ be our approximation to the problem $f(x)=0\,$, then we try to solve for the correction h such that
If $f\,$ is well-behaved function, we can then write the Taylor series at $x_{0}\,$ 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 $f\,$ 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: $\lim _{n\rightarrow \infty }x_{n}=r\,$ where r is the root of $f\,$.

## Code

The following is an example of a function that can be written using MATLAB to perform Newton's Method on any given mathematical function $f\,$.

## Example

We try to locate the root of the equation $f(x)=x^{3}-2x^{2}+x-3\,$ with initial starting point $x_{0}\,$ = 3. Note also that the derivative of the above function is $f'\!(x)=3x^{2}-4x+1$
Then we do the following:

## Problems and Restrictions of Newton's Method

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

Newton's method is said to converge quadratically to the root r, if r is a simple root, i.e. $f'\!(r)\neq \;0$. This means that the errors obey the inequality$|r-x_{n+1}|\leq \;c|r-x_{n}|^{2}$.
Using the Taylor Series, we see that there exists some point $\xi \,$ between $x_{n}\,$ and $r\,$ such that
Dividing the last equation throughout by $f'\!(x_{n})$, we get
Substituting the equation used in Newton's Method, we get
Thus

## Exercises

* Locate the root of $f(x)=\cos(2x)+\sin(3x)\,$ nearest $\pi \,$ using Newton's method.
* Two of the four zeros of $f(x)=x^{4}+3x^{3}-5x^{2}+1\,$ are positive. Find them by Newton's method, correct to two significant figures.