Plotting Differential Equation Phase Diagrams [closed]

I haven't got Matlab, nor have I found a suitable online tool. Could someone plot the phase diagram for the following, or point me in the right direction?

$$\frac{dx}{dt} = y - x, \frac{dy}{dt} = x(4 - y)$$


Solution 1:

You could use WolframAlpha:

stream plot (y-x,x(4-y)), x=-1..5, y=-1..5

enter image description here

It's always nice to verify this sort of thing with analytic tools. The equilibria satisfy

\begin{align} y-x &= 0 \\ x(4-y) &= 0 \end{align}

From the second equation, $x=0$ or $y=4$. From the first equation, $x=y$. Thus, there are two equilibria at the points $(0,0)$ and $(4,4)$. The nature of the equilibria can be determined from the eigenvalues of the matrix $$ \left( \begin{array}{cc} -1 & 1 \\ 4-y & -x \end{array} \right) $$ The rows are the partial derivatives with respect to $x$ and $y$ of the system. At $x=y=4$, the eigenvalues are $-4$ and $-1$ and at $x=y=0$, there is one positive eigenvalue and one negative eigenvalue. This is consistent with the picture.

Solution 2:

You can use octave instead (this is a free and open clone of matlab). You can assess your ODE system by a vector function such as:

function dx = f(x,t)
   dx(1) = x(2) - x(1);
   dx(2) = x(1)*(4-x(2));
end

Then you can solve it using lsode method for a given set of initial condition on a defined time range:

xs = lsode(@f,[1,2],0:0.01:10);

You can also plot the vector field associated with the system using quiver function. Printing xs over it give you the trajectory for the initial conditions you have chosen. By plotting several trajectories you will get a preciser idea of phase diagram associated with.

The following plots have been produced with octave using the above procedure:

SolutionsPhase Diagram