10
$\begingroup$

I'm having an issue with the Eigensystem command. I need to diagonalize a bunch of 3 by 3 complex valued matrices, but more importantly, I need to keep the exact ordering of their eigenvalues once brought to their diagonal form.

For example, if

A = { {1.999, 0.000428712*I, 0} , {-0.000428712*I, 2.00072, 0} , {0, 0, -4.00057} }

then Eigensystem[A] returns the three eigenvalues (with their corresponding eigenvectors) listed in order of decreasing magnitude (absolute value).

What is even more annoying is if my loop runs into an already diagonal 3 by 3 matrix such as B = {{2,0,0},{0,-3,0},{0,0,2}}, it will reorder the eigenvalues as {-3,2,2}.

Is there a command that gives me the eigenvalue without re-sorting them?

$\endgroup$
18
  • $\begingroup$ What is it about your application that requires the order to be maintained? $\endgroup$
    – rcollyer
    Jun 4, 2012 at 18:43
  • 4
    $\begingroup$ No, there is no command that returns the eigenvalues in a different order. Can you explain in exactly what order you need to have them? Any order is equally valid, just as any reordering of one diagonal matrix is an equally valid diagonalization. How do you define your preferred order? You're saying "How do I keep the right ordering of eigenvalues?", but you did not explain clearly what you consider to be the "right" order. $\endgroup$
    – Szabolcs
    Jun 4, 2012 at 18:45
  • 1
    $\begingroup$ Let me clarify. All my 3*3 matrices are given WRT an identical, ordered basis set. In my case the ordering matters because it relates to a certain physical system with three energy curves. For example, if B={{2,0,0},{0,-3,0},{0,0,2}} which is already diagonal, then the first eigenvalue 2 will correspond to (x1,y1), the second to (x1,y2) and the third to (x1,y3), where y1, y2 and y3 are three points on three different energy curves (in this case two of my eigenvalues are degenerate). If Eigensystem reorders my eigenvalues it becomes very complicated for me to tell these values apart. $\endgroup$
    – drg
    Jun 4, 2012 at 19:03
  • 1
    $\begingroup$ But, Eigensystem tells you how it reorders B by giving you the eigenvectors, too. $\endgroup$
    – rcollyer
    Jun 4, 2012 at 19:12
  • 3
    $\begingroup$ Just a guess, but maybe SchurDecomposition[matrix][[2]] will indicate the eigenvalues in the ordering you want. If so, then it should not be too difficult from there to get the corresponding eigenvectors, as delivered by Eigensystem, into the desired order. $\endgroup$ Jun 4, 2012 at 19:18

3 Answers 3

6
$\begingroup$

Just a guess, but maybe SchurDecomposition[matrix][[2]] will indicate the eigenvalues in the ordering you want. If so, then it should not be too difficult from there to get the corresponding eigenvectors, as delivered by Eigensystem, into the desired order.

$\endgroup$
2
  • $\begingroup$ This is not working for me. Can I get a slightly better explanation? $\endgroup$
    – Santiago
    Oct 21, 2015 at 15:52
  • $\begingroup$ @Santi I'm sure the statute of limitations has expired on this, but I guess the idea was that SchurDecomposition would not reorder if presented with an upper triangular matrix. So the eigenvalues would be seen as just the diagonal of the input, and obtained as Diagonal[SchurDecomposition[matrix][[2]]]. $\endgroup$ Oct 21, 2015 at 18:38
3
$\begingroup$

Make a list of {eigenvalues, eigenvectors} and sort it with respect to the eigenvalues.

A = {{1.999, 0.000428712*I, 0}, {-0.000428712*I, 2.00072, 0}, {0, 
0, -4.00057}};
{eigs, vecs} = Eigensystem[A];
list1 = Partition[Riffle[eigs, vecs], 2];
list2 = Sort[list1, #1[[1]] < #2[[1]] &]; 
list2 // MatrixForm

you getenter image description here

$\endgroup$
1
  • 2
    $\begingroup$ SortBy[] would be more convenient for this. $\endgroup$ Jul 2, 2016 at 20:25
0
$\begingroup$

This question has a lot of time, but I think that the following code may be usefull.

A = {{1.999, 0.000428712*I, 0}, {-0.000428712*I, 2.00072, 0}, {0, 
0, -4.00057}};
{eigs, vecs} = Eigensystem[A];
ord = Ordering[eigs];
eigsorted = eigs[[ord]];
vecsorted = vecs[[ord]];
{eigsorted, vecsorted}

you obtain

{{-4.00057, 1.9989, 2.00082}, {{0. + 0. I, 0. + 0. I, 1. + 0. I}, {0. - 0.973387 I, 0.229169 + 0. I, 0. + 0. I}, {0. + 0.229169 I, 0.973387 + 0. I, 0. + 0. I}}}

The result is sorted by increasing eigenvalues with its corresponding eigenvector. I use the above instruction within a module if the matrix A depends on an external parameter.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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