Gradient and Curl

The VectorCalculus  package also contains many of the operations performed on vector fields.  To begin with, if U ( x,y ) is a function of two variables, then the gradient of U  is a 2-dimensional vector field of the form   F ( x,y ) = `<,>`(U[x],U[y])   .

>    SetCoordinates(cartesian[x,y]):
U:=x^2-y^2;
F:=Gradient(U);

>   

The gradient can also be calculated by employing the "Del" operator:

>    F:=Del(U);

>   

The properties of the gradient imply that the vector field F ( x,y ) = `<,>`(U[x],U[y])  is orthogonal to the level curves of U.   Thus, in the plot below, vectors in the vector field are orthogonal to the level curves of U .  

>    p1:=contourplot(U,x=-1..1,y=-1..1,contours=12,color=blue):
p2:=fieldplot(F,x=-1..1,y=-1..1,grid=[8,8],color=red,arrows=slim):
display(p1,p2,scaling=constrained);

>   

Similarly, the gradient of a function U ( x,y,z ) of 3 variables returns a 3-dimensional vector field of the form F ( x,y,z ) = `<,>`(U[x],U[y], U[z]) .   

>    SetCoordinates(cartesian[x,y,z]):
U:=x^2-y^2+x*y*z;
F:=Del(U);

>   

Another important operation on vector fields is the Curl  of a vector field.  In particular, if F  = `<,>`(M,N, P) , then  

curl( F ) = `<,>`(P[y]-N[z],M[z]-P[x], N[x]-M[y])

In Maple, the curl is computed using the command 'Curl'.

>    F:=VectorField(<y,-x,z>);
Curl(F);

>   

Alternatively, the curl command can be calculated as the "crossproduct" of the Del operator on the vector field. The crossproduct is represented in the VectorCalculus package by &x.

>    Del &x F;

>   

The curl operation is important because if F  = `<,>`(M,N, P)  is the gradient of a function of 3 variables, then curl(F) = 0, where 0  is the zero vector. Let's look at an example:

>    U:=x^2-y^2+x*y*z;
F:=Del(U);
CurlF:=Curl(F);

>   

If F  is a vector field whose curl is equal to 0, then we say that F  is conservative.   It follows that conservative fields are those that are gradients of functions of 3 variables.

The divergence  of a vector field is also an important operation.  It is defined on a vector field   F  = `<,>`(M,N, P)  by

div( F ) = M[x]+N[y]+P[z]

The divergence of a vector field is a function of 3 variables.  It is often used to measure the local "expansion" of a vector field.  In Maple, the divergence of  a vector field is computed using the "diverge" command.

>    G:=VectorField(<x^2,y^2,z>);
Div_G:=Divergence(G);

>   

Alternatively, the curl command can be calculated as the "crossproduct" of the Del operator on the vector field.

>    Div_G:=Del.G;

>   

The divergence is closely related to the curl and the gradient, as we will see throughout this worksheet and throughout this chapter.