The purpose of this lab is to acquaint you with some Maple commands for visualizing and computing the divergence and curl of vector fields.
A vector field is a vector-valued function that associates a
vector with each point in its domain. For example the function
produces a vector at each point
. Probably the most familiar example of a vector field is the
velocity field in a fluid in motion. Here you would have a velocity
vector
that describes the velocity of the fluid at
a point
. If the flow is steady, then
will not
depend on t, but it still could depend on the position
in
space. Another example that we have seen already is the gradient
of a scalar-valued function
. The electric
field
and the magnetic field
might also be
familiar to you.
Just as we did with constant vectors, we can represent vector fields by ordered
pairs (in two dimensions) or triples (in three dimensions) of
component functions. For example, we could also represent our first
example by
. The dimension of a vector
field is the number of component functions it has. Thus, our example
is a two-dimensional vector field and the fluid
velocity
is a three-dimensional vector field. Note
that the dimension is not always the same as the number of independent
variables.
Two-dimensional vector fields are often represented graphically by
what are called vector or arrow plots. To see how these are generated,
suppose you have a vector field
and you fix a point
. To represent the vector field at this point you draw a
vector with its tail at
in the direction of
, with the length of the vector being some scaling factor
times the length of
. You then repeat this process
at a grid of points. If you think of a vector field as representing
the flow of a fluid, then an arrow plot gives you an idea of the paths
fluid particles will take.
Examples are probably easier to understand than explanations, and Maple has a procedure that draws arrow plots for two-dimensional vector fields. The procedure is called fieldplot and the following example shows how to use it. Note that you have to load the plots package before you can use it.
> with(plots):
> fieldplot([-x,y],x=-4..4,y=-4..4);
> fieldplot([cos(x+y),-sin(y)],x=-6..6,y=-6..6,grid=[25,25]);
The last line of the examples shows how to use the grid option to change the number of grid points. See the help for fieldplot for more details. There is also a fieldplot3d command for producing arrow plots of three dimensional vector fields, but we will not make use of it.
We have already seen the
symbol in the definition of the
gradient, but there are two other calculus operations on vector fields
involving it. To understand them, it is perhaps best to think of
in three dimensions as the operator

with the obvious change in definition for
in two dimensions.
Then the gradient
of a function
is obtained by
``scalar multiplication'' of f on the left by the vector operator
.
Whereas the gradient applies to a scalar function, the divergence and
curl are applied to vector-valued functions. Suppose
is a
vector-valued function with component functions
,
,
and
. That is, we can write

Then the divergence of the vector field
, written
is the scalar function

The divergence is also often written as
, which is useful for remembering the formula for
the divergence: think of it as the dot product of the operator
and the vector function
. For example, if

then

Having seen the dot product reappear, is it any surprise that the cross
product is waiting in the wings? The curl of a three-dimensional
vector field sometimes written
, is more
often represented as
. As you might
expect, the curl of a vector field produces another vector field. The
formula for
is

The formula is best remembered as the symbolic determinant

The linalg package in Maple has commands grad,
diverge, and curl that perform these vector operations.
Examples are shown below. The last example shows how to work with an
arbitrary vector function
.
> with(linalg):
Warning: new definition for normWarning: new definition for trace
> f := vector([x,y^3,x*y*z]);

> diverge(f,[x,y,z]);

> curl(f,[x,y,z]);

> F:= (x,y,z) -> vector([P(x,y,z),Q(x,y,z),R(x,y,z)]) ;

> diverge(F(x,y,z),[x,y,z]);

The Maple procedure diverge will work on vector fields of any dimension, but curl expects a three-dimensional vector field. The list [x,y,z] is used to specify the independent variables in their natural order.
.
.
.
.
.
.
.
for any
vector field
.
is a scalar function and
is a
three-dimensional vector, show that the following identities are true.
.
