# Eigenspaces of a matrix defined on GF(2)

what is wrong with the eigenspaces method here? thank you for your help

MS=MatrixSpace(GF(2),16,16)

A=MS([
[1,1,0,1,1,0,0,0,0,0,0,0,1,0,0,0],
[1,1,1,0,0,1,0,0,0,0,0,0,0,1,0,0],
[0,1,1,1,0,0,1,0,0,0,0,0,0,0,1,0],
[1,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1],
[1,0,0,0,1,1,0,1,1,0,0,0,0,0,0,0],
[0,1,0,0,1,1,1,0,0,1,0,0,0,0,0,0],
[0,0,1,0,0,1,1,1,0,0,1,0,0,0,0,0],
[0,0,0,1,1,0,1,1,0,0,0,1,0,0,0,0],
[0,0,0,0,1,0,0,0,1,1,0,1,1,0,0,0],
[0,0,0,0,0,1,0,0,1,1,1,0,0,1,0,0],
[0,0,0,0,0,0,1,0,0,1,1,1,0,0,1,0],
[0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,1],
[1,0,0,0,0,0,0,0,1,0,0,0,1,1,0,1],
[0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,0],
[0,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1],
[0,0,0,1,0,0,0,0,0,0,0,1,1,0,1,1]])

p=A.charpoly()
p.factor()


(x + 1)^16

A.eigenspaces()


Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_19.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("QS5laWdlbnNwYWNlcygp"),globals())+"\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module>

File "/private/var/folders/gm/z065gk616xg6g0xgn4c7_bvc0000gn/T/tmpZNvlMy/___code___.py", line 2, in <module> exec compile(u'A.eigenspaces() File "", line 1, in <module>

File "sage/structure/element.pyx", line 413, in sage.structure.element.Element.__getattr__ (/Applications/SageMath/src/build/cythonized/sage/structure/element.c:4531) File "sage/structure/misc.pyx", line 259, in sage.structure.misc.getattr_from_other_class (/Applications/SageMath/src/build/cythonized/sage/structure/misc.c:1771) AttributeError: 'sage.matrix.matrix_mod2_dense.Matrix_mod2_dense' object has no attribute 'eigenspaces'

A.rank()


16

edit retag close merge delete

@fagui

There must be an error in your question since the matrix you provide has only 13 rows instead of 16.

Can you edit your question to fix that?

( 2016-11-24 07:01:46 -0600 )edit

sorry i edited the question, i made a typo

( 2016-11-24 10:40:16 -0600 )edit

Sort by » oldest newest most voted

I do not know how you succeed to build such a matrix without getting an error (some rows are missing), but in any case, there is no eigenspaces method since a matrix generally acts differently on the right or on the left, so there is some ambiguity. Instead, you should use the eigenspaces_left and eigenspaces_right methods, for example:

sage: A = Matrix(GF(2),[[1,1,0],[0,1,0],[1,1,1]])
sage: A
[1 1 0]
[0 1 0]
[1 1 1]
sage: p=A.charpoly()
sage: p.factor()
(x + 1)^3
sage: A.eigenspaces_right()
[
(1, Vector space of degree 3 and dimension 1 over Finite Field of size 2
User basis matrix:
[0 0 1])
]
sage: A.eigenspaces_left()
[
(1, Vector space of degree 3 and dimension 1 over Finite Field of size 2
User basis matrix:
[0 1 0])
]


EDIT With the updated matrix, you get:

sage: E = A.eigenspaces_right() ; E
[
(1, Vector space of degree 16 and dimension 8 over Finite Field of size 2
User basis matrix:
[1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1]
[0 1 0 0 0 0 0 0 0 1 0 0 1 0 1 0]
[0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 1]
[0 0 0 1 0 0 0 0 0 0 0 1 1 0 1 0]
[0 0 0 0 1 0 0 0 0 1 0 1 1 0 0 0]
[0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0]
[0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0]
[0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1])
]


Since A is invertible, you only get one eigenspace (for the eigenvalue 1), so you get a list, you can get its first (unique) entry as follows:

sage: E[0]
(1, Vector space of degree 16 and dimension 8 over Finite Field of size 2
User basis matrix:
[1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1]
[0 1 0 0 0 0 0 0 0 1 0 0 1 0 1 0]
[0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 1]
[0 0 0 1 0 0 0 0 0 0 0 1 1 0 1 0]
[0 0 0 0 1 0 0 0 0 1 0 1 1 0 0 0]
[0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0]
[0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0]
[0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1])


Which is a tuple (eigenvalue, eigenspace). Tp get the eigenspace, you can do:

sage: V = E[0][1] ; V
Vector space of degree 16 and dimension 8 over Finite Field of size 2
User basis matrix:
[1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1]
[0 1 0 0 0 0 0 0 0 1 0 0 1 0 1 0]
[0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 1]
[0 0 0 1 0 0 0 0 0 0 0 1 1 0 1 0]
[0 0 0 0 1 0 0 0 0 1 0 1 1 0 0 0]
[0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0]
[0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0]
[0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1]


so if you want the basis of this vector space as a matrix, you just have to do:

sage: V.matrix()
[1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1]
[0 1 0 0 0 0 0 0 0 1 0 0 1 0 1 0]
[0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 1]
[0 0 0 1 0 0 0 0 0 0 0 1 1 0 1 0]
[0 0 0 0 1 0 0 0 0 1 0 1 1 0 0 0]
[0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0]
[0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0]
[0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1]


Or, in a single command:

sage: A.eigenspaces_right()[0][1].matrix()
[1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1]
[0 1 0 0 0 0 0 0 0 1 0 0 1 0 1 0]
[0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 1]
[0 0 0 1 0 0 0 0 0 0 0 1 1 0 1 0]
[0 0 0 0 1 0 0 0 0 1 0 1 1 0 0 0]
[0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0]
[0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0]
[0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1]

more

thank you . If i want the matrix returned in an object, what should i do ?

( 2016-11-24 10:43:33 -0600 )edit

I updatedd my answer for this.

( 2016-11-24 13:22:20 -0600 )edit

## Stats

Seen: 61 times

Last updated: Nov 24 '16