Mathematica: Stream plots for differential equations

Paul T. Allen

It is very easy to use Mathematica to make stream plots for differential equations.

Stream plots for a single equation

Consider the example


frac{dy}{dt} = (y-y^3)cos{(t)}.


Points on a solution curve to this equation will take the form $latex (t,y(t))$. Thus the slope will look like

$latex (frac{d}{dt}[t],frac{d}{dt}[y(t)]) = (1,frac{dy}{dt})$.

Using the differential equation, we see that


left((1,frac{dy}{dt}right) = left(1, (y-y^3)cos{(t)}right).


Thus this is what we want to plot. The Mathematica code for this is the following:

StreamPlot[{1,(y-y^3) Cos[t]}, {t,0,5},{y,-2,2}]

The output is this:


Notice the following:

  • The command {1,(y-y^3) Cos[t]} gives the slope to be plotted at each point.
  • The command {t,0,5} gives the range of $latex t$ values.
  • The command {y,-2,2} gives the range of $latex y$ values.

Notice also that it is easy to see the equilibrium solutions on the picture – how cool is that!

Stream plots for systems

For a system…

Ver la entrada original 61 palabras más