Mathematica Tutor
Part 12: Direction
fields
- Enter the command
<< Graphics`PlotField`
to load a package of graphics functions we will need.
The only one of these functions we will use here is "PlotVectorField".
To see a direction field plot for the logistic differential equation in
Part 11, first enter a function defining the right hand side:
f[t_,y_]:= y*(1-y)
Then, to make the plot and give it the name fieldPlot, enter:
fieldPlot = PlotVectorField[{1, f[t,y]}, {t, -2, 2}, {y, -0.5, 1.5},
ScaleFunction -> (1 &), PlotPoints -> 20, Axes -> True, HeadLength -> 0,
HeadWidth -> 0];
The first entry in the curly brackets will always be 1.
The second entry gives the right-hand side of the differential equation.
The third and fourth entries
give ranges for the independent and dependent variables. The options that follow
adjust special features of the plot.
- Now plot the function h[t]
from Part 11 with the same limits on t.
Does this solution look like it fits
the direction field?
- In order to be sure the
symbolic solution fits, we need to overlay the two plots we have made.
It is useful to have names for each plot. We already named the direction
field plot "fieldPlot" above.
Change your function
plot command to name it "solnPlot" and make it red:
solnPlot= Plot[ h[t], {t,-2,2}, PlotStyle->RGBColor[1,0,0] ]
Now we can use the "Show" command to show the plots superimposed. Enter:
Show[ fieldPlot, solnPlot ]
- Adjust
the horizontal ranges and redraw fieldPlot and solnPlot so that you can see the solution
function h[t] approach equilibrium. If necessary, enlarge the picture
so you can see more detail. Are you convinced that the symbolic solution
h[t] fits the direction field?
- Generate
direction fields over appropriate ranges of the variables for the following
differential equations
-
dy/dt = y2
-
dy/dt = ty + t