Matrices over QQbar

120 views
Skip to first unread message

Hakan Granath

unread,
May 3, 2024, 9:05:03 AMMay 3
to sage-...@googlegroups.com
Hi,

I think sometimes matrices over QQbar give erroneous results (sorry for the messy example, if I try to simplify it the problem disappears):

R.<y> = QQ[]
v1 = QQbar.polynomial_root(AA.common_polynomial(y^2 + 1), CIF(RIF(RR(0)), RIF(-RR(1))))
v2 = QQbar.polynomial_root(AA.common_polynomial(y^2 + 1), CIF(RIF(RR(0)), RIF(RR(1))))
v3 = 4*v2
v4 = AA.polynomial_root(AA.common_polynomial(y^2 - 2), RIF(-RR(1.4142135623730951), -RR(1.4142135623730949)))
v5 = AA.polynomial_root(AA.common_polynomial(y^2 - 2), RIF(RR(1.4142135623730949), RR(1.4142135623730951)))
v6 = QQbar.polynomial_root(AA.common_polynomial(y^2 + 16), CIF(RIF(RR(0)), RIF(-RR(4))))
v7 = v6*v6
v8 = QQbar.polynomial_root(AA.common_polynomial(y^2 + 1), CIF(RIF(RR(0)), RIF(RR(1))))

M = matrix(QQbar, [[0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [-4, 2*v1, 1, 64, -32*v1, -16, 8*v1, 4, -2*v1, -1], [4*v1, 1, 0, -192*v1, -80, 32*v1, 12, -4*v1, -1, 0], [2, 0, 0, -480, 160*v1, 48, -12*v1, -2, 0, 0], [-4, 2*v2, 1, 64, -32*v2, -16, 8*v2, 4, -2*v2, -1], [v3, 1, 0, -192*v2, -80, 32*v2, 12, -v3, -1, 0], [2, 0, 0, -480, 160*v2, 48, -12*v2, -2, 0, 0], [0, 0, 0, 8, QQbar(4*v4), 4, QQbar(2*v4), 2, QQbar(AA.polynomial_root(AA.common_polynomial(y^2 - 2), RIF(-RR(1.4142135623730951), -RR(1.4142135623730949)))), 1], [0, 0, 0, QQbar(24*v4), 20, QQbar(8*v4), 6, QQbar(2*v4), 1, 0], [0, 0, 0, 8, QQbar(4*v5), 4, QQbar(2*v5), 2, QQbar(AA.polynomial_root(AA.common_polynomial(y^2 - 2), RIF(RR(1.4142135623730949), RR(1.4142135623730951)))), 1], [0, 0, 0, QQbar(24*v5), 20, QQbar(8*v5), 6, QQbar(2*v5), 1, 0], [0, 0, 0, v7*v7*v7, v7*v7*v6, v7*v7, v6*v6*v6, v6*v6, v6, 1], [0, 0, 0, -4096, 1024*v8, 256, -64*v8, -16, 4*v8, 1]])

With this matrix I get:

  sage: M.right_kernel_matrix()
  []

but in fact the right kernel is generated by:

  sage: v = Matrix(QQbar, 10, 1, [-108, 0, 0, 1, 0, 12, 0, -60, 0, 64])
  sage: M * v == 0
  True

This is with SageMath version 10.3 using Python 3.11.1 on Ubuntu 22.04.4.

Best regards,

Håkan Granath

vdelecroix

unread,
May 3, 2024, 12:13:02 PMMay 3
to sage-devel
Thanks for your report! I simplified a bit your example and posted an issue https://github.com/sagemath/sage/issues/37927.

Vincent

Vincent Delecroix

unread,
May 5, 2024, 6:15:40 PMMay 5
to sage-...@googlegroups.com
Turns out to be a serious bug in complex interval fields. The problem
is hopefully fixed by https://github.com/sagemath/sage/pull/37941
which should make its way to the next sage release.

Thanks again for your report.
Vincent
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/1c927686-bada-4943-8000-a6fdf6e71029n%40googlegroups.com.

Hakan Granath

unread,
May 6, 2024, 3:27:24 AMMay 6
to sage-...@googlegroups.com
Great, thanks for working out and fixing the (quite non-trivial, it seems) root cause of this issue!

Just a curious question: would it be useful to add the functionality of your commit 8de6ba5 to potentially simplify QQbar objects? Especially doing linear algebra over QQbar I guess you get many trivial operations (like adding 0) and optimizing them away might maybe improve performance? Just an idea, I haven't done any benchmarking to support that hypothesis.

Best regards,

Håkan

Vincent Delecroix

unread,
May 6, 2024, 3:57:51 AMMay 6
to sage-...@googlegroups.com
The fix was easy. Much harder was to find the root of the problem!

If you are interested in intensive computations over QQbar I strongly
advise you to look towards https://flintlib.org/ maintained by Fredrik
Johansson. This library has *two* implementations of QQbar which are
way more performant (and probably more reliable) than what is in
SageMath. The more or less short term goal is to use flint
implementations to replace the current QQbar implementation in
SageMath.You could give it a try inside SageMath via
https://github.com/mezzarobba/flint_gr_sage (feel free to open an
issue there asking for installation help or describing the things you
want to compute).

I do intend to make my commit part of SageMath QQbar, but it is not on
the top priority list.

Best
Vincent
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAOnrL6%2BO0s%3D6poKYFo17xTLrrX4SdCFuj%2BQj7tpkjtQfL%2BvQNw%40mail.gmail.com.

Hakan Granath

unread,
May 6, 2024, 4:37:07 AMMay 6
to sage-...@googlegroups.com
Thank you for the Flint reference, I will check it out, and thanks again for your hard work debugging!

Best,

Håkan

Reply all
Reply to author
Forward
0 new messages