Student[Calculus1]
NewtonsMethod
demonstrate Newton's method
Calling Sequence
Parameters
Description
Examples
NewtonsMethod(f(x), x = a, opts)
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
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 Newton-Raphson 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 x-intercept b of the line tangent to the expression that passes through the point a,f⁡a:
b=xi−f⁡xif'⁢xi
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.
functionoptions = list
A list of options for the plot of the expression f⁡x. By default, the expression is plotted as a solid red line. For more information on plot options, see plot/options.
iterations = posint
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.
pointoptions = list
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⁡x 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.
showroot = true or false
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.
tangentoptions = list
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.
caption = anything
A caption for the plot.
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.
title = anything
A title for the plot.
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.
with⁡StudentCalculus1:
NewtonsMethod⁡sin⁡x+1,x=1
−1.619017361
NewtonsMethod⁡sin⁡x+1,x=2,output=sequence
2,6.588037826,5.225039135,4.962948756,4.837009302,4.774618375
NewtonsMethod⁡x3−x,x=−0.432,view=−2..1,DEFAULT,output=plot
NewtonsMethod⁡x3−x,x=2,view=0..3,DEFAULT,output=plot
To play the following animation in this help page, right-click (Control-click, on Mac) 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⁡x2+x+1,x=2,output=plot
See Also
plot/options
plot/typesetting
Student
Student plot options
Student[Calculus1][NewtonQuotient]
Student[Calculus1][NewtonsMethodTutor]
Download Help Document