rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

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

Open rtoy opened 3 months ago

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-08 07:12:21 Created by willisbl on 2005-01-28 12:03:05 Original: https://sourceforge.net/p/maxima/bugs/678


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 (TRUE); (%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 (TRUE);

(%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

Barton

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-08 07:12:21 Created by macrakis on 2005-01-30 22:44:12 Original: https://sourceforge.net/p/maxima/bugs/678/#52dd


Logged In: YES user_id=588346

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 arithmetic.

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....

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-08 07:12:25 Created by robert_dodier on 2006-08-04 05:42:15 Original: https://sourceforge.net/p/maxima/bugs/678/#db5c


rtoy commented 3 months ago

Imported from SourceForge on 2024-07-08 07:12:29 Created by robert_dodier on 2006-09-09 03:54:54 Original: https://sourceforge.net/p/maxima/bugs/678/#d542