Plotting Newton Method
Recall that Newton's Method, finds the place where a function crosses
the axis, by drawing a tangent line to the original function at a
specified (possibly random) StartingPoint and then repeating by
replacing the StartingPoint by the x coordinate of intersection of the
tangent line and the X axis. We first define a preliminary function
- show_newton(Function,StartingPoint,NumberOfIterations) which
takes three arguments:
- an Function is an expression x, ,
- a point to start at StartingPoint,
- a number of iterations of drawing the tangent line, and looking for
its intercept with the x axis.
It calculates and plots the curve as well
as the straight lines. See code .
- show_newton(x^2-2,7,4);
This shows 4 tangent lines, using different colors
lines are listed in order on the left. To do more lines replace the
4 by a higher number. The graph you see has a tangent line at the start
point x=7, and then another one where that tangent line meets the x axis,
and so on. The last line strikes the x axis very close to sqrt(2) where the
function crosses. When you get the graph you may want to go into
the config, and add more colors at the end, and click on 'replot'.
Result
gives
- show_newton(x^3+sin(x)+1,3,4); evaluates to
Result
gives
- show_newton(x^3+3*sin(x)-1,-.2,4); evaluates to
Result
gives
- show_newton(x^3+3*sin(x)-2,.3275,4); produces
Result
gives
- show_newton(x^3-4,.3275,6); evaluates to
Result
Go here to simply compute some approximations.