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.
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 angle-bracket notation creates a free vector in the extant coordinate system. At this point in this worksheet, that coordinate system is Cartesian.
The explicit use of the Vector command permits attaching coordinates to the free vector.
In each case, the free vector is really a point. In Cartesian coordinates, the free vector v1 is a vector from the origin to the point a,b,c, 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 v2 is a point in a rectangular frame with axes labeled r (horizontal) and θ (vertical). In this frame, the point with polar coordinates r,θ=a,b is connected to the origin with an arrow, and this arrow is v2.
Information about v1 and v2 is obtained as follows.
The VectorField command is used to create a vector field.
The unit basis vectors e&conjugate0;x and e&conjugate0;y are used in place of i and j, 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
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 r, and radial rays as lines of constant θ. In this view of the change of coordinates to polar coordinates, the vectors e&conjugate0;r and e&conjugate0;θ 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
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 G at the Cartesian point whose polar-coordinate description is r,θ=a,b is effected by
because the free vector v2 is the Maple representation of the point whose polar coordinates are a,b. Indeed, we have
The root point is the point of "attachment" for the single vector G1, which is actually a "bound" vector, bound to the root point.
A rooted vector can be defined directly with the RootedVector command.
To verify that this is a vector in polar coordinates, rooted at the polar point r,θ=3,π5, use
Information about the rooted vector is actually stored in a module that could be created with the VectorSpace command.
The vector space is the set of all vectors of appropriate dimension that have their root point at r,θ=3,π5. The basis for this vector space are the vectors e&conjugate0;r,e&conjugate0;θ,the moving basis vectors defined at the root point. Individual vectors in this space can be created as module exports via the syntax
That v4 is the vector α e&conjugate0;r+β e&conjugate0;θ rooted at the point r,θ=3,π5 can be see with
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 radius-vector form of curves and surfaces. The vectors
are position vectors, 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 one-parameter family of points represents a curve, and a two-parameter family, a surface. Indeed, we have
The PositionVector construct applies only in Cartesian coordinates. The Position Vector
describes the origin-centered circle of radius 2 drawn in the Cartesian plane, as we see from
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.
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 column-vector format with the BasisFormat command. The setting
causes the displays to be
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
in polar coordinates, use
This is equivalent to expressing the unit basis vectors i and j in terms of the vectors e&conjugate0;r and e&conjugate0;θ,then making the substitutions x=r cosθ,y=r sinθ. This calculation can be carried out from first principles if the following position vector is first defined.
The basis vectors e&conjugate0;r and e&conjugate0;θ are obtained from R via
Writing these vectors in terms of i and j can be done with
Solving for i and j in terms of vectors e&conjugate0;r and e&conjugate0;θ,we get
Representing the vector field F in terms of i and j, then replacing i and j with their equivalents in terms of the vectors e&conjugate0;r and e&conjugate0;θ,we get
Making the substitutions x=r cosθ, y=r sinθ, we get
A final rearrangement of terms, and an identification of er and et with vectors e&conjugate0;r and e&conjugate0;θ,respectively, gives
which compares favorably with
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
easier to understand. The Cartesian point x,y=1,2, represented as a free vector, has been transformed to r,θ=5,arctan2,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.
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.
The top level operators
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 w3=w1+w2 can be corroborated by performing the sum in Cartesian coordinates via
The lengths of the vectors w1 and w5=α w1 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 w1 and w6 (the Cartesian equivalent of w1) appear in Figure 1, with w1 in black, and w6 in red.
Figure 1 The vectors w1 in black and w6 (the Cartesian equivalent of w1) in red
Since the length of w6 is
it is clear that the length of w1 is a function of both components in polar coordinates, not just the radial component.
Differentiation of a Vector Field
Consider the vector field
defined in the parabolic coordinate system for which the transformation equations are
Parabolic coordinates are not as familiar as polar coordinates, so fewer background assumptions will interfere with the following calculations.
The derivative of F with respect to u is given by
This result can be checked by computing from first principles. To begin, obtain expressions for the unit basis vectors e&conjugate0;u and e&conjugate0;v. For this, start with the position vector R=xu,v i+yu,v j, defined in Maple via
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 ∂R∂u 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 e&conjugate0;u and e&conjugate0;v are both linear combinations of i and j, differentiation of F=e&conjugate0;u+e&conjugate0;v with respect to u can take place componentwise. In fact, the derivative of F componentwise is
To express A=∂F∂u in terms of e&conjugate0;u and e&conjugate0;v,solve the equations
for i and j in terms of e&conjugate0;u and e&conjugate0;v. Doing this gives
Make these replacements in A to obtain ∂F∂u as
Tangent Vector along a Curve
define a space curve Rs in Euclidean space. The "secant vector"
is given by
tangent to the curve R, can also be written as
Of course, this tangent vector could also be obtained with the built-in TangentVector command, as shown by
The dot product of free vectors is defined for Euclidean space only. For example, we have
However, in curvilinear coordinates, the dot product between free vectors is not defined because the free vector represents a point, not a vector, in non-Cartesian coordinates. Maple gives the following error for such a calculation.
Error, (in VectorCalculus:-DotProduct) cannot take the dot product of free Vectors in non-cartesian coordinates
The divergence of the vector field
even though F was defined in parabolic coordinates! Alternatively, the divergence of F can be obtained with
Recalling that F is given in terms of the unit vectors i and j by the sum
the divergence can also be computed in Cartesian coordinates by use of the chain rule. The computations are slightly simplified if the components of F are named
The divergence of F, computed in Cartesian coordinates, is given by
∇·F=∂f∂u ∂u∂x+∂f∂v ∂v∂x+∂g∂u ∂u∂y+∂g∂v ∂v∂y
where the derivatives of u and v are
Consequently, the chain rule gives
which, upon substitution for the derivatives of u and v, becomes
clearly the same as
Other operations with the ∇,the nabla, and the dot product appear in Table 1.
∇2=∇·∇, the Laplacian operator
The directional derivative operator L=v·∇
L≔VectorFieldu,v,w . Del:Lh⁡x,y,z
Table 1 Additional operations with ∇, the nabla operator, and the dot product
In Cartesian coordinates, the cross-product of the free vectors
BasisFormatfalse: unassign'f'; v≔a,b,c: w≔d,e,f: v,w
can be computed by any of the following three approaches.
v &x w
In non-Cartesian coordinates, the cross-product between free vectors is not defined because the free vector is merely a notational device for a point. However, the cross-product is defined for rooted vectors such as
Surprisingly, the formalism for the cross-product in such non-Cartesian coordinates as the spherical system is the same as it is in the Cartesian system.
A &x B
The curl of the vector field
Del &x F
Other cross-products in which the ∇,or nabla, appear can be found in Table 2.
Define the operator F×∇ and apply it to the scalar fx,y,z.
unassign'v','w': L≔VectorFieldu,v,w &x Del: Lfx,y,z
Define the operator ∇×∇ and apply it to the scalar fx,y,z.
L≔Del &x Del:L⁡f⁡x,y,z
Table 2 Cross-products in which the ∇,or nabla, appear
In the each case in Table 2, the cross-product is with ∇f,the gradient of the scalar f.
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.
∂∂r⁢r2⁢sin⁡φ⁢VF 1⁡r,φ,θ+∂∂φ⁢r⁢sin⁡φ⁢VF 2⁡r,φ,θ+∂∂θ⁢r⁢VF 3⁡r,φ,θr2⁢sin⁡φ
∂∂r⁢r2⁢sin⁡φ⁢∂∂r⁢SF ⁡r,φ,θ+∂∂φ⁢sin⁡φ⁢∂∂φ⁢SF ⁡r,φ,θ+∂∂θ⁢∂∂θ⁢SF ⁡r,φ,θsin⁡φr2⁢sin⁡φ
Table 3 The formal representations of the basic differential operators of vector calculus
Notation such as VFk stands for the kth component of a vector field, while the notation SF stands for a scalar field.
The Frenet-Serret Formalism
In the VectorCalculus package, the Frenet-Serret formalism for a curve can be implemented directly, or stepwise. Let Rp be any helix defined by
where a>0. The parameter along R is taken as p because the parameter is not necessarily the time t.
The tangent-normal-binormal frame is obtained with
simplifyTNBFrame⁡R,p assuming 0<a
and the curvature, radius of curvature, and torsion are obtained in Table 4.
simplifyCurvature⁡R,p assuming 0<a
Radius of Curvature
simplifyRadiusOfCurvature⁡R,p assuming 0<a
simplifyTorsion⁡R,p assuming 0<a
Table 4 Curvature, radius of curvature, and torsion for Rp=a⁢cos⁡pa⁢sin⁡pp
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.
simplifyTNBFrame⁡a⁢cos⁡p,a⁢sin⁡p,p,p assuming 0<a
In Cartesian coordinates, the identification of points and vectors is transparent. In non-Cartesian coordinates, curves represented by free vectors are actually one-parameter sets of points in the rectangular version of the coordinate space defined by the non-Cartesian coordinates.
In addition to the TNBFrame command, the VectorCalculus package has individual commands that compute vectors along each of T,N,and B. The vectors in Table 5 are not unit vectors.
n:=PrincipalNormal⁡R,p;Normn assuming 0<a
b:=simplify⁡Binormal⁡R,p;Normb assuming 0<a
Table 5 Vectors along the unit tangent, principle normal, and binormal vectors
Working from first principles, we obtain by differentiation the vector V, tangent to R.
If the parameter along the curve were the time t, this tangent vector would be the velocity vector, and its length would be the "speed." Hence, we use
The unit tangent vector along R is then
The curvature κ can be computed by the formula
or more directly by its definition
where s is the arc length along R.
Using the first formula, we obtain
temp:=Norm⁡V &x diffR,p,pρ3:κ≔simplifytemp assuming 0<a
a result equivalent to the direct calculation
simplifyNorm⁡diffT,pρ assuming 0<a
The principal normal
N=dTdsdTds=dTds 1κ=dTdp 1ρ 1κ
is obtained by
N≔simplifydiff⁢T,pκ⁢ρ assuming 0<a
The binormal vector can be obtained as B=T×N,leading to the unit vector
B≔simplifyT&x N assuming 0<a
The torsion of R is the rate at which the binormal varies. In particular, it is defined by
as can be demonstrated in Maple via the calculations
simplifyNorm⁡diff⁢B,pρ assuming 0<a
It is easy to show that dBds= −τ N,so that τ= −N·dBds= −N·dBdp 1ρ,a result verified by
simplify−N.diffB,pρ assuming 0<a
The vector dBds is along the negative of the principal normal N because N·N=1⇒2 N·dNds=0,so dNds lies in the plane of B and T. Since B=T×N,and N is along dTds,it follows that dBds=dTds×N+T×dNds=T×dNds. By the right-hand rule, dBds must be along the negative of N.
Indeed, for the example at hand, we have
dBds= −τ N
T &x diffN,pρ
simplify−Torsion⁡R,p⁢N assuming 0< a
The Evolute of a Plane Curve
The evolute of a plane curve C (called the involute) is defined as the locus of the centers of curvature of C. If C is described in radius-vector form by Rp,then the evolute is given in vector form by
where, along C, N is the (unit) principal normal and r is the radius of curvature.
It turns out that the envelope of the normals along C is also the evolute.
For example, let C be the ellipse by defined by
The (unit) principal normal is then
temp:=Normalize⁡PrincipalNormal⁡R: N≔simplifytemp assuming 0<p
and the radius of curvature is
r≔RadiusOfCurvatureR assuming 0<p
The evolute is then
This is a rooted vector, as we see from
It can be converted to a position vector via
and plotted with the PlotPositionVector command. Figure 2 shows the involute (C) in black, and the evolute, in red.
Figure 2 Involute (in black) and its evolute (in red)
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
Evaluating the integral
at top level is complicated only by the syntax it takes to write the unevaluated form. Within the VectorCalculus package, we have the alternative
Typically, this integral is evaluated in polar coordinates, as seen from the inert form given by
The integral of
over the triangle whose vertices are 0,0,5,2,3,5 is given by
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 W is defined as the line integral (along C) of the tangential component of a force F 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 F=f i + g j,and the curve, by r=xp i+ypj,a≤p≤b,the work and flux integrals are given respectively by
W=∫CF·T ds=∫CF·dr=∫abf dx+g dy
flux=∫CF·N ds=∫abf dy−g dx
where T and N are unit tangent and normal vectors along C. Note that for flux, there is no simple equivalent to the F·dr that is available for the work integral.
Let F be the vector field defined by
f≔3 x2−5 y3: g≔2 x y: F≔VectorFieldf,g,cartesianx,y
and C be the curve defined by
X≔p2: Y≔p3: R≔PositionVectorX,Y
where 0≤p≤1;see Figure 3.
PlotPositionVectorR, p=0..1, curveoptions=scaling=constrained
Figure 3 Path defined by R=p2p3,0≤p≤1
The work done by the field on a particle of unit mass as the particle traverses the circle counterclockwise is given by
The inert form of this integral, namely,
shows how the integral is parametrized. To verify this result from first principles, evaluate the integral
Other domains recognized by the LineInt command are Arc, Circle, Circle3D, Ellipse, Line, and LineSegments.
The flux of F through C is given by
For a closed curve, the Flux command selects the outward normal. Since C is not closed, the orientation of the normal is not clear from this result. The net "flow" of the field F is against the normal field, but without knowing the direction of the normal field, the direction of the net flow of F is as yet unknown.
The principal normal points towards the center of curvature of C. The normal to the right of the tangent vector along C would point in the opposite direction. Figure 4 shows the tangent and principal normal vectors at one point on C. The principal normal (in red) is to the left of the tangent vector (in black).
Figure 4 Tangent and principle normal vectors along C
Hence, take the normal field as
temp≔−NormalizePrincipalNormalR: N≔simplifytemp assuming p>0
and compute, from first principles, ∫CF·N ds. For the element of arc length along C, take
obtained by an inspection of
The flux is again
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.
The flux of a vector field F through a surface S is defined by the surface integral
where dσ is the element of surface area for the surface S,and N is a unit normal field on the surface. If S is closed, it is usual to take N pointed outward. If S is not a closed surface, then the orientation of N 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
through S,that portion of the plane
lying inside the cylinder whose footprint in the xy-plane is a circle with center at 1,1 and radius 2 is given by
To obtain this result from first principles, let N be the unit upward normal field
The flux of F through S is then given by the surface integral
Alternatively, if dσ=1+zx2+zy2 is given by
the flux of F through S is then given by
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 A,B,C to the plane gx,y,z=0,where g is given by
can be found by the Lagrange multiplier technique in which points where the gradient of the objective function
is collinear with the gradient of g are found. This is most easily done by solving the equations
in conjunction with the constraint equation g=0. This is readily done with
As well as having access to the built-in 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 built-in (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
Setting the default coordinate system via
allows calculations such as
Gradientfu,v,u,v assuming positive
Laplacianf⁡u,v,u,v assuming positive
Adding a non-orthogonal system such as
generates the warning
Warning, the unit Vectors in the new coordinate system are not orthogonal, only added to global coordinate system