Application Center - Maplesoft

App Preview:

Classroom Tips and Techniques:Vectors in the LinearAlgebra, VectorCalculus, and Physics Packages

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


Image 

Classroom Tips and Techniques: Vectors in the LinearAlgebra,
VectorCalculus, and Physics Packages
 

 

Robert J. Lopez
Emeritus Professor of Mathematics and Maple Fellow
Maplesoft 

Introduction 

 

In Maple, vectors appear at top-level, and in the MultivariateCalculus, LinearAlgebra, VectorCalculus, and Physics packages.  Within the packages, vectors  have different properties that we will compare and contrast in this article.  Throughout these remarks, we will consider just those vectors supported by the Maple rtable, and not the older type based on the table data structure.  These older vectors would be familiar to users of the now-deprecated linalg package. 

 

In the LinearAlgebra package vectors are essentially -tuples.  If thought of as arrows with length and direction, all arrows emanate from the origin of a Euclidean vector space.  In both the VectorCalculus and Physics packages, vectors are arrows bearing length and direction, but can be attached to arbitrary points in a Euclidean space that is referred to either Cartesian or nonCartesian coordinates.  The LinearAlgebra package supports basic algebraic calculations with -tuples and matrices, while the other two packages support the differential and integral calculus of vectors and vector fields.  Concomitant with the greater flexibility in these two packages is an increased complexity in data structures, syntax, and notation. 

 

>  
 

Deprecated Constructs 

 

The original vector construct in Maple, based on the array data structure, is entered as 

 

>
 

array( 1 .. 2, [( 1 ) = x, ( 2 ) = y ] )
 

>  
 

All such vectors are displayed as row vectors, but function as column vectors.  Without a distinction between row and column vectors, this construction necessarily treats covariant and contravariant vectors as equivalent. 

 

Both a strength and a weakness of these original vectors is last-name evaluation whereby the components are not displayed upon referencing just the name of the vector, as seen with 

 

>
 

v
 

>  
 

The evalm command fully evaluates the vector, as in 

 

>
 

array( 1 .. 2, [( 1 ) = x, ( 2 ) = y ] )
 

>  
 

If the evalm command is combined with lprint, one sees the explicit use of the array data structure that underlies these original vectors. 

 

>
 

array( 1 .. 2, [( 1 ) = x, ( 2 ) = y ] )
 

>  
 

The array data structure is not as robust as the newer rtable data structure upon which Maple now builds both Vectors and Matrices.  The older structures are therefore considered to be deprecated, that is, they still exist in Maple, but their use is not recommended. 

 

>  
 

Top Level 

Initializations 

 

>
 

>  
 


At "top-level," where no additional packages have been loaded, Maple now provides the Vector, built on the rtable data structure.  A Vector is entered with the syntax 

 

>
 

Vector[column](%id = 150555772)
 

>  
 

or equivalently, with the syntax 

 

>
 

Vector[column](%id = 151283036)
 

>  
 

Note the default to a column vector, as can be seen with 

 

>
 

Vector[column](2, {(1) = x, (2) = y}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
 

>  
 

A row vector can be constructed with the syntax 

 

>
 

Vector[row](%id = 151353600)
 

>  
 

and its inherent distinction from a column vector seen with 

 

>
 

Vector[row](2, {(1) = u, (2) = v}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
 

>  
 

Using the dot (period) for noncommutative multiplication, we see that Maple respects both the inner and outer products. 

 

>
 

 

 

Matrix(%id = 151741428)
 

>  
 

MultivariateCalculus 

Initializations 

 

>
 

>
 

>  
 


In the standard college curriculum, vectors are most likely first encountered in a multivariate calculus course.  One way such vectors will arise is via the gradient operator.  Hence, we have 

 

>
 

Vector[column](%id = 153157520)
 

>  
 

This vector is just a "top-level" Vector, as we see with 

 

>
 

Vector[column](2, {(1) = 2*x, (2) = 2*y}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
 

>  
 

Another appearance of the vector in the multivariate calculus course is in conjunction with the directional derivative.  The Student[MultiariateCalculus] package contains the DirectionalDerivative command, whose syntax is illustrated below. 

 

>
 

`+`(`/`(`*`(2, `*`(u, `*`(a))), `*`(`^`(`+`(`*`(`^`(a, 2)), `*`(`^`(b, 2))), `/`(1, 2)))), `/`(`*`(2, `*`(v, `*`(b))), `*`(`^`(`+`(`*`(`^`(a, 2)), `*`(`^`(b, 2))), `/`(1, 2)))))
 

>  
 

Note the use of the list for both the evaluation point and the direction vector.  Thus, the list is used for the point and the list is used for the vector , a potential source of confusion both here and in the VectorCalculus packages. 

 

>  
 

The LinearAlgebra Packages 

Initializations 

 

>
 

>
 

>  
 


The LinearAlgebra and Student[LinearAlgebra] packages use the "top-level" Vector.  There are no special vector constructors in either of these two packages.  As at top level, the vector can be constructed either as 

 

>
 

Vector[column](%id = 151126692)
 

>  
 

or as 

 

>
 

Vector[column](%id = 152379860)
 

>  
 

That V is a column vector can be seen with 

 

>
 

Vector[column](2, {(1) = x, (2) = y}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
 

>  
 

or with  

 

>
 

Vector[row](%id = 152485872)
 

>  
 

and 

 

>
 

Vector[row](2, {(1) = x, (2) = y}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
 

>  
 

These two packages also distinguish between the column (row) Vector and the Matrix with a single column (or row).  Thus, the matrix 

 

>
 

Matrix(%id = 152011764)
 

>  
 

 

>
 

Matrix(2, 1, {(1, 1) = x, (2, 1) = y}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
 

>  
 

 

>
 

Matrix(%id = 165216964)
 

>  
 

is a column vector, as we see from 

 

>
 

 

 

Vector[column](%id = 153097008)
Vector[column](2, {(1) = 1, (2) = 3}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
 

>  
 

Similarly, with the row. 

 

>
 

 

 

Vector[row](%id = 163888192)
Vector[row](2, {(1) = 1, (2) = 2}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
 

>  
 

The VectorCalculus Packages 

Initializations 

 

>
 

>
 

>
 

>  
 

Vectors 

 

The VectorCalculus packages support the data structures shown in Table 1. 

 

Free vector 

>
 

 

 

Typesetting:-mprintslash([`assign`(V, Vector[column]([[x], [y]], [
Typesetting:-mprintslash([Vector[column]([[x], [y]], [
 

PositionVector 

>
 

Typesetting:-mprintslash([`assign`(R, Vector[column]([[a], [b]]))], [Vector[column](%id = 152328144)])
 

RootedVector 

>
 

Typesetting:-mprintslash([`assign`(U, Vector[column]([[a], [b]]))], [Vector[column](%id = 163670024)])
 

VectorField 

>
 

Typesetting:-mprintslash([`assign`(F, Vector[column]([[`*`(x, `*`(y))], [`+`(x, `-`(y))]], [
 

Table 1   The four types of vectors in the VectorCalculus packages 

>  
 

The data structures provided in the VectorCalculus packages are richer and more complex than the structures in the LinearAlgebra packages.  The fundamental light illuminating the VectorCalculus packages is the identification of the Cartesian point with the vector .  This identification is obvious and harmless in the Cartesian plane, but is not possible in nonCartesian coordinates.  Any confusion users have with the VectorCalculus packages in Maple generally stems from failing to see that this identification of point and vector is valid only in Cartesian coordinates. 

 

Before clarifying the distinctions between these four data structures, we make the following observations.  

 

 

  • Each of these four data structures carries, as an attribute,  a coordinate system, and where applicable, the names of the coordinate variables.
 

 

 

  • The default system is Cartesian, but names for the coordinate variables are not set by default.
 

 

 

  • The SetCoordinates command defines an ambient (or background) coordinate system.
 

 

 

  • The BasisFormat command can be used to suppress the explicit display of basis vectors.
 

 

 

  • The About command provides information inherent in one of these data structures.
 

 

 

  • The MapToBasis command changes coordinates in these data structures.
 

 

Free Vector 

 

The default coordinate system is Cartesian, but the names of the coordinate variables are not set by default.  Thus, for the free vector  

 

>
 

Typesetting:-mprintslash([Vector[column]([[x], [y]], [
 

>  
 

we have 

 

>
 

Vector[column](2, {(1) = x, (2) = y}, datatype = anything, storage = rectangular, order = Fortran_order, attributes = [coords = cartesian], shape = [])
 

>  
 

or better still, 

 

>
 

Typesetting:-mprintslash([Matrix([[`Type: `, `Free Vector`], [`Components: `, [x, y]], [`Coordinates: `, cartesian]])], [Matrix(%id = 165720984)])
 

>  
 

The free vector V represents the Cartesian point and is identified with the arrow from the origin of the Cartesian plane to the point .  This identification of point and arrow is both common and innocuous in the Cartesian plane. 

 

The basis vectors and are essentially the more familiar and .  These basis vectors can be suppressed via 

 

>
 

>  
 

in which case the free vector is displayed as a column vector: 

 

>
 

Typesetting:-mprintslash([Vector[column]([[x], [y]])], [Vector[column](%id = 163390332)])
 

>  
 

The free vector can be constructed as a row vector with the syntax 

 

>
 

Typesetting:-mprintslash([`assign`(W, Vector[row]([u, v]))], [Vector[row](%id = 152130708)])
 

>  
 

Its nature as a row vector can be verified with 

 

>
 

Vector[row](2, {(2) = v, (1) = u}, datatype = anything, storage = rectangular, order = Fortran_order, attributes = [coords = cartesian], shape = [])
 

>  
 

In the VectorCalculus packages, the period (dot) is strictly the inner (or dot) product operator.  There is no recognition of an outer product in these packages, as we verify with the equivalent calculations 

 

>
 

 

 

`+`(`*`(u, `*`(x)), `*`(v, `*`(y)))
`+`(`*`(u, `*`(x)), `*`(v, `*`(y)))
 

>  
 

The VectorCalculus packages do not have a transpose operator.  If the Transpose command from the LinearAlgebra package is applied to V, we get the row vector 

 

>
 

Typesetting:-mprintslash([`assign`(U, Vector[row]([x, y]))], [Vector[row](%id = 163448160)])
 

>  
 

but U is now a "LinearAlgebra" vector and has lost the attribute containing the coordinate information, as we see with 

 

>
 

Vector[row](2, {(1) = x, (2) = y}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
 

>  
 

The MapToBasis command is used to change coordinates.  When applied to a free vector, it merely changes coordinates as for a point, and not for a vector.  Thus, the contravariant law for changing coordinates in a vector is not applied to the free vector. 

 

To illustrate, change the free vector V to polar coordinates, obtaining 

 

>
 

Typesetting:-mprintslash([`assign`(Vp, Vector[column]([[`*`(`^`(`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2))), `/`(1, 2)))], [arctan(y, x)]]))], [Vector[column](%id = 166090912)])
 

>  
 

The Cartesian point has become the polar point  No change of base vectors has occurred. 

 

In terms of explicit "basis vectors," we would have 

 

>
 

Typesetting:-mprintslash([Vector[column]([[`*`(`^`(`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2))), `/`(1, 2)))], [arctan(y, x)]], [
 

>  
 

The symbols and are not covariantly transformed basis vectors.  They merely indicate the coordinate system in which to interpret what are essentially coordinates of a point.  The identification of the point with the vector holds only in the Cartesian plane.  It does not extend to nonCartesian coordinates. 

 

One might think of a rectangular frame in which the coordinate axes represent (horizontally) and (vertically).  When the transformation from Cartesian to polar coordinates is interpreted as a mapping, the Cartesian point is physically mapped onto the polar point that resides in the rectangular -plane.  When the transformation from Cartesian to polar coordinates is interpreted as a change of coordinates, the Cartesian point remains fixed, but its address is changed to conform to the coordinates imposed by the concentric circles and radial lines pulled back to the Cartesian plane from the "polar" plane. 

 

Figure 1 illustrates a simple experiment in which MapToBasis is applied to the Cartesian free vector .  After conversion to polar coordinates, the "vector" retains its correspondence with the point to which it is drawn.  The transformed "vector," graphed via the PlotVector command, appears unchanged. 

 

>
 

Plot_2d
 

Figure 1   MapToBasis applied to the free vector  

>  
 

PositionVector 

 

Curves and surfaces embedded in a Cartesian space are often described with the radius-vector notation 

 

 

or 

 

 

Consequently, the VectorCalculus packages provide the PositionVector command.  For example, the parabola given parametrically by is captured with 

 

>
 

Typesetting:-mprintslash([`assign`(R, Vector[column]([[t], [`*`(`^`(t, 2))]]))], [Vector[column](%id = 152250332)])
 

>  
 

The PositionVector always echoes as a column vector, and always represents a vector in Cartesian coordinates.  By means of the PlotPositionVector command, Figure 2 provides a graph of the resulting curve. 

 

>
 

Plot_2d
 

Figure 2   Graph of a curve described in radius-vector notation 

>  
 

The PlotPositionVector command will also graph various vector fields along the curve.  On the graph in Figure 2, Figure 3 superimposes unit tangent vectors (in blue) and principal normal vectors (in green). 

 

>
 

Plot_2d
 

Figure 3   Unit tangent and principal normal vectors along the parabola in Figure 2 

>  
 

On the graph in Figure 2, Figure 4 superimposes the vectors and  

 

>
 

Plot_2d
 

Figure 4   Vectors and along the parabola in Figure 2 

>  
 

The cardioid is captured by the PositionVector construct via 

 

>
 

Typesetting:-mprintslash([`assign`(R, Vector[column]([[`*`(`+`(1, cos(theta)), `*`(cos(theta)))], [`*`(`+`(1, cos(theta)), `*`(sin(theta)))]]))], [Vector[column](%id = 165804808)])
 

>  
 

The coordinate parameter in the PositionVector command indicates the coordinate system in which the parametric representation is to be interpreted.  The resulting vector is a Cartesian vector.  Figure 5 shows a graph of this cardioid. 

 

>
 

Plot_2d
 

Figure 5   Cardioid captured as a PositionVector 

>  
 

RootedVector 

 

In a Cartesian space, parallel translation of vectors is taken for granted.  For example, the vector actually has its tail at the origin, and its head at the point .  This vector can always be thought of as the same arrow with its tail at an arbitrary point in the Cartesian plane.  In nonCartesian coordinates, we lose the construct of the position vector emanating from the origin.  Vectors are arrows with their tails at different points in the underlying Cartesian space, but are expressed in terms of the curvilinear basis vectors that change from point to point. 

 

The Maple construct for "attaching" a vector to a point is the RootedVector.  The vector 

 

>
 

Typesetting:-mprintslash([`assign`(V, Vector[column]([[-1], [1]]))], [Vector[column](%id = 167001936)])
 

>  
 

is attached to the root point as we verify in Figure 6. 

 

>
 

Plot_2d
 

Figure 6   The vector translated to the root point  

>  
 

Note that the RootedVector is always displayed as a column vector, and is of type RootedVector, as we seem from  

 

>
 

Typesetting:-mprintslash([Matrix([[`Type: `, `Rooted Vector`], [`Components: `, [-1, 1]], [`Coordinates: `, cartesian], [`Root Point: `, [1, 2]]])], [Matrix(%id = 165717972)])
 

>  
 

An arrow of length one and pointing in the radial direction of polar coordinates is attached to the polar point with the following syntax. 

 

>
 

Typesetting:-mprintslash([`assign`(W, Vector[column]([[1], [0]]))], [Vector[column](%id = 164527844)])
 

>  
 

Figure 7 verifies that the vector W, drawn in the Cartesian plane, is the correct polar vector. 

 

>
 

Plot_2d
 

Figure 7   Unit radial vector attached to the polar point but drawn in the underlying Cartesian plane 

>  
 

For another example of a RootedVector in polar coordinates, change coordinates in the vector to obtain 

 

>
 

Typesetting:-mprintslash([`assign`(Vp, Vector[column]([[`+`(`*`(`/`(1, 5), `*`(`^`(5, `/`(1, 2)))))], [`+`(`*`(`/`(3, 5), `*`(`^`(5, `/`(1, 2)))))]]))], [Vector[column](%id = 165085416)])
 

>  
 

Its root point becomes the root point as we verify with 

 

>
 

Typesetting:-mprintslash([Matrix([[`Type: `, `Rooted Vector`], [`Components: `, [`+`(`*`(`/`(1, 5), `*`(`^`(5, `/`(1, 2))))), `+`(`*`(`/`(3, 5), `*`(`^`(5, `/`(1, 2)))))]], [`Coordinates: `, polar[r, ...
 

>  
 

The components are with respect to the unit basis vectors (tangent to the coordinate curves) at the root point.  Figure 8 provides graphical evidence that the transformed vector determines the same arrow as seen in Figure 6. 

 

>
 

Plot_2d
 

Figure 8  The vector transformed to polar coordinates 

>  
 

The calculations leading to Figure 8 can be verified as follows.  First, define the curvilinear coordinate lines of polar coordinates by the PositionVector 

 

 

 

>
 

Typesetting:-mprintslash([`assign`(R, Vector[column]([[`*`(r, `*`(cos(theta)))], [`*`(r, `*`(sin(theta)))]]))], [Vector[column](%id = 165822924)])
 

>  
 

Unit tangent vectors along the coordinate curves are given by 

 

>
 

 

 

Typesetting:-mprintslash([`assign`(e[theta], Vector[column]([[`+`(`-`(sin(theta)))], [cos(theta)]]))], [Vector[column](%id = 167002128)])
 

>  
 

Evaluate these basis vectors at the point to obtain 

 

>
 

 

 

Typesetting:-mprintslash([`assign`(b[2], Vector[column]([[`+`(`-`(`*`(`/`(2, 5), `*`(`^`(5, `/`(1, 2))))))], [`+`(`*`(`/`(1, 5), `*`(`^`(5, `/`(1, 2)))))]]))], [Vector[column](%id = 154362416)])
 

>  
 

The components of the vector are the coefficients of the linear combination 

 

>
 

Typesetting:-mprintslash([Vector[column]([[-1], [1]])], [Vector[column](%id = 164833300)])
 

>  
 

Hence, we have recovered the vector

 

>  
 

VectorField 

 

A vector field is a function F from to .  This function is sometimes described as a vector-valued function of a vector argument, and is denoted by .  In simpler terms, the vector field provides a recipe for attaching an arrow to every point in a region of .  Maple provides the VectorField construct, exemplified via 

 

>
 

Typesetting:-mprintslash([`assign`(F, Vector[column]([[`*`(x, `*`(y))], [`+`(x, y)]], [
 

>  
 

The default display (with BasisFormat set to true) includes the moving basis vectors, here, and .  In Cartesian coordinates, these vectors are nothing more than and .  However, there is a fundamental difference between these over-barred vectors, and the unbarred "basis vectors" used in the display of a free vector.  Once again, we remind the reader that the free vector is merely notation for a point, and is equivalent to an arrow only in Cartesian coordinates.  In nonCartesian coordinates, the unbarred "basis vector" of the free vector is merely notation for a point. 

 

The over-barred basis vectors of the VectorField are the moving (unit) basis vectors in both Cartesian and nonCartesian coordinates.  Conceptually, they are functions of position, but in Maple it takes the RootedVector construct to express the positional dependency of any vector. 

 

If we set 

 

>
 

>  
 

the vector field F will be displayed as a column vector, as we see from 

 

>
 

Typesetting:-mprintslash([Vector[column]([[`*`(x, `*`(y))], [`+`(x, y)]])], [Vector[column](%id = 165982352)])
 

>  
 

The VectorField carries as attribute, both "vectorfield" and its coordinate system, as we see with 

 

>
 

Vector[column](2, {(1) = x*y, (2) = x+y}, datatype = anything, storage = rectangular, order = Fortran_order, attributes = [vectorfield, coords = cartesian[x, y]], shape = [])
 

>  
 

The MapToBasis command applies the contravariant transformation law to a VectorField, correctly transforming the vectors in the field from one coordinate system to another.  For example, if the field F is transformed to polar coordinates, we would obtain 

 

>
 

Typesetting:-mprintslash([`assign`(G, Vector[column]([[`*`(sin(theta), `*`(r, `*`(`+`(`*`(r, `*`(`^`(cos(theta), 2))), cos(theta), sin(theta)))))], [`*`(`+`(cos(theta), sin(theta), `-`(r), `*`(r, `*`(...
 

>  
 

When the field is displayed as a column vector, the basis vectors and must be inferred.  They can be made visible by 

 

>
 

Typesetting:-mprintslash([Vector[column]([[`*`(sin(theta), `*`(r, `*`(`+`(`*`(r, `*`(`^`(cos(theta), 2))), cos(theta), sin(theta)))))], [`*`(`+`(cos(theta), sin(theta), `-`(r), `*`(r, `*`(`^`(cos(thet...
Typesetting:-mprintslash([Vector[column]([[`*`(sin(theta), `*`(r, `*`(`+`(`*`(r, `*`(`^`(cos(theta), 2))), cos(theta), sin(theta)))))], [`*`(`+`(cos(theta), sin(theta), `-`(r), `*`(r, `*`(`^`(cos(thet...
 

>  
 

Evaluation of the VectorField results in a RootedVector, with the evaluation point becoming the root point.  For example, we would have 

 

>
 

Typesetting:-mprintslash([`assign`(G1, Vector[column]([[`+`(`*`(`/`(27, 13), `*`(`^`(13, `/`(1, 2)))))], [`+`(`-`(`*`(`/`(8, 13), `*`(`^`(13, `/`(1, 2))))))]]))], [Vector[column](%id = 167403564)])
 

>  
 

The vector is a RootedVector, as we see from 

 

>
 

Typesetting:-mprintslash([Matrix([[`Type: `, `Rooted Vector`], [`Components: `, [`+`(`*`(`/`(27, 13), `*`(`^`(13, `/`(1, 2))))), `+`(`-`(`*`(`/`(8, 13), `*`(`^`(13, `/`(1, 2))))))]], [`Coordinates: `,...
 

>  
 

The components are the coefficients of the moving basis vectors and evaluated at the root point the polar representation of the Cartesian point .  The evalVF command uses the free vector notation for the evaluation point, and this point is interpreted in the ambient coordinate system 

 

>
 

cartesian
 

>  
 

The ambient coordinate system can be set with 

 

>
 

polar[r, theta]
 

>  
 

in which case we would have obtained 

 

>
 

Typesetting:-mprintslash([`assign`(G2, Vector[column]([[`+`(`*`(2, `*`(sin(3), `*`(`+`(`*`(2, `*`(`^`(cos(3), 2))), cos(3), sin(3))))))], [`+`(`*`(2, `*`(`+`(cos(3), sin(3), `-`(2), `*`(2, `*`(`^`(cos...
 

>  
 

The root point for the vector is given by 

 

>
 

Typesetting:-mprintslash([Matrix([[`Type: `, `Rooted Vector`], [`Components: `, [`+`(`*`(2, `*`(sin(3), `*`(`+`(`*`(2, `*`(`^`(cos(3), 2))), cos(3), sin(3)))))), `+`(`*`(2, `*`(`+`(cos(3), sin(3), `-`...
Typesetting:-mprintslash([Matrix([[`Type: `, `Rooted Vector`], [`Components: `, [`+`(`*`(2, `*`(sin(3), `*`(`+`(`*`(2, `*`(`^`(cos(3), 2))), cos(3), sin(3)))))), `+`(`*`(2, `*`(`+`(cos(3), sin(3), `-`...
Typesetting:-mprintslash([Matrix([[`Type: `, `Rooted Vector`], [`Components: `, [`+`(`*`(2, `*`(sin(3), `*`(`+`(`*`(2, `*`(`^`(cos(3), 2))), cos(3), sin(3)))))), `+`(`*`(2, `*`(`+`(cos(3), sin(3), `-`...
Typesetting:-mprintslash([Matrix([[`Type: `, `Rooted Vector`], [`Components: `, [`+`(`*`(2, `*`(sin(3), `*`(`+`(`*`(2, `*`(`^`(cos(3), 2))), cos(3), sin(3)))))), `+`(`*`(2, `*`(`+`(cos(3), sin(3), `-`...
Typesetting:-mprintslash([Matrix([[`Type: `, `Rooted Vector`], [`Components: `, [`+`(`*`(2, `*`(sin(3), `*`(`+`(`*`(2, `*`(`^`(cos(3), 2))), cos(3), sin(3)))))), `+`(`*`(2, `*`(`+`(cos(3), sin(3), `-`...
 

>  
 

so that it is now  

 

>  
 

Differential Operators 

 

The differential operators Divergence and Curl act on VectorFields, the first returning a scalar field; the second, a VectorField.  The differential operator Gradient acts on a scalar field and returns a VectorField, whereas the operator Laplacian maps a scalar field to a scalar field. 

 

While there is a special data structure for the vector field, there is no structure provided for the scalar field.  These are instead given by ordinary Maple expressions, and as such, cannot carry the attribute of coordinate system. 

 

We next give examples of the behavior of the four differential operators of vector calculus, using the field 

 

>
 

Error, (in VectorCalculus:-Vector[column]) Vector has incorrect dimension for polar[r, theta] coordinates: try changing the default coordinates
 

>  
 

The Error can be explained as follows.  Recall that earlier, the ambient coordinate system was set to polar, as we see from  

 

>
 

polar[r, theta]
 

>  
 

There are then two options: use the SetCoordinates command to change the ambient system, or force the issue by defining the vector 

 

>
 

Typesetting:-mprintslash([`assign`(V, Vector[column]([[`*`(x, `*`(y))], [`+`(y, z)], [`+`(x, `-`(z))]], [
 

>  
 

then writing 

 

>
 

Typesetting:-mprintslash([`assign`(F, Vector[column]([[`*`(x, `*`(y))], [`+`(y, z)], [`+`(x, `-`(z))]], [
 

>  
 

The curl of F can be computed by the command 

 

>
 

Typesetting:-mprintslash([Vector[column]([[-1], [-1], [`+`(`-`(x))]], [
 

>  
 

or by the notation 

 

>
 

Typesetting:-mprintslash([Vector[column]([[-1], [-1], [`+`(`-`(x))]], [
 

>  
 

In either case, the barred basis vectors indicate that the curl is again a VectorField

 

The divergence of F can be computed by the command 

 

>
 

y
 

>  
 

or by the notation 

 

>
 

y
 

>  
 

The gradient of the scalar field 

 

>
 

Typesetting:-mprintslash([`assign`(f, `+`(`*`(`^`(x, 2)), `*`(`^`(y, 2))))], [`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2)))])
 

>  
 

can be computed by the command 

 

>
 

Typesetting:-mprintslash([Vector[column]([[`+`(`*`(2, `*`(x)))], [`+`(`*`(2, `*`(y)))]], [
 

>  
 

The barred basis vectors indicate that this result is a VectorField.  Here, it is essential to include the name of the coordinate system in the Gradient command since the ambient system is not the one governing the variables in .  

 

A similar remark applies to the computation of the Laplacian, given by 

 

>
 

4
 

>  
 

If the ambient coordinate system is changed to 

 

>
 

cartesian[x, y]
 

>  
 

the gradient and Laplacian, respectively, could have been computed with the commands 

 

>
 

Typesetting:-mprintslash([Vector[column]([[`+`(`*`(2, `*`(x)))], [`+`(`*`(2, `*`(y)))]], [
 

>  
 

and 

 

>
 

4
 

>  
 

or with the notation 

 

>
 

Typesetting:-mprintslash([Vector[column]([[`+`(`*`(2, `*`(x)))], [`+`(`*`(2, `*`(y)))]], [
 

>  
 

and 

 

>
 

4
 

>  
 

Velocity and Acceleration in Polar Coordinates 

 

Determining expressions for the velocity and acceleration vectors in nonCartesian coordinates is a typical task in mechanics.  To obtain these expressions in polar coordinates, recall  

 

>
 

Typesetting:-mprintslash([Vector[column]([[cos(theta)], [sin(theta)]]), Vector[column]([[`+`(`-`(sin(theta)))], [cos(theta)]])], [Vector[column](%id = 152673748), Vector[column](%id = 167002128)])
 

>  
 

as representations of the moving (or local) unit basis vectors in polar coordinates.  Introduce the symbols and in place of the basis vectors i and j, and write as  

 

>
 

 

 

Typesetting:-mprintslash([`assign`(b[1], `+`(`*`(cos(theta(t)), `*`(i)), `*`(sin(theta(t)), `*`(j))))], [`+`(`*`(cos(theta(t)), `*`(i)), `*`(sin(theta(t)), `*`(j)))])
Typesetting:-mprintslash([`assign`(b[2], `+`(`-`(`*`(sin(theta(t)), `*`(i))), `*`(cos(theta(t)), `*`(j))))], [`+`(`-`(`*`(sin(theta(t)), `*`(i))), `*`(cos(theta(t)), `*`(j)))])
 

>  
 

Next, express i and j in terms of the vectors and , where, to avoid name clashes, use the symbols and

 

>
 

Typesetting:-mprintslash([`assign`(q, {i = `+`(`*`(cos(theta(t)), `*`(E[r])), `-`(`*`(sin(theta(t)), `*`(E[theta])))), j = `+`(`*`(sin(theta(t)), `*`(E[r])), `*`(E[theta], `*`(cos(theta(t)))))})], [{i...
 

>  
 

Write the position vector as 

 

>
 

Typesetting:-mprintslash([`assign`(R, Vector[column]([[`*`(r(t), `*`(cos(theta(t))))], [`*`(r(t), `*`(sin(theta(t))))]]))], [Vector[column](%id = 163844900)])
 

>  
 

and differentiate with respect to to obtain 

 

>
 

Typesetting:-mprintslash([`assign`(Rt, Vector[column]([[`+`(`*`(diff(r(t), t), `*`(cos(theta(t)))), `-`(`*`(r(t), `*`(sin(theta(t)), `*`(diff(theta(t), t))))))], [`+`(`*`(diff(r(t), t), `*`(sin(theta(...
 

>  
 

Replace the implied basis vectors i and j with their equivalents in terms of and , obtaining 

 

>
 

Typesetting:-mprintslash([v(t) = `+`(`*`(r(t), `*`(diff(theta(t), t), `*`(E[theta]))), `*`(diff(r(t), t), `*`(E[r])))], [v(t) = `+`(`*`(r(t), `*`(diff(theta(t), t), `*`(E[theta]))), `*`(diff(r(t), t),...
 

>  
 

Similarly, to obtain the acceleration vector, differentiate the position vector twice, obtaining 

 

>
 

Typesetting:-mprintslash([`assign`(Rtt, Vector[column]([[`+`(`*`(diff(r(t), `$`(t, 2)), `*`(cos(theta(t)))), `-`(`*`(2, `*`(diff(r(t), t), `*`(sin(theta(t)), `*`(diff(theta(t), t)))))), `-`(`*`(r(t), ...
Typesetting:-mprintslash([`assign`(Rtt, Vector[column]([[`+`(`*`(diff(r(t), `$`(t, 2)), `*`(cos(theta(t)))), `-`(`*`(2, `*`(diff(r(t), t), `*`(sin(theta(t)), `*`(diff(theta(t), t)))))), `-`(`*`(r(t), ...
Typesetting:-mprintslash([`assign`(Rtt, Vector[column]([[`+`(`*`(diff(r(t), `$`(t, 2)), `*`(cos(theta(t)))), `-`(`*`(2, `*`(diff(r(t), t), `*`(sin(theta(t)), `*`(diff(theta(t), t)))))), `-`(`*`(r(t), ...
Typesetting:-mprintslash([`assign`(Rtt, Vector[column]([[`+`(`*`(diff(r(t), `$`(t, 2)), `*`(cos(theta(t)))), `-`(`*`(2, `*`(diff(r(t), t), `*`(sin(theta(t)), `*`(diff(theta(t), t)))))), `-`(`*`(r(t), ...
 

>  
 

then replace the basis vectors i and j to obtain 

 

>
 

Typesetting:-mprintslash([`+`(`*`(`+`(diff(r(t), `$`(t, 2)), `-`(`*`(r(t), `*`(`^`(diff(theta(t), t), 2))))), `*`(E[r])), `*`(`+`(`*`(2, `*`(diff(r(t), t), `*`(diff(theta(t), t)))), `*`(r(t), `*`(diff...
 

>  
 

The Physics Package 

Projected Vectors 

Initializations 

 

>
 

>
 

>
 

>  
 


A projected vector is one for which the components are explicitly given.  For example, the following vector V is a projected vector. 

 

>
 

Typesetting:-mprintslash([`assign`(V, `+`(`*`(f(x, y, z), `*`(_i)), `*`(g(x, y, z), `*`(_j)), `*`(h(x, y, z), `*`(_k))))], [`+`(`*`(f(x, y, z), `*`(_i)), `*`(g(x, y, z), `*`(_j)), `*`(h(x, y, z), `*`(...
 

>  
 

In text mode (1D math) basis vectors are entered with a lead underscore.  Conversion of such a symbol to 2D math input mode renders the basis vector as a character with a superimposed "^" symbol.  To enter the lead underscore while typing in math mode, the escape character (\) must first be typed. 

 

 

  • At the present time, three systems of coordinates are recognized: Cartesian, cylindrical, and spherical.
 

 

 

  • If the parameter mathematicalnotation is set to true, then unit basis vectors are displayed as , where is the appropriate symbol from Table 2.
 

 

 

  • Coordinates are changed with the ChangeBasis command, with systems referenced by number as per Table 2.
 

 

Reference Number 

System 

Basis Vectors 

Coordinate Variables 

Cartesian 

i, j, k 

 

Cylindrical 

 

 

Spherical 

 

 

Table 2   Coordinate systems supported in the Physics package 

 

In the spherical coordinate system, where is measured downward from the positive -axis; and where is measured from the positive -axis counterclockwise around the -axis. 

 

In cylindrical coordinates, the vector V is given by 

 

>
 

Typesetting:-mprintslash([`assign`(Vc, `+`(`*`(`+`(`*`(f(x, y, z), `*`(cos(phi))), `*`(g(x, y, z), `*`(sin(phi)))), `*`(_rho)), `*`(`+`(`-`(`*`(f(x, y, z), `*`(sin(phi)))), `*`(g(x, y, z), `*`(cos(phi...
Typesetting:-mprintslash([`assign`(Vc, `+`(`*`(`+`(`*`(f(x, y, z), `*`(cos(phi))), `*`(g(x, y, z), `*`(sin(phi)))), `*`(_rho)), `*`(`+`(`-`(`*`(f(x, y, z), `*`(sin(phi)))), `*`(g(x, y, z), `*`(cos(phi...
 

>  
 

and in spherical coordinates, it is given by 

 

>
 

Typesetting:-mprintslash([`assign`(Vs, `+`(`*`(`+`(`*`(f(x, y, z), `*`(sin(theta), `*`(cos(phi)))), `*`(g(x, y, z), `*`(sin(theta), `*`(sin(phi)))), `*`(h(x, y, z), `*`(cos(theta)))), `*`(_r)), `*`(`+...
Typesetting:-mprintslash([`assign`(Vs, `+`(`*`(`+`(`*`(f(x, y, z), `*`(sin(theta), `*`(cos(phi)))), `*`(g(x, y, z), `*`(sin(theta), `*`(sin(phi)))), `*`(h(x, y, z), `*`(cos(theta)))), `*`(_r)), `*`(`+...
Typesetting:-mprintslash([`assign`(Vs, `+`(`*`(`+`(`*`(f(x, y, z), `*`(sin(theta), `*`(cos(phi)))), `*`(g(x, y, z), `*`(sin(theta), `*`(sin(phi)))), `*`(h(x, y, z), `*`(cos(theta)))), `*`(_r)), `*`(`+...
 

>  
 

In each case, note that no substitutions are made in the coefficients.  Just the basis vectors are changed, leaving the user the task of implementing the appropriate substitutions in the coefficients. 

 

Another feature of projected vectors is demonstrated by the addition of the following two vectors given in spherical coordinates.   

 

>
 

 

 

Typesetting:-mprintslash([`assign`(V1, `+`(`*`(a[1], `*`(_r)), `*`(b[1], `*`(_theta)), `*`(c[1], `*`(_phi))))], [`+`(`*`(a[1], `*`(_r)), `*`(b[1], `*`(_theta)), `*`(c[1], `*`(_phi)))])
Typesetting:-mprintslash([`assign`(V2, `+`(`*`(a[2], `*`(_r)), `*`(b[2], `*`(_theta)), `*`(c[2], `*`(_phi))))], [`+`(`*`(a[2], `*`(_r)), `*`(b[2], `*`(_theta)), `*`(c[2], `*`(_phi)))])
 

>  
 

The sum, namely, 

 

>
 

`+`(`*`(_r, `*`(`+`(a[1], a[2]))), `*`(_theta, `*`(`+`(b[1], b[2]))), `*`(_phi, `*`(`+`(c[1], c[2]))))
 

>  
 

is computed without regard for the root point of the vectors.  The design assumes the underlying Cartesian space is flat (zero curvature) so that even if the vectors are given in nonCartesian coordinates, parallel translation is allowed, and the vectors can be added.  This feature rules out many of the graphical features provided in the VectorCalculus packages. 

 

Another consequence of having the basis vectors be just symbols and not functions of position becomes apparent in the computation of the velocity and acceleration vectors in mechanics.  Suppose we define the position of a particle in polar coordinates (a specialization of the cylindrical system) by means of the vector 

 

>
 

Typesetting:-mprintslash([`assign`(R, `*`(rho(t), `*`(_rho)))], [`*`(rho(t), `*`(_rho))])
 

>  
 

then differentiate with respect to to obtain the velocity.  We get the erroneous 

 

>
 

Typesetting:-mprintslash([`*`(diff(rho(t), t), `*`(_rho))], [`*`(diff(rho(t), t), `*`(_rho))])
 

>  
 

because the basis vector is just a symbol without any explicit dependence on position, and hence, time. 

 

If we try writing explicit positional dependence into the position vector, as in 

 

>
 

Typesetting:-mprintslash([`assign`(R, `*`(rho(t), `*`(_rho(rho(t), phi(t)))))], [`*`(rho(t), `*`(_rho(rho(t), phi(t))))])
 

>  
 

differentiation leads to 

 

>
 

Typesetting:-mprintslash([`+`(`*`(diff(rho(t), t), `*`(_rho(rho(t), phi(t)))), `*`(rho(t), `*`(`+`(`*`((D[1](_rho))(rho(t), phi(t)), `*`(diff(rho(t), t))), `*`((D[2](_rho))(rho(t), phi(t)), `*`(diff(p...
 

>  
 

where the derivatives of the moving basis vector must still be computed.  Given the complexity of the notation, we will go about this calculation in a way more like the method we used in the VectorCalculus package.  However, we will find that calculation to be simpler to implement in the Physics package. 

 

We can very easily obtain expressions for the basis vectors i and j in terms of the moving basis vectors and as follows. 

 

>
 

 

 

Typesetting:-mprintslash([`assign`(e[i], `+`(`*`(cos(phi(t)), `*`(_rho)), `-`(`*`(sin(phi(t)), `*`(_phi)))))], [`+`(`*`(cos(phi(t)), `*`(_rho)), `-`(`*`(sin(phi(t)), `*`(_phi))))])
Typesetting:-mprintslash([`assign`(e[j], `+`(`*`(sin(phi(t)), `*`(_rho)), `*`(cos(phi(t)), `*`(_phi))))], [`+`(`*`(sin(phi(t)), `*`(_rho)), `*`(cos(phi(t)), `*`(_phi)))])
 

>  
 

We then define parametrically via 

 

>
 

 

 

Typesetting:-mprintslash([`assign`(xt, `*`(r(t), `*`(cos(phi(t)))))], [`*`(r(t), `*`(cos(phi(t))))])
Typesetting:-mprintslash([`assign`(yt, `*`(r(t), `*`(sin(phi(t)))))], [`*`(r(t), `*`(sin(phi(t))))])
 

>  
 

The position vector in Cartesian coordinates is then 

 

>
 

Typesetting:-mprintslash([`assign`(R, `+`(`*`(r(t), `*`(cos(phi(t)), `*`(_i))), `*`(r(t), `*`(sin(phi(t)), `*`(_j)))))], [`+`(`*`(r(t), `*`(cos(phi(t)), `*`(_i))), `*`(r(t), `*`(sin(phi(t)), `*`(_j)))...
 

>  
 

so that the velocity vector is readily obtained as 

 

>
 

Typesetting:-mprintslash([`assign`(V, `+`(`*`(r(t), `*`(diff(phi(t), t), `*`(_phi))), `*`(diff(r(t), t), `*`(_rho))))], [`+`(`*`(r(t), `*`(diff(phi(t), t), `*`(_phi))), `*`(diff(r(t), t), `*`(_rho)))]...
 

>  
 

The acceleration vector is also readily obtained as 

 

>
 

Typesetting:-mprintslash([`assign`(A, `+`(`*`(2, `*`(diff(r(t), t), `*`(diff(phi(t), t), `*`(_phi)))), `*`(r(t), `*`(diff(phi(t), `$`(t, 2)), `*`(_phi))), `*`(diff(r(t), `$`(t, 2)), `*`(_rho)), `-`(`*...
 

>  
 

or better yet, as 

 

>
 

Typesetting:-mprintslash([`+`(`*`(`+`(diff(r(t), `$`(t, 2)), `-`(`*`(r(t), `*`(`^`(diff(phi(t), t), 2))))), `*`(_rho)), `*`(`+`(`*`(2, `*`(diff(r(t), t), `*`(diff(phi(t), t)))), `*`(r(t), `*`(diff(phi...
 

>  
 


Notice that no special provisions had to be made to ensure that time-derivatives were expressed with the over-dot notation.  This is another useful feature of the Physics package. 

 

>  
 

Non-Projected Vectors 

Initializations 

 

>
 

>
 

>  
 

Introduction 

 

Projected vectors require explicit indications of components.  Non-projected vectors, entered with a postfix underscore, can be manipulated as symbols sans components.  This is probably the most significant property of vectors in the Physics package. 

 

We will illustrate this feature via several examples. 

 

>  
 

Example 1 

 

Obtain the vector equation of a plane passing through three given points.  Then specialize the resulting formula by passing the plane through the three points  

 

Let the points be , and let the Cartesian position vectors for these points be .  Define the vectors , and by 

 

>
 

 

 

Typesetting:-mprintslash([`assign`(A_, `+`(c_, `-`(a_)))], [`+`(c_, `-`(a_))])
Typesetting:-mprintslash([`assign`(B_, `+`(b_, `-`(a_)))], [`+`(b_, `-`(a_))])
 

>  
 

With the parameter mathematicalnotation set to true, non-projected vectors are displayed with a surmounted arrow.  In text (1D math) mode, they are entered with a trailing underscore.  In math mode (2D math input mode), the underscore must be preceded by the escape character (\).  The underscore will be visible as input, but will disappear upon output.  If 1D math is converted to 2D math (as we did here), then the input will display the arrow notation. 

 

The vectors A and B lie in the desired plane.  If r is the position vector of an arbitrary point in the plane, then the vector given by 

 

>
 

Typesetting:-mprintslash([`assign`(C_, `+`(r_, `-`(a_)))], [`+`(r_, `-`(a_))])
 

>  
 

also lies in the plane.  The absolute value of the triple scalar (or box) product is the volume of the parallelopiped defined by the vectors A, B, and C.  If these vectors are to lie in a common plane, this volume must be zero.  Hence, the equation of the plane must be given by 

 

>
 

Typesetting:-mprintslash([`assign`(q, Physics:-Vectors:-`.`(`+`(r_, `-`(a_)), `&x`(`+`(c_, `-`(a_)), `+`(b_, `-`(a_)))) = 0)], [Physics:-Vectors:-`.`(`+`(r_, `-`(a_)), `&x`(`+`(c_, `-`(a_)), `+`(b_, `...
 

>  
 

To instantiate this formula with the given points, use 

 

>
 

Typesetting:-mprintslash([`assign`(qq, `+`(`-`(`*`(16, `*`(x))), 32, `*`(32, `*`(y)), `*`(40, `*`(z))) = 0)], [`+`(`-`(`*`(16, `*`(x))), 32, `*`(32, `*`(y)), `*`(40, `*`(z))) = 0])
 

which, with slight modification, simplifies to 

 

>
 

`+`(`-`(`*`(2, `*`(x))), `*`(4, `*`(y)), `*`(5, `*`(z)), 4) = 0
 

>  
 

Example 2 

 

To verify the vector identity 

 

 

 

implement the calculations on the left-hand and right-hand sides separately, as in 

 

>
 

 

 

Typesetting:-mprintslash([`assign`(LEFTSIDE, `+`(`*`(f(x, y, z), `*`(Divergence(V_(x, y, z)))), Physics:-Vectors:-`.`(`*`(diff(f(x, y, z), x), `*`(_i)), V_(x, y, z)), Physics:-Vectors:-`.`(`*`(diff(f(...
Typesetting:-mprintslash([`assign`(LEFTSIDE, `+`(`*`(f(x, y, z), `*`(Divergence(V_(x, y, z)))), Physics:-Vectors:-`.`(`*`(diff(f(x, y, z), x), `*`(_i)), V_(x, y, z)), Physics:-Vectors:-`.`(`*`(diff(f(...
Typesetting:-mprintslash([`assign`(RIGHTSIDE, `+`(`*`(f(x, y, z), `*`(Divergence(V_(x, y, z)))), Physics:-Vectors:-`.`(`*`(diff(f(x, y, z), x), `*`(_i)), V_(x, y, z)), Physics:-Vectors:-`.`(`*`(diff(f...
Typesetting:-mprintslash([`assign`(RIGHTSIDE, `+`(`*`(f(x, y, z), `*`(Divergence(V_(x, y, z)))), Physics:-Vectors:-`.`(`*`(diff(f(x, y, z), x), `*`(_i)), V_(x, y, z)), Physics:-Vectors:-`.`(`*`(diff(f...
 

>  
 

then compare the resulting expressions with 

 

>
 

0
 

>  
 

Alternatively, using the inert forms for the divergence operator, we could write 

 

> expand(%Divergence(f*V_));
 

Typesetting:-mprintslash([`+`(`*`(f, `*`(%Divergence(V_))), Physics:-Vectors:-`.`(%Gradient(f), V_))], [`+`(`*`(f, `*`(%Divergence(V_))), Physics:-Vectors:-`.`(%Gradient(f), V_))])
 

>  
 

To verify the vector identity 

 

 

 

implement the calculations on the left-hand and right-hand sides separately, as in 

 

>
 

 

 

Typesetting:-mprintslash([`assign`(LEFTSIDE, Curl(Curl(V_(x, y, z))))], [Curl(Curl(V_(x, y, z)))])
Typesetting:-mprintslash([`assign`(RIGHTSIDE, `+`(`*`(diff(Divergence(V_(x, y, z)), x), `*`(_i)), `*`(diff(Divergence(V_(x, y, z)), y), `*`(_j)), `*`(diff(Divergence(V_(x, y, z)), z), `*`(_k)), `-`(di...
Typesetting:-mprintslash([`assign`(RIGHTSIDE, `+`(`*`(diff(Divergence(V_(x, y, z)), x), `*`(_i)), `*`(diff(Divergence(V_(x, y, z)), y), `*`(_j)), `*`(diff(Divergence(V_(x, y, z)), z), `*`(_k)), `-`(di...
 

>  
 

then compare the resulting expressions with 

 

>
 

0
 

>  
 

Using the inert forms of the curl operator, we could alternatively write 

 

> expand(%Curl(%Curl(V_)));
 

Typesetting:-mprintslash([`+`(%Gradient(%Divergence(V_)), `-`(%Laplacian(V_)))], [`+`(%Gradient(%Divergence(V_)), `-`(%Laplacian(V_)))])
 

>  
 


Legal Notice: The copyright for this application is owned by the author(s). Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities.
 

Image