I have two matrices. Is there any command to show these two matrices are similar? I searched but I couldn't find anything.

Thank you.

  • 2
    $\begingroup$ If they're exact or symbolic matrices, check the result of JordanDecomposition[]. Use SchurDecomposition[] otherwise. $\endgroup$ Commented Oct 31, 2017 at 12:51

2 Answers 2


You could use the Jordan normal form provided by JordanDecomposition...

n = 15;
a = RandomReal[{-1, 1}, {n, n}];
b = RandomReal[{-1, 1}, {n, n}];
g = RandomReal[{-1, 1}, {n, n}];
c = LinearSolve[g, a].g;
Max[Abs[JordanDecomposition[a][[2]] - JordanDecomposition[b][[2]]]] < 10^-12
Max[Abs[JordanDecomposition[a][[2]] - JordanDecomposition[c][[2]]]] < 10^-12

(* False *)
(* True *)
  • 1
    $\begingroup$ JordanDecomposition[] is unreliable in the inexact case if the matrices to be compared are very nearly defective. Compare the results of SchurDecomposition[] instead. $\endgroup$ Commented Oct 31, 2017 at 12:56
  • 1
    $\begingroup$ @J.M. Hm. In my example, a and c are similar but I see no coincidences in the Schur decompositions... Schur decomposition is a normal form only for conjugacy under orthogonal transformations. $\endgroup$ Commented Oct 31, 2017 at 13:01

You could check if the Eigenvalues of both matrices are the same, and if both matrices are Diagonalizable . To do so you could create two functions that does this and combine them like this:

l[x_, y_] := (If[Length[Eigenvalues[x]] == Length[Eigenvalues[y]], If[Sort[Eigenvalues[x]] == Sort[Eigenvalues[y]], True, False], 
r[x_, y_] := (If[Det[Eigenvectors[x]] != 0 && Det[Eigenvectors[y]] != 0, True, 
AreSimilar[x_, y_] := (If[l[x, y] == True && r[x, y] == True, True, False]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.