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.
 A: First off, the $2\times2$ case is easy: two distinct $2\times2$ matrices are similar if and only if they have the same characteristic polynomial, and neither of them is a scalar matrix (multiple of the identity). This is essentially because for such small matrices the characteristic polynomial leaves very little room for variation of the minimal polynomial (and other invariant factors that in this case follow from it).
There is a decision method that works in full generality (any field$~K$, any size$~n$ square matrices) and is theoretically simple: compute the invariant factors by determining the Smith normal form of the matrices $XI_n-A$ and $XI_n-B$ (those whose determinants define the respective characteristic polynomials) as matrices with polynomials in$~X$ as entries; then $A$ and $B$ are similar if and only if identical lists of invariant factors are found.
With "theoretically simple" I mean the method only uses basic operations in$~K$ you might be expected to perform: arithmetic of scalars and testing for equality; notably it does not require finding roots or factoring polynomials as any method based on eigenvalues would do. Essentially the Smith normal form algorithm is a generalisation of Gaussian elimination, but working over a PID rather than over a field (which here means: doing polynomial operations on polynomial entries, rather than just using scalars), and allowing column operations as well as row operations. The final goal is to reduce the matrix to its Smith normal form, which has nonzero (polynomial) entries only on the main diagonal, and which are monic polynomials such that each one divides the next (in general there could also be trailing zeros, but that does not happen here since our initial matrices have monic, therefore nonzero, determinants). The diagonal entries found that are different from$~1$ are the invariant factors of $A,B$ respectively; the last one is the minimal polynomial and their product is the characteristic polynomial. Those two polynomials can of course also be computed by other methods, and if either of them differs between $A$ and $B$ this suffices to show they are not similar; in the (rather rare) general case however all invariant factors are needed. In most cases there will be many diagonal entries$~1$, followed by one or very few non-constant polynomials that are the invariant factors.
Being theoretically simple does not mean the procedure is easy to perform (by hand), as it is like in iterated version of the Euclidean algorithm in the ring $K[X]$ of polynomials, which algorithm is notable for producing very complicated intermediate results, at least when $K=\Bbb Q$ (and over $\Bbb R$ or $\Bbb C$ the algorithm isn't really effective, as testing for equality is not accurately possible). It works fine over finite fields though.
A: 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). 
A: A simple proof that matrices $A=\begin{bmatrix}1 & 0\\0 & 1\end{bmatrix}$ and $B=\begin{bmatrix}1 & 1\\0 & 1\end{bmatrix}$ stated above as a counterexample are not similar.
If they were, then $B=P^{-1}AP$ for an invertible $2 \times 2$ matrix $P$. But $A=I$ and, therefore, $B=P^{-1}AP=P^{-1}IP=I$, which is a contradiction.
A: 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 ):


*

*Show that the matrices represent the same linear transformation according to different bases.  This is generally hard to do.

*If one is diagonalizable and the other not, then they are not similar.

*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.

*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$, $\dim \ker(\lambda_i I-A_k)$ must be equal for each matrix.  This also implies that for each $\lambda_i$, $\dim \text{im}(\lambda_i I-A_k)$ must be equal since $\dim \text{im}+\dim \ker=\dim V$

*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 $\dim V$, or if all the eigenvalues are distinct, or if they have $\dim V$ linearly independent eigenvectors.


Numbers 3 and 4 are necessary but not sufficient for similarity.
A: 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.
A: Here is a MATLAB .m function that computes a real similarity matrix for two real matrices known to be similar http://deadbeatjeff.sdf.org/Scripts/transitionjeff.m, implementing the algorithm from the answer https://math.stackexchange.com/a/639369/329781 above. It uses the randsoln.m function (which possibly depends on other .m functions) in Joel Robbin's .m functions .zip file corresponding to his book Matrix Algebra Using MINimal MATlab; the .zip file can be found here and here. My .m function takes a while to run but is factually accurate.
This .m function http://deadbeatjeff.sdf.org/Scripts/transitionDiagJeff.m uses diagonalization to compute the transition matrix but 1) will likely fail if the Jordan normal form of the two matrices is not a diagonal matrix and 2) will likely produce a similarity matrix that is imaginary if the similar matrices have an imaginary eigenvalue.
Here is a script to test the function http://deadbeatjeff.sdf.org/Scripts/test.m
