inconsistencies when computing eigenvectors over a number field and over QQbar

57 views
Skip to first unread message

Paul Nelson

unread,
Aug 6, 2020, 10:18:02 AM8/6/20
to sage-devel
Hello,

I'm using SAGE 8.9 via CoCalc.

Calling eigenvectors_right() on a matrix m with entries in the number field Q(i) returns some vectors with entries in Q(i), others with entries in QQbar (see example below).  I would have expected that applying change_ring(QQbar) to such vectors would produce the same vectors as returned by m.change_ring(QQbar).eigenvectors_right(), at least for some choice of embedding Q(i) -> QQbar.  This does not appear to be the case: the former approach gives inconsistent answers, the latter seems correct.

I've pasted below some code and output demonstrating the issue in the simplest example I could find.

The reason I'm not just working over QQbar from the beginning is that doing so seems much slower than working directly over Q(i).  I managed to circumvent the issue by using eigenspaces_right(format='galois') and embedding things clunkily by hand (see below), but would appreciate any suggestions on how to do things better.

Thanks,

Paul

---

Code:

def print_eigenspace(e):
    print "Eigenvalue:", e[0]
    print "Basis for eigenspace:"
    for v in e[1]:
        print "  ", v.change_ring(QQbar)

K.<i> = QuadraticField(-1)
M = MatrixSpace(K, 4)
m = M([2,4*i,-i,0, -4*i,2,-1,0, 2*i,-2,0,0, 4*i+4, 4*i-4,1-i,-2])
print "The following matrices are related by i \mapsto I:"
print
print m
print
print m.change_ring(QQbar)
print
print "We note that the results of m.eigenvectors_right() are defined over both Q(i) and QQbar:"
print
for e in m.eigenvectors_right():
    print "Eigenvalue:", e[0]
    print e[0].parent()
    assert e[0].parent() == e[1][0][0].parent()
    print
print
print "We aim to compute a basis of eigenvectors for these matrices."
print
print "1. Working over QQbar gives the correct answer:"
print
for e in m.change_ring(QQbar).eigenvectors_right():
    print_eigenspace(e)
    print
print
print "2. Working over Q(i) and  changing to QQbar gives the wrong answer: some (but not all) eigenspaces get conjugated:"
print
for e in m.eigenvectors_right():
    print_eigenspace(e)
    print
print
print "3. We obtain the correct answer by working over Q(i) and calling eigenspaces() with format='galois':"
print
for e in m.eigenspaces_right(format='galois'):
    I = QQbar.gens()[0]
    F = e[0].parent()
    for iota in F.embeddings(QQbar):
        if iota(i) == I:
            print_eigenspace((iota(e[0]), [v.apply_map(iota) for v in e[1].basis()]))
    print


---

Output:

The following matrices are related by i \mapsto I: [ 2 4*i -i 0] [ -4*i 2 -1 0] [ 2*i -2 0 0] [4*i + 4 4*i - 4 -i + 1 -2] [ 2 4*I -I 0] [ -4*I 2 -1 0] [ 2*I -2 0 0] [4*I + 4 4*I - 4 -I + 1 -2] We note that the results of m.eigenvectors_right() are defined over both Q(i) and QQbar: Eigenvalue: -2 Number Field in i with defining polynomial x^2 + 1 with i = 1*I Eigenvalue: -0.6055512754639893? Algebraic Field Eigenvalue: 6.605551275463989? Algebraic Field We aim to compute a basis of eigenvectors for these matrices. 1. Working over QQbar gives the correct answer: Eigenvalue: 6.605551275463989? Basis for eigenspace: (1.000000000000000? + 0.?e-17*I, 0.?e-17 - 1.000000000000000?*I, 0.?e-17 + 0.6055512754639893?*I, 1.000000000000000? + 1.000000000000000?*I) Eigenvalue: -0.6055512754639893? Basis for eigenspace: (1.000000000000000? + 0.?e-16*I, 0.?e-16 - 1.000000000000000?*I, 0.?e-16 - 6.605551275463989?*I, 1.000000000000000? + 1.000000000000000?*I) Eigenvalue: -2 Basis for eigenspace: (1, 1*I, 0, 0) (0, 0, 0, 1) 2. Working over Q(i) and changing to QQbar gives the wrong answer: some (but not all) eigenspaces get conjugated: Eigenvalue: -2 Basis for eigenspace: (1, I, 0, 0) (0, 0, 0, 1) Eigenvalue: -0.6055512754639893? Basis for eigenspace: (1, 0.?e-54 + 1.000000000000000?*I, 0.?e-53 + 6.605551275463989?*I, 1.000000000000000? - 1.000000000000000?*I) Eigenvalue: 6.605551275463989? Basis for eigenspace: (1, 0.?e-53 + 1.000000000000000?*I, 0.?e-52 - 0.6055512754639893?*I, 1.000000000000000? - 1.000000000000000?*I) 3. We obtain the correct answer by working over Q(i) and calling eigenspaces() with format='galois': Eigenvalue: -2 Basis for eigenspace: (1, 1*I, 0, 0) (0, 0, 0, 1) Eigenvalue: -0.6055512754639893? + 0.?e-54*I Basis for eigenspace: (1, 0.?e-54 - 1.000000000000000?*I, 0.?e-53 - 6.605551275463989?*I, 1.000000000000000? + 1.000000000000000?*I) Eigenvalue: 6.605551275463989? + 0.?e-51*I Basis for eigenspace: (1, 0.?e-52 - 1.000000000000000?*I, 0.?e-51 + 0.6055512754639893?*I, 1.000000000000000? + 1.000000000000000?*I)

Markus Wageringel

unread,
Sep 6, 2020, 11:56:57 AM9/6/20
to sage-devel
Hello Paul, thank you for the report. I can confirm that the problem is still present in the current version of Sage and have opened https://trac.sagemath.org/ticket/30518 for it.
Reply all
Reply to author
Forward
0 new messages