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.
eqs, <FixedPrecision>, <SquareFree>, <Factor>, <NoWarning>)
numeric::polyroots(eqs) returns numerical
approximations of all real and complex roots of the univariate polynomials
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
Up to roundoff effects, the numerical roots should be accurate
digits, unless the option
FixedPrecision is used.
All floating-point entries in
eqs are internally
approximated by rational numbers:
the roots of
For polynomial expressions in factored form, the numerical search is applied to each factor separately.
The function is sensitive to the environment variable
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
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:
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:
The following polynomial has badly separated roots.
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:
Alternatively, one can increase the working precision to separate the roots:
DIGITS := 20: numeric::polyroots(p)
delete p, DIGITS:
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
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
List of numerical roots.
The numerical root finding algorithm implemented by
Laguerre's method: W.H. Press, B.P. Flannery, S.A. Teukolsky and W.T.
Vetterling: Numerical Recipes in C, Cambridge
University Press, 1988.