solve.polynomial.RdFind the zeros, if any, of a given polynomial.
# S3 method for class 'polynomial'
solve(a, b, ...)A numeric vector, generally complex, of zeros.
This is a method for the generic function solve.
The zeros are found as the eigenvalues of the companion matrix, sorted according to their real parts.
p <- polynomial(6:1)
p
#> 6 + 5*x + 4*x^2 + 3*x^3 + 2*x^4 + x^5
## 6 + 5*x + 4*x^2 + 3*x^3 + 2*x^4 + x^5
pz <- solve(p)
pz
#> [1] -1.4917980+0.000000i -0.8057865-1.222905i -0.8057865+1.222905i
#> [4] 0.5516855-1.253349i 0.5516855+1.253349i
## [1] -1.49180+0.0000i -0.80579-1.2229i -0.80579+1.2229i
## [4] 0.55169-1.2533i 0.55169+1.2533i
## To retrieve the original polynomial from the zeros:
poly.calc(pz)
#> Warning: imaginary parts discarded in coercion
#> 6 + 5*x + 4*x^2 + 3*x^3 + 2*x^4 + x^5
## Warning: imaginary parts discarded in coercion
## 6 + 5*x + 4*x^2 + 3*x^3 + 2*x^4 + x^5