# [SOLVED]Phase Plane Mathematica

#### dwsmith

##### Well-known member
How can I plot the different phase planes for a system of ODEs in Mathematica?

Last edited:

#### dwsmith

##### Well-known member
$$\displaystyle\begin{array}{lcl} \displaystyle \frac{du_1}{d\tau} & \displaystyle = & \displaystyle u_1\left(1 - u_1 - a_{12}u_2\right)\\ \frac{du_1}{d\tau} & \displaystyle = & \displaystyle\rho u_1\left(1 - a_{21}u_1\right) \end{array}$$

Where $\rho,a_{12},a_{21}$ are constants.

Last edited:

#### dwsmith

##### Well-known member
I am pretty sure this works:

Show[StreamPlot[{(1 - x - 2 y), (1 - 2 x)}, {x, 0, 2}, {y, 0, 2},
Axes -> True]]

How can I plot the null clines simultaneously?

For the above phase plane, I used the case $a_{12},a_{21}>1$

#### Ackbach

##### Indicium Physicus
Staff member
I am pretty sure this works:

Show[StreamPlot[{(1 - x - 2 y), (1 - 2 x)}, {x, 0, 2}, {y, 0, 2},
Axes -> True]]

How can I plot the null clines simultaneously?

For the above phase plane, I used the case $a_{12},a_{21}>1$
Any time you want to plot multiple plots simultaneously, you can assign a Plot command to a variable like this:

PlotOne = Plot[x^2,{x,-2,2}]
PlotTwo = Plot[Sin[x],{x,-Pi,Pi}]

Then you show them simultaneously by doing

Show[PlotOne, PlotTwo]

So, if you can plot everything you need separately, this is a way to combine it all.

#### dwsmith

##### Well-known member
Any time you want to plot multiple plots simultaneously, you can assign a Plot command to a variable like this:

PlotOne = Plot[x^2,{x,-2,2}]
PlotTwo = Plot[Sin[x],{x,-Pi,Pi}]

Then you show them simultaneously by doing

Show[PlotOne, PlotTwo]

So, if you can plot everything you need separately, this is a way to combine it all.
Plotting the nullclines for these plots dont work the same since I have y and x terms. Do you know how to overcome that?

#### Ackbach

##### Indicium Physicus
Staff member
Plotting the nullclines for these plots dont work the same since I have y and x terms. Do you know how to overcome that?
It doesn't matter how you generate a plot, you can still assign it to a variable like PlotOne, PlotTwo. You could say

PlotThree = ImplicitPlot[...]

or

PlotFour = ContourGraphics[...]

etc.

Let's back up a bit and ask this question: is your problem the problem of showing multiple plots simultaneously, or is the problem plotting one thing in the first place?

#### dwsmith

##### Well-known member
It doesn't matter how you generate a plot, you can still assign it to a variable like PlotOne, PlotTwo. You could say

PlotThree = ImplicitPlot[...]

or

PlotFour = ContourGraphics[...]

etc.

Let's back up a bit and ask this question: is your problem the problem of showing multiple plots simultaneously, or is the problem plotting one thing in the first place?
plotting the null cline for

$\frac{du_1}{d\tau}$

#### Ackbach

##### Indicium Physicus
Staff member
Ah. So, is your system in Post # 2 correct? I'm a bit confused, since the subscripts appear to be the same everywhere. Should it be, rather,

\begin{align*}
\frac{du_1}{d\tau} & = u_1\left(1 - u_1 - a_{12}u_2\right)\\
\frac{du_2}{d\tau} & = \rho u_1\left(1 - a_{21}u_1\right)?
\end{align*}

• dwsmith

#### dwsmith

##### Well-known member
Ah. So, is your system in Post # 2 correct? I'm a bit confused, since the subscripts appear to be the same everywhere. Should it be, rather,

\begin{align*}
\frac{du_1}{d\tau} & = u_1\left(1 - u_1 - a_{12}u_2\right)\\
\frac{du_2}{d\tau} & = \rho u_1\left(1 - a_{21}u_1\right)?
\end{align*}
the second one should be rho u_2

• Ackbach

#### Ackbach

##### Indicium Physicus
Staff member
the second one should be rho u_2
And what are $\rho, a_{21}$, and $a_{12}$?

#### dwsmith

##### Well-known member
And what are $\rho, a_{21}$, and $a_{12}$?
a_{12} and a_{21} have 4 cases. Both greater than 1, less than 1, and then one less and greater. Rho positive.

#### Ackbach

##### Indicium Physicus
Staff member
Well, ok, but you're going to have to have actual values in order to plot anything in Mathematica. Perhaps, if you're allowed to pick values, you could show me what commands you've used so far. The way I see it, you've got the two axes, and two other straight lines.

Last edited:

#### dwsmith

##### Well-known member
Well, ok, but you're going to have to have actual values in order to plot anything in Mathematica. Perhaps, if you're allowed to pick values, you could show me what commands you've used so far. The way I see it, you've got the two axes, and two other straight lines.
For all my cases, I just used 2 and 1/2

Last edited by a moderator:

#### Ackbach

##### Indicium Physicus
Staff member
For all my cases, I just used 2 and 1/2
So, using those values, what commands have you used so far?

#### Ackbach

##### Indicium Physicus
Staff member
Try this sort of thing:

Code:
PlotOne = StreamPlot[{x(1-x-2y),y(1-2x)},{x,0,2},{y,0,2}];
PlotTwo = Plot[{(1-x)/2,{x,0,2}];
<< GraphicsImplicitPlot
PlotThree = ImplicitPlot[x==1,{x,0,2},{y,0,2}];
Show[PlotOne,PlotTwo,PlotThree]
My PlotThree line probably does not have the right equation in there. You might need x == 0, or whatever. Does this solve your problem?

• dwsmith

#### dwsmith

##### Well-known member
Try this sort of thing:

Code:
PlotOne = StreamPlot[{x(1-x-2y),y(1-2x)},{x,0,2},{y,0,2}];
PlotTwo = Plot[{(1-x)/2,{x,0,2}];
<< GraphicsImplicitPlot
PlotThree = ImplicitPlot[x==1,{x,0,2},{y,0,2}];
Show[PlotOne,PlotTwo,PlotThree]
My PlotThree line probably does not have the right equation in there. You might need x == 0, or whatever. Does this solve your problem?
Was the phase plan and null clines correct for that system of DEs?

That worked too thanks.

#### Ackbach

##### Indicium Physicus
Staff member
Was the phase plan and null clines correct for that system of DEs?

That worked too thanks.
The first two lines of code in Post # 16 were taken directly from your first .jpg. To be honest, the version of Mathematica I have doesn't support the StreamPlot command, so I don't know much about it. One thing that puzzles me is what are the axes on these plots corresponding to? That is, what variables in your system of DE's are being plotted against which variables?

\begin{align*}
\frac{du_{1}}{d\tau}&=u_{1}(1-u_{1}-a_{12}u_{2})\\
\frac{du_{2}}{d\tau}&=\rho u_{2}(1-a_{21}u_{1}).
\end{align*}

Null clines are by definition regions in the $u_{1}-u_{2}$ plane where the derivatives of the system are zero simultaneously. That is, we must have
\begin{align*}
0&=u_{1}(1-u_{1}-a_{12}u_{2})\\
0&=\rho u_{2}(1-a_{21}u_{1}).
\end{align*}
The $\rho$ disappears. The logic goes like this:

(Either $u_{1}=0$ OR $1-u_{1}-a_{12}u_{2}=0$) AND (Either $u_{2}=0$ OR $1-a_{21}u_{1}=0$).

There are four possibilities:

1. $u_{1}=0$ and $u_{2}=0$
2. $u_{1}=0$ and $1-a_{21}u_{1}=0$ (this one seems unlikely)
3. $1-u_{1}-a_{12}u_{2}=0$ and $u_{2}=0$
4. $1-u_{1}-a_{12}u_{2}=0$ and $1-a_{21}u_{1}=0$.

Each of these possibilities describe a single point in the $u_{1}-u_{2}$ plane. So, if the goal of your problem is to plot the null clines, then I'd say you need to plot the three points described by 1, 3, and 4.

#### dwsmith

##### Well-known member
I let x = u_1 and y = u_2.

I just set rho to 1 since Mathematica wont graph with an unknown parameter.

Last edited:

#### Ackbach

##### Indicium Physicus
Staff member
Have you been able to plot the three points described in Post # 18? Those ARE the null clines. If you're supposed to plot the null clines simultaneously with the stream plot, then you need to figure out how to plot individual points clearly (marked with an "x" or something).

#### dwsmith

##### Well-known member
Have you been able to plot the three points described in Post # 18? Those ARE the null clines. If you're supposed to plot the null clines simultaneously with the stream plot, then you need to figure out how to plot individual points clearly (marked with an "x" or something).

Those lines are plotted already plotted. You sent the syntax to include them all prior.

#### Ackbach

##### Indicium Physicus
Staff member
Those lines are plotted already plotted. You sent the syntax to include them all prior.
Ah, but the null clines for your system are three POINTS, not lines. Now, if you think it's clearer to just plot lines so that people can see the intersection, I suppose that'd be one way to present your solution. However, not all of the line represented by $1-a_{21}u_{1}=0$ is a null cline. Only one point on that line is a null cline.