# Find the eigenvector associated with the smallest eigenvalue, not smallest in magnitude

I am trying to find the eigenvector of a $20000 \times 20000$ sparse matrix associated with the smallest eigenvalue. I realized that the smallest eigenvalue might be negative; for example, if the eigenvalues of the matrix are $\{-3,1,2,5 \}$, I want to find the eigenvector associated with $-3$, not $1$ or $5$. Therefore the commands Eigensystem[matrix,-1] or Eigensystem[matrix,1] cannot be guaranteed to return the desired result. Furthermore, I don't have a lower bound estimate for the possible smallest eigenvalue. Is there a way to find the eigenvectors efficiently?

-
I would have suggested finding the eigenvectors of $I + \epsilon A$ for sufficiently small $\epsilon$, but since you don't have a lower bound for the smallest eigenvalue you can't be sure that $\epsilon$ is sufficiently small. And in any case this might amplify the numerical error you incur. –  Rahul Mar 17 at 3:52
Have you looked at the second argument of Eigenvectors? (I don't know if this is necessarily efficient...) –  rm -rf Mar 17 at 3:55
@rm-rf, I thought of that but that's assuming the eigenvectors will be returned sorted by eigenvalue, which may not be the case. –  RunnyKine Mar 17 at 3:56
@rm-rf I think Eigenvectors[Matrix,-1] will give me the eigenvector associated with the smallest eigenvalue in magnitude. So in the example I gave in the question, this line of code will return the eigenvector associated with $1$, not $-10$. –  SlipStream Mar 17 at 3:58
@belisarius For large sparse matrix, mathematica will convert the matrix into a dense matrix when the second argument is not used. A dense $20000 \times 20000$ matrix just takes too much memory. –  SlipStream Mar 17 at 4:50

You can always modify the matrix so that the most negative eigenvalue is also the one with the largest absolute value, and hence corresponds to the first in the list returned by EigenVectors.

An upper bound for the largest absolute value of any eigenvalue is the Hilbert-Schmidt norm. So you can rescale your matrix by subtracting this norm times the unit matrix. The eigenvalues will then be guaranteed to be no larger than zero, and therefore the most negative eigenvalue is the one with the largest absolute value.

Here I do this with the random matrix d, nicely constructed by @belisarius to be symmetric:

d = (# + Transpose@#) &@N@RandomInteger[{-10, 10}, {2000, 2000}];

nn = Norm[Flatten[d]];
Eigenvalues[d - nn IdentityMatrix[Dimensions[d]], 1] + nn

{-765.515}


As mentioned, you can then also get the eigenvector this way:

ev = Eigenvectors[d - nn IdentityMatrix[Dimensions[d]], 1];

-

The function sortify[] given in this question:

Should eigenvalues be ordered?

Tells you how to sort the eigenvalues AND eigenvectors in the canonical order for real numbers.

-
For the problem in this question, sorting the eigenvalues after the fact would be prohibitively slow. –  Jens Sep 8 at 15:42

I had a chance to experiment with large matrices (up to 1000 x 1000 and beyond). The main problem might be coming from a completely different angle. From my experience, you absolutely must use high precision arithmetic (by using SetPrecision with some fairly large number) in order to obtain meaningful results, especially for the extreme values of eigenvalues and for the values near zero. Just experiment with Eigenvalues with and without SetPrecision with at least 100-200 digits and you will see if it affects your particular case.

I also wonder what is the mathematics behind such large matrices. Understanding the task might help.

-