so, I have a symmetric, analytic matrix $\mathbf{H}(x)$ ($x$ is real). Because $\mathbf{H}(x)$ is analytic and $x$ is real, it is possible to find analytic functions for the eigenvectors and the eigenvalues of $\mathbf{H}(x)$. at $x=0$, each eigenvalue $\vec v_i(0)$ is associated with an eigenvalue $\lambda_i(0)$, where the eigenvalues are ordered $\lambda_{i}\leq\lambda_{i+1}$.
As $x$ changes, some eigenvector $\vec v_i(x)$ "switch place" because the eigenvalues cross. This is illustrated in the following example. The green and grey lines switch place at $x\approx1.2$, because I used a diagonalization algorithm that orders the eigenvalues by their values:
Algorithms such as numpy's og scipy's $\texttt{eigh}$, of course, do not have information about the function $\mathbf{H}(x)$ and simply order the eigenvalues by their value for each $x$.
So, my questions are:
- Does anyone know of a good algorithm to re-order the eigenvector-eigenvalue pair in such a way that they are analytic functions (that is, to "swap green and grey" at $x\approx1.2$ etc.?)
- In my application, I will only have the eigenvalues and eigenvectors for few $x$ (I can generate them for more values, but that is expensive), but I still need them in such an order that they are associated with the right function. Hence, the function $\mathbf{H}(x)$ is not explicitely available.
- Some eigenvalues are degenerate for all $x$ (in addition to them switching places with other eigenvalues). So, numpy/scipy will return a "random" orthogonal pair of vectors. Of course, the subspace spanned by these eigenvectors will be analytic, but some type of algorithm needs to be applied to make the individual eigenvectors analytic.
What I have been thinking so far:
- Because the eigenvectors are analytic, when no crossings occur, we have that $\vec v_i(x)^T \vec v_j(x+\delta x)\approx\delta_{ij}$. Based on this observation, we can "regain" the correct order. This seems to work pretty well, unlike (Continuity of eigenvectors of parametric matrix), where it seems to have failed.
- The same answer as 1., where some threshold is used for when more samples need to be obtained.
- One can use the orthogonal Procrustes algorithm to "similarize" the pair of vectors as much as possible to some arbitrary reference,for example $x=0$, though I am not sure whether this will yield analytic eigenvectors.
Before I implement any more of this, it would be nice to hear if someone has a more elegant solution or possibly knows of an implementation in some library (ideally Python).