Always I have to sort the results manually it is very tedious . Is there any other way to carry out this with out using revers function.


The answer, so far as I can tell, is the Reverse function:


Alternately, if you want to extract the $n$th smallest eigenvalue and the $n$th smallest eigenvector, you can use

First[Eigenvectors[{K, M}, -n]]
First[Eigenvalues[{K, M}, -n]]

All of this assumes that by "largest" and "smallest", you mean largest & smallest by absolute value. If all of the eigenvalues are known to be positive, then these are the same thing. (I assume from your notation that you're doing a normal mode problem, in which case all the eigenvalues should be positive if the system is stable.)

| improve this answer | |

Eigensystem orders eigenvalues and eigenvectors in decending order with respect to absolute value. So Reverse is not always the right answer. But you may employ Ordering:

A = # + #\[Transpose] &@RandomReal[{-1, 1}, {6, 6}];
B = #.#\[Transpose] &@RandomReal[{-1, 1}, {6, 6}];
{val, vec} = Eigensystem[{A,B}];
i = Ordering[val]
{val[[i]], vec[[i]]}

{2, 3, 5, 6, 4, 1}

| improve this answer | |
  • $\begingroup$ SeedRandom[1]; {val, vec} = Eigensystem[# + #[Transpose] &@{K, M}] i = Ordering[val] {val[[i]], vec[[i]]} $\endgroup$ – acoustics Oct 25 '18 at 5:39
  • $\begingroup$ I Tried this but its in not working $\endgroup$ – acoustics Oct 25 '18 at 5:40
  • 1
    $\begingroup$ Then try SeedRandom[1]; {val, vec} = Eigensystem[{K, M}]; i = Ordering[val]; {val[[i]], vec[[i]]}. I used # + #[Transpose] &@ only to obtain a symmetric, indefinite matrix. $\endgroup$ – Henrik Schumacher Oct 25 '18 at 5:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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