# Large matrix: Finding eigenvalues and ordering it with respec to the highest coefficient of its eigenvectors

I have a 900x900 matrix to diagonalize. After diagonalizing it, I have a table of eigenvalues and eigenvectors. For convenience, I start with 3x3 matrix.

A = N[{{5, 0.1, 0.1}, {2, 60, 1}, {1, 0, 9}}]


Its eigenvalues and eigenvector are:

TableForm[Eigensystem[A]]


Here I have three eigenvalue which is

{60.003, 9.024, 4.971}

and the three eigenvectors respectively.

{-0.001818122243425529, -0.9999983465790367, -0.000035646889249054265}
{0.0243252697816448, -0.0205616388684505, 0.9994926214120311}
{-0.9700753102787193, 0.030880967853586353, 0.2408324276588856}


For each vetor, I want to determine the position of the biggest coefficient (in magnitude) and numbering it. For the above example, the biggest coefficient of each one is at: position 2 (the middle of the first vector), position 3 (the last element of the second vector), position 1 (the first element of the third vector). Then after that, I want the corresponding eigenvalues to be listed in the order of 1,2,3 which means 4.971 goes first and then 60.003 and finally 9.024. Do you guys have any method to do it since when I expand it to 900x900 I can not keep track of them anymore. Thank you.

Sort[MapThread[{First@Ordering[-Abs[#2], 1], #1} &,
Eigensystem[A]]][[All, 2]]


{4.97199, 60.0037, 9.02434}

• Thank you, I try it with my big matrix. I roughly check the result. Some of them are in the wrong order. Could it be any modifications for big matrix? Jul 27, 2016 at 16:21
• can you see if it works or not with a modest size matrix (maybe 10x10) that you can post? Also, You do realize your procedure is not guaranteed a unique result, ie its possible (for a large matrix quite likely) that multiple eignevectors will have their largest component in the same position. Jul 27, 2016 at 16:54

Set your matrix and take the eigensystem:

a = {{5, 0.1, 0.1}, {2, 60, 1}, {1, 0, 9}};
{eigVal, eigVec} = Eigensystem[a];


Find the max values in each eigenvector, and find their positions in order:

maxes = Max /@ Abs[eigVec];
ord = Flatten@Table[Position[Abs[eigVec[[i]]], maxes[[i]]], {i, Length[eigVal]}]

{2, 3, 1}


Then use the ordering to permute the eigenvalues

Permute[eigVal, ord]

{4.97199, 60.0037, 9.02434}

• you need to do maxes = First@MaximalBy[#, Abs] & /@ eigVec; else Position wont work due to the Abs, but note also Permute won't work in cases where the resulting ordering isn't unique. Jul 27, 2016 at 13:26
• @bill s: I checked it. It works for the above matrix, but when I extend it to 900x900, it does not work for the Permute command. Jul 27, 2016 at 16:16
• Do you have repeated eigenvalues? Jul 27, 2016 at 17:47
• @bills: yeah I do have a lot of repeated eigenvalue. Do you have any idea to solve it? Jul 29, 2016 at 21:33
• Can you build a small example where it fails? Jul 29, 2016 at 22:48