# Non linear equation phase space

As a supplementary to my question solution of differential equation I post a new question of how is it possible to make a Table that has elements the solutions of a non linear differential equation, so that to plot them. In a linear system you can do the following:

ss = DSolve[{x'[t] == 3 x[t], y'[t] == -y[t], x[0] == x0, y[0] == y0}, {x, y}, t];
toplot = Table[{x@t, y@t} /. ss, {x0, -0.5, 0.5, 0.25}, {y0, -0.5, 0.5, 0.25}];
ParametricPlot[Evaluate[toplot], {t, -1, 1}]

as @belisarius proposed.

If I have to use NDSolve can I use variables as above in initial conditions? I first tried the following example.

Plot[r (1 - r^2), {r, 0, 1}, AxesLabel -> {r, r'}]
ssa = NDSolve[{r'[t] == r[t] (1 - r[t]^2), u'[t] == 1, r[0] == r0,
u[0] == u0}, {r[t], u[t]}, {t, 0, 100}]
toplot = Table[{r@t Cos[u@t], r@t Sin[u@t]} /. ssa, {r0, -.5, .5, 0.25},
{u0, -.5, .5, 0.25}];
ParametricPlot[toplot, {t, 0, 100}]

The solution is what I expected, but it opened a message that said that initial condition r0 is not a number or rectangular array of numbers.

I then tried another example, it opened the same message but the solution was nearly what I wanted for some values of μ. For μ>0 the solution was OK except that it wasn't shown the second fixed point. For μ<=0 I didn't get any solution.

sol = NDSolve[{x'[t] == μ - x[t]^2, y'[t] == -y[t], x[0] == x0, y[0] == y0},
{x[t], y[t]}, {t, 0, 100}]

toplot = Table[{x@t, y@t} /. sol, {x0, -.5, 2, .25}, {y0, -.5, .5, .25}];

ParametricPlot[Evaluate[toplot], {t, 0, 100}, PlotRange -> All]

if you copy-paste the code remember to manually treat μ

The expected plots are shown bellow:

-
NDSolve cannot numerically integrate the system of equations since at this point r0 and u0 don't have numerical values. You have to wrap Table[..., {r0, ...}, {u0, ...}] around NDSolve instead of the plot curves! –  István Zachar Apr 25 '13 at 5:32
Ok! I suppose that u propose me something like this: a = Table[ sol = NDSolve[{x'[t] == 1 - x[t]^2, y'[t] == -y[t], x[0] == x0, y[0] == y0}, {x[t], y[t]}, {t, 0, 100}], {x0, -.5, 5}, {y0, -.5, .5}]; After that how can I plot this table that has elements the solutions of an equation? Sorry about my question it might be elementary but now I am really confused. –  2island Apr 25 '13 at 9:47
You might also be interested in the EquationTrekker package. –  Ｊ. Ｍ. May 4 '13 at 13:31

The problem is, that you call NDSolve while you haven't specified numerical values. Later, in your Table they are put in. In your second example you never say which value $\mu$ should get.

An easy way to fix this, is to make a function call out of your NDSolve. In this way it gets only evaluated when you put values in.

sol = Function[{x0, y0, mu},
NDSolve[{x'[t] == mu - x[t]^2, y'[t] == -y[t], x[0] == x0,
y[0] == y0}, {x[t], y[t]}, {t, 0, 100}]]

toplot = Table[{x@t, y@t} /. sol[x0, y0, .5], {x0, -.5,
2, .25}, {y0, -.5, .5, .25}];

ParametricPlot[Evaluate[toplot], {t, 0, 100}, PlotRange -> All]

To interpret the output is of course your job.

-
As I understand u call the NDSolve with sol[x0,y0,.5] where .5 is the value of mu (or μ). Again it doesn't work for values less than .2, I can't make plots as I posted in my question. I want μ to take values <0, =0 and >0. I know what the output should be like and what does it mean. Is there any way to make the plots as I posted above? I can't find where is the problem, the methodology seems to be right. –  2island Apr 25 '13 at 9:42
I tried another equation and it work exaclty as I a expected! Thank you very much for your answer! –  2island Apr 25 '13 at 10:01
@2island That it doesn't work with mu less than .2 is a problem of the equation and/or the numerical method used by NDSolve. You have to check yourself why it doesn't work. –  halirutan Apr 25 '13 at 10:28