** 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 *x _{0}*, and third is the number of repetitions of Newton-Raphson.

For instance, to see the first 15 approximations to a root of *x ^{5}*-6

> with(CalcP);

> f := x -> x^5-6*x^4+x^3+2*x^2-5*x+7;

> Newton(f,x=-9,15);

This will display *x _{0}* and

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

*x*_{i} = . . . . . . , *Expr*(*x*_{i}) = . . . . . . .

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.

> NewtonPlot(f,x=a);

9/30/1997