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}


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)

  • 2
    $\begingroup$ Please share your 12x12 matrix as well. Also, take a look at (59172), (63003), and (25743). $\endgroup$
    – MarcoB
    Jun 12, 2016 at 18:28
  • $\begingroup$ 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. $\endgroup$
    – Manuel
    Jun 12, 2016 at 22:02
  • 1
    $\begingroup$ You should add your matrix to your original question (use the edit link underneath it) or, perhaps preferentially, paste it somewhere online (e.g. pastebin) and provide a link to download it. $\endgroup$
    – MarcoB
    Jun 12, 2016 at 23:55
  • 1
    $\begingroup$ related mathematica.stackexchange.com/q/83906/2079 $\endgroup$
    – george2079
    Jun 13, 2016 at 1:50
  • $\begingroup$ @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?) $\endgroup$
    – Manuel
    Jun 13, 2016 at 8:40

1 Answer 1


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}]

enter image description here

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}];

enter image description here

  • $\begingroup$ I believe that the OP is interested in the case where the surfaces intersect one another. $\endgroup$
    – bbgodfrey
    Jun 13, 2016 at 12:37
  • $\begingroup$ Yes indeed. surfaces might inteesct or even be degenerate for a volume in space $\endgroup$
    – Manuel
    Jun 13, 2016 at 12:56
  • $\begingroup$ 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}}. $\endgroup$
    – Sumit
    Jun 13, 2016 at 13:07
  • $\begingroup$ 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. $\endgroup$
    – Manuel
    Jun 13, 2016 at 13:38

Your Answer

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

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