Sage EE Eigenvalues and Eigenvectors

Sage can compute eigenvalues and eigenvectors of matrices. We will see shortly that there are subtleties involved with using these routines, but here is a quick example to begin with. These two commands should be enough to get you started with most of the early examples in this section. See the end of the section for more comprehensive advice.

For a square matrix, the methods .eigenvalues() and .eigenvectors_right() will produce what you expect, though the format of the eigenvector output requires some explanation. Here is Example SEE from the start of this chapter.





The three eigenvalues we know are included in the output of eigenvalues(), though for some reason the eigenvalue $\lambda=2$ shows up twice.

The output of the eigenvectors_right() method is a list of triples. Each triple begins with an eigenvalue. This is followed by a list of eigenvectors for that eigenvalue. Notice the first eigenvector is identical to the one we described in Example SEE. The eigenvector for $\lambda=0$ is different, but is just a scalar multiple of the one from Example SEE. For $\lambda=2$, we now get two eigenvectors, and neither looks like either of the ones from Example SEE. (Hint: try writing the eigenvectors from the example as linear combinations of the two in the Sage output.) An explanation of the the third part of each triple (an integer) will have to wait, though it can be optionally surpressed if desired.

One cautionary note: The word lambda has a special purpose

in Sage, so do not try to use this as a name for your eigenvalues.