# Diagonalize matrix but keep the order of basis

I have a unitary matrix $$U$$ UMatrix. It looks like

{{0.822075, 0.548446, -0.113679 + 0.102357 I,
0}, {-0.353904 + 0.0562876 I, 0.665882 + 0.0375522 I, 0.65328,
0}, {0.437829 + 0.063889 I, -0.502575 + 0.0426234 I, 0.741502,
0}, {0. + 0. I, 0. + 0. I, 0., 1}}


I also have a matrix $$M$$massMatrix. It looks like

{{0, 0, 0, 0}, {0, 0.0000754, 0, 0}, {0, 0, 0.00244, 0}, {0, 0, 0,
0}}


Now if I do $$U M U^\dagger$$. I should be able to be able to diagonalize $$U M U^\dagger$$ and get back $$U$$ (or $$U^\dagger$$).

However, I found JordanDecomposition[UMatrix .massMatrix.ConjugateTranspose[UMatrix]][[1]] as

{{0.0314079 + 0.821475 I, 0. + 0. I, -0.529795 + 0.141809 I,
0.152284 - 0.0144812 I}, {-0.0697676 - 0.351495 I,
0. + 0. I, -0.652948 + 0.135899 I, -0.524682 -
0.389208 I}, {-0.0471148 + 0.43995 I, 0. + 0. I,
0.474463 - 0.171123 I, -0.595539 - 0.441768 I}, {0. + 0. I,
1. + 0. I, 0. + 0. I, 0. + 0. I}}


and Transpose[Eigensystem[UMatrix .massMatrix.ConjugateTranspose[UMatrix][[2]]] is

{{-0.113679 + 0.102357 I, 0.547576 - 0.0308803 I, 0.822075 + 0. I,
0. + 0. I}, {0.65328 + 1.28954*10^-16 I,
0.66694 + 0. I, -0.353904 + 0.0562876 I,
0. + 0. I}, {0.741502 + 0. I, -0.499377 + 0.0708533 I,
0.437829 + 0.063889 I, 0. + 0. I}, {0. + 0. I, 0. + 0. I, 0. + 0. I,
1. + 0. I}}


Looks like JordanDecomposition does not really give what I want (but I don't know why), but Eigensystem do. The problem is the order of basis is different. We see each column the order is correct but each row is not. This is expected as there is no way for mathematica to know the order of eigenvlaue I want. Is there is a way to tell Mathematica which order I want? Later I will do a perturbation on $$U M U^\dagger$$ I also need to fix the order for that.

• Eigensystem orders the eigenvalues (and corresponding eigenvectors) from large to small. Since your massMatrix doesn't have an ordered diagonal, you're going to need to permute the eigenvectors to recover UMatrix at the very least. Your mass matrix also has zeros on the diagonal, so I doubt you can recover it at all from Eigensystem. Aug 12, 2020 at 7:46

I'm not sure how to automate this, since the order of the eigenvalues is seemingly arbitrary (although I can see that it's based on the original matrix), so here's how to do it by-hand-ish:

UMat = {{0.822075, 0.548446, -0.113679 + 0.102357 I, 0},
{-0.353904 + 0.0562876 I, 0.665882 + 0.0375522 I, 0.65328, 0},
{0.437829 + 0.063889 I, -0.502575 + 0.0426234 I, 0.741502, 0},
{0. + 0. I, 0. + 0. I, 0., 1}} // Chop;
massMatrix = {{0, 0, 0, 0}, {0, 0.0000754, 0, 0}, {0, 0, 0.00244, 0}, {0, 0, 0, 0}};
eigs = Transpose[Eigensystem[uMat.mMat.ConjugateTranspose[uMat]]];


The eigenvalues are in the following order:

eigs[[All, 1]]
(* {0.00244, 0.0000754, 0, 0} *)


It seems you want the order {3, 2, 1, 4} or {3, 2, 4, 1}, based on the diagonal of the mass matrix. After trying both, it seems like

eigs[[{3, 2, 1, 4}]][[All, 2]] // MatrixForm


is what you want:

Note however that even though the eigenvectors come out normalized, they can still be scaled by an arbitrary complex number of modulus one. This number is determined by the numerics behind the scenes, and so it cannot be controlled. In particular, the second eigenvector is not the same as your original one, but it can be scaled to be:

eigs[[2, 2]]
#/Exp[I Arg[#[[1]]]] &@% // Chop
UMatrix[[All, 2]]
(* {0.547576 - 0.0308803 I, 0.66694, -0.499378 + 0.0708532 I, 0} *)
(* {0.548446, 0.665882 + 0.0375521 I, -0.502575 + 0.0426233 I, 0} *)
(* {0.548446, 0.665882 + 0.0375522 I, -0.502575 + 0.0426234 I, 0} *)

• Yeah I do know I can just order them by hand.. but I am just thinking is there an automatic way of doing it. But thank you!
– Awoo
Aug 11, 2020 at 23:06