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.

  • 2
    $\begingroup$ use Eigensystem, ordering in not guaranteed to match if you use Eigenvectors and Eigenvalues separately $\endgroup$
    – I.M.
    Jul 5, 2022 at 8:25
  • $\begingroup$ 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. $\endgroup$
    – Rafifoo
    Jul 5, 2022 at 8:32

1 Answer 1


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


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


Remark. Note that your eigenvalues are only nonnegative if

(* 0 <= x <= 1 *)
  • $\begingroup$ Indeed, you are right, this is working now! Thank you ! And I agree, I forgot to mention that $x \in [0,1]$. $\endgroup$
    – Rafifoo
    Jul 5, 2022 at 9:39

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.