Message Boards Message Boards

GROUPS:

Visualize a root of one variable equation with Manipulate?

Posted 9 days ago
97 Views
|
3 Replies
|
1 Total Likes
|

Hello. I am trying to visualize root of third degree one variable equation. Delta^3-C0*delta+2==0, C is between [0,10]. But there occurs an error. Could you help to fix this problem. Thanks a lot. Here is the code:

Manipulate[
 f1 = \[CapitalDelta]0^3 - ะก*\[CapitalDelta]0 + 2;
 sol1 = FindRoot[f1 == 0, {\[CapitalDelta]0, 0.9}];
 Plot[ f1, {\[CapitalDelta]0, 0, 1}, PlotRange -> 0.1, 
  Epilog -> {{PointSize[0.03], Point[{\[CapitalDelta]0 /. sol1, 0}]},
    Text["\!\(\*SubscriptBox[\(\[CapitalDelta]\), \(0\)]\)=", {0.75, \
-0.05}], Text[
     ToString[N[\[CapitalDelta]0 /. sol1, 10]], {0.9, -0.05}]}]
 , {C0, 0.1, 5}]
3 Replies
Manipulate[g = d^3 - C0*d + 2; 
sol = NSolve[g == 0 && -4 < d < 4, d, Reals]; 
Column[{StringForm["C0=`` and Roots=``.", C0, d /. sol], 
Plot[g, {d, -4, 4}, ImageSize -> 300, 
Epilog -> {PointSize[0.02], 
Point[Transpose[{d /. sol, g /. sol}]]}, 
PlotRange -> {-15, 15}]}], {{C0, 3.5}, 0, 10}]

Or:

f[x_, c_] := x^3 - c*x + 2

Manipulate[roots = x /. NSolve[f[x, C0] == 0, x];
pts = Select[{#, 0} & /@ roots, Element[#[[1]], Reals] &] // Union;
{xmin, xmax} = If[Length[pts] > 1, MinMax[pts[[All, 1]]], {-2, 2}];
Column[{StringForm["C0=`` and Roots=``.", C0, d /. sol], 
Plot[f[x, C0], {x, xmin, xmax}, 
Epilog ->  If[Length[pts] > 0, {Red, AbsolutePointSize[6], Point[pts]}, {}],
ImageSize -> 500]}], 
Grid[{{Control[{{C0, 0}, 0, 10, 0.1, Appearance -> "Labeled"}]}}]]

Regards MI.

Thanks a lot, it works. In addition, is it possible to make show the numerical value of C?

I updated my answer. You can also press a small plus(Show Animation Control) to see values C0.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract