Go to CCP Homepage Go to Materials Page Go to Engineering Mathematics Materials Go to Table of Contents
Go Back One Page Go Forward One Page

Mathematica Tutor

Part 12: Direction fields

  1. 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.

  2. 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?

  3. 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 ]

  4. 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?

  5. Generate direction fields over appropriate ranges of the variables for the following differential equations

Go to CCP Homepage Go to Materials Page Go to Engineering Mathematics Materials Go to Table of Contents
Go Back One Page Go Forward One Page


modules at math.duke.edu Copyright CCP and the author(s), 1998, 1999, 2000