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.
Initializations
restart
withStudentVectorCalculus:
withVectorCalculus:
withplots:
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 angle-bracket notation creates a free vector in the extant coordinate system. At this point in this worksheet, that coordinate system is Cartesian.
v1:=a,b,c
The explicit use of the Vector command permits attaching coordinates to the free vector.
v2:=Vector⁡a,b,coordinates=polarr,θ
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.
Aboutv1About⁡v2
GetCoordinates⁡v1GetCoordinates⁡v2
cartesian
polarr,θ
attributes⁡v1attributesv2
coords=cartesian
coordinates=polarr,θ
The VectorField command is used to create a vector field.
F:=VectorField⁡x2,1+x⁢y,cartesianx,y
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
G:=VectorField⁡r2⁢cos⁡2⁢θ,r+sin⁡θ,polarr,θ
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
v2
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
G1:=evalVF⁡G,v2
because the free vector v2 is the Maple representation of the point whose polar coordinates are a,b. Indeed, we have
About⁡G1
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.
v3:=RootedVector⁡root=3,π5,α,β,polarr,θ
To verify that this is a vector in polar coordinates, rooted at the polar point r,θ=3,π5, use
About⁡v3
Information about the rooted vector is actually stored in a module that could be created with the VectorSpace command.
VS:=VectorSpace⁡polarr,θ,3,π5
VS:=modulelocal_origin,_coords,_coords_dim;exportGetCoordinates,GetRootPoint,Vector;end module
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
v4≔VS:-Vectorα,β
That v4 is the vector α e&conjugate0;r+β e&conjugate0;θ rooted at the point r,θ=3,π5 can be see with
About⁡v4
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
R1≔PositionVectorx⁡t,t⁡t,z⁡t,cartesianx,y,z:R2≔PositionVectorx⁡a,b,y⁡a,b,z⁡a,b,cartesianx,y,z: R1,R2
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
About⁡R1
About⁡R2
The PositionVector construct applies only in Cartesian coordinates. The Position Vector
PositionVector⁡2⁢cos⁡θ,2⁢sin⁡θ,cartesianx,y
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.
ConvertVector⁡R1,free
ConvertVector⁡v1,rooted
ConvertVector⁡v1,position
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
BasisFormat⁡false:
causes the displays to be
v1,F
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
F
in polar coordinates, use
simplify⁡MapToBasis⁡F,polarr,θ
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.
R:=PositionVector⁡r⁢cos⁡θ,r⁢sin⁡θ,cartesianx,y
The basis vectors e&conjugate0;r and e&conjugate0;θ are obtained from R via
Er≔diffR,r
Et:=assuming⁡Normalize⁡diff⁢R,θ,0<r
Writing these vectors in terms of i and j can be done with
eq1:=Er.i,j=ereq2≔Et.i,j=et
eq1:=cos⁡θ⁢i+sin⁡θ⁢j=er
eq2:=−sin⁡θ⁢i+cos⁡θ⁢j=et
Solving for i and j in terms of vectors e&conjugate0;r and e&conjugate0;θ,we get
q:=solve⁡eq1,eq2,i,j
q:=i=−sin⁡θ⁢et+er⁢cos⁡θ,j=cos⁡θ⁢et+sin⁡θ⁢er
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
q1:=simplify⁡eval⁡F.VectorField⁡i,j,cartesianx,y,q
q1:=−x2⁢sin⁡θ⁢et+x2⁢er⁢cos⁡θ+cos⁡θ⁢et+sin⁡θ⁢er+x⁢y⁢cos⁡θ⁢et+x⁢y⁢sin⁡θ⁢er
Making the substitutions x=r cosθ, y=r sinθ, we get
q2:=simplify⁡eval⁡q1,x=r⁢cos⁡θ,y=r⁢sin⁡θ
q2:=cos⁡θ⁢et+sin⁡θ⁢er+r2⁢cos⁡θ⁢er
A final rearrangement of terms, and an identification of er and et with vectors e&conjugate0;r and e&conjugate0;θ,respectively, gives
q3:=collect⁡q2,er,et
q3:=sin⁡θ+r2⁢cos⁡θ⁢er+cos⁡θ⁢et
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
BasisFormat⁡true:
will make the result of
MapToBasis⁡1,2,polarr,t
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.
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.
w1:=RootedVector⁡root=1,2,2,3,polarr,θ;About⁡w1
w2:=RootedVector⁡root=1,2,5,−4,polarr,θ;About⁡w2
The basic operations of addition, subtraction, and scalar multiplication are then obtained as follows.
w3:=w1+w2;About⁡w3
w4:=w1−w2;About⁡w4
w5:=α⁢w1;About⁡w5
The addition w3=w1+w2 can be corroborated by performing the sum in Cartesian coordinates via
w6:=MapToBasis⁡w1,cartesian:w7≔MapToBasisw2,cartesian:w8≔w6+w7:simplify⁡MapToBasis⁡w8,polar
The lengths of the vectors w1 and w5=α w1 are respectively
Norm⁡w1
13
and
assuming⁡Norm⁡w5,0<α
13⁢α
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.
PlotVector⁡w1,scaling=constrained,view=−4..0,0..2,labels=x,y,axes=frame
PlotVector⁡w6,scaling=constrained,color=red,view=−4..0,0..2,labels=x,y,axes=frame
Figure 1 The vectors w1 in black and w6 (the Cartesian equivalent of w1) in red
Since the length of w6 is
Norm⁡w6
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
unassign'v'; F:=VectorField⁡1,1,parabolicu,v
defined in the parabolic coordinate system for which the transformation equations are
X:=u2−v22;Y≔u v
X:=12⁢u2−12⁢v2
Y:=u⁢v
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
ans≔simplifydiffF,u
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
R:=PositionVector⁡X,Y
The unit basis vectors are obtained from the position vector by the following calculations.
temp1:=Normalize⁡diffR,u;eu:=assuming⁡simplify⁡temp1,real
temp2:=Normalize⁡diff⁢R,v;ev:=assuming⁡simplify⁡temp2,real
(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
A≔collectdiffeu+ev,u,i,j,simplify
To express A=∂F∂u in terms of e&conjugate0;u and e&conjugate0;v,solve the equations
eqn1:=Eu=eu.i,jeqn2:=Ev=ev.i,j
eqn1:=Eu=u⁢iv2+u2+v⁢jv2+u2
eqn2:=Ev=−v⁢iv2+u2+u⁢jv2+u2
for i and j in terms of e&conjugate0;u and e&conjugate0;v. Doing this gives
B:=solve⁡eqn1,eqn2,i,j
B:=i=Eu⁢u−v⁢Evv2+u2,j=Ev⁢u+v⁢Euv2+u2
Make these replacements in A to obtain ∂F∂u as
collect⁡eval⁡A.i,j,B,Eu,Ev,simplify
v⁢Euv2+u2−v⁢Evv2+u2
ans
Tangent Vector along a Curve
Let
R:=PositionVector⁡a⁡s,b⁡s,c⁡s
define a space curve Rs in Euclidean space. The "secant vector"
Rs+h−Rsh
is given by
SV:=Rs=s+h|Rs=s+h−Rh
The vector
TV:=limh→0SV
tangent to the curve R, can also be written as
convert⁡TV,diff
Of course, this tangent vector could also be obtained with the built-in TangentVector command, as shown by
TangentVector⁡R
Dot Products
The dot product of free vectors is defined for Euclidean space only. For example, we have
a,b.c,d
a⁢c+b⁢d
or even
DotProduct⁡a,b,c,d
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.
DotProduct⁡Vector⁡a,b,coordinates=polar,Vector⁡c,d,coordinates=polar
Error, (in VectorCalculus:-DotProduct) cannot take the dot product of free Vectors in non-cartesian coordinates
The divergence of the vector field
DivergenceF;
uv2+u2+vv2+u2v2+u2
even though F was defined in parabolic coordinates! Alternatively, the divergence of F can be obtained with
Del.F
Recalling that F is given in terms of the unit vectors i and j by the sum
Fij:=simplify⁡eu+ev
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
f:=Fij1g:=Fij2
f:=u−vv2+u2
g:=v+uv2+u2
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
dx:=implicitdiff⁡x=X,y=Y,u⁡x,y,v⁡x,y,u,v,xdy:=implicitdiff⁡x=X,y=Y,u⁡x,y,v⁡x,y,u,v,y
dx:=D1⁡u=uv2+u2,D1⁡v=−vv2+u2
dy:=D2⁡u=vv2+u2,D2⁡v=uv2+u2
Consequently, the chain rule gives
DF:=diff⁢f,u⁢D1u+diff⁢f,v⁢D1v+diffg,u⁢D2u+diff⁢g,v⁢D2v
DF:=1v2+u2−u−v⁢uv2+u23/2⁢D1⁡u+−1v2+u2−v⁢u−vv2+u23/2⁢D1⁡v+1v2+u2−v+u⁢uv2+u23/2⁢D2⁡u+1v2+u2−v⁢v+uv2+u23/2⁢D2⁡v
which, upon substitution for the derivatives of u and v, becomes
simplify⁡eval⁡DF,dx∪dy
v+uv2+u23/2
clearly the same as
simplify⁡Del.F
Other operations with the ∇,the nabla, and the dot product appear in Table 1.
∇2=∇·∇, the Laplacian operator
SetCoordinatescartesianx,y,z:Del.Del
VectorCalculus:-Laplacian
∇2hx,y,z
Del.Del⁡h⁡x,y,z
∂2∂x2⁢h⁡x,y,z+∂2∂y2⁢h⁡x,y,z+∂2∂z2⁢h⁡x,y,z
The directional derivative operator L=v·∇
unassign⁡'v':
L≔VectorFieldu,v,w . Del:Lh⁡x,y,z
u⁢∂∂x⁢h⁡x,y,z+v⁢∂∂y⁢h⁡x,y,z+w⁢∂∂z⁢h⁡x,y,z
Table 1 Additional operations with ∇, the nabla operator, and the dot product
Cross-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
CrossProduct⁡v,w
v×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
unassign⁡'v';A≔RootedVectorpoint=a,b,c,u1,u2,u3,sphericalρ,φ,θ:B:=RootedVectorpoint=a,b,c,v1,v2,v3,sphericalρ,φ,θ:A,B
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
unassign⁡'g';F≔VectorFieldf⁡x,y,z,g⁡x,y,z,h⁡x,y,z,cartesianx,y,z
CurlF
Del &x F
∇×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
SetCoordinates⁡sphericalr,φ,θ:
then execute the commands in Table 3.
Divergence
∂∂r⁢r2⁢sin⁡φ⁢VF 1⁡r,φ,θ+∂∂φ⁢r⁢sin⁡φ⁢VF 2⁡r,φ,θ+∂∂θ⁢r⁢VF 3⁡r,φ,θr2⁢sin⁡φ
Gradient
Curl
Laplacian
Laplacian⁡
∂∂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.
Curves
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
SetCoordinatescartesianx,y,z:R:=PositionVector⁡a⁢cos⁡p,a⁢sin⁡p,p
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.
Curvature
simplifyCurvature⁡R,p assuming 0<a
a1+a2
Radius of Curvature
simplifyRadiusOfCurvature⁡R,p assuming 0<a
1+a2a
Torsion
simplifyTorsion⁡R,p assuming 0<a
11+a2
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.
v:=TangentVectorR,p;Norm⁡v
1+a2
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.
V≔diff R,p
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
ρ=dRdp=dxdp2+dydp2+dzdp2=dsdp
and compute
ρ:=Norm⁡V
ρ:=1+a2
The unit tangent vector along R is then
T:=Vρ
The curvature κ can be computed by the formula
κ=R′×R″ρ3
or more directly by its definition
κ=dTds=dTdpdpds=dTdp 1ρ
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
κ:=a1+a2
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
τ=dBds=dBdpdpds=dBdp 1ρ
as can be demonstrated in Maple via the calculations
τ
dBdp 1ρ
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=dBdp 1ρ
T×dNds=T×dNdp 1ρ
dBds= −τ N
diffB,pρ
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
R+r N
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
SetCoordinatescartesianx,y:R≔PositionVector2⁢cos⁡p,sin⁡p
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
r:=12⁢−3⁢cos⁡p2+43/2
The evolute is then
Ev:=simplify⁡R+r⁢N
This is a rooted vector, as we see from
About⁡Ev
It can be converted to a position vector via
E:=ConvertVector⁡Ev,position
and plotted with the PlotPositionVector command. Figure 2 shows the involute (C) in black, and the evolute, in red.
p1:=PlotPositionVector⁡R,p=0..2⁢π,curveoptions=color=black:p2:=PlotPositionVector⁡E,p=0..2⁢π,curveoptions=color=red:display⁡p1,p2,scaling=constrained
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
unassign'b','r'∫−∞∞ⅇ−x2ⅆx=∫−∞∞ⅇ−x2ⅆx
∫−∞∞ⅇ−x2ⅆx=π
Evaluating the integral
q:=∫−∞∞∫−∞∞ⅇ−x2−y2ⅆxⅆy:q=value⁡q
∫−∞∞∫−∞∞ⅇ−x2−y2ⅆxⅆy=π
at top level is complicated only by the syntax it takes to write the unevaluated form. Within the VectorCalculus package, we have the alternative
int⁡ⅇ−x2−y2,x,y=Circle⁡0,0,∞
π
Typically, this integral is evaluated in polar coordinates, as seen from the inert form given by
int⁡ⅇ−x2−y2,x,y=Circle⁡0,0,∞,r,θ,inert
∫0∞∫02⁢πr⁢ⅇ−r2ⅆθⅆr
The integral of
f:=3⁢x2−5⁢y3
over the triangle whose vertices are 0,0,5,2,3,5 is given by
int⁡f,x,y=Triangle⁡0,0,5,2,3,5
−14632
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
LineInt⁡F,Path⁡R,p=0..1
3744
The inert form of this integral, namely,
LineInt⁡F,Path⁡R,p=0..1,inert
∫012⁢3⁢p4−5⁢p9⁢p+6⁢p7ⅆp
shows how the integral is parametrized. To verify this result from first principles, evaluate the integral
W:=∫01eval⁡f,x=X,y=Y⁢∂∂p⁢X+eval⁡g,x=X,y=Y⁢∂∂p⁢Yⅆp
W:=∫012⁢3⁢p4−5⁢p9⁢p+6⁢p7ⅆp
to obtain
value⁡W
Other domains recognized by the LineInt command are Arc, Circle, Circle3D, Ellipse, Line, and LineSegments.
The flux of F through C is given by
Flux⁡F,Path⁡R,p=0..1
−1528
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).
PlotPositionVector⁡R,p=0..1,tangent=true,tangentoptions=color=black,normal=true,normaloptions=color=red,vectornum=1,curveoptions=scaling=constrained
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
ds:=p⁢4+9⁢p2
obtained by an inspection of
ArcLength⁡R,p=0..1,inert
∫014⁢p2+9⁢p4ⅆp
The flux is again
∫01F.N⁢dsⅆp
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 F through a surface S is defined by the surface integral
flux=∫∫SF·N dσ
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
SetCoordinatescartesianx,y,z:F:=VectorField⁡y2⁢z,z2⁢x,x2⁢y
through S,that portion of the plane
Z:=4−x+y
lying inside the cylinder whose footprint in the xy-plane is a circle with center at 1,1 and radius 2 is given by
Flux⁡F,Surface⁡x,y,Z,x,y=Circle⁡1,1,2
8⁢π
To obtain this result from first principles, let N be the unit upward normal field
N:=Normalize⁡VectorField⁡1,−1,1
The flux of F through S is then given by the surface integral
SurfaceInt⁡F.N,x,y,z=Surface⁡x,y,Z,x,y=Circle⁡1,1,2
Alternatively, if dσ=1+zx2+zy2 is given by
d_sigma:=1+∂∂x⁢Z2+∂∂y⁢Z2
d_sigma:=3
the flux of F through S is then given by
int⁡F.N⁢d_sigmaz=Z|F.N⁢d_sigmaz=Z,x,y=Circle⁡1,1,2
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
g:=a⁢x+b⁢y+c⁢z−d
can be found by the Lagrange multiplier technique in which points where the gradient of the objective function
unassign⁡'A','B';f:=x−A2+y−B2+z−C2
f:=x−A2+y−B2+z−C2
is collinear with the gradient of g are found. This is most easily done by solving the equations
q:=convert⁡Equate⁡Gradientf,λ⋅Gradient g,set
q:=2⁢x−2⁢A=λ⁢a,2⁢y−2⁢B=λ⁢b,2⁢z−2⁢C=λ⁢c
in conjunction with the constraint equation g=0. This is readily done with
Q:=solve⁡q∪g=0,x,y,z,λ
Q:=x=A⁢b2+A⁢c2−a⁢b⁢B−a⁢c⁢C+a⁢da2+b2+c2,y=−−B⁢a2−B⁢c2+b⁢a⁢A+b⁢c⁢C−b⁢da2+b2+c2,z=−−C⁢a2−C⁢b2+c⁢a⁢A+c⁢b⁢B−c⁢da2+b2+c2,λ=−2⁢a⁢A+b⁢B+c⁢C−da2+b2+c2
Extensibility
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
unassign⁡'v','f':X≔u2+v2Y:=u2−v2
X:=v2+u2
Y:=u2−v2
use
AddCoordinates⁡mycoords1u,v,X,Y
mycoords1
Setting the default coordinate system via
SetCoordinates⁡mycoords1u,v:
allows calculations such as
Gradientfu,v,u,v assuming positive
Laplacianf⁡u,v,u,v assuming positive
18⁢−v⁢∂∂u⁢f⁡u,vu2+v⁢∂2∂u2⁢f⁡u,vu−u⁢∂∂v⁢f⁡u,vv2+u⁢∂2∂v2⁢f⁡u,vvu⁢v
Adding a non-orthogonal system such as
X:=u2+v2Y≔u2−2⁢v2
Y:=u2−2⁢v2
generates the warning
AddCoordinates⁡mycoords2u,v,X,Y
Warning, the unit Vectors in the new coordinate system are not orthogonal, only added to global coordinate systems
mycoords2
However, plots in the non-orthogonal system are still available, as Figure 5 verifies.
coordplot⁡mycoords2,−3..3,−3..3
Figure 5 Grid lines for a non-orthogonal system added to Maple
See Also
assume, VectorCalculus , Student[VectorCalculus]
Return to Index for Example Worksheets
Download Help Document