The MATHEMATICA command for sketching vector fields is PlotVectorField . This command is in a special Graphics Package which is not automatically loaded by MATHEMATICA. So to use it you must first load the Graphics Package by entering the command

(SPECIAL NOTE: in this command the word PlotField is immediately preceded and immediately followed by a left quotation mark<<Graphics`PlotField`

For example the output of the command

To get a more controlled output we might add some modifiers such as

Note that the modifier ColorFunction->Hue colors vectors with equal magnitude with the same color.

Many of the modifiers used for the ContourPlot command will also work for PlotVectorField. Others may be found in MATHEMATICA's HELP utility by searching under Graphics`PlotField`. Here are some useful ones:

AspectRatio -> NN | set the aspect ratio to use in representing the viewing rectangle--the default is 1. |

Axes -> BB | include or omit axes |

AxesLabel -> {"text","text"} | label the axes |

ColorFunction -> Hue | color the vectors as a function of magnitude |

PlotLabel -> "TEXT" | create a label for the vector field plot |

PlotPoints -> NN | number of points in each direction at which to draw vectors. The default is NN=15. |

ScaleFactor -> NN | scales the magnitudes of displayed vectors--the default is NN=1. |

HeadWidth -> NN | controls the size of the heads of the vectors--the default is NN=.5. |

HeadCenter -> NN | controls the shape of the heads of the vectors--the default is NN=1. |

HeadLength -> NN | allows more controls of the shape of the heads of the vectors. (Usually NN would be a very small positive number such as NN=.007) |

In this table, NN denotes a numerical value, and the symbol BB takes one of the values True or False.

Here's an example showing how one might combine PlotVectorField with other graphics commands. This particular example displays a contour map for the function of two variables f(x,y) = x^2 - y^2 with its gradient vector field superimposed. Of course the gradient vector field is orthogonal to the family contour curves for the function.

Contours->31, ContourShading->False];

G2=PlotVectorField[ {2x,-2y}, {x,-8,8}, {y,-8,8},

ColorFunction->Hue, ScaleFactor->2];

Show[{G1,G2}, Background->RGBColor[.95, .95, .8] ]

Special commands are available for plotting gradient vector fields and Hamiltonian vector fields:

PlotGradientField[ ((x-k)^2-(y-k)^2) *Cos[k/4]-2 (x-k)* (y-k)* Sin[k/4], {x,-12,12}, {y,-12,12},

ColorFunction->Hue,ScaleFactor->2,AspectRatio->1, Frame->True,Background->RGBColor[.94, .97, .92]]

,{k,-3.5Pi,3.5Pi,Pi/4}]

It is also possible to have MATHEMTICA sketch 3-dimensional vector fields. For this you must first load the Graphics Package PlotField3D by entering

Now use the command<<Graphics`PlotField3D`

VectorHeads -> True, ScaleFactor -> 2.5, ColorFunction -> Hue, ColorFunction -> Hue, PlotPoints -> 8]

URL: http://math.ou.edu/~amiller/math/vfield.htm

November, 1999