
Calling Sequence


NewtonsMethod(f(x), x = a, opts)


Parameters


f(x)



algebraic expression in variable 'x'

x



name; specify the independent variable

a



algebraic expression, assumed to be real; specify initial point

opts



equation(s) of the form option=value where option is one of functionoptions, iterations, output, pointoptions, showfunction, showpoints, showroot, showtangents, showverticallines, tangentoptions, verticallineoptions, or Student plot options; specify output options





Description


•

The NewtonsMethod(f(x), x=a) command returns the result of applying 5 iterations of Newton's method for approximating a root. This method is also known as the NewtonRaphson method. By using options, you can specify that the command returns a plot, animation, or sequence of iterations instead.

•

If the independent variable can be uniquely determined from the expression, the parameter x need not be included in the calling sequence.

•

Given an initial approximation a of a root (a zero) of an expression expr, Newton's method attempts to improve the approximation by finding the xintercept b of the line tangent to the expression that passes through the point $\left(a\,f\left(a\right)\right)$:

$b={x}_{i}\frac{f\left({x}_{i}\right)}{\mathrm{f\text{'}}\left({x}_{i}\right)}$

In general, by repeating this process, you obtain a better approximation.

•

The opts argument can contain any of the Student plot options or any of the following equations that (excluding output) set plot options.


A list of options for the plot of the expression $f\left(x\right)$. By default, the expression is plotted as a solid red line. For more information on plot options, see plot/options.


The number of times that Newton's method is applied iteratively to a. If a root is found, the routine may perform fewer than this number of iterations.


output = value, sequence, plot, or animation


This option controls the return value of the function.

–

output = value specifies that the approximation after $5$ iterations of Newton's method is returned. Plotting options are ignored if output = value. This is the default.

–

output = sequence specifies that a sequence of iterations of Newton's method is returned. Plotting options are ignored if output = sequence.

–

output = plot specifies that a plot, which shows the expression and the Newton iterations from the initial point a, connecting these points with lines to show the progression, is returned.

–

output = animation specifies that an animation demonstrating successive iterations of Newton's method is returned.


A list of options for the plot of the Newton iterates and the expression evaluated at these points. By default, these points are plotted as circles. For more information on plot options, see plot/options.


showfunction = true or false


Whether the expression $f\left(x\right)$ is plotted. By default, the value is true.


showpoints = true or false


Whether the Newton iterates and the expression evaluated at these points are marked. By default, the value is true.


If this option is set to true, the last approximation is given to fsolve as an initial point, and if fsolve finds a root, it is plotted as a box. By default, the value is false.


showtangents = true or false


Whether the tangent lines of the expression evaluated at the Newton iterates is plotted. By default, the value is true.


showverticallines = true or false


Whether the lines from the Newton iterates and the expression evaluated at these points are plotted. By default, the value is true.


A list of options for the plot of the tangents where the expression is evaluated at the Newton iterates. By default, these are plotted as solid blue lines. For more information on plot options, see plot/options.


verticallineoptions = list


A list of options for the plot of the vertical lines connecting the Newton iterates and the expression evaluated at these points. By default, these are plotted as dashed blue lines. For more information on plot options, see plot/options.


The default caption is constructed from the parameters and the command options. caption = "" disables the default caption. For more information about specifying a caption, see plot/typesetting.


The default title is constructed from the parameters and the command options. title = "" disables the default title. For more information about specifying a title, see plot/typesetting.



Examples


>

with(Student[Calculus1]):

>

NewtonsMethod(sin(x) + 1, x = 1);

${\mathrm{1.619017361}}$
 (1) 
>

NewtonsMethod(sin(x) + 1, x = 2, output = sequence);

${2}{,}{6.588037826}{,}{5.225039135}{,}{4.962948756}{,}{4.837009302}{,}{4.774618375}$
 (2) 
>

NewtonsMethod(x^3  x, x = 0.432, view = [2..1, DEFAULT], output = plot);

>

NewtonsMethod(x^3  x, x = 2, view = [0..3, DEFAULT], output = plot);

To play the following animation in this help page, rightclick (Controlclick, on Macintosh) the plot to display the context menu. Select Animation > Play.
>

NewtonsMethod(x*sin(x), x = 1, output = animation);

The command to create the plot from the Plotting Guide is
>

NewtonsMethod(x^2 + x + 1, x=2, output=plot);



