AssertionError when finding roots over the Real Algebraic Field

21 views
Skip to first unread message

Tracy Hall

unread,
Sep 22, 2021, 3:10:41 AM9/22/21
to sage-support
I ran into an assertion error when trying to return a sorted list whose key was a certain linear combination of eigenvalues of the Laplacian matrix over graphs on nine vertices. Digging into it a bit, the failure happened when comparing an algebraic real number against the same number that was constructed differently (starting with the graph complement). Digging further, the error happens when finding roots of a certain degree 56 polynomial over AA (all the roots are real) but there is no error doing the same thing over QQbar.

Here is a minimal working example:

P.<z> = QQ[]
rootlist = (z^8 - 32*z^7 + 425*z^6 - 3044*z^5 + 12789*z^4 - 32090*z^3 + 46672*z^2 - 35734*z + 10917).roots(AA)
problem = rootlist[-1][0] - rootlist[0][0] - 9

problem.minpoly().roots(AA)

Dima Pasechnik

unread,
Sep 22, 2021, 4:19:50 AM9/22/21
to sage-support, sage-devel, sage-nt
indeed, problem.minpoly().roots(QQbar) produces a list of 56 QQbar elements, more precisely, pairs (t,1)), each t convertible into AA.
One funny discrepancy is that one of the elements of this list is shown as
(-6.390396068452545? + 0.?e-170*I, 1)

sage: rrr=problem.minpoly().roots(QQbar)
sage: rrr[-1]
(-6.390396068452545? + 0.?e-170*I, 1)
sage: AA(rrr[-1][0])
-6.390396068452545?

Not sure whether this is the cause of the bug, though.

Dima

Dima Pasechnik

unread,
Sep 22, 2021, 4:23:15 AM9/22/21
to sage-support, sage-devel, sage-nt
The behaviour  of QQbar is not very consistent there. Only one root is shown with an imaginary part, but
the polynomial has integer coefficients --- it ought to "know" that complex roots come in pairs :-)


Dima

John Cremona

unread,
Sep 22, 2021, 7:06:15 AM9/22/21
to sage-nt, sage-support, sage-devel
More generally uf all the coefficients can be coerced into AA then the roots in QQbar not in AA come in pairs.

--
You received this message because you are subscribed to the Google Groups "sage-nt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-nt+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-nt/CAAWYfq35Omovg-jPnG6a3eKLLa%2BpaL-%3D%3DCRFpgPRasn%2BwBf8qA%40mail.gmail.com.

Tracy Hall

unread,
Sep 22, 2021, 6:54:20 PM9/22/21
to sage-support
I wondered whether the not-obviously-real output of roots(QQbar) were related to the cause of the but, too, but I have seen other polynomials with all real roots for which roots(QQbar) gives one or several roots that instead of showing as exactly real are displayed with an imaginary part that is zero to within the given precision, but for which roots(AA) correctly identifies them as among the real roots.

Here by the way is how this problem manifests as an assertion error even when simply checking whether two algebraic reals are equal:

P.<z> = QQ[]
poly = z^8 - 32*z^7 + 425*z^6 - 3044*z^5 + 12789*z^4 - 32090*z^3 + 46672*z^2 - 35734*z + 10917
rootlist1 = poly.roots(AA)
a = rootlist1[-1][0] - rootlist1[0][0] - 9; a

rootlist2 = poly(z=9 - z).roots(AA)
b = rootlist2[-1][0] - rootlist2[0][0] - 9; b

a == b
Reply all
Reply to author
Forward
0 new messages