numeric
::polyroots
Numerical roots of a univariate polynomial
MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
numeric::polyroots(eqs
, <FixedPrecision>, <SquareFree>, <Factor>, <NoWarning>)
numeric::polyroots(eqs)
returns numerical
approximations of all real and complex roots of the univariate polynomials eqs
.
The coefficients may be real or complex numbers. Also symbolic coefficients are accepted if they can be converted to floats.
The trivial polynomial eqs = 0 results in an error message. The empty list is returned for constant polynomials eqs ≠ 0.
Multiple roots are listed according to their multiplicities, i.e., the length of the root list coincides with the degree of eqs.
The root list is sorted by numeric::sort
.
Up to roundoff effects, the numerical roots should be accurate
to DIGITS
significant
digits, unless the option FixedPrecision
is used.
All floatingpoint entries in eqs
are internally
approximated by rational numbers: numeric::polyroots(eqs)
computes
the roots of numeric::rationalize(eqs, Minimize)
.
For polynomial expressions in factored form, the numerical search is applied to each factor separately.
It is recommended to use numeric::realroots
or polylib::realroots
if eqs
is
a real polynomial and only real roots are of interest.
The function is sensitive to the environment variable DIGITS
,
which determines the numerical working precision.
Both polynomial expressions as well as DOM_POLY
objects may be
used to specify the polynomial:
numeric::polyroots(x^3  3*x  sqrt(2))
numeric::polyroots(PI*z^4 + I*z + 0.1)
numeric::polyroots(poly(x^5  x^2, [x]))
The following polynomial has exact coefficients:
p := poly((x  1)*(x  PI)^3, [x]): numeric::polyroots(p)
Note that roundoff errors in the coefficients of eqs
have
a dramatic effect on multiple roots:
p := poly((x  1.0)*(x  float(PI))^3, [x]): numeric::polyroots(p)
These are the roots of the following rationalized polynomial:
numeric::rationalize(p, Minimize)
delete p:
The multiple root of the following polynomial can only be computed with restricted precision by fixed precision arithmetic:
p := poly((x^2  6*x +8)*(x  I/3)^5, [x]): numeric::polyroots(p, FixedPrecision)
Without the option FixedPrecision
, the working
precision is increased internally to compute better approximations:
numeric::polyroots(p)
delete p:
The following polynomial has badly separated roots. numeric::polyroots
does
not manage to separate them properly:
p := poly(_mult((x  1  i/10^9) $ i=0..5), [x]): numeric::polyroots(p)
One can preprocess the polynomial by a symbolic factorization:
numeric::polyroots(p, Factor)
Alternatively, one can increase the working precision to separate the roots:
DIGITS := 20: numeric::polyroots(p)
delete p, DIGITS:

A univariate polynomial expression or a univariate polynomial
of domain type 

This option provides the fastest way to obtain approximations of the roots by a numerical search with a fixed internal precision of 2 DIGITS decimal places. Note that badly isolated roots or multiple roots will usually
not be approximated to Without this option, 

With this option, a symbolic square free factorization is computed
via This option is recommended, when For polynomials with real rational coefficients, a square free factorization is always used, i.e., this option does not have any effect for such polynomials. For all other types of coefficients, a square free factorization may be costly and must be requested by this option. Multiple roots of 

With this option, a symbolic factorizations of This option is useful, when 

Suppresses warnings 
List of numerical roots.
The numerical root finding algorithm implemented by numeric::polyroots
is
Laguerre's method: W.H. Press, B.P. Flannery, S.A. Teukolsky and W.T.
Vetterling: Numerical Recipes in C, Cambridge
University Press, 1988.