Last chance! 50% off unlimited learning
Sale ends in
newtonRaphson(fun, x0, dfun = NULL, ...,
maxiter = 100, tol = .Machine$double.eps^0.5)secant(fun, a, b, ..., maxiter = 100, tol = .Machine$double.eps^0.5)
f
.
If NULL
, a numeric derivative will be computed.secant
one of the two starting values.eps^(1/2)
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 last solution before stop; this may be misleading.
newtonHorner
# Legendre polynomial of degree 5
lp5 <- c(63, 0, -70, 0, 15, 0)/8
f <- function(x) polyval(lp5, x)
newtonRaphson(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
Run the code above in your browser using DataLab