I want to compute the eigenvalues of a family of $2 \times 2$ unitary matrices $M: [0, 2 \pi] \to U(2), k \mapsto M(k)$, which is given by \begin{align*} M(k) = \frac{1}{2} \, \begin{pmatrix} 2i \sin(k) & -2 \cos(k) \\ 1+e^{2ik} & 1-e^{2ik} \end{pmatrix}. \end{align*} Since $M(k)$ is unitary, the eigenvalues are of the form $e^{i \lambda_1(k)}$ and $e^{i \lambda_2(k)}$. My goal is to plot the bands $\lambda_1(k)$ and $\lambda_2(k)$. For this, I use the following code:

m[k_] = {{I Sin[k], -Cos[k]}, {1/2 + 1/2 Exp[2 I k], 1/2 - 1/2 Exp[2 I k]}};
evals[k_] = Eigenvalues[m[k]] // FullSimplify;
bands[k_] = -I Log[evals[k]] // FullSimplify;
Plot[{bands[k][[1]], bands[k][[2]]}, {k, 0, 2 Pi}]

enter image description here

However, we see that shortly after $k=2$ and again after $k=4$ the bands swap for reasons I don't know. I can "fix" the jump that happens when the bands go higher than $\pi$ by changing the code to

bands[k_] = -I Log[evals[k]*Exp[I 1.5 Pi]] // FullSimplify
Plot[{bands[k][[1]] + 0.5 Pi, bands[k][[2]] + 0.5 Pi}, {k, 0, 2 Pi}]

But that still leaves me with the change in color at $2$ and $4$. Is there a way to avoid this? Why does Eigenvalues suddenly swap the bands here? And also, why is the lower band not defined around $k = \pi$ (i.e. the blue line disappears around $k = \pi$)?

  • 2
    $\begingroup$ Maybe some answers to this question will help $\endgroup$
    – Chris K
    Jul 14, 2023 at 16:23

2 Answers 2


So for reasons I can not explain it makes a difference whether I use Eigenvalues or Solve on the characteristic polynomial. Additionally, using a shift I managed to eliminate the small hole I had at $\pi$. Following is the code that works

m[k_] = {{I Sin[k], -Cos[k]}, {1/2 + 1/2 Exp[2 I k], 1/2 - 1/2 Exp[2 I k]}};
cproots[k_] = x /. Solve[CharacteristicPolynomial[m[k], x] == 0, x];
shift = 0.502;
bands[k_] = -I Log[cproots[k]*Exp[ shift I Pi]];
Plot[{bands[k][[1]] + (shift) Pi, bands[k][[2]] + (shift) Pi}, {k, 0, 
  2 Pi}]

enter image description here

To get the shift of $0.502$ I just had to experiment a bit, and somehow this one does not cause any problems. So yes, I'd consider this question answered (at least according to my needs), but if someone has a short explanation as to why this works, that would be interesting.


The reason that there is a "hole" around Pi is that the function gets Complex (which Mathematica will not draw). So just take the real part, which removes the hole.

Actually, the curves are pieced together from different branches of the Log function, so mathematically they are not at all continuous but have jumps, that's why from plotting just two curves it appears you have three. The jumps you can see in your original plot at the points where the colour jumps.

You can use your original approach and colour all pieces of the function in the same colour and they will appear continuous like so:

p1 = Plot[Re[bands[k][[1]]], {k, 0, 2 Pi}, PlotStyle -> Orange];
p2 = Plot[Re[bands[k][[2]]], {k, 0, 2 Pi}, PlotStyle -> Orange];
Show[p1, p2, PlotRange -> All]

You can play with the coloring of the pieces any way you want to get the appearance you desire, but mathematically the functions are not continuous, of course this does not say anything about the physics behind the eigenvalue problm you are considering.


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.