ASCIIMathML-SVG A demonstration of Newton's method.

If `f(x)` is a differentiable function, with derivative `f'(x)`, and we want to find approximate solutions to `f(x)=0`, then we can follow the approach Newton took: Start with an initial approximation `x_1`, calculate the tangent line to `f(x)` through the point `(x_1,f(x_1))`, and find the point where this line cuts the `x`-axis. Since the tangent line is an approximation to `f(x)` near `x_1`, this point is usually a better approximation for a solution to `f(x)=0`, so we call it `x_2` and repeat the process.

The equations of the tangent line is `y-f(x_1)=f'(x_1)(x-x_1)`, so we let `y=0` and solve for `x`.

`=> 0-f(x_1)=f'(x_1)(x-x_1)` `=> x-x_1=(-f(x_1))/(f'(x_1))` `=> x=x_1-(f(x_1))/(f'(x_1))`

Therefore `x_2=x_1-(f(x_1))/(f'(x_1))`, and when we repeat this process with `x_2`, we get `x_3=x_2-(f(x_2))/(f'(x_2))`. So, in general, the formula for Newton's method is `x_(n+1)=x_n-(f(x_n))/(f'(x_n))`.

 `y=x^3-x-1` ```agraph setViewport(400,400,0); setGraphArea(-10,10,-10,10); initPicture(); drawGraphArea(); p = []; for (var x = -3; x < 3+.01; x += 0.1) p[p.length] = [x, x*x*x-2]; stroke = "red"; path(p,"func"); xn = [0,1]; stroke = "blue"; update(); endagraph ``` `x_1=` x `x_2=` x `x_3=` x `x_4=` x `x_5=` x `x_6=` x `x_7=` x `x_8=` x `x_9=` x
.

Move the pointer over the graph to see what happens with other initial values. Note that if the function has local maxima and minima below (or above) the `x`=axis near the root we are trying to approximate, then the procedure can have difficulties finding the root.

Here is the ASCIIsvg code that produces the interactive picture.

```<script>
function update() {
for (var i = 1; i < 10; i++) {
setText(xn[i],"xn"+i);
if (xn[i] != NaN) {
fxi = xn[i]*xn[i]*xn[i]-2;
fpxi = 3*xn[i]*xn[i];
}
if (fpxi != 0) xn[i+1]=xn[i]-fxi/fpxi;
else xn[i+1] = NaN;
if (xn[i] != NaN) {
line([xn[i],fxi],[xn[i],0],"vertical"+i);
if (xn[i+1] != NaN) line([xn[i],fxi],[xn[i+1],0],"tangent"+i);
}
}
xn = xcoord;
}
</script>``` The original ASCIIMathML and ASCIIsvg scripts have been developed by by Peter Jipsen, Chapman University (jipsen@chapman.edu) LaTeXMathML has been developed by Douglas Woodall (and exteded by Jeff Knisley), based on ASCIIMathML The version of ASCIIMathML used here, is a modified and extended version, developed by Dr.ir. S.A. Miedema Other sources: An ASCIIsvg manual by Robert Fant.  An ASCIIsvg manual by Peter Jipsen. An ASCIIMathML manual by James Gray. Plugins and fonts required (depending on your browser): MIT MathML font packages, MathPlayer, Adobe SVGviewer Look at: http://www.w3.org/TR/SVG11/ for detailed information about SVG. Look at: http://www.w3.org/Math/ for detailed information about MathML Copyright © Dr.ir. S.A. Miedema, Delft University of Technology, Faculty of Mechanical Engineering, Marine Technology & Materials Science Department of Marine & Transport Technology, The Chair of Dredging Engineering 