ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 21 Dec 2010 20:35:36 -0600Is it possible to get normalised eigenvectors using eigenmatrix_right()?http://ask.sagemath.org/question/7812/is-it-possible-to-get-normalised-eigenvectors-using-eigenmatrix_right/I am trying to find out the diagonalizing matrix for a matrix using eigenmatrix_right(). The problem is that the eigenvector matrix returned by sage is not normalized. I have been writing a couple of for loops to normalize the eigenvectors. I was wondering whether there is a easier way maybe a option in eigenmatrix_right() which would give me an eigenmatrix with normalized eigenvectors?Mon, 13 Dec 2010 09:20:49 -0600http://ask.sagemath.org/question/7812/is-it-possible-to-get-normalised-eigenvectors-using-eigenmatrix_right/Answer by niles for <p>I am trying to find out the diagonalizing matrix for a matrix using eigenmatrix_right(). The problem is that the eigenvector matrix returned by sage is not normalized. I have been writing a couple of for loops to normalize the eigenvectors. I was wondering whether there is a easier way maybe a option in eigenmatrix_right() which would give me an eigenmatrix with normalized eigenvectors?</p>
http://ask.sagemath.org/question/7812/is-it-possible-to-get-normalised-eigenvectors-using-eigenmatrix_right/?answer=11861#post-id-11861Try the following:
M = Matrix(2,2,range(4)) # or any matrix you have around
M.eigenmatrix_right??
This will show the source code for `eigenmatrix_right` -- there, you'll see that `eigenmatrix_right` is defined by calling `eigenmatrix_left` on the transpose . . . checking
M.eigenmatrix_left??
will show you that `eigenmatrix_left` just builds a matrix from the vectors in `eigenvectors_left` . . .
M.eigenvectors_left??
does some real work: it gets the eigenspaces from `eigenspaces_left` and performs some further checks on the basis for each eigenspace.
So the short answer to your question is "No, there is not an option for `eigenmatrix_right` which will return normalized eigenvectors". However, you might be able to get them easily by getting the basis of [`eigenspaces_right`](http://www.sagemath.org/doc/reference/sage/matrix/matrix2.html#sage.matrix.matrix2.Matrix.eigenspaces_right) and normailzing it yourself.
Good luck :)
Wed, 15 Dec 2010 02:21:51 -0600http://ask.sagemath.org/question/7812/is-it-possible-to-get-normalised-eigenvectors-using-eigenmatrix_right/?answer=11861#post-id-11861Answer by Jason Grout for <p>I am trying to find out the diagonalizing matrix for a matrix using eigenmatrix_right(). The problem is that the eigenvector matrix returned by sage is not normalized. I have been writing a couple of for loops to normalize the eigenvectors. I was wondering whether there is a easier way maybe a option in eigenmatrix_right() which would give me an eigenmatrix with normalized eigenvectors?</p>
http://ask.sagemath.org/question/7812/is-it-possible-to-get-normalised-eigenvectors-using-eigenmatrix_right/?answer=11890#post-id-11890If you use RDF matrices, the eigenvectors are normalized, since scipy by default normalizes eigenvectors:
sage: m=random_matrix(RDF, 3)
sage: D,P=m.eigenmatrix_right()
sage: P
[ 0.772199899036 0.772199899036 -0.343345671023]
[-0.293125911736 - 0.444881864588*I -0.293125911736 + 0.444881864588*I 0.612459302127]
[ 0.174684604473 + 0.298914588669*I 0.174684604473 - 0.298914588669*I 0.712044488377]
sage: P.column(0).norm()
1.0
sage: P.column(1).norm()
1.0
sage: P.column(2).norm()
1.0
Tue, 21 Dec 2010 20:35:36 -0600http://ask.sagemath.org/question/7812/is-it-possible-to-get-normalised-eigenvectors-using-eigenmatrix_right/?answer=11890#post-id-11890