Lets say I have the following matrix:
M={{1,3+E^(I x),-1+2I x},{3+E^(-I x),2,E^(3I x)},{-1-2I x,E^(-3I x),-2}};
$$ M=\begin{pmatrix} 1& 3+\mathrm e^{ix} & -1+2ix\\3+\mathrm e^{-ix}&2&\mathrm e^{3ix}\\-1-2ix&\mathrm e^{-3ix}&-2\end{pmatrix} $$
The matrix, being Hermitian, has real eigenvalues. If I plot them, I get the following graph:
Eigenvalues[M]
Plot[%, {x, -1, 1}]
As you can see, we get discontinuous curves at $x\approx 0.51$, I believe, because of the branch cuts of the roots of the characteristic polynomial (ie, the roots are something like $A(x)\pm B(x)$ and the sign depends on $x$, so the roots change $A(x)+B(x)\to A(x)-B(x)$ at some $x\approx 0.51$). My question is: how can I solve this issue?
Please, consider the following aspects in regard to possible answers:
1) The curves need not be drawn in different colors: they can all be, for example blue.
2) The actual matrix I have is much more complicated that $M$, and it depends on a lot of parameters, so a definite localisation of the discontinuities has to be found at the time of plotting (no exact algebra is possible).
My attepmt
Draw the curves at specific points:
Eigenvalues[M]
ListPlot[Transpose@Table[%, {x, -1, 1, .05}],PlotStyle->Gray]
This is not really convincing, because Id rather have a continuous curve, as with Plot. Joined->True
doesnt help. There has to be a better way.
ADDENDUM
As @J.M. said, this can be fixed by defining a function:
m[x_]:=Eigenvalues[M]
The problem is, this doesnt work for more complex situations; consider, for example, an extension of the matrix above:
M2={{1,3+E^(I x),-1+2I x,E^(I x)},{3+E^(-I x),2,Exp[3I x],1},{-1-2I x, E^(-3I x),-2,3},{E^(-I x),1,3,4}};
$$ M_2=\begin{pmatrix} 1&1+3\mathrm e^{ix} & -1+2ix & \mathrm e^{ix}\\ 3+\mathrm e^{-ix} &2&\mathrm e^{3ix}&1\\ -1-2ix & \mathrm e^{-3ix}&-2&3\\ \mathrm e^{-ix}&1&3&4\end{pmatrix} $$
so that
m2[x_]:=Eigenvalues[M2]
Plot[m2[x], {x, -1, 1}]
the same behaviour as before.