2
$\begingroup$

Eigenvalues[M,1] can be used to return the largest eigenvalue in absolute value. Is there a simple way to obtain the largest positive eigenvalue instead, as well as the corresponding eigenvector/s?

$\endgroup$
3
  • $\begingroup$ Eigensystem[M, 1]? $\endgroup$ – kglr Jul 7 '17 at 13:31
  • $\begingroup$ @kglr That gives the largest eigenvalue according to absolute value. I want the largest positive eigenvalue (there might be another negative eigenvalue with larger absolute value that I do not want). $\endgroup$ – becko Jul 7 '17 at 13:33
  • $\begingroup$ becko, i see. thanks. $\endgroup$ – kglr Jul 7 '17 at 13:33
2
$\begingroup$
evv = Module[{es = Eigensystem[#], ord}, ord = Ordering[-es[[1]]]; es[[All, ord[[1]]]]] &;


m = N[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}];    
evv @ m

{16.1168, {-0.231971, -0.525322, -0.818673}}

evv[-m]

{1.11684, {0.78583, 0.0867513, -0.612328}}

Update: Using the options in Jens's answer in the q/a linked by @Carl

evv2 = Eigensystem[#, 1, Method -> {"Arnoldi", "Criteria" -> "RealPart"}][[All,1]]&;
evv2@ m

{16.1168, {-0.231971, -0.525322, -0.818673}}

$\endgroup$
3
  • $\begingroup$ There is no way to bypass the computation of all the eigenvalues when you are only interested in the largest positive one? $\endgroup$ – becko Jul 7 '17 at 14:04
  • $\begingroup$ @becko, good point. i can't think of any way. $\endgroup$ – kglr Jul 7 '17 at 14:11
  • $\begingroup$ I figured out something that could work in some cases, see my answer. $\endgroup$ – becko Jul 7 '17 at 14:15
0
$\begingroup$

This should do it:

Last@Sort@Cases[Transpose@Eigensystem@M,{_Real,__}]
$\endgroup$
1
  • 1
    $\begingroup$ It would be helpful to demonstrate the code by running in on m given in other answers. $\endgroup$ – bbgodfrey Jul 7 '17 at 14:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.