# How to plot trajectory for a differential equation in polar coordinates? [duplicate]

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.

• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – bbgodfrey May 11 '15 at 23:55
• Please provide your equations in the question, so readers know what problem you are trying to solve. For instance, I would think you should use ParametricPlot, not StreamPlot. – bbgodfrey May 11 '15 at 23:57
• duplicate for field: StreamPlot in Polar Coordinates, answer for single trajectory: graph in the Polar Plane. TransformedField may be of use. – Kuba May 12 '15 at 6:44

## 1 Answer

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 == r0, theta == 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}] • 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 0:09
• @KennyL You should add this important information to your question. – Michael E2 May 12 '15 at 0:31
• @KennyL : Done! – Ivan May 12 '15 at 1:34