# How do I tell if matrices are similar?

I have two $2\times 2$ matrices, $A$ and $B$, with the same determinant. I want to know if they are similar or not.

I solved this by using a matrix called $S$: $$\left(\begin{array}{cc} a& b\\ c& d \end{array}\right)$$ and its inverse in terms of $a$, $b$, $c$, and $d$, then showing that there was no solution to $A = SBS^{-1}$. That worked fine, but what will I do if I have $3\times 3$ or $9\times 9$ matrices? I can't possibly make system that complex and solve it. How can I know if any two matrices represent the "same" linear transformation with different bases?

That is, how can I find $S$ that change of basis matrix?

I tried making $A$ and $B$ into linear transformations... but without the bases for the linear transformations I had no way of comparing them.

(I have read that similar matrices will have the same eigenvalues... and the same "trace" --but my class has not studied these yet. Also, it may be the case that some matrices with the same trace and eigenvalues are not similar so this will not solve my problem.)

I have one idea. Maybe if I look at the reduced col. and row echelon forms that will tell me something about the basis for the linear transformation? I'm not really certain how this would work though? Please help.

-
Your question has different answers depending on what kind of matrices you allow. Are $A$ and $B$ real matrices? Do you care if $S$ is allowed to be complex or not? unitary/orthogonal or not, etc.. –  Ryan Budney Dec 12 '10 at 20:50

There is something called "canonical forms" for a matrix; they are special forms for a matrix that can be obtained intrinsically from the matrix, and which will allow you to easily compare two matrices of the same size to see if they are similar or not. They are indeed based on eigenvalues and eigenvectors.

At this point, without the necessary machinery having been covered, the answer is that it is difficult to know if the two matrices are the same or not. The simplest test you can make is to see whether their characteristic polynomials are the same. This is necessary, but not sufficient for similarity (it is related to having the same eigenvalues).

Once you have learned about canonical forms, one can use either the Jordan canonical form (if the characteristic polynomial splits) or the rational canonical form (if the characteristic polynomial does not split) to compare the two matrices. They will be similar if and only if their rational forms are equal (up to some easily spotted differences; exactly analogous to the fact that two diagonal matrices are the same if they have the same diagonal entries, though the entries don't have to appear in the same order in both matrices).

The reduced row echelon form and the reduced column echelon form will not help you, because any two invertible matrices have the same forms (the identity), but need not have the same determinant (so they will not be similar).

-
"The simplest test you can make is to see whether their characteristic polynomials are the same. This is necessary, but not sufficient for similarity (it is related to having the same eigenvalues)." - To illustrate, look at $$\bigl(\begin{smallmatrix}1&0\\0&1\end{smallmatrix}\bigr)$$ and $$\bigl(\begin{smallmatrix}1&1\\0&1\end{smallmatrix}\bigr)$$ ; they have the same characteristic polynomial, but are definitely not similar (the latter is a defective matrix, not having a complete eigenvector set). –  Ｊ. Ｍ. Dec 13 '10 at 1:00
In the realm of inexact arithmetic, the Jordan decomposition cannot be stably computed (since the similarity transformations required can be arbitrarily ill-conditioned), and in its place, the Schur decomposition (which uses orthogonal/unitary similarity transformations) is used. –  Ｊ. Ｍ. Dec 13 '10 at 1:02
@J.M. Good point, and good illustration. –  Arturo Magidin Dec 13 '10 at 1:05

My lecturer, Dr. Miryam Rossett, provided the following in her supplementary notes to her linear 1 course ( with a few small additions of my own ):

1. Show that the matrices represent the same linear transformation according to different bases. This is generally hard to do.
2. If one is diagonalizable and the other not, then they are not similar.
3. Examine the properties of similar matrices. Do they have the same rank, the same trace, the same determinant, the same eigenvalues, the same characteristic polynomial. If any of these are different then the matrices are not similar.
4. Check the geometric multiplicity of each eigenvalue. If the matrices are similar they must match. Another way of looking at this is that for each $\lambda_i$, $dimKer(\lambda_i I-A_k)$ must be equal for each matrix. This also implies that for each $\lambda_i$, $dimIm(\lambda_i I-A_k)$ must be equal since $dimIm+dimKer=dimV$
5. Assuming they're both diagonalizable, if they both have the same eigenvalues then they're similar because similarity is transitive. They'e diagonalizable if the geometric multiplicities of the eigenvalues add up to $dimV$, or if all the eigenvalues are distinct, or if they have $dimV$ linearly independent eigenvectors.

Numbers 3 and 4 are necessary but not sufficient for similarity.

-
tr(A) can also be found from the sum of the eigenvalues. –  Robert S. Barnes Oct 15 '12 at 11:24

If you have two specific matrices, A and B, here is a method that will work. It's messy, but it will work for any two matrices, regardless of size. First, rewrite the similarity equation in the form AS=SB, where S is a matrix of variables. Multiply out both matrices to obtain a set of n-squared linear equations in n-squared unknowns. Solve the system using Gaussian-Jordan elimination. You need to use the form of the Gaussian-Jordan algorithm that produces matrices in row-echelon form when there is no single solution to the system. The system of equations always has a solution, the zero matrix. If the Gaussian-Jordan elimination produces a single solution, the matrices are not similar. If there is more than one solution, the row-echelon matrix can be solved for a set of basis vectors of the solution space. Since the constant terms are all zero, any matrix generated by the basis vectors is a similarity matrix for A and B.

-

For $A, B \in \mathbb{R}^{2,2}$ it might be possible to test by finding whether there exists matrix $S \in \mathbb{R}^{2,2}$ such that $B=S^{-1}AS$.

$$A= \begin{bmatrix} 0 & 1\\ 1 & 1\\ \end{bmatrix}$$ $$B= \begin{bmatrix} 1 & 1\\ 1 & 1\\ \end{bmatrix}$$
$$\begin{bmatrix} 1 & 1\\ 1 & 1\\ \end{bmatrix} = \frac{1}{ad-bc} \begin{bmatrix} a & -b\\ -c & d\\ \end{bmatrix} \begin{bmatrix} 0 & 1\\ 1 & 1\\ \end{bmatrix} \begin{bmatrix} a & c\\ b & d\\ \end{bmatrix}$$