Plotting Vector Fields with Maple

Copyright 2001 by James F. Hurley, University of Connecticut Department of Mathematics, Unit 3009, Storrs CT 06269-3009. All rights reserved.

1. Two-dimensional vector fields . Maple has commands to plot general two-dimensional vector fields, as well as gradient fields. The basic command is

fieldplot( [f (x, y), g(x,y)], x = a..b, z = c..d ) ;


To use it, the
plots library must be loaded. The following routine illustrates fieldplot for the vector field F in Exercise 4, Section 17.1, of James Stewart, Calculus, 4th Edition, ITP Brooks/Cole, 1999: F(x, y) = -x i + 2 y j .

> with (plots):
fieldplot( [-x, 2*y], x = -4..4, y = -4..4);

[Maple Plot]


The arrows look a bit
too thin (the default option in the fieldplot command is thin ), so try the following slightly altered version. You can also experiment with the other options: slim and thick .

> with (plots):
fieldplot( [-x, 2*y], x = -4..4, y = -4..4, arrows = medium);

[Maple Plot]


Maple's
gradplot command, which also requires loading the plots library, makes quick work of a problem that asks for a plot of the gradient of a scalar function of two variables. The syntax of the gradplot command is

gradplot( [f (x, y), g(x,y)], x = a..b, z = c..d ) ;


The next routine illustrates this by plotting the gradient of the scalar function
f with formula f(x,y) = sqrt(x^2+y^2) .

> with (plots):
gradplot( sqrt(x^2 + y^2), x = -3..3, y = -3..3, arrows = medium, color = sqrt(x^2 + y^2) );

[Maple Plot]


2. Three-dimensional vector fields. Maple plots three-dimensional vector fields via its fieldplot3d and gradplot3d commands, whose syntax is nearly identical to that for the corresponding two-dimensional commands illustrated above. The next routine plots the vector field F of three variables with formula F ( x , y , z ) = < x^2, x*y, z^2 >, and displays it with coordinate axes. (Note: Although Maple's documentation indicates that only the option arrows = medium is not available for three-dimensional field plots, on the Macintosh any arrow or color options seem to generate error messages in Version 6.0.1).)

> with(plots):
deft := fieldplot3d( [x^2, x*y, z^2],x =-1..1,y =-1..1, z = -1..2):
xaxis := spacecurve([t, 0, 0, t = -1..1.5, color = magenta]) :
yaxis := spacecurve([0, t, 0, t = -1..1.5, color = magenta]) :
zaxis := spacecurve([0, 0, t, t = -1..2.5, color = magenta]) :
labx := textplot3d([1.6, 0, -.2, `x`], color = magenta):
laby := textplot3d([0,1.6, -.2, `y`], color = magenta):
labz := textplot3d([0, 0, 2.6, `z`], color = magenta):
display (deft, xaxis, yaxis, zaxis, labx, laby, labz, axes = boxed);

[Maple Plot]


The last routine illustrates the
gradplot3d command.

> with(plots):
deft := gradplot3d( x*cos(y/z),x =-1..1,y =-1..1, z = -1..2):
xaxis := spacecurve([t, 0, 0, t = -1..1.5, color = magenta]) :
yaxis := spacecurve([0, t, 0, t = -1..1.5, color = magenta]) :
zaxis := spacecurve([0, 0, t, t = -1..2.5, color = magenta]) :
labx := textplot3d([1.6, 0, -.2, `x`], color = magenta):
laby := textplot3d([0,1.6, -.2, `y`], color = magenta):
labz := textplot3d([0, 0, 2.6, `z`], color = magenta):
display (deft, xaxis, yaxis, zaxis, labx, laby, labz, axes = boxed);

[Maple Plot]