Sage CEVEC Computing Eigenvectors

There are three ways to get eigenvectors in Sage. For each eigenvalue, the method .eigenvectors_right() will return a list of eigenvectors that is a basis for the associated eigenspace. The method .eigenspaces_right() will return an eigenspace (in other words, a vector space, rather than a list of vectors) for each eigenvalue. There are also eigenmatrix methods which we will describe at the end of the chapter in Sage MD.

The matrix method .eigenvectors_right() (or equivalently the matrix method .right_eigenvectors()) produces a list of triples, one triple per eigenvalue. Each triple has an eigenvalue, a list, and then the algebraic multiplicity of the eigenvalue. The list contains vectors forming a basis for the eigenspace. Notice that the length of the list of eigenvectors will be the geometric multiplicity (and there is no easier way to get this information).



Note that this is a good place to practice burrowing down into Sage output that is full of lists (and lists of lists). See if you can extract just the second eigenvector for $\lambda=3$ using a single statement. Or perhaps try obtaining the geometric multiplicity of $\lambda=-2i$. Notice, too, that Sage has automatically upgraded to QQbar to get the complex eigenvalues.

The matrix method .eigenspaces_right() (equal to .right_eigenspaces()) produces a list of pairs, one pair per eigenvalue. Each pair has an eigenvalue, followed by the eigenvalue's eigenspace. Notice that the basis matrix of the eigenspace may not have the same eigenvectors you might get from other methods. Similar to the eigenvectors method, the dimension of the eigenspace will yield the geometric multiplicity (and there is no easier way to get this information). If you need the algebraic multiplicities, you can supply the keyword option algebraic_multiplicity=True to get back triples with the algebraic multiplicity in the third entry of the triple. We will recycle the example above, and not demonstrate the algebraic multiplicity option. (We have formatted the one-row basis matrices over QQbar across several lines.)



Notice how the output includes a subspace of dimension two over the rationals, and two subspaces of dimension one over the algebraic numbers.

The upcoming Subsection EE.ECEE has many examples, which mostly reflect techniques that might be possible to verify by hand. Here is the same matrix as above, analyzed in a similar way. Practicing the examples in this subsection, either directly with the higher-level Sage commands, and/or with more primitive commands (as below) would be an extremely good exercise at this point.













Notice how we changed the number system to the algebraic numbers before working with the complex eigenvalues. Also, we are using the basis='pivot' keyword option so that bases for the eigenspaces look more like the bases described in Theorem BNS.

By now, it should be clear why we keep using the “right” variants of these methods. Eigenvectors can be defined “on the right”, $A\vect{x}=\lambda\vect{x}$ as we have done, or “on the left,” $\vect{x}A=\lambda\vect{x}$. So use the “right” versions of the eigenvalue and eigenvector commands to stay consistent with the text. Recognize, too, that eigenspaces may be computed with different bases than those given in the text (typically like those for null spaces with the basis='echelon' option).

Why does the .eigenvalues() method not come in left and right versions? The upcoming Theorem ETM can be used to show that the two versions would have identical output, so there is no need.