# Plotting Particular Solutions of a System of Polar ODEs

I'm new to Mathematica, and I'm writing a math research paper and I need to generate a phase portrait of the following system of polar equations

$\qquad \dot r=r(r-1)(r-2)$

$\qquad \dot \theta=1$

where $r$ and $\theta$ are the polar radial and angular coordinates, respectively, both are functions of $t$, and the dots mean derivative with respect to $t$.

All the equations I've used up until now have been in Cartesian coordinates; as an example, for the system

$\qquad \dot x = y$

$\qquad \dot y = -x + y(1-x^2)$

I used the following Mathematica commands to generate a phase portrait (with one particular solution):

p1 =
StreamPlot[{y, -x + -y*x^2 + y}, {x, -4, 4}, {y, -4, 4},
Axes -> True, StreamStyle -> Gray, ImageSize -> Large]

deq1 = x'[t] == y[t];

deq2 = y'[t] == -x[t] + y[t] (1 - x[t]^2);

solution1 =
NDSolve[{deq1, deq2, x == .0001, y == .0001}, {x[t], y[t]}, {t, 0, 100}]

p2 =
ParametricPlot[Evaluate[{x[t], y[t]} /. solution1], {t, 0, 100},
PlotStyle -> Thickness[0.005]]

Show[p1, p2, ImageSize -> Large]


Also, I found, through a google search, one way to generate a polar stream plot:

field1 = {r (r - 1) (r - 2), 1}

StreamPlot[
Evaluate @ TransformedField["Polar" -> "Cartesian", field1, {r, θ} -> {x, y}],
{x, -3, 3}, {y, -3, 3},
Axes -> True, StreamStyle -> Gray, ImageSize -> Large]


However, I do not know how to plot particular solutions for this system to overlay onto the stream plot like I did with the Cartesian systems. Does anyone know how to do this in Mathematica?

Here's an approach that uses FromPolarCoordinates. Note that Mod is required to handle situations when θ is outside the range [-π,π].

field1 = {r (r - 1) (r - 2), 1};

p1 = StreamPlot[Evaluate@TransformedField["Polar" -> "Cartesian", field1, {r, θ} -> {x, y}],
{x, -3, 3}, {y, -3, 3}, Axes -> True, StreamStyle -> Gray, ImageSize -> Large];

solution1 = NDSolve[{r'[t] == r[t] (r[t] - 1) (r[t] - 2), θ'[t] == 1, r == 0.01, θ == 0},
{r, θ}, {t, 0, 100}];

p2 = ParametricPlot[Evaluate[FromPolarCoordinates[{r[t], Mod[θ[t], 2 π, -π]}] /. solution1],
{t, 0, 100}, PlotStyle -> Thickness[0.005]];

Show[p1, p2, ImageSize -> Large] Looking at the origin, the StreamPlot looks a little wonky compared to the numerical solution -- I don't think the solution should cross a flow arrow like that!

Update: Since you don't have FromPolarCoordinates, it should be easy enough to roll your own:

FromPolarCoordinates[{r_, θ_}] := {r Cos[θ], r Sin[θ]};

• Thank you so much for answering. This is exactly what I was looking for. I agree with the wonky StreamPlot, is there something that can be done about that, or is it just a numerical error made by the software? – AlteredReality Nov 27 '16 at 1:27
• @AlteredReality sorry, no clue – Chris K Nov 27 '16 at 1:59
• I just ran the code, and it didn't generate the numerical solution. Then I found out that FromPolarCoordinates only works with Mathematica versions 10+, but I have 9. Is there another way that you know of to generate this plot? – AlteredReality Dec 3 '16 at 3:59
• @AlteredReality Sure, see my update – Chris K Dec 4 '16 at 3:15
• It worked! Thank you so much for that – AlteredReality Dec 4 '16 at 4:52