0
$\begingroup$

Right now, I'm using this set-up to calculate one part of my differential equation function.

Manipulate[
 s = NDSolve[{p''[t] - 3 Sqrt[8*Pi*(p[t]*p[t] + p'[t]*p'[t])/6.0]*p'[t] 
 - p[t]*p[t] == 0, p[0] == po, p'[0] == ppo}, p, {t, 0, ttop}];
 Plot[Evaluate[p'[t] /. s], {t, 0, ttop}], {{po, 0},0, .1},
 {{ppo, 0}, 0, .001}, {{ttop, 1}, 0, 3}]

And that works fine, however I want to use parametric plot to plot $p'[t]$ against $p[t]$ over {t,0,ttop}. Or really I wouldn't mind specifying the range as {t,0,3} and removing the variable. However, I can't figure out how to plot two functions from the NDSolve on the parametric plot.

Currently, I'm trying this:

Manipulate[
  s = NDSolve[{p''[t] - 
  3 Sqrt[8*Pi*(p[t]*p[t] + p'[t]*p'[t])/6.0]*p'[t] - p[t]*p[t] == 
 0, p[0] == po, p'[0] == ppo}, p, {t, 0, ttop}];
 ParametricPlot[Evaluate[{p'[t], p[t]} /. s], {t, 0, ttop}], {{po, 0},
 0, .1}, {{ppo, 0}, 0, .001}, {{ttop, 1}, 0, 3}]

But this isn't working. Does anyone know how I could use parametric plot to plot $p'[t]$ against $p[t]$ for a given range of $t$ $(0,3)$?

$\endgroup$
  • 2
    $\begingroup$ Welcome to Mathematica StackExchange. In ParametricPlot use {p'[t],p[t]} rather than (p'[t],p[t]). $\endgroup$ – Dunlop May 12 '18 at 19:05
1
$\begingroup$

Change this

s=NDSolve[{p''[t]-3 Sqrt[8*Pi*(p[t]*p[t]+p'[t]*p'[t])/6.0]*p'[t]-p[t]*p[t]==0,
  p[0]==po, p'[0]==ppo}, p, {t,0,ttop}];

to this

s=NDSolve[{p''[t]-3 Sqrt[8*Pi*(p[t]*p[t]+p'[t]*p'[t])/6.0]*p'[t]-p[t]*p[t]==0,
  p[0]==po, p'[0]==ppo}, p, {t,0,ttop}][[1]];

And I believe you will get your desired ParametricPlot.

Look carefully, the change might be easily missed, perhaps look at the value of s from each of those to more easily spot it. Once you find it then study why this makes the difference and why the original version worked with Plot, but not with ParametricPlot.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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