Ask Your Question
1

Eigenspaces of a matrix defined on GF(2)

asked 2016-11-24 13:51:02 +0100

fagui gravatar image

updated 2016-11-24 17:39:47 +0100

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 flag offensive close merge delete

Comments

@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?

slelievre gravatar imageslelievre ( 2016-11-24 14:01:46 +0100 )edit

sorry i edited the question, i made a typo

fagui gravatar imagefagui ( 2016-11-24 17:40:16 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-11-24 14:46:17 +0100

tmonteil gravatar image

updated 2016-11-24 20:19:45 +0100

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]
edit flag offensive delete link more

Comments

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

fagui gravatar imagefagui ( 2016-11-24 17:43:33 +0100 )edit

I updatedd my answer for this.

tmonteil gravatar imagetmonteil ( 2016-11-24 20:22:20 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-11-24 13:51:02 +0100

Seen: 739 times

Last updated: Nov 24 '16