powered by
Use Newton's method to find real roots
newton(f, fp, x, tol = 0.001, m = 100)
function to integrate
function representing the derivative of f
f
an initial estimate of the root
the error tolerance
the maximum number of iterations
the real root found
Newton's method finds real roots of a function, but requires knowing the function derivative. It will return when the interval between them is less than tol, the error tolerance. However, this implementation also stops after m iterations.
tol
m
Other optimz: bisection(), goldsect, gradient, hillclimbing(), sa(), secant()
bisection()
goldsect
gradient
hillclimbing()
sa()
secant()
# NOT RUN { f <- function(x) { x^3 - 2 * x^2 - 159 * x - 540 } fp <- function(x) {3 * x^2 - 4 * x - 159 } newton(f, fp, 1) # }
Run the code above in your browser using DataLab