powered by
Newton-Raphson root finder
newton(f, fp, x, tol = 0.001, m = 100)
The estimated root.
Function whose root is sought.
Derivative function of f.
f
Numeric starting value.
Convergence tolerance (default 1e-3).
1e-3
Maximum number of iterations (default \(100\)).
Iterates \(x_{new} = x - f(x)/f'(x)\) until the change is below tol or m iterations are reached (then issues a warning).
tol
m
# Solve x^2 - 2 = 0 newton(function(x) x^2 - 2, function(x) 2*x, 1)
Run the code above in your browser using DataLab