# Obtain only positive complex solutions

By setting the determinant of a matrix to 0, I obtain 6 complex solutions for w and plot them. However, You can clearly see that the negative solutions mirror the positive solutions as the solution corresponds to the positive and negative roots.

k = 9; l = 12; m = 2; M = 4 ;
mat = {{m*w^2 - 2*k, k, k*Exp[-3 I*ka]}, {k, M*w^2 - (l + k),
l}, {-k*Exp[-3 I*ka], l, M*w^2 - (k - l)}};
mydet = ExpToTrig[Det[mat]];
sol = Solve[mydet == 0, w];
funcs = w /. sol;
ReImPlot[funcs, {ka, 0, \[Pi]}, PlotLabel -> "\[Omega](ka) ",
PlotLegends -> {{"\[Omega]1", "\[Omega]2", "\[Omega]3", "\[Omega]4",
"\[Omega]5", "\[Omega]6"}, "ReIm"}, ReImLabels -> {"Re", "Im"},
Frame -> True]


I would like to extract the positive complex solutions of w to use in the following derivative to find the density of states. I tried plotting for w2, w4, w6 only but it seems that I will be missing some other positive solutions for different ka's.

n = Pi / ka;
dkdw = D[funcs, ka];
dNdw = n/Pi * dkdw;
ReImPlot[dNdw , {ka, 0, \[Pi]}, PlotLabel -> "Density of States ",
PlotLegends -> {{"dN/d\[Omega]1", "dN/d\[Omega]2", "dN/d\[Omega]3",
"dN/d\[Omega]4", "dN/d\[Omega]5", "dN/d\[Omega]6"}, "ReIm"},
ReImLabels -> {"Re", "Im"}, Frame -> True]


In summary, I want to extract the upper part of the first graph to plot the derivative of those solutions in the second graph.

• Your solutions are all contained in the funcs list, and there’s only six of them, so can’t you just plot them one by one (say, the real part only for instance), so you can inspect them visually and select the ones that you want? – MarcoB Dec 11 '19 at 12:54

Just consider the fourth one:

Plot[Re@funcs[[4]], {ka, 0, Pi}, PlotPoints -> 100]


The plot hints the standard Mathematica approach is trajecting across an "implied" branch-cut in a non-analytically-continuous path. Note the function has square and cube roots. I can't imagine you would want this if you plan to take derivatives. If you need analytically-continuous routes over the solutions, you may be able to use this approach: Dealing with branch cuts

Perhaps it would also be useful if I point out, thanks to J.M. in the link above, we could make the substitution $$e^{-3 i ka}=z$$, then apply GroebnerBasis to the first function for example and obtain: $$f(z,w)=-432 w^4 + 32 w^6 + 81 (43 - 21 z^2) + 18 w^2 (31 + 18 z^2)$$ Now that's an easy function to route an analytically-continuously path through the solution by letting $$z=e^{-3 i ka}$$ and following the technique in the link.

Take real numbers

k = 9.; l = 12.; m = 2.; M = 4.;
mat = {{m*w^2 - 2*k, k, k*zeta}, {k, M*w^2 - (l + k),
l}, {-k*zeta, l, M*w^2 - (k - l)}};
mydet = ExpToTrig[Det[mat]];
sol = Quiet@Solve[mydet == 0, w];
funcs = Chop[w /. sol /. {zeta -> Exp[-3I ka]} // FullSimplify];
Show[Table[Plot[Max[0, (funcs[[k]] + Conjugate[funcs[[k]]])/2], {ka, 0, \[Pi]}, PlotStyle -> Black], {k, 1, Length[funcs]}], PlotRange -> All]
Show[Table[Plot[Max[0, (funcs[[k]] - Conjugate[funcs[[k]]])/(2 I)], {ka,
0, \[Pi]}, PlotStyle -> Blue], {k, 1, Length[funcs]}], PlotRange -> All]


• Brilliant, thanks! But I do need them all to be in one plot and to indicate the labels of each solution. I can't seem to figure out how to do that with your code. I tried PlotLabels in the Plot but it did not work. I believe that the solutions for w are no longer separated? – Melav Dec 13 '19 at 12:46