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.
from sympy import *
init_printing(use_latex='mathjax')
A=Matrix([[-7,-48,-16],[1,14,6],[-3,-45,-19]])
P=Matrix([[-3,-2,3],[1,1,-1],[-3,-3,0]])
A
P
Now for the matrix we're actually after, i.e. $P^{-1}AP$:
P.inv()*A*P
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$):
b1=P.col(0)
b1
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$.
(A+7*eye(3))*b1
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.