3
$\begingroup$

I'm having a bit of trouble making a ParametricPlot from two curves, At fisrt I was having difficulty solving my systems of autonomous ODEs, but then finally got a way to solve it. However, I am now not able to figure out how to get the parametric plot.

solution[t_] = 
  With[{n = 1.5}, 
    NDSolve[
      {q'[t] == 
         ((q[t]^2)/3)*(3 - n)*x[t]^2 - ((q[t]^2)/3)*n*(y[t] - 1) - ((q[t]^2)/3) + (q[t]*x[t]/3)*(3 - n)*x[t]^2 - (q[t]*x[t]/3)*n*(y[t] - 1) + (q[t]*x[t]/3) + (1/3)*x[t]^2 - (1/3) + (1/3)*((n*y[t]/(n - 1))), 
       y'[t] == 
         ((2*y[t]*x[t]^2)/3)*(3 - n)*(x[t] + q[t]) + (2*x[t]*y[t]/3)*((n^2 - 2*n + 2)/(n - 1)) - (2*x[t]*y[t]/3)*n*y[t] + (2*q[t]*n*y[t]*((1 - y[t])/3)), 
       x'[t] == 
         ((x[t]^3)/3)*(3 - n)*(q[t] + x[t]) + ((x[t]^2)/3)*n*(2 - y[t]) - 5*((x[t]^2)/3) + (q[t]*x[t]/3)* n*(1 - y[t]) - (q[t]*x[t]) + (1/3)*((n*(n - 2)*y[t])/(n - 1)) - (1/3)*n + 2/3, 
       q[0] == -1.33, y[0] == 0.88, x[0] == 0.33}, 
      {q[t], y[t],  x[t]}, {t, 0, 10}]][[1, All, 2]]

Plot[solution[t], {t, 0, 10}]

I want to get a parametric plot of q[t] and y[t]. And eventually a 3D plot of q[t], y[t], x[t].

$\endgroup$
3
$\begingroup$

The issue you are facing is to correctly call out the desired dependent variables. So, you need to specify the position of the output. For example, you want to have q[x] then you need to use solution[t][[1]].

For parametric plot, try this out,

ParametricPlot[{solution[t][[1]], solution[t][[2]]}, {t, 0, 10}]

and then for 3D

ParametricPlot3D[{solution[t][[1]], solution[t][[2]], solution[t][[3]]}, {t, 0, 10}]
$\endgroup$
2
$\begingroup$

Redefine your solution a little bit to

solution := 
With[{n = 1.5}, 
NDSolve[{q'[t] == ((q[t]^2)/3)*(3 - n)*x[t]^2 - ((q[t]^2)/3)*
   n*(y[t] - 1) - ((q[t]^2)/3) + (q[t]*x[t]/3)*(3 - n)*
   x[t]^2 - (q[t]*x[t]/3)*n*(y[t] - 1) + (q[t]*x[t]/3) + (1/3)*
   x[t]^2 - (1/3) + (1/3)*((n*y[t]/(n - 1))), 
y'[t] == ((2*y[t]*x[t]^2)/3)*(3 - n)*(x[t] + q[t]) + (2*x[t]*
     y[t]/3)*((n^2 - 2*n + 2)/(n - 1)) - (2*x[t]*y[t]/3)*n*
   y[t] + (2*q[t]*n*y[t]*((1 - y[t])/3)), 
x'[t] == ((x[t]^3)/3)*(3 - n)*(q[t] + x[t]) + ((x[t]^2)/3)*
   n*(2 - y[t]) - 
  5*((x[t]^2)/3) + (q[t]*x[t]/3)*
   n*(1 - y[t]) - (q[t]*
    x[t]) + (1/3)*((n*(n - 2)*y[t])/(n - 1)) - (1/3)*n + 2/3, 
q[0] == -1.33, y[0] == 0.88, x[0] == 0.33}, {q , y , x }, {t, 0, 
10}]] [[1]]

Now you can plot your results

Plot[Evaluate[ {q[t], y[t]} /. solution ], {t, 0, 10}]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you so much for the assist! $\endgroup$ – Logan Jacobs Oct 10 '18 at 9:51

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.