How to find invertible matrix $P$ Such that $B=P^{-1}AP$ 
Let $A,B$ be the two $3 \times 3$ matrices
$$A=\begin{bmatrix}
3 & 2 &-5\\2 &6&-10\\1 &2 & -3 \end{bmatrix}$$
$$B=
\begin{bmatrix}
6 &20 &-34\\6 &32&-51\\4 &20 &-32 \end{bmatrix}
$$
Suppose that there is a Non Singular matrix $P$ that $P^{-1}AP=B$. Find $P$

My idea is using Eigen Values we get Diagonilization of Matrices $A$ and $B$ as:
$$A=RD_AR^{-1}$$
$$B=QD_BQ^{-1}$$
Then we get:
$$QD_BQ^{-1}=P^{-1}RD_AR^{-1}P$$
But i feel this is very tedious procedure?

When we don't know explicitly the eigenvalues, there are two methods


*

*We solve the equation $PB=AP$; the space of solutions has dimension $dim(C(A))$ where $C(A)$ is the commutant of $A$ (here $5$). The general solution is in the form $P=a_1P_1+\cdots+a_5P_5$ where the $(P_i)$ are known matrices.  We randomly choose the coefficients $(a_i)$ and we obtain (with probability $1$) an invertible matrix $P$ and we are done (of course, if your matrix $P$ is not invertible, then you start again for free).

*We calculate the Frobenius normal forms (with a PC, it's very fast) $A=QFQ^{-1},B=RFR^{-1}$ (with the same $F$) and we deduce $P$.
Yet, here we know $spectrum(A)=\{2,2,2\}$ and that  $dim(\ker(A-2I))=2$. 
$e_1=(1,0,0)$ is not in $\ker(A-2I)$ or in $\ker(B-2I)$ and $e_2=(B-2I)(e_1)=[4,6,4]^T\in \ker(B-2I),e'_2=(A-2I)(e_1)=[1,2,1]^T\in\ker(A-2I)$.
We complete the bases of $\ker(B-2I),\ker(A-2I)$ with $e_3=[-5,1,0]^T$ and $e'_3=[-2,1,0]^T$.
We choose $P$ s.t. $P(e_1)=e_1,P(e_2)=e'_2,P(e_3)=e'_3$.
Finally $P\begin{pmatrix}1&4&-5\\0&6&1\\0&4&0\end{pmatrix}=\begin{pmatrix}1&1&-2\\0&2&1\\0&1&0\end{pmatrix}$ and $P=\begin{pmatrix}1&3&-21/4\\0&1&-1\\0&0&1/4\end{pmatrix}$.
