Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I want to plot the parametric diagram of {y[t],z[t]}, in which I manipulate a parameter, ω, from $[1, 10 \pi]$. Here is what I have attempted, but I can't get a plot. I think there is something wrong with my Manipulate expression.

Can anyone give me some advice?

Remove["Global`*"]

dieff = {y''[t] == ω z'[t], 
z''[t] == -ω y'[t] + ω E1/B};

inicond = {y[0] == y'[0] == z[0] == z'[0] == 0};

eqnlist = Join[dieff, inicond];

soln = DSolve[eqnlist, {y[t], z[t]}, t][[1]];

E1 = B = 1;

Print["y[t] = ", y[t] /. soln]
Print["z[t] = ", z[t] /. soln]

Manipulate[ParametricPlot[ {y[t], z[t]} /. soln, {t, 0, 2}], {ω, 0, 10 π}]
share|improve this question

marked as duplicate by Michael E2, ubpdqn, m_goldberg, bobthechemist, rm -rf Mar 11 at 0:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers 3

I post for insights into $\omega$ bounds:

fun[w_] := {y[t], z[t]} /. 
  First@DSolve[{y''[t] == w z'[t], z''[t] == -w y'[t] + w , 
     y[0] == y'[0] == z[0] == z'[0] == 0}, {y[t], z[t]}, t]
Manipulate[
 Column[{ParametricPlot[Evaluate[fun[w] /. t -> u], {u, 0, 2}, 
    PlotRange -> {{-1.5, 1.5}, {0, 2}}, Frame -> True, 
    FrameLabel -> TraditionalForm /@ {y[t], z[t]}], 
   Plot[Evaluate[fun[w] /. t -> u], {u, 0, 2}, 
    PlotStyle -> {Red, Blue}, PlotRange -> {-2, 2}, 
    PlotLegends -> TraditionalForm /@ {y[t], z[t]}]}], {{w, 0, 
   "\[Omega]"}, 0, 2 Pi}]

enter image description here

share|improve this answer
    
+1 ubpdqn, you make the neatest animated examples that always further illuminate the question at hand! –  rasher Mar 6 at 10:47
    
@rasher thank you for the kind words...just thought important to notice solution blows out as $\omega$ passes around $2\pi$ –  ubpdqn Mar 6 at 10:57

Try changing Manipulate to

With[{f1 = y[t] /. soln, f2 = z[t] /. soln}, 
 Manipulate[ParametricPlot[{f1, f2}, {t, 0, 2}], {ω, 0.1, 10 π}]]

Note also change to omega lower bound - you had division by zero with current example.

share|improve this answer
    
It works! But I think yours is essentially the same as mine;yet, mine wouldn't work. I'm confused. –  Lawerance Mar 6 at 0:09
    
@Lawerance: There's several ways to accomplish same thing, but while yours may look the same basically, what happens within Manipulate causes different outcome. See the documentation re: Manipulate, and the hows/whys of evaluation using it. There's a good tutorial overview as part of the documentation. –  rasher Mar 6 at 0:12

Another solution :

 Manipulate[
  ParametricPlot[soln[[All, 2]] /.ω -> s, {t, 0, 2}, 
   PlotRange -> {{0, 3}, {0, 2}}], {s, $MachineEpsilon, 10 π}]
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.