Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

newtonHorner

Newton's Root Finding Method for Polynomials.


Description

Finding roots of univariate polynomials.

Usage

newtonHorner(p, x0, maxiter = 50, tol = .Machine$double.eps^0.5)

Arguments

p

Numeric vector representing a polynomial.

x0

starting value for newtonHorner().

maxiter

maximum number of iterations; default 100.

tol

absolute tolerance; default eps^(1/2)

Details

Similar to newtonRahson, except that the computation of the derivative is done through the Horner scheme in parallel with computing the value of the polynomial. This makes the algorithm significantly faster.

Value

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

The estimated precision is given as the difference to the last solution before stop.

References

Quarteroni, A., R. Sacco, and F. Saleri (2007). Numerical Mathematics. Second Edition, Springer-Verlag, Berlin Heidelberg.

See Also

Examples

##  Example: x^3 - 6 x^2 + 11 x - 6  with roots 1, 2, 3
p <- c(1, -6, 11, -6)
x0 <- 0
while (length(p) > 1) {
    N <- newtonHorner(p, x0)
    if (!is.null(N$root)) {
        cat("x0 =", N$root, "\n")
        p <- N$deflate
    } else {
        break
    }
}
##  Try: p <- Poly(c(1:20))

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.