The VectorCalculus Package
This worksheet demonstrates examples using the VectorCalculus and Student[VectorCalculus] packages. The StudentVectorCalculus example worksheet provides additional examples, particularly of the Student[VectorCalculus] features for plotting, animation and interactive tutors.

Basic Objects


The main objects upon which this package operates are the free vector, the PositionVector, the RootedVector, the VectorField, curves, surfaces, and scalar fields. Lists cannot be used in place of vectors, and scalar fields are ordinary Maple functions and expressions. Information about vector objects  coordinate systems and names of coordinates  are stored as attributes of the vector objects. The About, attributes, and GetCoordinates commands can be used to recover this information.
The free vector is is created in one of two ways. The anglebracket notation creates a free vector in the extant coordinate system. At this point in this worksheet, that coordinate system is Cartesian.
>


 (2.1) 
The explicit use of the Vector command permits attaching coordinates to the free vector.
>


 (2.2) 
In each case, the free vector is really a point. In Cartesian coordinates, the free vector is a vector from the origin to the point , and the identification of the point with the free vector is permissible because the unit basis vectors are everywhere parallel.
By analogy, the free vector is a point in a rectangular frame with axes labeled (horizontal) and (vertical). In this frame, the point with polar coordinates is connected to the origin with an arrow, and this arrow is .
Information about and is obtained as follows.
The VectorField command is used to create a vector field.
>


 (2.6) 
The unit basis vectors and are used in place of and , respectively. The bar denotes that the domain of these basis vectors is the underlying Cartesian space, and that the vectors themselves are position dependent. Of course, in Cartesian coordinates, these basis vectors are independent of position, but the bar is still used to denote that these are the "moving" basis vectors that are defined at each point in the space supporting the vector field, and that are given in the coordinate system in which the vector field is given.
Alternatively, the vector field
>


 (2.7) 
defines a field of vectors whose domain is each point (except for the origin) in the Cartesian plane on which the coordinate curves of the polar coordinate system have been "pulled back." This is the familiar view of polar coordinates superimposed on the Cartesian plane  concentric circles as lines of constant , and radial rays as lines of constant . In this view of the change of coordinates to polar coordinates, the vectors and are position dependent. These "moving" basis vectors change direction from point to point, and are not to be confused with the basis vectors appearing in
>


 (2.8) 
If the evalVF command is used to evaluate the vector field G at a point in the Cartesian plane, the result is a RootedVector. For example, evaluating at the Cartesian point whose polarcoordinate description is is effected by
>


 (2.9) 
because the free vector is the Maple representation of the point whose polar coordinates are . Indeed, we have
>


 (2.10) 
The root point is the point of "attachment" for the single vector , which is actually a "bound" vector, bound to the root point.
A rooted vector can be defined directly with the RootedVector command.
>


 (2.11) 
To verify that this is a vector in polar coordinates, rooted at the polar point use
>


 (2.12) 
Information about the rooted vector is actually stored in a module that could be created with the VectorSpace command.
>


 (2.13) 
The vector space is the set of all vectors of appropriate dimension that have their root point at The basis for this vector space are the vectors the moving basis vectors defined at the root point. Individual vectors in this space can be created as module exports via the syntax
>


 (2.14) 
That is the vector rooted at the point can be see with
>


 (2.15) 
Creating rooted vectors via the VectorSpace command works well when many such vectors will have the same root point. The RootedVector command is most convenient for single rooted vectors.
Finally, there is the PositionVector command that creates the radiusvector form of curves and surfaces. The vectors
 (2.16) 
are PositionVectors, vectors from the origin of a Cartesian frame to the relevant point in that frame. Points can be parameterized by up to two parameters; a oneparameter family of points represents a curve, and a twoparameter family, a surface. Indeed, we have
The PositionVector construct applies only in Cartesian coordinates. The Position Vector
>


 (2.19) 
describes the origincentered circle of radius 2 drawn in the Cartesian plane, as we see from
>


 (2.20) 
Consequently, in the Cartesian plane the PositionVector, the free vector, and the vector rooted at the origin are essentially the same arrow, but because these are represented in the VectorCalculus package by distinct data structures, they are not necessarily recognized by Maple as being the same. Thus, the package provides the ConvertVector command for converting one form of the Cartesian vector to another.
>


 (2.21) 

>


 (2.22) 

>


 (2.23) 



A final word about the visual display of vectors and vector fields in the VectorCalculus package. The default display for free vectors and vector fields is explicitly in terms of basis vectors. This display can be changed to a columnvector format with the BasisFormat command. The setting
>


causes the displays to be
>


 (2.24) 
respectively, for a free vector and a vector field. The PositionVector is always displayed as a column vector.
The MapToBasis command imposes a change of coordinates on a vector or vector field. For example, to express the Cartesian vector field
>


 (2.25) 
in polar coordinates, use
>


 (2.26) 
This is equivalent to expressing the unit basis vectors and in terms of the vectors and then making the substitutions . This calculation can be carried out from first principles if the following position vector is first defined.
>


 (2.27) 
The basis vectors and are obtained from R via
Writing these vectors in terms of and can be done with
>


 (2.30) 
Solving for and in terms of vectors and we get
>


 (2.31) 
Representing the vector field in terms of and , then replacing and with their equivalents in terms of the vectors and we get
>


 (2.32) 
Making the substitutions , we get
>


 (2.33) 
A final rearrangement of terms, and an identification of and with vectors and respectively, gives
>


 (2.34) 
which compares favorably with
>


 (2.35) 
The MapToBasis command can also be used to transform a point in one coordinate system to its representation in another. Setting
>


will make the result of
>


 (2.36) 
easier to understand. The Cartesian point , represented as a free vector, has been transformed to also given as a free vector. This is not a vector transformation. The MapToBasis command applies the contravariant transformation law to a rooted vector or a vector field. Applied to a free vector, it transforms just the components. The basis vectors are not so transformed because the free vector is not a vector; it is really just a representation of a point in curvilinear coordinates.


Standard Operations


Three of the top level operators, `+` ( addition ), `*` ( scalar multiplication ), and `.` ( dot product ), have been overloaded to operate on the Vector/attribute combinations created by the package. Within the package, the diff command is also modified. It will act directly on vectors and vector fields without having to be mapped onto the target structures.
Also, a new operator, `&x` ( cross product ), is exported by the package. Where possible, these operators have been extended to understand the standard vector differential operator, Del ( or Nabla ), which is also a package export.

Basic Arithmetic


The top level operators

addition


subtraction

*

scalar multiplication



have been overloaded to operate on the Vector/attribute combinations created by the package. To illustrate this, first define the following vectors with a common root point.
The basic operations of addition, subtraction, and scalar multiplication are then obtained as follows.
The addition can be corroborated by performing the sum in Cartesian coordinates via
 (3.1.6) 
The lengths of the vectors and are respectively
In particular, this calculation highlights the possible misconception that the radial component of a vector expressed in polar coordinates determines the length of that vector. Graphs of the vectors and (the Cartesian equivalent of ) appear in Figure 1, with in black, and in red.
Since the length of is
>


 (3.1.9) 
it is clear that the length of is a function of both components in polar coordinates, not just the radial component.


Differentiation of a Vector Field


Consider the vector field
>


 (3.2.1) 
defined in the parabolic coordinate system for which the transformation equations are
>


 (3.2.2) 
Parabolic coordinates are not as familiar as polar coordinates, so fewer background assumptions will interfere with the following calculations.
The derivative of with respect to is given by
>


 (3.2.3) 
This result can be checked by computing from first principles. To begin, obtain expressions for the unit basis vectors and . For this, start with the position vector , defined in Maple via
>


 (3.2.4) 
The unit basis vectors are obtained from the position vector by the following calculations.
(Differentiation of the PositionVector creates a RootedVector, an object captured in a module data structure. If the normalized form of the vector were simplified with an assumption in the step that creates the module, the root point in the module would be stored with the assumption. Since this later leads to difficulties, the creation of the module is done first, and the simplification with the assumption is done in a second and separate step.)
Noting that and are both linear combinations of and , differentiation of with respect to can take place componentwise. In fact, the derivative of componentwise is
>


 (3.2.7) 
To express in terms of and solve the equations
>


 (3.2.8) 
for and in terms of and Doing this gives
>


 (3.2.9) 
Make these replacements in to obtain as
>


 (3.2.10) 
which compares favorably with
>


 (3.2.11) 


Tangent Vector along a Curve


Let
>


 (3.3.1) 
define a space curve in Euclidean space. The "secant vector"
is given by
>


 (3.3.2) 
The vector
>


 (3.3.3) 
tangent to the curve , can also be written as
>


 (3.3.4) 
Of course, this tangent vector could also be obtained with the builtin TangentVector command, as shown by
>


 (3.3.5) 


Dot Products


The dot product of free vectors is defined for Euclidean space only. For example, we have
>


 (3.4.1) 
or even
>


 (3.4.2) 
However, in curvilinear coordinates, the dot product between free vectors is not defined because the free vector represents a point, not a vector, in nonCartesian coordinates. Maple gives the following error for such a calculation.
>


Error, (in VectorCalculus:DotProduct) cannot take the dot product of free Vectors in noncartesian coordinates
 
The divergence of the vector field
>


 (3.4.3) 
is given by
>


 (3.4.4) 
even though was defined in parabolic coordinates! Alternatively, the divergence of can be obtained with
>


 (3.4.5) 
Recalling that is given in terms of the unit vectors and by the sum
>


 (3.4.6) 
the divergence can also be computed in Cartesian coordinates by use of the chain rule. The computations are slightly simplified if the components of are named
>


 (3.4.7) 
The divergence of , computed in Cartesian coordinates, is given by
where the derivatives of and are
>


 (3.4.8) 
Consequently, the chain rule gives
>


 (3.4.9) 
which, upon substitution for the derivatives of and , becomes
>


 (3.4.10) 
clearly the same as
>


 (3.4.11) 
Other operations with the the nabla, and the dot product appear in Table 1.
the Laplacian operator

>


 (3.4.12) 


>


 (3.4.13) 

The directional derivative operator

>


>


 (3.4.14) 

Table 1 Additional operations with ∇, the nabla operator, and the dot product





CrossProduct


In Cartesian coordinates, the crossproduct of the free vectors
>


 (3.5.1) 
can be computed by any of the following three approaches.
>


 (3.5.2) 

>


 (3.5.3) 

>


 (3.5.4) 



In nonCartesian coordinates, the crossproduct between free vectors is not defined because the free vector is merely a notational device for a point. However, the crossproduct is defined for rooted vectors such as
 (3.5.5) 
Surprisingly, the formalism for the crossproduct in such nonCartesian coordinates as the spherical system is the same as it is in the Cartesian system.
>


 (3.5.6) 
The curl of the vector field
>


 (3.5.7) 
can be computed by any of the following three approaches.
>


 (3.5.8) 

>


 (3.5.9) 

>


 (3.5.10) 



Other crossproducts in which the or nabla, appear can be found in Table 2.
Define the operator and apply it to the scalar

>


 (3.5.11) 

Define the operator and apply it to the scalar

>


 (3.5.12) 

Table 2 Crossproducts in which the or nabla, appear



In the each case in Table 2, the crossproduct is with the gradient of the scalar .


Displaying Symbolic Forms of the Differential Operators of Vector Calculus


In any orthogonal coordinate system, to display the differential forms of the divergence, gradient, curl, and Laplacian operators, do not specify any arguments for the corresponding Maple functions. For example, to obtain the format of these operators in spherical coordinates, first set the coordinate system to the spherical system with the command
>


then execute the commands in Table 3.
Divergence

>


 (3.6.1) 

Gradient

>


 (3.6.2) 

Curl

>


 (3.6.3) 

Laplacian

>


 (3.6.4) 

Table 3 The formal representations of the basic differential operators of vector calculus



Notation such as stands for the th component of a vector field, while the notation stands for a scalar field.



Curves



The FrenetSerret Formalism


In the VectorCalculus package, the FrenetSerret formalism for a curve can be implemented directly, or stepwise. Let be any helix defined by
>


 (4.1.1) 
where The parameter along is taken as because the parameter is not necessarily the time .
The tangentnormalbinormal frame is obtained with
>


 (4.1.2) 
and the curvature, radius of curvature, and torsion are obtained in Table 4.
Curvature

>


 (4.1.3) 

Radius of Curvature

>


 (4.1.4) 

Torsion

>


 (4.1.5) 

Table 4 Curvature, radius of curvature, and torsion for



Note that we have represented the curve via the PositionVector command. It is also possible to represent the curve as a free vector, as we see below.
>


 (4.1.6) 
In Cartesian coordinates, the identification of points and vectors is transparent. In nonCartesian coordinates, curves represented by free vectors are actually oneparameter sets of points in the rectangular version of the coordinate space defined by the nonCartesian coordinates.
In addition to the TNBFrame command, the VectorCalculus package has individual commands that compute vectors along each of and The vectors in Table 5 are not unit vectors.
>


 (4.1.7) 

>


 (4.1.8) 

>


 (4.1.9) 

Table 5 Vectors along the unit tangent, principle normal, and binormal vectors



Working from first principles, we obtain by differentiation the vector , tangent to
>


 (4.1.10) 
If the parameter along the curve were the time , this tangent vector would be the velocity vector, and its length would be the "speed." Hence, we use
and compute
>


 (4.1.11) 
The unit tangent vector along is then
>


 (4.1.12) 
The curvature can be computed by the formula
or more directly by its definition
where is the arc length along .
Using the first formula, we obtain
>


 (4.1.13) 
a result equivalent to the direct calculation
>


 (4.1.14) 
The principal normal
is obtained by
>


 (4.1.15) 
The binormal vector can be obtained as leading to the unit vector
>


 (4.1.16) 
The torsion of is the rate at which the binormal varies. In particular, it is defined by
as can be demonstrated in Maple via the calculations
It is easy to show that so that a result verified by
>


 (4.1.19) 
The vector is along the negative of the principal normal because so lies in the plane of and Since and is along it follows that By the righthand rule, must be along the negative of .
Indeed, for the example at hand, we have



>


 (4.1.20) 

>


 (4.1.21) 

>


 (4.1.22) 





The Evolute of a Plane Curve


The evolute of a plane curve (called the involute) is defined as the locus of the centers of curvature of If is described in radiusvector form by then the evolute is given in vector form by
where, along , is the (unit) principal normal and is the radius of curvature.
It turns out that the envelope of the normals along is also the evolute.
For example, let be the ellipse by defined by
>


 (4.2.1) 
The (unit) principal normal is then
>


 (4.2.2) 
and the radius of curvature is
>


 (4.2.3) 
The evolute is then
>


 (4.2.4) 
This is a rooted vector, as we see from
>


 (4.2.5) 
It can be converted to a position vector via
>


 (4.2.6) 
and plotted with the PlotPositionVector command. Figure 2 shows the involute () in black, and the evolute, in red.

Figure 2 Involute (in black) and its evolute (in red)






Integrals



Introduction


At "top level," the int command immediately evaluates a single integral, with Int being the inert form. Multiple (iterated) integrals require repeated applications of these commands.
In the VectorCalculus package, the int command has been modified to recognize multiple (iterated) integration, and to recognize such easily described domains as circles and piecewise linear paths. The inert integral is obtained by including the "inert" parameter.
In addition to the modifications to int, the VectorCalculus package contains the LineInt, SurfaceInt, Flux, ArcLength and PathInt commands, each of which also recognizes the "inert" parameter.


The Modified int Command


Although the syntax for the int command is modified in the VectorCalculus package, int continues to function as it does at top level, as we see from
>


 (5.2.1) 
Evaluating the integral
>


 (5.2.2) 
at top level is complicated only by the syntax it takes to write the unevaluated form. Within the VectorCalculus package, we have the alternative
>


 (5.2.3) 
Typically, this integral is evaluated in polar coordinates, as seen from the inert form given by
>


 (5.2.4) 
The integral of
>


 (5.2.5) 
over the triangle whose vertices are is given by
>


 (5.2.6) 
Obtaining this result from first principles is extremely tedious because the edges of the triangle first have to be parametrized, and then two (iterated) double integrals have to be written and evaluated.
In addition to recognizing the domains Circle and Triangle, the int command recognizes Ellipse, Sector, Parallelepiped, Rectangle, Region, Sphere, and Tetrahedron, where Region is used to define more general domains.


Line Integrals for Work and Flux


Mechanical work is defined as the line integral (along ) of the tangential component of a force and the flux of a planar force is defined as the line integral of the normal component. The work integral has the same form in any number of dimensions, but the flux integral becomes a surface integral in three dimensions.
Both work and flux are defined for curves parametrized by arc length, but are generally computed using whatever parametrization is convenient. For example, if the force is given by and the curve, by the work and flux integrals are given respectively by
and
where and are unit tangent and normal vectors along . Note that for flux, there is no simple equivalent to the that is available for the work integral.
Let be the vector field defined by
>


 (5.3.1) 
and be the curve defined by
>


 (5.3.2) 
where see Figure 3.
>



Figure 3 Path defined by



The work done by the field on a particle of unit mass as the particle traverses the circle counterclockwise is given by
>


 (5.3.3) 
The inert form of this integral, namely,
>


 (5.3.4) 
shows how the integral is parametrized. To verify this result from first principles, evaluate the integral
>


 (5.3.5) 
to obtain
>


 (5.3.6) 
Other domains recognized by the LineInt command are Arc, Circle, Circle3D, Ellipse, Line, and LineSegments.
The flux of through is given by
>


 (5.3.7) 
For a closed curve, the Flux command selects the outward normal. Since is not closed, the orientation of the normal is not clear from this result. The net "flow" of the field is against the normal field, but without knowing the direction of the normal field, the direction of the net flow of is as yet unknown.
The principal normal points towards the center of curvature of . The normal to the right of the tangent vector along would point in the opposite direction. Figure 4 shows the tangent and principal normal vectors at one point on . The principal normal (in red) is to the left of the tangent vector (in black).
>



Figure 4 Tangent and principle normal vectors along



Hence, take the normal field as
>


 (5.3.8) 
and compute, from first principles, For the element of arc length along , take
>


 (5.3.9) 
obtained by an inspection of
>


 (5.3.10) 
The flux is again
>


 (5.3.11) 
indicating that the Flux command also took the normal to the right of the tangent vector.
Other curves recognized by the Flux command are Arc, Circle, Ellipse, Line, and LineSegments. In three dimensions, the Flux command recognizes the regions Box, Sphere, and Surface. See below under Surface Integrals for examples of flux through a surface.


Surface Integrals


The flux of a vector field through a surface is defined by the surface integral
where is the element of surface area for the surface and is a unit normal field on the surface. If is closed, it is usual to take pointed outward. If is not a closed surface, then the orientation of must be specified for the value of the flux to be meaningful.
Surface flux is the natural generalization of the planar flux of a field through a curve.
The flux of the vector field
>


 (5.4.1) 
through that portion of the plane
>


 (5.4.2) 
lying inside the cylinder whose footprint in the plane is a circle with center at and radius 2 is given by
>


 (5.4.3) 
To obtain this result from first principles, let be the unit upward normal field
>


 (5.4.4) 
The flux of through is then given by the surface integral
>


 (5.4.5) 
Alternatively, if is given by
>


 (5.4.6) 
the flux of through is then given by
>


 (5.4.7) 
In addition to the Surface parameter, the Flux command recognizes the surfaces Box and Sphere.



The Lagrange Multiplier Method for Constrained Optimization


The shortest distance from the point to the plane where is given by
>


 (6.1) 
can be found by the Lagrange multiplier technique in which points where the gradient of the objective function
>


 (6.2) 
is collinear with the gradient of are found. This is most easily done by solving the equations
>


 (6.3) 
in conjunction with the constraint equation . This is readily done with
>


 (6.4) 


Extensibility


As well as having access to the builtin coordinate systems, you can add coordinate systems to the package so that all of the VectorCalculus commands can compute in this coordinate system. The only requirement is that the unit basis vectors of this new coordinate system must be orthogonal with one another.
In addition to the builtin (orthogonal) coordinate systems known to the VectorCalculus package, additional coordinate systems can be added to Maple via the AddCoordinates command. If the new coordinate system is also orthogonal, Maple will be able to implement vector operations in that system. If the new system is not orthogonal, Maple issues a warning, but permits the system to be added to the global coordinate system table upon which graphing commands are based.
For example, to add the orthogonal system determined by the equations
 (7.1) 
use
>


 (7.2) 
Setting the default coordinate system via
>


allows calculations such as
>


 (7.3) 
and
>


 (7.4) 
Adding a nonorthogonal system such as
>


 (7.5) 
generates the warning
>


Warning, the unit Vectors in the new coordinate system are not orthogonal, only added to global coordinate systems
 
 (7.6) 
However, plots in the nonorthogonal system are still available, as Figure 5 verifies.
>


>



Figure 5 Grid lines for a nonorthogonal system added to Maple




Return to Index for Example Worksheets
