You can use the Sage code below to plot any vector field. All you need to do is type in the field $F(x,y)$. The computer will plot the field in two ways.

When you are ready, just click "Evaluate" or type "Shift+Enter" while your cursor is in the input box.

<sagecell> var('x','y') #Define your variables F(x,y) = (2*x+y,-3*x+2*y) #State the vector field. Make sure you use a * when you want to multiply. xbounds = (x,-5,5) ybounds = (y,-5,5)

p=plot_vector_field(F,xbounds,ybounds)

  1. If you want to see what the plot of some vectors by hand is, then the code below will show it without having the computer automatically shrink them.

for i in (-1..1):

    for j in (-1,0,1):
        p += arrow( vector([i,j]), vector([i,j])+vector(F(i,j)),color='red')

print("This plot preserves the ratio between lengths of vectors.") print("If one vector is really long, it might be hard to see the direction of the shorter vectors.") show(p)

  1. For a final plot, let's shrink all the arrows to have size 1.
  2. The .norm() command computes the length of a vector,
  3. Writing F/F.norm() will shrink all vectors to be size 1.
  4. This won't work if one of the vectors has length zero.

print("This plot makes all vectors have the same length. It only shows direction.") print("If you see an error message, that means one of the vectors had length zero, and ignore this part.")

plot_vector_field(F/F.norm(),xbounds,ybounds)

</sagecell>

Here's the command for plotting a vector field in Mathematica.

VectorPlot[{x+y,-x+y},{x,-3,3},{y,-3,3}]

You could achieve the same simplicity with sage by just using the following, but I prefer to separate the declaration of a variable from the action we take on that variable.

<sagecell> var('x','y') plot_vector_field((x+y,-x+y),(x,-5,5),(y,-5,5)) </sagecell>

Here's a link to a vector field plotter WolframAlpha.

{{page>get_sage}}