Group Abstract Group Abstract

Message Boards Message Boards

Plot a system of differential parametric equations with ParametricNDSolve?

Posted 6 years ago

Hey all,

I'm pretty new to Mathematica so go easy on me. I have been trying to plot a system of differential parametric equations without any success. It appears as though Mathematica is solving them, but it won't plot them. I have put my code that I am using below and was hoping someone could take a look at what I did wrong:

a = .1
ParametricPlot3D[{Sin[t], Cos[t], t/4}, {t, 0, 2 Pi}]

 sol = ParametricNDSolve[{x'[t] == t,  y'[t] == t^2, z'[t] == 3*t, 
   x[0] == 1, y[0] == 0, z[0] == 0}, {x, y, z}, {t, 0, 100} , {}]
ParametricPlot3D[sol, {t, 0, 100 }, PlotRange -> All]
 sol2 = ParametricNDSolve[{x'[
     t] == ( -Sin[t]*(1 + a^2 + t^2) - 
       2*t*Cos (t))/(1 + a^2 + t^2)^2,  
   y'[t] == ( 
      Cos[t]*(1 + a^2 + t^2) - 2*t*Sin (t))/(1 + a^2 + t^2)^2, 
   z'[t] == a*(1 + a^2 - t^2)/(1 + a^2 + t^2)^2, x[0] == 1, 
   y[0] == 0, z[0] == 0}, {x, y, z}, {t, 0, 100} , {}]
ParametricPlot3D[sol2, {t, 0, 100 }, PlotRange -> All]
POSTED BY: Michael Solomon
2 Replies
POSTED BY: Martijn Froeling

Try,using NDSolve:

 ClearAll["Global`*"]; Remove["Global`*"];

 sol = NDSolve[{x'[t] == t, y'[t] == t^2, z'[t] == 3*t, x[0] == 1, 
     y[0] == 0, z[0] == 0}, {x, y, z}, {t, 0, 10}];
 ParametricPlot3D[{x[t], y[t], z[t]} /. sol, {t, 0, 10}, 
  PlotRange -> All, AspectRatio -> 1/2, 
  AxesLabel -> {"x[t]", "y[t]", "z[t]"}]

 a = 1/10; 
  sol2 = NDSolve[{x'[
      t] == (-Sin[t]*(1 + a^2 + t^2) - 2*t*Cos[t])/(1 + a^2 + t^2)^2, 
    y'[t] == (Cos[t]*(1 + a^2 + t^2) - 2*t*Sin[t])/(1 + a^2 + t^2)^2, 
    z'[t] == a*(1 + a^2 - t^2)/(1 + a^2 + t^2)^2, x[0] == 1, y[0] == 0,
     z[0] == 0}, {x, y, z}, {t, 0, 10}];
ParametricPlot3D[{x[t], y[t], z[t]} /. sol2, {t, 0, 10}, 
 PlotRange -> All, AspectRatio -> 1, 
 AxesLabel -> {"x[t]", "y[t]", "z[t]"}]

Or using ParametricNDSolve:

  ClearAll["Global`*"]; Remove["Global`*"];

  sol3 = ParametricNDSolve[{x'[
        t] == (-Sin[t]*(1 + a^2 + t^2) - 2*t*Cos[t])/(1 + a^2 + t^2)^2, 
      y'[t] == (Cos[t]*(1 + a^2 + t^2) - 2*t*Sin[t])/(1 + a^2 + t^2)^2, 
      z'[t] == a*(1 + a^2 - t^2)/(1 + a^2 + t^2)^2, x[0] == 1, 
      y[0] == 0, z[0] == 0}, {x, y, z}, {t, 0, 10}, {a}];
ParametricPlot3D[{x[a][t], y[a][t], z[a][t]} /. sol3 /. a -> 1/10, {t,0, 10}, PlotRange -> All, AspectRatio -> 1, AxesLabel -> {"x[t]", "y[t]", "z[t]"}]
POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard