1

I have a differential equation for dr/dt and d[Theta]/dt in terms of r and theta, and I am trying to plot the trajectory in the x-y plane for a given initial condition (r,theta).

http://reference.wolfram.com/language/ref/StreamPlot.html

There is an example on this page for a set of differential equations already in cartesian coordinates, but I don't know what to do for polar.

Kenny L
  • 63
  • 1
  • 6

1 Answers1

1

Define:

 polarToCartesian[r_,theta_]:=r*{Cos[theta],Sin[theta]}

Then, after you solve the differential equation, use ParametricPlot:

 ParametricPlot[polarToCartesian[r[t],theta[t]],{t,0,t0}]

UPDATE

polarToCartesian[{r_, theta_}] := r*{Cos[theta], Sin[theta]}

s = ParametricNDSolve[
      {r'[t] == r[t] (1 - (r[t])^2) (4 - (r[t])^2), 
       theta'[t] == 2 - (r[t])^2,
       r[0] == r0, theta[0] == theta0},
       {r, theta}, {t, 0, 10}, {r0, theta0}];


solution[r0_, theta0_, t_] := 
 Evaluate[{r[r0, theta0][t], theta[r0, theta0][t]} /. s]

Manipulate[
 ParametricPlot[polarToCartesian[solution[r0, theta0, t]], {t, 0, 10},
   PlotRange -> {-2.5, 2.5}]
   ,{r0, 0.01, 2}, {theta0, 0, 2 Pi}]

enter image description here

Ivan
  • 2,207
  • 15
  • 25
  • could you please try plotting my example? It seems to keep running and won't display anything for me, I think it's having trouble trying to solve the equations. My differential equations are r'[t] == r[t] (1 - (r[t])^2) (4 - (r[t])^2), [Theta]'[t] == 2 - (r[t])^2 – Kenny L May 12 '15 at 00:09
  • 1
    @KennyL You should add this important information to your question. – Michael E2 May 12 '15 at 00:31
  • @KennyL : Done! – Ivan May 12 '15 at 01:34