# How to sort eigenvalues?

I am trying to find Eigenvalues to a 12x12 Matrix ($H$) dependent on two variables $x$ and $y$. Later I want to do a 3D plot of one eigenvalue ($E$) over $x$ and $y$.

An analytical solution is not possible so what I calculate a Table of numerical solutions and a ListPlot:

Solution = Table[
Table[{x, y, N[Eigenvalue[H[x, y]]][[E]]}, {x, 0, 1}, {y, 0, 1}],
{E, 1, 12}
];

ListPlot3D[{Solution[[1]]}]


My Problem: apparently every time the eigenvalues to $H$ for a specific $x$ and $y$ is found, the order of eigenvalues is not the same as before. So if I do the ListPlot3D[{Solution[[1]]}] I don't actually plot the eigenvalue 1 of $H$ but points of different eigenvalues of $H$.

So my question: How can I assign an order to my eigenvalues so that I know which value belongs to which eigenstate?

(Here you can find a link to the 12x12 matrix: http://pastebin.com/kUX4gdk8)

• Please share your 12x12 matrix as well. Also, take a look at (59172), (63003), and (25743). Jun 12, 2016 at 18:28
• The matrix is to long by 8400 characters... The matrix is hermitian with constants on the diagonal and big expressions depending on x and y on the off diagonal elements. The proposed answers seam only to order the eigenvalues depending on their values which does not help me. Jun 12, 2016 at 22:02
• Jun 13, 2016 at 1:50
• @george2079 I got the exact same problem but in a 3D situation. I have dificulties understanding and complete the code for the 3D situation. How long will this calculation approximatly take? (10 minutes or 3days?) Jun 13, 2016 at 8:40

Eigenvalues are ordered by their magnitude in general. If you want to preserve the order all over the region, the only way (as much I know) is to try to get an analytical expression. For example consider this simple matrix

H[x_, y_] = {{0, Cos[x] + Cos[y]}, {Cos[x] + Cos[y], 0}}


If I go with analytical expression

ev = Eigenvalues[H[x,y]];
Plot3D[Evaluate[ev], {x, -2, 2}, {y, -2, 2}]


The eigenvalues are properly ordered. But if you try to evaluate it numerically. It will always be reordered.

data = Flatten[ Table[Join[{x, y}, Eigenvalues[H[x, y]] // N]
, {x, -2, 2, 0.1}, {y, -2., 2., 0.1}], 1];
data1 = Table[data[[All, {1, 2, 2 + n}]], {n, 2}];
ListPlot3D[data1]


• I believe that the OP is interested in the case where the surfaces intersect one another. Jun 13, 2016 at 12:37
• Yes indeed. surfaces might inteesct or even be degenerate for a volume in space Jun 13, 2016 at 12:56
• I just took a simple matrix for example. The algorithm will work for any matrix. For a simple case try H[x_, y_] = {{0, Cos[x] + Cos[y]}, {Cos[x] + Cos[y], 0}}. Jun 13, 2016 at 13:07
• This method has no use for me because I need to see the real development of one Eigenvalue. Intersections and the right color coding is essential for the interpretation of my results. Jun 13, 2016 at 13:38