Problem 38, Section 5.1

I'll work through this one, since it's a larger version of your homework problem 37. We want the eigenvalues of the matrix

$$ \left[ \begin{array}{rrrr} 9&-4&-2&-4\\ -56&32&-28&44\\ -14&-14&6&-14\\ 42&-33&21&-45 \end{array} \right] $$

Let's go for it.

In [1]:
from sympy import *
init_printing(use_latex='mathjax')
In [8]:
M=Matrix([[9,-4,-2,-4],[-56,32,-28,44],[-14,-14,6,-14],[42,-33,21,-45]])
M
Out[8]:
$\displaystyle \left[\begin{matrix}9 & -4 & -2 & -4\\-56 & 32 & -28 & 44\\-14 & -14 & 6 & -14\\42 & -33 & 21 & -45\end{matrix}\right]$

Getting eigenvalues is as easy as calling the eigenvals method on the matrix:

In [4]:
M.eigenvals()
Out[4]:
$\displaystyle \left\{ -12 : 2, \ 13 : 2\right\}$

That says that it has eigenvalues $-12$ and $13$, each with algebraic multiplicity $2$: see section 5.2 of your textbook (the subsection titled The Characteristic Equation) for the notion of algebraic multiplicity for an eigenvalue.

Now, how about eigenvectors? Just as easy:

In [9]:
M.eigenvects()
Out[9]:
$\displaystyle \left[ \left( -12, \ 2, \ \left[ \left[\begin{matrix}\frac{2}{7}\\1\\1\\0\end{matrix}\right], \ \left[\begin{matrix}0\\-1\\0\\1\end{matrix}\right]\right]\right), \ \left( 13, \ 2, \ \left[ \left[\begin{matrix}- \frac{1}{2}\\0\\1\\0\end{matrix}\right], \ \left[\begin{matrix}\frac{1}{3}\\- \frac{4}{3}\\0\\1\end{matrix}\right]\right]\right)\right]$

So: the eigenspace for eigenvalue $-12$ has dimension $2$ (i.e. the geometric multiplicity of the eigenvalue $-12$ is also $2$, just like its algebraic multiplicity), and the vectors

$$ \left[ \begin{array}{r} \frac 27\\ 1\\ 1\\ 0 \end{array} \right] \text{ and } \left[ \begin{array}{r} 0\\ -1\\ 0\\ 1 \end{array} \right] $$

form a basis for it. Similarly for the other eigenvalue. How about a quick sanity check that these indeed are eigenvectors? I'll pick one for each eigenvalue, being careful to define the entries as Rational numbers so they don't get rounded; that would lead to rounding errors, as described in this longer document I linked a long time ago on our class web page.

In [16]:
v0=Matrix([Rational(2,7),1,1,0])
v1=Matrix([Rational(1,3),-Rational(4,3),0,1])
v0, v1
Out[16]:
$\displaystyle \left( \left[\begin{matrix}\frac{2}{7}\\1\\1\\0\end{matrix}\right], \ \left[\begin{matrix}\frac{1}{3}\\- \frac{4}{3}\\0\\1\end{matrix}\right]\right)$

OK, now for the check. I want v0 to be an eigenvector for $M$, with eigenvalue $-12$, and similarly, I want v1 to be an eigenvector with eigenvalue $13$. So, recalling that eye(n) means the $n\times n$ identity matrix in SymPy, I can do

In [19]:
(M+12*eye(4))*v0
Out[19]:
$\displaystyle \left[\begin{matrix}0\\0\\0\\0\end{matrix}\right]$

Yes, that worked: it tells me that indeed

$$ (M+12I_4)v_0 = 0, $$

so

$$ Mv_0 = -12 v_0. $$

Now for the other one:

In [20]:
(M-13*eye(4))*v1
Out[20]:
$\displaystyle \left[\begin{matrix}0\\0\\0\\0\end{matrix}\right]$

Confirmed again: v1 is an eigenvector with eigenvalue $13$, because $Mv_1=13v_1$.