# Keep important eigenvectors according to the important eigenvalues except one unimportant eigenvalue

I have an iteration whose steps extract a matrix with any possible dimension for example 3*3, 6*6, 10*10 , 4*4 ... . In any iteration I have eigenvalues and eigenvectors of the matrix extracted, for example {10^-6, 10^-4, 10^-3, 0.1, 0.4}. I wish to keep eigenvectors corresponding to just {10^-3, 0.1, 0.4}.

In fact with the below code I could sort eigenvalues and corresponded eigenvectors:

{eivals, eivecs} = Eigensystem[matrix];
{eivals, eivecs}= {eivals[[#]], eivecs[[#]]} &@ Ordering[eivals];


But, when I want to use

desiredeigenvecs=Drop[eivecs, x]


I do not know how I insert a suitable x to keep eigenvectors according to the important eigenvalues except the first unimportant eigenvalues?!!

• In this context, how do you define "important" and "unimportant"? It seems from your comment on @HenrikShumacher's post that you do not know what the threshold should be, so we can't possibly know either? Can you explain what you really mean here? Jan 9, 2020 at 17:12
• This critically depends on how you define important vs. unimportant. For instance, I could say that the only "unimportant" eigenvalue in your list is 10^-6; you, on the other hand, seem to have decided that the first unimportant one is 10^-3. That choice is arbitrary, so you have to come up with an appropriate rule yourself. Jan 9, 2020 at 17:12
• Yes, Your are completely right Jan 9, 2020 at 17:40
• I can get 10^-3 as threshold value Jan 9, 2020 at 17:43

Let's get some sample data and generate a numerical eigensystem:

iris = Keys@ExampleData[{"MachineLearning", "FisherIris"}, "Data"];
{evals, evecs} = Eigensystem@Correlation@iris;


Correlation[iris] above happens to be a $$4\times 4$$ matrix. You can then use e.g. Pick to extract the eigenvectors corresponding to eigenvalues with absolute value higher than your user-defined threshold using any one of the equivalent expressions below:

With[{threshold = 0.1}, {
Pick[evecs, evals, _?(Abs[#] > threshold &)],

Note also that, if your results are numerical, Eigensystem is guaranteed to return eigenvalues ordered in decreasing absolute value, and the corresponding normalized eigenvectors in the same order as the eigenvalues to which they correspond (see Details section). Since you seem to imply that your results are numerical, there should be no need for further ordering of the results.
x = RandomPrivatePositionsOf[UnitStep[Abs[eivals] - threshold], 0]

• I supposed you would consider eigenvalues of magnitude less than a certain threshold as unimportant. So you have to know the size of threshold, not me. Jan 9, 2020 at 17:18
• I can get 10^-3 as threshold value. But I could not understand the mean of RandomPrivatePositionsOf. Please let see for example I have UnitStep[{1, 2, 3, 10^-3, 10^-4} - 10^-3] which results in {1, 1, 1, 1, 0}. After that I must know how many 1 is in the last list for determining x!! it is correct? Jan 9, 2020 at 17:52