Maxima Function
allroots (expr)
allroots(eqn)
Computes numerical approximations of the real and complex roots of the polynomial expr or polynomial equation eqn of one variable.
The flag polyfactor
when true
causes
allroots
to factor the polynomial over the real numbers if the
polynomial is real, or over the complex numbers, if the polynomial is
complex.
allroots
may give inaccurate results in case of multiple roots.
If the polynomial is real, allroots (%i*p)
) may yield
more accurate approximations than allroots (p)
,
as allroots
invokes a different algorithm in that case.
allroots
rejects non-polynomials. It requires that the numerator
after rat
'ing should be a polynomial, and it requires that the
denominator be at most a complex number. As a result of this allroots
will always return an equivalent (but factored) expression, if
polyfactor
is true
.
For complex polynomials an algorithm by Jenkins and Traub is used (Algorithm 419, Comm. ACM, vol. 15, (1972), p. 97). For real polynomials the algorithm used is due to Jenkins (Algorithm 493, ACM TOMS, vol. 1, (1975), p.178).
Examples:
(%i1) eqn: (1 + 2*x)^3 = 13.5*(1 + x^5); 3 5 (%o1) (2 x + 1) = 13.5 (x + 1) (%i2) soln: allroots (eqn); (%o2) [x = .8296749902129361, x = - 1.015755543828121, x = .9659625152196369 %i - .4069597231924075, x = - .9659625152196369 %i - .4069597231924075, x = 1.0] (%i3) for e in soln do (e2: subst (e, eqn), disp (expand (lhs(e2) - rhs(e2)))); - 3.5527136788005E-15 - 5.32907051820075E-15 4.44089209850063E-15 %i - 4.88498130835069E-15 - 4.44089209850063E-15 %i - 4.88498130835069E-15 3.5527136788005E-15 (%o3) done (%i4) polyfactor: true$ (%i5) allroots (eqn); (%o5) - 13.5 (x - 1.0) (x - .8296749902129361) 2 (x + 1.015755543828121) (x + .8139194463848151 x + 1.098699797110288)