| newtonRaphson {pracma} | R Documentation |
Finding roots of univariate functions.
newtonRaphson(fun, x0, dfun = NULL, ...,
maxiter = 100, tol = .Machine$double.eps^0.5)
newton(fun, x0, dfun = NULL, ...,
maxiter = 100, tol = .Machine$double.eps^0.5)
secant(fun, a, b, ..., maxiter = 100, tol = .Machine$double.eps^0.5)
fun |
Function or its name as a string. |
x0 |
starting value for newtonRaphson(). |
dfun |
A function to compute the derivative of |
a |
For |
b |
Another starting value. |
maxiter |
maximum number of iterations; default 100. |
tol |
absolute tolerance; default |
... |
Additional arguments to be passed to f. |
Well known root finding algorithms for real, univariate, continuous functions.
Return a list with components root, f.root,
the function value at the found root, iter, the number of iterations
done, and root, and the estimated precision estim.prec
For both methods the estimated precision is given as the difference to the last solution before stop; this may be misleading.
Quarteroni, A., R. Sacco, and F. Saleri (2007). Numerical Mathematics. Second Edition, Springer-Verlag, Berlin Heidelberg.
# Legendre polynomial of degree 5 lp5 <- c(63, 0, -70, 0, 15, 0)/8 f <- function(x) polyval(lp5, x) newton(f, 1.0) # 0.9061798459 correct to 10 decimals in 5 iterations secant(f, 0.9, 1) # 0.9061798459 correct to 10 decimals in 5 iterations