roots: Polynomial Roots

View source: R/roots.R

roots, polyrootsR Documentation

Polynomial Roots

Description

Computes the roots (and multiplicities) of a polynomial.

Usage

  roots(p)
  polyroots(p, ntol = 1e-04, ztol = 1e-08)

  rootsmult(p, r, tol=1e-12)

Arguments

p

vector of real or complex numbers representing the polynomial.

r

a possible root of the polynomial.

tol, ntol, ztol

norm tolerance and accuracy for polyroots.

Details

The function roots computes roots of a polynomial as eigenvalues of the companion matrix.

polyroots attempts to refine the results of roots with special attention to multiple roots. For a reference of this implementation see F. C. Chang, "Solving multiple-root polynomials", IEEE Antennas and Propagation Magazine Vol. 51, No. 6 (2010), pp. 151-155.

rootsmult determines te order of a possible root r. As this computation is problematic in double precision, the result should be taken with a grain of salt.

Value

roots returns a vector holding the roots of the polynomial, rootsmult the multiplicity of a root as an integer. And polyroots returns a data frame witha column 'root' and a column 'mult' giving the multiplicity of that root.

See Also

polyroot

Examples

  roots(c(1, 0, 1, 0, 0))                     # 0 0 1i -1i
  p <- Poly(c(-2, -1, 0, 1, 2))               # 1*x^5 - 5*x^3 + 4*x
  roots(p)                                    # 0 -2  2 -1  1

  p <- Poly(c(rep(1, 4), rep(-1, 4), 0, 0))   # 1  0 -4  0  6  0 -4  0  1
  rootsmult(p, 1.0); rootsmult(p, -1.0)       # 4  4
  polyroots(p)
  ##   root mult
  ## 1    0    2
  ## 2    1    4
  ## 3   -1    4

pracma documentation built on March 19, 2024, 3:05 a.m.