Next: Exercises Up: The Newton-Raphson Method Previous: Background
The CalcP package (which must be called using the with(CalcP); command) contains an implementation of the Newton-Raphson method called Newton. This Newton command takes three arguments. The first is the function that is set equal to zero, next is the initial guess x0, and third is the number of repetitions of Newton-Raphson.
For instance, to see the first 15 approximations to a root of x5-6x4+x3+2x2-5x+7=0 when x0 is taken as -9, the syntax would be as follows.
> f := x -> x^5-6*x^4+x^3+2*x^2-5*x+7;
This will display x0 and f(x0) and xn and f(xn) for n equal 1 to 15. By looking at the f(xn), one can see if f(xn) is tending to 0 as n increases.
If an expression is used as the first argument of Newton as in
> Newton(x^7-5*x^3-3*x+7,x=2,10);then each line of output will be of the form
xi = . . . . . . , Expr(xi) = . . . . . . ..
In the CalcP package there is a routine called NewtonPlot which can help you visualize the action of the Newton-Raphson algorithm. You may find it useful in dealing with some of the exercises below. Basically, it plots the sequence of approximations to a root generated by Newton-Raphson. The syntax is as follows where a is the initial guess for a root.
William W. Farr