Newton's method (also known as the Newton-Raphson method or the Newton-Fourier method) is an efficient algorithm for finding approximations to the zeros (or roots) of a real-valued function .
The iteration goes on in this way:
From the starting value , vertical lines and points are plotted to show the location of the sequence of iteration values
,
, …; tangent lines are drawn to illustrate the relationship between successive iterations; the iteration values are in the right margin of the plot.
library(animation)
saveHTML({
ani.options(nmax = 100, interval = 1)
par(mar = c(3, 3, 1, 1.5), mgp = c(1.5, 0.5, 0), pch = 19)
newton.method(function(x) 5 * x^3 - 7 * x^2 - 40 * x + 100,
7.15, c(-6.2, 7.1), main = "")
}, img.name = "newton_method", htmlfile = "newton_method.html",
ani.height = 500, ani.width = 500, outdir = getwd(), title = "Demonstration of the Newton-Raphson Method",
description = c("Go along with the tangent lines and iterate."))