We will use Sage to find the eigenvalues and eigenvectors of a matrix. Let's begin with the matrix \(A = \left[\begin{array}{rr} 1 \amp 2 \\ 2 \amp 1 \\ \end{array}\right] \text{.}\)

  1. We can find the characteristic polynomial of a matrix \(A\) by writing A.charpoly('lam'). Notice that we have to give Sage a variable in which to write the polynomial; here, we use lam though you could just as well use x.

    The factored form of the characteristic polynomial may be more useful since it will tell us the eigenvalues and their multiplicities. The factor chacteristic polynomial is found with A.fcp('lam').

  2. If we only want the eigenvalues, we can use A.eigenvalues().

    Notice that the multiplicity of an eigenvalue is the number of times it is repeated in the list of eigenvalues.

  3. Finally, we can find eigenvectors by A.eigenvectors_right(). (We are looking for right eigenvalues since the vector \(\vvec\) appears to the right of \(A\) in the definition \(A\vvec=\lambda \vvec\text{.}\))

    At first glance, the result of this command can be a little confusing to interpret. What we see is a list with one entry for each eigenvalue. For each eigenvalue, there is a triple consisting of (i) the eigenvalue \(\lambda\text{,}\) (ii) a basis for \(E_\lambda\text{,}\) and (iii) the multiplicity of \(\lambda\text{.}\)

  4. When working with decimal entries, which are called floating point numbers in computer science, we must remember that computers perform only approximate arithmetic. This is a problem when we wish to find the eigenvectors of such a matrix. To illustrate, consider the matrix \(A=\left[\begin{array}{rr} 0.4 \amp 0.3 \\ 0.6 \amp 0.7 \\ \end{array}\right] \text{.}\)

    1. Without using Sage, find the eigenvalues of this matrix.

    2. What do you find for the reduced row echelon form of \(A-I\text{?}\)

    3. Let's now use Sage to determine the reduced row echelon form of \(A-I\text{:}\)

      What result does Sage report for the reduced row echelon form? Why is this result not correct?

    4. Because the arithmetic Sage performs with floating point entries is only approximate, we are not able to find the eigenspace \(E_1\text{.}\) In this next chapter, we will revisit learn how to address this issue. In the meantime, we can get around this problem by writing the entries in the matrix as rational numbers: