24
$\begingroup$

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?

$\endgroup$
10
  • 2
    $\begingroup$ 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. $\endgroup$
    – user484
    Mar 17, 2014 at 3:52
  • $\begingroup$ Have you looked at the second argument of Eigenvectors? (I don't know if this is necessarily efficient...) $\endgroup$
    – rm -rf
    Mar 17, 2014 at 3:55
  • $\begingroup$ @rm-rf, I thought of that but that's assuming the eigenvectors will be returned sorted by eigenvalue, which may not be the case. $\endgroup$
    – RunnyKine
    Mar 17, 2014 at 3:56
  • 1
    $\begingroup$ @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$. $\endgroup$
    – SlipStream
    Mar 17, 2014 at 3:58
  • 2
    $\begingroup$ @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. $\endgroup$
    – SlipStream
    Mar 17, 2014 at 4:50

3 Answers 3

32
$\begingroup$

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

(* ==> {-762.081} *)

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

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

Update: version 10

In Mathematica version 10, there is another way to get the largest or smallest eigenvalues: using a Method setting with non-default "Criteria":

-Eigenvalues[-d, 1, Method -> {"Arnoldi", "Criteria" -> "RealPart"}]

(* ==> {-762.081} *)

The Arnoldi method is used when only a few eigenvalues of a large matrix are needed. By default it uses the "Magnitude" as the criteria for finding these eigenvalues. But if you specify "RealPart" instead, the eigenvalue with the largest real part is found. Since we wanted the smallest real part, I simply reversed the sign of the matrix and undid that reversal in the end.

$\endgroup$
-1
$\begingroup$

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.

$\endgroup$
1
  • 8
    $\begingroup$ For the problem in this question, sorting the eigenvalues after the fact would be prohibitively slow. $\endgroup$
    – Jens
    Sep 8, 2014 at 15:42
-1
$\begingroup$

You can try this code to get the eigenvector of the smallest eigenvalue:

M = Table[RandomReal[],{i,5},{j,5}]; 
A = Table[M[[i,j]]+M[[j,i]],{i,5},{j,5}];
Eigensystem[A]//MatrixForm
Sort[Transpose[Eigensystem[A]],Re[#1[[1]]]<Re[#2[[1]]]&]//MatrixForm
Sort[Transpose[Eigensystem[A]],Re[#1[[1]]]<Re[#2[[1]]]&][[1,2]]//MatrixForm

the result of these codes are: enter image description here

And then you will get the eigenvector with smallest eigenvalue. The function Sort[list, p] is used to order the elements in list list by condition p. Here Transpose[Eigensystem[A]] is given by a list like:

{{eigenvalue1,{eigenvector1}},{eigenvalue2,{eigenvector2}},...}

so Sort[list,p] will help you to place the eigenvectors in the order you want.

hope it will be useful to you :)

$\endgroup$
3
  • $\begingroup$ Your method doesn't return a single value like the answer above, in fact it returns a list of unrelated values. $\endgroup$
    – Feyre
    Feb 13, 2017 at 21:21
  • $\begingroup$ sorry the brackets in the codes have some mistake. I think it is correct now. $\endgroup$
    – fan9x13
    Feb 13, 2017 at 22:19
  • 1
    $\begingroup$ see Igor Rivin's answer and the following comment. mathematica.stackexchange.com/a/59174/2079 $\endgroup$
    – george2079
    Feb 13, 2017 at 22:59

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.