#678 nroots(sqrt(3),minf,inf) & ....


nroots claims that 1 isn't a univariate polynomial,
and that sqrt(3) is. This is chaotic. Further,

nroots(%pi,minf,inf) --> 1,
nroots(sqrt(3),minf,inf) --> 1.

These are both wrong. It's not clear from the
documentation, but it seems that nroots does
not allow algebraic coefficients; if that's the
case, the documentation should say so. Finally,
nroots counts multiplicities, but the user
documentation doesn't say that it does.

(%i1) nroots(1,minf,inf);
Argument must be a univariate polynomial
-- an error. Quitting. To debug this try DEBUGMODE
(%i2) nroots(sqrt(3),minf,inf);
(%o2) 1
(%i3) nroots(%pi,minf,inf);
(%o3) 1
(%i4) nroots(sqrt(3)*x+sqrt(7));
Argument must be a univariate polynomial
-- an error. Quitting. To debug this try DEBUGMODE

(%i14) nroots(x^2,minf,inf);
(%o14) 2

One more comment about the documentation--it
doesn't mention what happends when low > high.

(%i18) nroots(x^2,1,-1);
(%o18) - 2

Maxima version: 5.9.1
Maxima build date: 7:34 9/24/2004
host type: i686-pc-mingw32
lisp-implementation-type: Kyoto Common Lisp
lisp-implementation-version: GCL 2.6.5



  • Stavros Macrakis

    Logged In: YES

    Agreed that the univariate polynomial stuff is random.

    As for excluding algebraic coefficients.... I agree that
    this should be documented. The method (Sturm sequences) is
    exact for exact evaluation of polynomials. Exact evaluation
    is easy for rational coefficients. The result is
    approximate for approximate coefficients (floats), which is
    also fine. However, though algebraic numbers are exact,
    calculating with them exactly is a problem. If this matters
    to you, I suppose you can use increasingly precise intervals
    until the signs are unambiguous (though checking for 0 is
    harder...), but Maxima doesn't currently support interval

    Anyway, what I would suggest is not changing the
    documentation, but instead converting algebraic numbers to
    rationals (at what precision?) and giving the warning:

    Warning: nroots will not always give exact results with
    non-rational coefficients

    Unfortunately, nroots does not currently support bfloats....

  • Robert Dodier

    Robert Dodier - 2006-08-04
    • labels: --> 460522
  • Robert Dodier

    Robert Dodier - 2006-09-09
    • labels: 460522 --> Lisp Core - Polynomials

Log in to post a comment.