I have the following equation : $ \tilde{B} = U B U^{\dagger} $

I also know both $ B $ and $ \tilde{B} $ , I just want to find the matrix U, that gives me the transformation. I tried using LinearSolve, but I can't get it into the form required by that function. Is there another way to do that?

I must note that the condition that U be Unitary is ESSENTIAL. I make this remark because of the interesting solutions proposed below, none of which, however, gives a unitary matrix U.

Edit: If it is of any help, the two matrices B and $ \tilde B $ are two quantum density matrices.

Edit2: I also added the two matrices here: http://pastebin.com/s3B1T0HD

  • $\begingroup$ If $\mathbf B$ is normal and similar to $\tilde{\mathbf B}$, then it's actually quite easy... $\endgroup$ Nov 3, 2015 at 11:17
  • $\begingroup$ How big are these matrices? $\endgroup$ Nov 4, 2015 at 12:12
  • $\begingroup$ smallest is 16x16. the largest case I want to test is 64x64. $\endgroup$
    – PhysNerd90
    Nov 4, 2015 at 12:14
  • $\begingroup$ Okay, let me give you something to try on your smallest case: apply Chop[SchurDecomposition[mat, RealBlockDiagonalForm -> False]] to both of your matrices, and check if the triangular (diagonal?) matrices produced are the same (up to roundoff and permutation). We can proceed after you do this. $\endgroup$ Nov 4, 2015 at 12:19
  • $\begingroup$ This gives me a matrix of vectors, every element is a column vector. The two matrices are also very different (no 2 elements are equal). $\endgroup$
    – PhysNerd90
    Nov 4, 2015 at 12:23

2 Answers 2


For normal matrices:

Find the unitary matrices $P$ and $S$ that diagonalize $\tilde{B}$ and $B$.

$D=P^{-1}\tilde{B}P\\ D'=S^{-1}BS\\ \tilde{B}=PS^{-1}BSP^{-1}\\ => U=PS^{-1}$

B1 = {{2, 1}, {-1, -1}};
B2 = {{-2, 5}, {-1, 3}};

P = Transpose@Eigenvectors@B1;
S = Transpose@Eigenvectors@B2;
U = P.Inverse@S;

B1 == Simplify[U.B2.Inverse@U]


  • $\begingroup$ Alternatively, one could use SchurDecomposition[] to generate the required unitary matrices. Though, this solution assumes $\mathbf B$ and $\tilde{\mathbf B}$ are similar, of course. $\endgroup$ Nov 3, 2015 at 11:28
  • 2
    $\begingroup$ @paw: The procedure is not valid in general because B and B~ might be such that they cannot be diagonalized. Example $ B $ = {{0,1},{0,0}}, $ \tilde{B} $ = {{0,0},{-1,0}} and U = {{0,1},{-1,0}} $\endgroup$ Nov 4, 2015 at 6:30
  • 1
    $\begingroup$ @paw: the OP asks for a unitary matrix U. Your U is not unitary. Also in the final comparision you should use $ U^{\dagger} $ rather than $ U^{-1} $, i.e. you missed a transposition. Hence I would reject your answer. $\endgroup$ Nov 4, 2015 at 6:45
  • $\begingroup$ @ J.M. Despite of my comments I see another upvoting and the acceptance of the answer, without further discussion. Can somebody please explain this to me? $\endgroup$ Nov 4, 2015 at 8:36
  • $\begingroup$ Now I have tried the above, it does NOT give me a unitary matrix U. Does anyone have any other suggestion? I have to say that IT IS ESSENTIAL THAT U BE A UNITARY MATRIX. $\endgroup$
    – PhysNerd90
    Nov 4, 2015 at 10:57

The eigenvectors space of a normal matrix are orthogonal. So in this case you can use Orthogonalize to get a set of orthogonal eigenvectors.

H = {{1, 1 + I}, {1 - I, 1}};
{Lambda, SA} = Eigensystem[H]
UA = Orthogonalize[SA]
UAT = Transpose[UA];
DiagonalMatrix[Lambda] == ConjugateTranspose[UAT].H.UAT

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.