Function: realroots (<expr>, <bound>)
Function: realroots (<eqn>, <bound>)
Function: realroots (<expr>)
Function: realroots (<eqn>) Computes rational approximations of the real roots of the polynomial <expr> or polynomial equation <eqn> of one variable, to within a tolerance of <bound>. Coefficients of <expr> or <eqn> must be literal numbers; symbol constants such as
%pi are rejected.
realroots assigns the multiplicities of the roots it finds to the global variable
realroots constructs a Sturm sequence to bracket each root, and then applies bisection to refine the approximations. All coefficients are converted to rational equivalents before searching for roots, and computations are carried out by exact rational arithmetic. Even if some coefficients are floating-point numbers, the results are rational (unless coerced to floats by the
When <bound> is less than 1, all integer roots are found exactly. When <bound> is unspecified, it is assumed equal to the global variable
When the global variable
realroots returns a list of the form
[x = <x_1>, x = <x_2>, ...]. When
realroots creates intermediate expression labels
%t2, ..., assigns the results to them, and returns the list of labels.
(%i1) realroots (-1 - x + x^5, 5e-6); 612003 (%o1) [x = ------] 524288 (%i2) ev (%, float); (%o2) x = 1.167303085327148 (%i3) ev (-1 - x + x^5, %); (%o3) - 7.396496210176905E-6
(%i1) realroots (expand ((1 - x)^5 * (2 - x)^3 * (3 - x)), 1e-20); (%o1) [x = 1, x = 2, x = 3] (%i2) multiplicities; (%o2) [5, 3, 1]
(%o1) true (%i2)