polyroot: Find Zeros of a Real or Complex Polynomial

Description Usage Arguments Details Value Source References See Also Examples

View source: R/New-Internal.R

Description

Find zeros of a real or complex polynomial.

Usage

1

Arguments

z

the vector of polynomial coefficients in increasing order.

Details

A polynomial of degree n - 1,

p(x) = z1 + z2 * x + … + z[n] * x^(n-1)

is given by its coefficient vector z[1:n]. polyroot returns the n-1 complex zeros of p(x) using the Jenkins-Traub algorithm.

If the coefficient vector z has zeroes for the highest powers, these are discarded.

There is no maximum degree, but numerical stability may be an issue for all but low-degree polynomials.

Value

A complex vector of length n - 1, where n is the position of the largest non-zero element of z.

Source

C translation by Ross Ihaka of Fortran code in the reference, with modifications by the R Core Team.

References

Jenkins and Traub (1972) TOMS Algorithm 419. Comm. ACM, 15, 97–99.

See Also

uniroot for numerical root finding of arbitrary functions; complex and the zero example in the demos directory.

Examples

1
2
3
4
polyroot(c(1, 2, 1))
round(polyroot(choose(8, 0:8)), 11) # guess what!
for (n1 in 1:4) print(polyroot(1:n1), digits = 4)
polyroot(c(1, 2, 1, 0, 0)) # same as the first

robertzk/monadicbase documentation built on May 27, 2019, 10:35 a.m.