Problem 31, Section 5.4

We'll work out this one, as an analogue to your homework problem 30. We are asked to find the matrix of the transformation $x\mapsto Ax$ in the basis $\mathcal{B}$, where

$$ A= \left[ \begin{array}{rrr} -7&-48&-16\\ 1&14&6\\ -3&-45&-19 \end{array} \right] $$

and $\mathcal{B}$ consists of the basis elements

$$ {\bf b}_1= \left[ \begin{array}{r} -3\\ 1\\ -3 \end{array} \right],\ {\bf b}_2= \left[ \begin{array}{r} -2\\ 1\\ -3 \end{array} \right]\ \text{ and }\ {\bf b}_3= \left[ \begin{array}{r} 3\\ -1\\ 0 \end{array} \right]. $$

We know precisely what to do from Example 4 in the same section 5.4 (and its solution, if you bother to read it): collect the vectors ${\bf b}_i$, $i=1,2,3$ together as columns of a matrix $P$, and then the matrix you're after is $P^{-1}AP$. So we'll do just that.

In [2]:
from sympy import *
init_printing(use_latex='mathjax')
In [3]:
A=Matrix([[-7,-48,-16],[1,14,6],[-3,-45,-19]])
P=Matrix([[-3,-2,3],[1,1,-1],[-3,-3,0]])
In [4]:
A
Out[4]:
$\displaystyle \left[\begin{matrix}-7 & -48 & -16\\1 & 14 & 6\\-3 & -45 & -19\end{matrix}\right]$
In [5]:
P
Out[5]:
$\displaystyle \left[\begin{matrix}-3 & -2 & 3\\1 & 1 & -1\\-3 & -3 & 0\end{matrix}\right]$

Now for the matrix we're actually after, i.e. $P^{-1}AP$:

In [6]:
P.inv()*A*P
Out[6]:
$\displaystyle \left[\begin{matrix}-7 & -2 & -6\\0 & -4 & -6\\0 & 0 & -1\end{matrix}\right]$

Done! Let's do a quick check though. The fact that its first column is the column vector with entries $-7$, $0$ and $0$ means precisely that the first basis vector ${\bf b}_1$ of our basis is an eigenvector for the matrix $A$, with eigenvalue $-7$. Why not check that real quick?

The vector ${\bf b}_1$ can be extracted from $P$ as its first column (though remember, for Python that means column indexed $0$):

In [7]:
b1=P.col(0)
b1
Out[7]:
$\displaystyle \left[\begin{matrix}-3\\1\\-3\end{matrix}\right]$

Now let's check that it is indeed an eigenvector for $A$ with eigenvalue $-7$, i.e. that $A{\bf b}_1=-7{\bf b}_1$.

In [8]:
(A+7*eye(3))*b1
Out[8]:
$\displaystyle \left[\begin{matrix}0\\0\\0\end{matrix}\right]$

Since, as you know, eye(3) is the $3\times 3$ identity matrix, that just says that indeed $(A+7I_3){\bf b}_1$ is the zero vector. Verification done.