\HeaderA{polyroot}{Find Zeros of a Real or Complex Polynomial}{polyroot}
\keyword{math}{polyroot}
\begin{Description}\relax
Find zeros of a real or complex polynomial.
\end{Description}
\begin{Usage}
\begin{verbatim}
polyroot(z)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{z}] the vector of polynomial coefficients in increasing order.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
A polynomial of degree \eqn{n - 1}{},
\deqn{
p(x) = z_1 + z_2 x + \cdots + z_n x^{n-1}}{p(x) = z1 + z2 * x + \ldots + z[n] * x^(n-1)}
is given by its coefficient vector \code{z[1:n]}.
\code{polyroot} returns the \eqn{n-1}{} complex zeros of \eqn{p(x)}{}
using the Jenkins-Traub algorithm.

If the coefficient vector \code{z} has zeroes for the highest powers,
these are discarded.

As from \R{} 2.8.0 there is no maximum degree, but numerical stability
may be an issue for all but low-degree polynomials.
\end{Details}
\begin{Value}
A complex vector of length \eqn{n - 1}{}, where \eqn{n}{} is the position
of the largest non-zero element of \code{z}.
\end{Value}
\begin{References}\relax
Jenkins and Traub (1972)
TOMS Algorithm 419.
\emph{Comm. ACM}, \bold{15}, 97--99.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{uniroot}{uniroot}} for numerical root finding of arbitrary
functions;
\code{\LinkA{complex}{complex}} and the \code{zero} example in the demos
directory.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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
\end{ExampleCode}
\end{Examples}

