I have the following function
eigen1 = 1/3*(p + sig - u2/(2^(8/3)*sig) - 3*I*ω);
Where
p = (Γ + κ1 + κ2)/2;
u1 = 36 g1^2 (-2 p + 3 κ2) + (36 g2^2 + (2 p - 3 κ1) (2 p - 3 κ2)) (4 p
- 3(κ1 + κ2));
u2 = (2^(2/3)*(12 g1^2 + 12 g2^2 - 4 p^2 + 6 p (κ1 + κ2) - 3 (κ1^2 + κ1 κ2 +
κ2^2)));
sig = ((u1 + Sqrt[u1^2 + u2^3])/16)^(1/3);
I am only interested in plotting the imaginary part of eigen1
as a function of g1
while varying the parameter g2
and letting the other parameters (κ1
, κ2
, Γ
, ω
) take on fixed values
testplot1 = ComplexExpand[Im[eigen1]] /. {Γ -> 1, κ1 -> 2, κ2 -> 3, ω -> 0};
This should leave testplot1
only dependent on g1
and g2
. But doing
Manipulate[Plot[Evaluate@testplot1, {g1, 0, 5}, PlotRange -> All], {g2, 1, 10}]
returns a blank graph. I decided to print testplot1
to see if there are any missing variables that I have yet to define, but everything in testplot1
really is just a function of g1
and g2
. Printing testplot1
gives
-((7 Sin[1/
3 Arg[108 g1^2 - 108 g2^2 +
Sqrt[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]]])/(3 2^(
2/3) ((108 g1^2 -
108 g2^2 + (((108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3)^2)^(1/4)
Cos[1/2 Arg[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]])^2 +
Sqrt[((108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3)^2]
Sin[1/2 Arg[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]]^2)^(1/6))) + (2 2^(1/3)
Sin[1/3 Arg[
108 g1^2 - 108 g2^2 +
Sqrt[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]]])/(3 ((108 g1^2 -
108 g2^2 + (((108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3)^2)^(1/4)
Cos[1/2 Arg[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]])^2 +
Sqrt[((108 g1^2 - 108 g2^2)^2 + 4 (-3 + 12 g1^2 + 12 g2^2)^3)^2]
Sin[1/2 Arg[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]]^2)^(1/6)) + (2 2^(1/3)
g1^2 Sin[
1/3 Arg[108 g1^2 - 108 g2^2 +
Sqrt[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]]])/((108 g1^2 -
108 g2^2 + (((108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3)^2)^(1/4)
Cos[1/2 Arg[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]])^2 +
Sqrt[((108 g1^2 - 108 g2^2)^2 + 4 (-3 + 12 g1^2 + 12 g2^2)^3)^2]
Sin[1/2 Arg[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]]^2)^(1/6) + (2 2^(1/3)
g2^2 Sin[
1/3 Arg[108 g1^2 - 108 g2^2 +
Sqrt[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]]])/((108 g1^2 -
108 g2^2 + (((108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3)^2)^(1/4)
Cos[1/2 Arg[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]])^2 +
Sqrt[((108 g1^2 - 108 g2^2)^2 + 4 (-3 + 12 g1^2 + 12 g2^2)^3)^2]
Sin[1/2 Arg[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]]^2)^(1/6) + (1/(6 2^(1/3)))((108 g1^2 -
108 g2^2 + (((108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3)^2)^(1/4)
Cos[1/2 Arg[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]])^2 +
Sqrt[((108 g1^2 - 108 g2^2)^2 + 4 (-3 + 12 g1^2 + 12 g2^2)^3)^2]
Sin[1/2 Arg[(108 g1^2 - 108 g2^2)^2 +
4 (-3 + 12 g1^2 + 12 g2^2)^3]]^2)^(1/6)Sin[1/3 Arg[
108 g1^2 - 108 g2^2 +
Sqrt[(108 g1^2 - 108 g2^2)^2 + 4 (-3 + 12 g1^2 + 12 g2^2)^3]]]]]]
which seems long and nasty. The point is that the only variables in here are g1
and g2
so Manipulate should really work and I don't know what went wrong. My initial diagnosis would be that the Arg
that appears in testplot1
throughout was interfering with Manipulate but I am not sure if that's the real issue. I intend to vary not just g2
but eventually all of the other parameters (κ1
, κ2
, Γ
, ω
) down the road but I cannot vary even one parameter at this point. Any thoughts?
ComplexExpand
, which is really only a function for manipulating the form of an equation, and then re-printtestplot
you'll see that you're trying to take the imaginary part of a real number, which is why this is 0 regardless of the values ofg1
andg2
. It looks like there may be values ofg1
andg2
for which this has an imaginary part, but it isn't imaginary in general. $\endgroup$Re
part ofeigen1
Manipulate
does seem to give a blank plot, so your problem still stands, but I think you could reduce this to an MWE. My guess is it has to do with some tricky evaluation, since if I copy and paste the expression forRe[eigen1] /. {\[CapitalGamma] -> 1, \[Kappa]1 -> 2, \[Kappa]2 -> 3, \[Omega] -> 0}
directly into the manipulate it works. $\endgroup$ComplexExpand
, I concur that there may be values ofg1
andg2
for which it becomes imaginary, since there is a square root in the denominator and it's possible to make the argument less than 0 by picking appropriateg1
andg2
values. But why wouldn't manipulate take that into account when I'm varyingg1
andg2
? Surely if I keep increasingg1
andg2
it should be imaginary but this is not the case even if I increase the range ofg1
andg2
from 5 to 50 and 10 to 100 respectively $\endgroup$Manipulate
can get hairy but there are some experts around.DynamicModule
is a little more work, but can make things more straight forward, you might search the site for some old questions aboutManipulate
andDynamicModule
. $\endgroup$