Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Trying to close some loose plotting
Replies: 2   Last Post: Feb 1, 2012 3:55 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Christopher O. Young

Posts: 182
Registered: 2/13/11
Re: Trying to close some loose plotting
Posted: Feb 1, 2012 3:52 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 2012-01-30 10:08:50 +0000, carlos@colorado.edu said:

> Hi - I am trying to plot the real roots of a cubic equation as
> functions of one parameter called rc, using the code below, on Mathematica 5.2.
> The plotted curves, however, show some dead spots that should not be there.
> How can I get them to fill up? I tried getting rid of the imaginary
> part when its absolute value is less that a given tolerance, but that
> trick does not
> work.
>
> Thanks for any suggestions.


I'm no expert on any of this, but I had to change a couple of
occurrences of "[Mu]" to the Greed letter mu before anything would
work. After that I only got plots for the lamda1 curve, not the lambda2
and lambda3 curves.

If I could if I could figure out what the original complex polynomial
was, I'd plot it using the height-for-modulus,
color-for-complex-argument plot at bottom, to see why lambda1 and
lambda2 weren't plotting. Or maybe I made a typo when I tried to
simplify things a little.

Is this based on Cardano's formula for the roots of a cubic?




ClearAll[\[Mu], \[Lambda], \[Beta], a, b, rc];

\[ScriptCapitalA] = Sqrt[
4 (-3 + 2 \[Mu]^2)^3 + (27 rc - 18 \[Mu] + 20 \[Mu]^3)^2]^(1/3)

\[Lambda]1 =
2 \[Mu] - (2*2^(1/3)*(-3 + 2*\[Mu]^2))/\[ScriptCapitalA]^(1/3) +
2^(2/3)*\[ScriptCapitalA]/6;

\[Lambda]2 =
1/12 (4*\[Mu] + (
2*2^(1/3)*(1 + I Sqrt[3])*(-3 + 2*\[Mu]^2))/\[ScriptCapitalA]^(1/
3) + I*2^(2/3)*(I + Sqrt[3])*\[ScriptCapitalA]^(1/3));

\[Lambda]3 =
1/12 (4*\[Mu] + (
2*2^(1/3)*(1 - Sqrt[3] I)*(-3 + 2*\[Mu]^2))/\[ScriptCapitalA]^(1/
3) - 2^(2/3)*(1 + Sqrt[3] I)*(\[ScriptCapitalA])^(1/3));

thick = AbsoluteThickness[1.25];

(*rctab={0,0.04,0.08,0.15,0.3,0.5,1,2,-0.04,-0.08,-0.15,-0.3,-0.5,-1,-\
2};*)
rctab2 = {-2, -1, -0.5`, -0.3`, -0.15`, -0.08`, -0.04`, 0,
0.04`, 0.08`, 0.15`, 0.3`, 0.5`, 1, 2};

Np = Length[rctab];

\[Lambda]1tab = Table[\[Lambda]1 /. rc -> rctab2[[i]], {i, 1, Np}];
\[Lambda]2tab = Table[\[Lambda]2 /. rc -> rctab2[[i]], {i, 1, Np}];
\[Lambda]3tab = Table[\[Lambda]3 /. rc -> rctab2[[i]], {i, 1, Np}];

\[Lambda]123 = Flatten[{\[Lambda]1tab, \[Lambda]2tab, \[Lambda]3tab}];


Plot[
(*Evaluate[\[Lambda]123],*)
\[Lambda]1tab, {\[Mu], -1, 1},
PlotStyle -> Hue[0.8 (k - 1)/(Np - 1)]~Table~{k, 1, Np},
PlotRange -> {{-1.1, 1.1}, {-0.1, 12}},
AspectRatio -> 1/5 12.1/2.2,
Frame -> True,
ImageSize -> 300
]

Here's a height-for-modulus plot of a complex cubic with real coefficients:

f[a_, b_, c_, d_, z_] := a z^3 + b z^2 + c z + d

Manipulate[
Plot3D[
Abs[f[a, b, c, d, x + y I]], {x, -4, 4}, {y, -4, 4},

PlotPoints -> 50,
MaxRecursion -> 2,

Mesh -> 11,
MeshStyle -> AbsoluteThickness[0.01],
MeshFunctions -> ({x, y} \[Function] Arg[f[a, b, c, d, x + y I]]),

ColorFunctionScaling -> False,
ColorFunction -> ({x, y} \[Function]
Hue[0.425 \[LeftFloor]12 (Arg[f[a, b, c, d, x + y I]] + \[Pi])/(
2 \[Pi])\[RightFloor]/12, sat, bri]),
PlotStyle -> Opacity[opac],
AxesLabel -> {"x", "i y", "|f(x + iy)|"}],

{{a, -1}, -2, 2},
{{b, 0}, -2, 2},
{{c, 1}, -2, 2},
{{d, 0}, -2, 2},

{{opac, 0.5, "Opacity"}, 0, 1},
{{sat, 0.5, "Saturation"}, 0, 1},
{{bri, 1, "Brightness"}, 0, 1}
]





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.