I want to implement the quantum Uhlmann fidelity $$F(\rho, \sigma) := \mathrm{tr} \left[\sqrt{\sqrt{\rho} \sigma \sqrt{\rho}} \right]^2.$$ in Mathematica as a measure of "closeness" between two density matrices.
However, I think that my implementation is wrong.
$$fidelity[\rho\_, \sigma\_] := (\mathrm{Tr} \left[\sqrt{(\sqrt{\rho}).\sigma.(\sqrt{\rho})} \right])^2$$
When I test it on test$\rho$ = {{1/9, 2/3, 2/9}, {1/3, 4/9, 4/9}, {2/9, 4/9, 4/9}};
test$\sigma$ = {{1/9, 1/3, 2/9}, {1/3, 4/9, 4/9}, {2/9, 4/9, 4/9}};
I get a fidelity of 1, which is obviously not correct, as these matrices are not the same. I would expect that the fidelity is 1 if and only if $\rho=\sigma$.
MatrixPower
to take a matrix square root. What you do in your code takes each matrix element’s square root, which is very different. $\endgroup$ – Roman Sep 5 '20 at 9:08