Vector Fields

You must include this line before you can plot vector fields

In[1]:=

<< Graphics`PlotField`

Here we define a vector field explicitly

In[2]:=

VF[x_, y_] := {-y, x}

In[3]:=

VF[x, y]

Out[3]=

{-y, x}

We plot the vecor field with the command:

In[5]:=

PlotVectorField[VF[x, y], {x, -2, 2}, {y, -2, 2}]

[Graphics:HTMLFiles/index_6.gif]

Out[5]=

⁃Graphics⁃

This time will compute the vector field which is the gradient of a function f:

In[6]:=

F[x_, y_] := y Cos[x]       

In[7]:=

F[x, y]

Out[7]=

y Cos[x]

Mathematica can compute the partial derivatives for us:

In[8]:=

D[F[x, y], x] D[F[x, y], y]

Out[8]=

-y Sin[x]

Out[9]=

Cos[x]

Now, create a new function which gives us the gradient of f at the point (x,y):

In[10]:=

GradF[x_, y_] := {-y Sin[x], Cos[x]}

In[11]:=

GradF[x, y]

Out[11]=

{-y Sin[x], Cos[x]}

Now, we plot this new vector field

In[12]:=

PlotVectorField[GradF[x, y], {x, -1, 1}, {y, -1, 1}]

[Graphics:HTMLFiles/index_18.gif]

Out[12]=

⁃Graphics⁃

Here we plot more points

In[13]:=

PlotVectorField[GradF[x, y], {x, -5, 5}, {y, -5, 5}, PlotPoints->30]

[Graphics:HTMLFiles/index_21.gif]

Out[13]=

⁃Graphics⁃

In[14]:=

PlotVectorField[GradF[x, y], {x, -5, 5}, {y, 15, 25}, PlotPoints->30]

[Graphics:HTMLFiles/index_24.gif]

Out[14]=

⁃Graphics⁃

    


Created by Mathematica  (October 21, 2004)