Subsection Computing Eigenthings
Although we could use determinants to solve for eigenvalues and row reducing to solve for eigenvectors, both NumPy and SymPy have commands to directly determine eigenthings.
NumPy’s linalg.eig(matrix_name)
can be used to find numerical approximations for the eigenvalues and eigenvectors (where the latter are normalized to have magnitude 1). Note that linalg.eig(matrix_name)
returns a tuple of both the eigenvalues and the eigenvectors.
You can also find just the characteristic polynomial using poly(matrix_name)
and just the eigenvalues using linalg.eigvals(matrix_name)
.
You Try 2.49.
Use the above code to write down the characteristic polynomials for matrix \(A\text{.}\) Note that you have to interpret the output correctly.
You Try 2.50.
Use the above NumPy code to write down the eigenvalues and eigenvectors for matrix \(A\text{.}\)
You Try 2.51.
Repeat both of the above exercises for the matrix \(B\text{.}\) Why might someone prefer to solve a \(2\times 2\) eigenvalue question by hand instead?
As before, SymPy works well with symbolic manipulation. You can find the characteristic polynomial via matrix.charpoly()
. SymPy’s .eigenvects()
also returns a tuple of exact eigenvalues, their multiplicities, and exact eigenvectors. Since computing eigenvectors can be costly, we have the option of just computing eigenvalues using .eigenvals()
instead. If instead of exact values you want a decimal approximation you can use the command .evalf()
or N()
.
You Try 2.52.
Use the above SymPy code to write down the characteristic polynomial for matrix \(A\text{.}\) Note that you have to interpret the output correctly.
You Try 2.53.
Use the above code to write down the eigenvalues and eigenvectors for matrix \(A\text{.}\)
You Try 2.54.
Repeat the above two exercises for matrix \(B\text{.}\)
Subsection Visualizing with Eigenthings
Recall from
Section 2.3 since a matrix transformation is linear, we can visualize using a standard basis grid and the transformed basis grid. Every other point in space is a linear combination. We can visualize with either a standard basis coordinate point grid and its image or a standard basis coordinate line grid and its image under the transformation.
Example 2.55. Visualizing using the Standard Basis grid.
Consider the matrix transformation \(\mathbb{R}^2 \rightarrow \mathbb{R}^2\) given by \(A = \left[
\begin{matrix}
3 \amp 1 \\
2 \amp 2 \\
\end{matrix}
\right].\)
We can visualize the matrix transformation using the standard basis. Here \(A = \left[
\begin{matrix}
3 \amp 1 \\
2 \amp 2 \\
\end{matrix}
\right]
\left[ \begin{matrix} 1 \\ 0 \\ \end{matrix} \right]
= \left[ \begin{matrix} 3 \\ 2 \\ \end{matrix} \right]\) and \(A = \left[
\begin{matrix}
3 \amp 1 \\
2 \amp 2 \\
\end{matrix}
\right]
\left[ \begin{matrix} 0 \\ 1 \\ \end{matrix} \right]
= \left[ \begin{matrix} 1 \\ 2 \\ \end{matrix} \right].\)
First we will visualize the transformation using the standard basis vectors and a resulting coordinate point grid and their transformations.
We could also visualize the transformation using a coordinate line grid from the standard basis and the resulting transformed line grid.
Eigenvalues and eigenvectors give us additional information about a matrix transformation, however. And we can use that information to better understand the transformation of our space. In particular, if the eigenvectors of our transformation form a basis for the domain of our transformation, we can use the eigenbasis instead of the standard basis.
Example 2.56. Visualizing using an Eigen-basis grid.
\(A\) has eigenvalues of \(\lambda_1 =1\) and \(\lambda_2 = 4\) with corresponding eigenspaces \(E_{\lambda_1 =1} = span \left\{ \left[ \begin{matrix} -1 \\ 2 \\ \end{matrix} \right]\right\} \) and \(E_{\lambda_2 =4} = span \left\{ \left[ \begin{matrix} 1 \\ 1 \\ \end{matrix} \right]\right\}. \) (See below.)
Since we have two linearly independent eigenvectors, \(\left\{ \left[ \begin{matrix} 1 \\ 1 \\ \end{matrix} \right], \left[ \begin{matrix} -1 \\ 2 \\ \end{matrix} \right] \right\}\) forms an alternate basis of eigenvectors for \(\mathbb{R}^2\text{.}\) Now consider what the transformation does to this eigenbasis for \(\mathbb{R}^2\text{.}\)
Since these are eigenvectors with eigenvalues \(4\) and \(1\) respectively, we know the first eigenvector is scaled by 4, while the second eigenvector remains the same (scaled by 1). Any grid of linear combinations of these eigen-basis vectors will scale similarly.
But how can we create a grid based on these eigenvectors?
Simple. We can take a standard basis grid and use a matrix transformation that sends \(\vec{e}_1\) to one eigenvector and \(\vec{e}_2\) to our linearly independent eigenvector.
Below is a coordinate grid of points generated by the eigenbasis vectors.
Now we can apply our matrix transformation \(A\) to this alternate eigenbasis point grid.
You Try 2.57.
Edit
Example 2.39 to plot and animate the eigenbasis grid under the transformation by
\(A\) in the above example.
Thus we can use an eigenbasis for an alternative visualization of a transformation. Note that the process of converting from the standard basis to an eigenbasis using a matrix transformation is more than just a hand up in visualizing these matrix transformations, however. A similar approach allows us to relate any matrix transformation with a basis of eigenvectors to a simple scaling matrix, which are diagonal matrices and very easy to work with.
Subsection Diagonalization
Example 2.58. Diagonalizing A.
Consider the matrix transformation given by
\(A = \left[
\begin{matrix}
3 \amp 1 \\
2 \amp 2 \\
\end{matrix}
\right].\) As we saw in
Example 2.56,
\(A\) has an eigen-basis for
\(\mathbb{R}^2\text{.}\) Moreover, we found a transformation from the standard basis to those eigenvectors is given by
\begin{equation*}
E =\left[ \begin{matrix} 1 \amp -1 \\ 1 \amp 2 \\ \end{matrix} \right].
\end{equation*}
Since the eigenvectors are merely scaled by \(A\) we can relate \(A\) to a scaling (dilation) matrix coming from the eigenvalues corresponding to the eigenvectors in \(E\text{,}\) namely,
\begin{equation*}
D =\left[ \begin{matrix} 4 \amp 0 \\ 0 \amp 1 \\ \end{matrix} \right].
\end{equation*}
But the scaling matrix \(D\) scales the standard basis vectors by 4 and 1. If we want to instead scale our eigenvectors we can
Transform our eigenbasis vectors to standard basis vectors using \(E^{-1}\text{.}\)
Scale the target standard basis vectors by the corresponding eigenvalues using \(D\text{.}\)
Transform back to the eigenbasis grid of \(\mathbb{R}^2\) using \(E\text{.}\)
Since we mapped the eigenvector with eigenvalue of 4 to \(\vec{e}_1\) and the eigenvector with eigenvalue of 1 to \(\vec{e}_2\text{,}\) we want to scale \(\vec{e}_1\) by the eigenvalue of 4 and \(\vec{e}_2\) by the eigenvalue of 1. If instead we had swapped those, we would need to swap in both \(E\) and \(D\text{.}\)
In other words, the matrix transformation \(A = EDE^{-1}\text{.}\)
You Try 2.59.
Confirm that \(A=EDE^{-1}\) by computing the matrix product in NumPy or SymPy in the code below.
Note the above example worked because we could find a real eigen-basis for the domain of our transformation. If instead, we can not find a real eigenbasis for the domain we say that the matrix is NOT diagonalizable.