1

I'm doing a double pendulum system and I wish to plot the phase portraits for each angle. I've successfully used NDSolve to solve for each of the angles. Let's just work with one angle.

What's confusing me is how $\theta$ is a function of time $t$ and I'm not sure how to "write out" $\theta'$ as a function of $\theta$. I've seen other questions and have read the answers on StreamPlot, but I find it a little confusing.

My main confusion is with the actual arguments for StreamPlot. I want to plot $\theta '$ as a function of $\theta$ (which itself is a function of $t$) over the range, say, {t, 0, 100}. But looking at the documentation for StreamPlot, it tells me I need {vx, vy} over {x, 0, 100} and {y, 0, 100}. I'm not understanding how I can turn this into something with only one variable t.

According to documentation:

enter image description here

I'm assuming we want to work with {θ'[θ], θ[t]} and (for example) {θ, 0, 100}, {t, 0, 100} which would "[generate] a stream plot of the vector field {θ'[θ], θ[t]} as a function of θ and t."

So I try:

StreamPlot[
 {Subscript[\[θ], 2]'[Subscript[\[θ], 2]] /. sol, 
 Subscript[\[θ], 2][t] /. sol}, {Subscript[\[θ], 2], 0, 
  100}, {t, 0, 100}, StreamColorFunction -> "Rainbow"
]

enter image description here

I have no idea if this is the correct plot. I'm asking: is my syntax correct for the arguments of StreamPlot if I desire to plot $θ'(θ)$?

Edit: here is my code, though I'm more looking for a general solution to my problem of "how to put in the paramters into StreamPlot":

Subscript[m, 1] = 2;
Subscript[m, 2] = 1;
Subscript[l, 1] = 1;
Subscript[l, 2] = 4;
g = 9.8;
sol = First[
   NDSolve[{Subscript[l, 1]*
        Subscript[θ, 1]''[
         t]*(Subscript[m, 1] + Subscript[m, 2]) + 
       Subscript[m, 2]*Subscript[l, 2]*Subscript[θ, 2]''[t]*
        Cos[Subscript[θ, 1][t] - Subscript[θ, 2][t]] + 
       Subscript[m, 2]*Subscript[l, 2]*(Subscript[θ, 2]'[t])^2*
        Sin[Subscript[θ, 1][t] - Subscript[θ, 2][t]] + 
       g*(Subscript[m, 1] + Subscript[m, 2])*
        Sin[Subscript[θ, 1][t]] == 0,

     Subscript[m, 2]*Subscript[l, 2]*Subscript[θ, 2]''[t] + 
       Subscript[m, 2]*Subscript[l, 1]*Subscript[θ, 1]''[t]*
        Cos[Subscript[θ, 1][t] - Subscript[θ, 2][t]] - 
       Subscript[m, 2]*Subscript[l, 1]*(Subscript[θ, 1]'[t])^2*
        Sin[Subscript[θ, 1][t] - Subscript[θ, 2][t]] + 
       Subscript[m, 2]*g*Sin[Subscript[θ, 2][t]] == 0,
     Subscript[θ, 1][0] == Pi, 
     Subscript[θ, 2][0] == Pi/2, 
     Subscript[θ, 1]'[0] == 0, Subscript[θ, 2]'[0] == 0},
    {Subscript[θ, 1], Subscript[θ, 2]},
    {t, 0, 1000}]
   ];
Michael E2
  • 235,386
  • 17
  • 334
  • 747
Sultan of Swing
  • 913
  • 1
  • 6
  • 19
  • You need to provide sol I'm afraid. – Öskå Nov 24 '14 at 10:31
  • Sure thing, I'll provide more code, but I was mainly looking for a general solution to my problem. Like say I have x[t]/.sol and x'[t]/.sol, how would I plot the phase portrait? – Sultan of Swing Nov 24 '14 at 10:34
  • This seems to be a duplicate of Phase portraits and StreamPlot – Artes Nov 24 '14 at 10:34
  • @Artes what I"m not getting is how to actually put in the parameters for StreamPlot. I'm using that question as a guide but I'm not "getting it" for some reason. – Sultan of Swing Nov 24 '14 at 10:35
  • I don't think that's the issue at this point (yes I have tried some other things and haven't gotten Subscript errors). The documentation for StreamPlot says to use {vx, vy}, and then a range for each x and y. My confusion stems from the fact that I'm using {theta1, theta1'} and a range for t. – Sultan of Swing Nov 24 '14 at 10:41
  • If you want to plot $\theta'$ vs. $\theta$ for a specific known solution, what you want is not StreamPlot, it's ParametricPlot. –  Nov 24 '14 at 10:56
  • My last comment made it sound like that, but no, that's not what I want. – Sultan of Swing Nov 24 '14 at 10:58
  • In that case, you should edit your question, because "I want to plot $θ(t)$ and $θ'(t)$, over the range, say, {t, 0, 100}" is precisely what ParametricPlot is for. ParametricPlot[{θ2[t], θ2'[t]} /. sol, {t, 0, 100}]: http://i.stack.imgur.com/MAgJO.png –  Nov 24 '14 at 11:22
  • Yeah I understand that, but immediately after that statement, I said I wanted $\theta' (\theta ( t))$. Anyways, I've tried to make it more clear. I'm just confused because the documentation calls for two functions, each with their own variable. In my case, I have two functions, both of the same variable. – Sultan of Swing Nov 24 '14 at 11:35

0 Answers0