I have two symbolic matrices, with the same eigensystems, with arbitrary elements that read

Amat = ( {
         {a11, a12, a13, a14},
         {a21, a22, a23, a24},
         {a31, a32, a33, a34},
         {a41, a42, a43, a44}
      } );
Bmat = ( {
       {b11, 0, 0, 0},
       {0, b22, b23, 0},
       {0, b32, b33, 0},
       {0, 0, 0, b44}
     } );

How can I find a transformation that imposes $U^{-1} A U =B$? The b11 and b44 elements can be considered as two numbers proportional to the eigenvalues of Amat. However, calling Eigenvectors[Amat] does not give me a simplified solution for this $4 \times 4 $ matrix. I am mainly concerned with symbolic calculations, but even a numerical solution is appreciated if symbolic calculations seem infeasible.

  • 1
    $\begingroup$ What does "proportional to the eigenvalues" mean? An eigenvalue is a number. It is not surprisung that Eigenvectors does not work when applied to a fully symbolic matrix. Overall, I think the question is not clear. $\endgroup$
    – user293787
    Jul 12, 2022 at 18:29
  • $\begingroup$ I meant ‘\alpha \lambda’ with $\lambda$ be one of the eigenvalues of Amat. $\endgroup$
    – Shasa
    Jul 12, 2022 at 19:58
  • 1
    $\begingroup$ For this to work, the eigenvalues of A must equal the eigenvalues of B. Otherwise no such U exists. If they are equal, then the matrix given by Eigenvectors will do the transformation. $\endgroup$
    – bill s
    Jul 12, 2022 at 21:38
  • $\begingroup$ @bills Bmat is not a diagonal matrix so it needs more work on eigenvalues. $\endgroup$
    – cvgmt
    Jul 13, 2022 at 2:41
  • $\begingroup$ @bills It is alright if both matrices have the same eigenvalues. But how can I find the transformation matrix U? $\endgroup$
    – Shasa
    Jul 13, 2022 at 5:12

1 Answer 1


I reinterpreted OPs question a little bit: Given two square matrices $A$ and $B$ of the same size, we want a function that decides if there exists an invertible matrix $U$ such that $AU = UB$. If yes, return $U$. If no, return {}.

Further simplifications. I am going to assume without check that A and B are diagonalizable, since I do not want to get into Jordan normal forms and such. I am going to assume that the matrices have numeric entries. I am going to check if the eigenvalues coincide without reordering them; note that Eigensystem order eigenvalues by absolute value, and if a matrix has several eigenvalues with same absolute value (for example unitary matrices) then what I do here can easily fail.

findIntertwiner[A_?SquareMatrixQ,B_?SquareMatrixQ] := Module[{vecsA,valsA,vecsB,valsB},
 {valsA,vecsA} = Eigensystem[A];
 {valsB,vecsB} = Eigensystem[B];
 If[Chop[Norm[valsA-valsB]]===0, (* <--- will work sometimes, not always *)


A = RandomReal[{-1,1},{4,4}];
V = RandomReal[{-1,1},{4,4}];
B = Inverse[V].A.V;

(* find U *)
U = findIntertwiner[A,B]

(* check that this gives zero *)

Note that U need not coincide with V, since the intertwiner is not unique.

  • 1
    $\begingroup$ @usr293787 (+1) With a bit modifying B to have the block structure in my question and considering A = Inverse[V] . DiagonalMatrix[Eigenvalues[B]] . V; Your script does the job for me. Thank you! $\endgroup$
    – Shasa
    Jul 13, 2022 at 14:59

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.