First I will give the context of my problem. I don't know how essential it is for the question I have, but I will describe it for clarity and in case it is needed:
I have a $n \times n$ hermitian (positive definite) non full rank matrix $\rho$. This matrix depends on a parameter $\theta$ and I can find the derivative $d_{\theta} \rho$. I need to calculate a quantity $L$ that depends on the eigenvectors $|\psi_{i} \rangle $ of the matrix $\rho$ using the formula
\begin{equation} L= 2 \sum_{nm}\frac{\langle \psi_{m}|d_{\theta} \rho | \psi_{n} \rangle}{\rho_{n}+\rho_{m}} |\psi_{m}\rangle \langle \psi_{n} | \end{equation}
where $\rho_{i}$ are the eigenvalues. Then I need to calculate the quantity
\begin{equation} tr[\rho LL]\end{equation}
Analytically, the procedure is that we find the eigenvectors of the matrix $\rho$ and then we need to find the extra vectors that support the derivative of this matrix $d_{\theta} \rho $, because in general the derivative will need to be expressed in terms of all (or part of) the eigenvectors (basis) of the space. So in some cases it is easy to construct just the extra ones needed to support the derivative (and plug them into the formula above).
If we work numerically, it is possible to find all the eigenvectors of the space (and those with eigenvalue $0$), so I thought that we wouldn't have to find the part of the eigenvectors that support the derivative. But, since I was working with mathematica and matlab I found that the give different eigenvectors for the $0$ eigenvalue and that affected the result I was expecting. These eigenvectors are elements of the null space of the matrix (right?) and so there are many unitaries that can transform the eigenvectors to a different set, but they would still form a basis. So, in this case should I still choose the vectors that support the derivative or it is fine to use the basis generated by the functions? If I still need to find the appropriate vectors, how can I do that? (Or if you could refer me somewhere)
Secondly, I said that I expected that the unitary transformation wouldn't affect the result, because I can construct a unitary transformation $U$ that leaves the eigenvectors of the non zero eigenvalues the same and alters the eigenvectors of the $0$ eigenvalue. In that case it would be the same as applying this transformation to the matrix $U \rho U^{\dagger}$ and then (as long as $U$ does not depend on $\theta$) L transforms as $ULU^{\dagger}$ giving $Tr[U\rho U^{\dagger}ULU^{\dagger}ULU^{\dagger}]$ which means that this trace is invariant under unitary transformations. However, when I tried some examples in mathematica with some random generated unitaries I saw that for some transformation this is not true and the result changes. And I cannot understand why this happens, especially since there is not explicit dependence on the parameter $\theta$ in the unitary transformation. I don't know if it helps, but the difference occurs when there are complex values in the unitary (and not when they are reals, although I haven't tried every unitary). So, the second question is Why the choice of the eigenvectors of the $0$ eigenvalue change the result of the trace, especially since they are related by a unitary?
So, to sum up, my questions are the following:
1) If I have a set of eigenvectors, $k$ of them corresponding to $0$ eigenvalue, do I have to choose the vectors that support the derivative or I use the eigenvectors? If yes, how can I do that?
2) Does it make sense that if I apply a unitary to the eigenvectors, I get different results? And why?
Thank you in advance!