I am plotting the roots of a fourth-order polynomial as a function of some parameter $r$ with the following code:
mat = {{\[Lambda]^2 - 2 \[Lambda]/r + 3/(4 r^2) + 1, 2},
{2, \[Lambda]^2 + 2 \[Lambda]/r + 3/(4 r^2) + 3}};
sol1 = \[Lambda] /. Solve[Det[mat]== 0, \[Lambda]][[1]];
sol2 = \[Lambda] /. Solve[Det[mat]== 0, \[Lambda]][[2]];
sol3 = \[Lambda] /. Solve[Det[mat]== 0, \[Lambda]][[3]];
sol4 = \[Lambda] /. Solve[Det[mat]== 0, \[Lambda]][[4]];
Plot[{Im[sol1], Im[sol2], Im[sol3], Im[sol4]}, {r, .1, 2},
Frame -> True, PlotStyle -> styles, Exclusions -> None]
Plot[{Re[sol1], Re[sol2], Re[sol3], Re[sol4]}, {r, .1, 2},
Frame -> True, PlotStyle -> styles, Exclusions -> None]
The plot of the real part looks fine, but for the imaginary part it looks like Mathematica is switching between a solution and its complex conjugate for different values of the parameter $r$. This is confirmed by plotting the absolute value of the imaginary part of the four different solutions.
Hence, my question is: is there a simple way to make sure that Mathematica is plotting the same solution for every value of $r$, without switching between conjugate solutions?
Root[]
, and put in a conditional as its second argument if you already know where the conjugate switching happens. $\endgroup$