Demo 1.1

Plotting Direction Fields

We will use the command PlotVectorfield to plot direction fields. The equation y'(t)=f(t,y) tells us that at the point (t,y) we have to plot a short line with slope f(t,y). The vector (1,f(t,y)) has slope f(t,y), so we simply plot the vector field (1,f(t,y)), but we add an option ScaleFunction->(1&) to make all the arrows the same length. (1&) is a pure function in Mathematica standing for the constant function 1. We need a graphics package to plot a vector field.

Needs["Graphics`PlotField`"]

Example 1.                   y'=t-y

\(PlotVectorField[{1, t - y}, \ {t, \(-3\), 5}, {y, \(-3\), 3}, 
	\ 
      PlotPoints\  -> \ 15, \ Axes\  -> \ True, \ 
      ScaleFunction\  -> \ \((1&)\), \ Ticks\  -> \ None, \ 
      Frame\  -> \ True, \ AspectRatio\  -> \ 1]\)

It appears that all solutions are asymptotic to the line y=t-1.

Caution:

If you execute a PlotVectorField command before you do the Needs command, the best thing to do is to restart!

A Palette for Direction Fields

Here is a Palette for the command above. This button was made by choosing "Create Table/Matrix/Palette..." from the Input menu, and then filling in the commands we want. The squares are given by pressing the key marked "esc" followed by the letters  spl  followed by the "esc" key again. Next select the cell and then "Generate Palette from Selection" from the File menu.

({{\(PlotVectorField[{1, \[SelectionPlaceholder]}, 
              \ {t, \[SelectionPlaceholder], \[SelectionPlaceholder]}, 
              \ {y, \[SelectionPlaceholder], \[SelectionPlaceholder]}, 
	\ 
              PlotPoints\  -> \ 15, \ Axes\  -> \ True, \ 
	
              ScaleFunction\  -> \ \((1&)\), \ Ticks\  -> \ None, 
	\ 
              Frame\  -> \ True, \ AspectRatio\  -> \ 1]\)}})

Example 2.                            y' = y+2

Click on the palette and fill in the blanks. If you want more vectors, raise the PlotPoints option,  but remember that vector fields are slow to plot.

\(PlotVectorField[{1, y + 2}, \ {t, \(-5\), 5}, \ {y, \(-5\), 5}, 
	\ 
      PlotPoints\  -> \ 15, \ Axes\  -> \ True, \ 
	
      ScaleFunction\  -> \ \((1&)\), \ Ticks\  -> \ None, 
	\ 
      Frame\  -> \ True, \ AspectRatio\  -> \ 1]\)

Here it seems that solutions which start with y > -2 tend to infinity, those which start with 
y = -2 remain -2 constantly and those which start with y < -2 tend to  negative infinity.

Example 3.                            y' = (E^(-t))+y

\(PlotVectorField[{1, E^\((\(-t\))\) + y}, \ {t, 0, 10}, 
      \ {y, \(-3\), 3}, 
	\ PlotPoints\  -> \ 15, \ Axes\  -> \ True, \ 
	
      ScaleFunction\  -> \ \((1&)\), \ Ticks\  -> \ None, 
	\ 
      Frame\  -> \ True, \ AspectRatio\  -> \ 1]\)

Here it seems likely that solutions which start with y > 0 tend to infinity, while those which start with y < -1 tend to negative infinity. There seem to be at least one solution with y(0) between -1 and 0, which tends to zero.

Example 4.                             y' = -y(3-y)

Sometimes it is useful to plot more lines. The default option is PlotPoints -> 15.

\(PlotVectorField[{1, \(-y\) \((3 - y)\)}, \ {t, \(-5\), 5}, 
      \ {y, \(-2\), 6}, 
	\ PlotPoints\  -> \ 20, \ Axes\  -> \ True, \ 
	
      ScaleFunction\  -> \ \((1&)\), \ Ticks\  -> \ None, 
	\ 
      Frame\  -> \ True, \ AspectRatio\  -> \ 1]\)

Solutions starting with y(0) = 0 or y(0) = 3 remain constant. If the initial y(0) > 3, the solution goes to infinity. If  y(0) < 3 the solution tends to (or remains constant) 0.

Example 5.                            y' = t (E^(-2 t))\(TraditionalForm\`\(\^\ \)\)-2y

\(PlotVectorField[{1, t\ E^\((\(-2\) t)\) - 2  y}, \ {t, \(-2\), 3}, 
      \ {y, \(-4\), 4}, 
	\ PlotPoints\  -> \ 15, \ Axes\  -> \ True, \ 
	
      ScaleFunction\  -> \ \((1&)\), \ Ticks\  -> \ None, 
	\ 
      Frame\  -> \ True, \ AspectRatio\  -> \ 1]\)

My guess is that all solutions tend to 0 as t tends to infinity.