I am trying to solve a characteristic polynomial and plotting its output. The problem is that I do not know how to take the output automatically. My current code is
det2 = -λ^3 - λ^2*(p1 + p2) + λ*(p1 - p2)^2 + p3^3 + (p1 - p2)^2*(p1 + p2)
sol = Solve[det2 == 0, λ] /. {p3 -> 1 - p1 - p2, p1 -> 0}
with the output
{{λ -> 1/3 (-p2 - (4 2^(1/3) p2^2)/(-27 (1 - p2)^3 - 16 p2^3 +
3 Sqrt[3] Sqrt[27 (1 - p2)^6 + 32 (1 - p2)^3 p2^3])^(1/3) -
(-27 (1 - p2)^3 - 16 p2^3 + 3 Sqrt[3] Sqrt[27 (1 - p2)^6 +
32 (1 - p2)^3 p2^3])^(1/3)/2^(1/3))},
{λ -> -(p2/3) + (2 2^(1/3) (1 + I Sqrt[3]) p2^2)/(
3 (-27 (1 - p2)^3 - 16 p2^3 +
3 Sqrt[3] Sqrt[27 (1 - p2)^6 + 32 (1 - p2)^3 p2^3])^(
1/3)) + ((1 - I Sqrt[3]) (-27 (1 - p2)^3 - 16 p2^3 +
3 Sqrt[3] Sqrt[27 (1 - p2)^6 + 32 (1 - p2)^3 p2^3])^(1/3))/(
6 2^(1/3))},
{λ -> -(p2/3) + (2 2^(1/3) (1 - I Sqrt[3]) p2^2)/(3 (-27
(1 - p2)^3 - 16 p2^3 + 3 Sqrt[3] Sqrt[27 (1 - p2)^6 +
32 (1 - p2)^3 p2^3])^(1/3)) + ((1 + I Sqrt[3]) (-27
(1 - p2)^3 - 16 p2^3 + 3 Sqrt[3] Sqrt[27 (1 - p2)^6 +
32 (1 - p2)^3 p2^3])^(1/3))/(6 2^(1/3))}}
Usually I take the output manually. In this case I would create a three objects
eps1 = lambda1 (first solve output)
eps2 = lambda2 (second solve output)
eps3 = lambda3 (third solve output)
and finally
Plot[
{eps1, eps2, eps3}, {p2, 0, 1}, PlotRange -> {{0, 1}, {0.4, 1}},
PlotLegends -> "Expressions", GridLines -> Automatic
]
The problem is that this is a small example, but I have to do this several times for bigger matrices. Is there a way to plot the outputs in a more efficient manner?
