Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8240 > unrolled thread
| Started by | carlos@colorado.edu |
|---|---|
| First post | 2012-01-30 10:08 +0000 |
| Last post | 2012-02-01 08:55 +0000 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Trying to close some loose plotting carlos@colorado.edu - 2012-01-30 10:08 +0000
Re: Trying to close some loose plotting Chris Young <cy56@comcast.net> - 2012-02-01 08:52 +0000
Re: Trying to close some loose plotting Chris Young <cy56@comcast.net> - 2012-02-01 08:55 +0000
| From | carlos@colorado.edu |
|---|---|
| Date | 2012-01-30 10:08 +0000 |
| Subject | Trying to close some loose plotting |
| Message-ID | <jg5q7i$h4d$1@smc.vnet.net> |
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.
ClearAll[\[Mu],\[Lambda],\[Beta],a,b,rc];
\[Lambda]1=(2*\[Mu]-(2*2^(1/3)*(-3+2*\[Mu]^2))/(27*rc-18*\[Mu]+20*\
[Mu]^3+
Sqrt[4*(-3+2*\[Mu]^2)^3+(27*rc-18*\[Mu]+20*\
[Mu]^3)^2])^(1/3)+2^(2/3)*
(27*rc-18*\[Mu]+20*\[Mu]^3+Sqrt[4*(-3+2*\[Mu]^2)^3+(27*rc-18*\[Mu]
+20*\[Mu]^3)^2])^(1/3))/6;
\[Lambda]2=(4*\[Mu]+(2*2^(1/3)*(1+I*Sqrt[3])*(-3+2*\[Mu]^2))/(27*rc-18*
\[Mu]+20*\[Mu]^3+
Sqrt[4*(-3+2*\[Mu]^2)^3+(27*rc-18*\[Mu]+20*\[Mu]^3)^2])^(1/3)+
I*2^(2/3)*(I+Sqrt[3])*(27*rc-18*\[Mu]+20*\[Mu]^3+Sqrt[4*(-3+2*\
[Mu]^2)^3+
(27*rc-18*\[Mu]+20*\[Mu]^3)^2])^(1/3))/12;
\[Lambda]3=(4*\[Mu]+(2*2^(1/3)*(1-I*Sqrt[3])*(-3+2*\[Mu]^2))/(27*rc-18*
\[Mu]+20*\[Mu]^3+
Sqrt[4*(-3+2*\[Mu]^2)^3+(27*rc-18*\[Mu]+20*\[Mu]^3)^2])^(1/3)-
2^(2/3)*(1+I*Sqrt[3])*(27*rc-18*\[Mu]+20*\[Mu]^3+Sqrt[4*(-3+2*\
[Mu]^2)^3+
(27*rc-18*\[Mu]+20*\[Mu]^3)^2])^(1/3))/12;
thick=AbsoluteThickness[1.25];
p1style={{thick,RGBColor[0,0,0]},
{thick,RGBColor[1,0,0]}, {thick,RGBColor[0,1,0]},
{thick,RGBColor[0,0,1]}, {thick,RGBColor[1,1/2,0]},
{thick,RGBColor[1/2,0,1]},{thick,RGBColor[1,0,1]},
{thick,RGBColor[1,0,1/2]},{thick,RGBColor[1,0,0]},
{thick,RGBColor[0,1,0]}, {thick,RGBColor[0,0,1]},
{thick,RGBColor[1,1/2,0]},{thick,RGBColor[1/2,0,1]},
{thick,RGBColor[1,0,1]}, {thick,RGBColor[1,0,1/2]}};
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};
Np=Length[rctab];
\[Lambda]1tab=Table[\[Lambda]1/.rc->rctab[[i]],{i,1,Np}];
\[Lambda]2tab=Table[\[Lambda]2/.rc->rctab[[i]],{i,1,Np}];
\[Lambda]3tab=Table[\[Lambda]3/.rc->rctab[[i]],{i,1,Np}];
\[Lambda]123=Flatten[{\[Lambda]1tab,\[Lambda]2tab,\[Lambda]3tab}];
Off[Plot::"plnr"];
Plot[Evaluate[\[Lambda]123],{\[Mu],-1,1},PlotStyle->p1style,
PlotRange->{-1.5,1.5},AspectRatio->1.5,Frame->True,
ImageSize->300,DisplayFunction->$DisplayFunction]
[toc] | [next] | [standalone]
| From | Chris Young <cy56@comcast.net> |
|---|---|
| Date | 2012-02-01 08:52 +0000 |
| Message-ID | <jgauh7$etg$1@smc.vnet.net> |
| In reply to | #8240 |
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}
]
[toc] | [prev] | [next] | [standalone]
| From | Chris Young <cy56@comcast.net> |
|---|---|
| Date | 2012-02-01 08:55 +0000 |
| Message-ID | <jgaum0$eul$1@smc.vnet.net> |
| In reply to | #8240 |
Here's a correction. My last posted version didn't plot on its own.
http://home.comcast.net/~cy56/Mma/RootsOfCubicPic3.png
http://home.comcast.net/~cy56/Mma/RootsOfCubic;6.nb
\[ScriptCapitalA][\[Mu]_, rc_] = Sqrt[
4 (-3 + 2 \[Mu]^2)^3 + (27 rc - 18 \[Mu] + 20 \[Mu]^3)^2]^(1/3);
\[Lambda]1[\[Mu]_, rc_] =
2 \[Mu] - (
2*2^(1/3)*(-3 + 2 \[Mu]^2))/\[ScriptCapitalA][\[Mu], rc]^(1/3) +
2^(2/3)*\[ScriptCapitalA][\[Mu], rc]/6;
\[Lambda]2[\[Mu]_, rc_] =
1/12 (4*\[Mu] + (
2*2^(1/3)*(1 + I Sqrt[3])*(-3 +
2*\[Mu]^2))/\[ScriptCapitalA][\[Mu], rc]^(1/3) +
2^(2/3)*(-1 + Sqrt[3] I)*\[ScriptCapitalA][\[Mu], rc]^(1/3));
\[Lambda]3[\[Mu]_, rc_] =
1/12 (4*\[Mu] + (
2*2^(1/3)*(1 - Sqrt[3] I)*(-3 +
2*\[Mu]^2))/\[ScriptCapitalA][\[Mu], rc]^(1/3) -
2^(2/3)*(1 + Sqrt[3] I)* \[ScriptCapitalA][\[Mu], rc]^(1/3));
thick = AbsoluteThickness[1.25];
rctab = {-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[\[Mu]_] =
Table[\[Lambda]1[\[Mu], rc] /. rc -> rctab[[i]], {i, 1, Np}];
\[Lambda]2tab[\[Mu]_] =
Table[\[Lambda]2[\[Mu], rc] /. rc -> rctab[[i]], {i, 1, Np}];
\[Lambda]3tab[\[Mu]_] =
Table[\[Lambda]3[\[Mu], rc] /. rc -> rctab[[i]], {i, 1, Np}];
\[Lambda]123[\[Mu]_, rc_] =
Flatten[{\[Lambda]1tab[\[Mu], rc], \[Lambda]2tab[\[Mu],
rc], \[Lambda]3tab[\[Mu], rc]}];
Off[Plot::"plnr"];
Plot[
Evaluate @ \[Lambda]1tab[\[Mu]], {\[Mu], -1, 1},
PlotStyle -> Table[Hue[0.8 (k - 1)/(Np - 1)], {k, 1, Np}],
PlotRange -> {{-1.1, 1.1}, {-0.1, 12}},
PlotPoints -> 300,
MaxRecursion -> 6,
AspectRatio -> 1/5 12.1/2.2,
Frame -> True,
FrameStyle -> LightGray,
Axes -> False,
ImageSize -> 300
]
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web