# Some questions about similar matrices

Two matrices $A$ and $B$ are similar, if and only if there exists an invertible matrix $C$ with $A=C^{-1}BC$. A necessary condition for the similarity is, that the characteristic polynomials coincide.

• I read in one answer concerning similar matrices : If $A$ and $B$ are $2\times{2}$-matrices, they are similar if and only if they have the same characteristic polynomial and both are not a multiple of the identity matrix. Is this true and how can it be proven ?

• In one answer it was stated that it is not easy to determine, if two matrices $A,B$ are similar. Isn't there an easy sufficient condition ?

• How can I check similarity with PARI/GP ?

• For example, the two random matrices

$$\begin {bmatrix} 2 & 7 & -8 \\ -8 & -4 & -3 \\ 2 &-3 & -6 \end{bmatrix}$$

$$\begin {bmatrix} -2 & -2 & -10 \\ 7 & 0 & -3 \\ 2 & 7 & -6 \end{bmatrix}$$

have the same characteristic polynomial.
Are they similar, and if yes, what is the matrix $C$ doing the job ?

I know that there is already an answer to the question, when matrices are similar. Nevertheless, I hope, that my question brings new aspects and is therefore not marked as a duplicate.

• In your example, both matrices are diagonalisable and have the same eigenvalues. Hence they are similar, over the complex numbers. – Dietrich Burde Jun 21 '14 at 18:52
• How can I find the matrix C with $C^{-1}BC=A$ ? – Peter Jun 21 '14 at 18:54
• This is easy. You get $9$ equations from $CA=BC$ in the $9$ unknowns of $C$, and then one condition $\det(C)\neq 0$ over your field $K$. – Dietrich Burde Jun 21 '14 at 18:55

If the two matrices are diagonalizable, then $$\exists P_A\,:\,\,P_A^{-1} A P_A = D_A\\ \exists P_B\,:\,\,P_B^{-1} B P_B = D_B$$ with $D_A$ and $D_B$ diagonal matrices. $P_A$ and $P_B$ are simply the matrices whose columns are the eigenvectors of $A$ and $B$, respectively (I think that the columns in $P_B$ could be arranged to have the same ordering of the relative eigenvalues than $P_A$). If $A$ and $B$ are similar, then they have the same eigenvalues, so $D_A=D_B$, then $$P_A^{-1}AP_A=P_B^{-1}BP_B\qquad\implies\qquad A=P_A P_B^{-1} B P_B P_A^{-1}$$ so the similarity matrix to change $B$ in $A$ is $C=P_B P_A^{-1}$.

If the matrices are not diagonalizable, then they have the same Jordan Normal Form, and the similarity matrix $P$ is built using generalized eigenvectors.

• So, is it sufficient for the similarity that both matrices are diagonalizable and have the same characteristic polynomial ? – Peter Jun 21 '14 at 19:50
• The exchange of the positions of the eigenvalues should be no problem. For example, using C = [ [0,-1,0] , [1,0,0] , [0,0,1] ], A = diag(j,k,l) , B = diag(k,j,l), we have $C^{-1}AC=B$ – Peter Jun 21 '14 at 21:32

It is necessary to have the same characteristic and minimal polynomials, but even this is not sufficient once dimension is at least 4.

As you can confirm with gp-pari, for both matrices below, the characteristic polynomial is $(x-3)^4$ and the minimal polynomial is $(x-3)^2.$ However, they are not similar, the Jordan normal forms are different. The exponents in the minimal polynomial tell us only the size of the largest Jordan block with a given eigenvalue. They do not tell us the full partition of Jordan block sizes. Below, for $A$ we have $2 + 2$ but for $B$ we have $1+1+2.$

$$A \; = \; \left( \begin{array}{cccc} 3 & 1 & 0 & 0 \\ 0 & 3 & 0 & 0 \\ 0 & 0 & 3 & 1 \\ 0 & 0 & 0 & 3 \end{array} \right).$$

$$B \; = \; \left( \begin{array}{cccc} 3 & 0 & 0 & 0 \\ 0 & 3 & 0 & 0 \\ 0 & 0 & 3 & 1 \\ 0 & 0 & 0 & 3 \end{array} \right).$$

I do not see how to get such an example in dimension 3 or 2, so in those dimensions characteristic and minimal polynomials suffice. Note that these examples are not diagonalizable, they are already in Jordan Normal Form, these are the best that can be done.