# Eigendecomposition of a matrix with a variable

I have an issue with a decomposition of a matrix $$B$$ that is positive semidefinite and that depends on a parameter $$x$$. Writing $$\lambda_i\geq0$$ the eigenvalues and $$\psi_i$$ the corresponding orthonormal eigenvectors, I have $$B = \sum_i \lambda_i \psi_i \psi_i^\dagger$$. Then I would like to rewrite $$B$$ as $$B = \sum_i \phi_i \phi_i^\dagger$$, with $$\phi_i = \sqrt{\lambda_i}\psi_i$$.

Concerning the Mathematica code: the matrix $$B$$ is defined as the tensor product of the following matrix $$A$$:

A = {{1, 0, 0, 1 - 2x}, {0, 0, 0, 0}, {0, 0, 0,
0}, {1 - 2x, 0, 0, 1}};
B = KroneckerProduct[A, A, A];


Once having defined matrix $$B$$, I compute the normalized eigenvectors and eigenvalues of it:

EigenVec = Map[Normalize, Eigenvectors[B]];
EigenVal = Eigenvalues[B];


Then, I define

phi[i_] := Sqrt[EigenVal[[i]]] EigenVec[[i]];


and I should be done. Yet, when checking if the rewriting of $$B$$ is working, I find that it is not, indeed

FullSimplify[Sum[KroneckerProduct[phi[i],Conjugate[Transpose[phi[i]]]], {i, 1, 64}] - B] // MatrixForm


output a non-zero matrix that has some dependency on the parameter $$x$$. I checked that there were no crossings between the eigenvalues and eigenvectors, as well as other consistency checks, without managing to understand what is wrong with that...

Any help would be appreciated.

• use Eigensystem, ordering in not guaranteed to match if you use Eigenvectors and Eigenvalues separately
– I.M.
Commented Jul 5, 2022 at 8:25
• I tried as well with Eigensystem, but I had the same kind of issue. I don't think it is coming from orderings of the eigenvectors and eigenvalues. Commented Jul 5, 2022 at 8:32

Your eigenvectors in EigenVec are normalized but not orthogonal to each other, as you can see using

Table[Dot[Conjugate[EigenVec[[i]]],EigenVec[[j]]],{i,1,64},{j,1,64}]


Your matrix B has multiple eigenvalues, which can lead to this problem. You should get the correct result using

EigenVec=Orthogonalize[Eigenvectors[B]];


Remark. Note that your eigenvalues are only nonnegative if

Reduce[Thread[EigenVal>=0]]
(* 0 <= x <= 1 *)

• Indeed, you are right, this is working now! Thank you ! And I agree, I forgot to mention that $x \in [0,1]$. Commented Jul 5, 2022 at 9:39