newtonHorner: Newton's Root Finding Method for Polynomials. In pracma: Practical Numerical Math Functions

Description

Finding roots of univariate polynomials.

Usage

 1 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.

Examples

 1 2 3 4 5 6 7 8 9 10 11 12 13 ## 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))

Example output

x0 = 1
x0 = 2
x0 = 3

pracma documentation built on Dec. 11, 2021, 9:57 a.m.