TensorCalculus Maple
TensorCalculus Maple
Robert J. Lopez
Emeritus Professor of Mathematics and Maple Fellow
Maplesoft
Introduction
The Tensor subpackage of the DifferentialGeometry package supplants the now-deprecated
tensor package in Maple. The tensor package made essential use of the also-deprecated linalg
package, so although worksheets that used these deprecated packages still work, it is imperative
to move to using the new formalisms in the Tensor package.
This article is a "survivor's guide" for implementing tensor calculus in the new Tensor package.
It explains the constructs in this package from the perspective of classical (i.e., indicial) tensor
notation.
The DifferentialGeometry package itself contains some 34 command but also six subpackages,
themselves contributing to a total of some 184 commands. These subpackages, and a measure
of their "size" are listed in Table 1.
Subpackage
Number of Commands
Tensor
61
Tools
21
JetCalculus
GroupActions
Library
LieAlgebras
Table 1
33
sets of useful tutorials, a comprehensive collection of Lessons, and a set of Tutorials. The
Lessons worksheets provide a systematic approach to learning the commands in the
DifferentialGeometry, Tensor, LieAlgebras and JetCalculus subpackages. Each lesson also
contains a set of exercises that range in difficulty from simple computations to programming
problems. Solutions are given. The tutorials present specialized applications of the
DifferentialGeometry package.
Our more modest goal for this article is to show how to enter covariant and contravariant tensors,
compute their covariant derivatives, obtain the equations of parallel transport and geodesics, and
compute the basic tensors of general relativity.
Initializations
>
>
>
We have elected to suspend this default behavior for three reasons. First, interactive editing of a
worksheet can create a confusing display. If in a section where one frame name appears in all
prompts, a new frame is defined, the subsequent prompts that show the earlier name do not
change to show the new name. Only a "new" prompt will display the new frame name. The
result is a worksheet with prompts showing different frame names where they might not be
relevant. Such misplaced prompts have to be deleted manually if they are not to provide
incorrect information.
Second, these modified prompts are persistent - they cannot be removed by any Maple
command. They have to be removed by deletion. (The Maple interface command that
modifies prompts does not cascade the change through existing prompts. It only modifies new
prompts.)
Finally, if the commands are executed in Document Blocks, and not at prompts, there will be no
visible prompt to modify. Thus, the modified prompt is a worksheet paradigm that does not
carry through all of Maple usage. For all these reasons, we will not have frame names visible in
our prompts.
Basis Type
Transformation Law
Contravariant
Covariant
Table 3
and
and
and
. Thus, an
orthonormal basis is self-reciprocal. That is why the distinction between contravariant and
covariant basis does not matter in Cartesian spaces.
If
to
is interpreted as a row
If
to
To facilitate the implementation of the contravariant transformation law, writing the components
as a column vector v means the sums with the Jacobian matrix are along a row and across the
columns of the matrix. Hence, the matrix product
implements the contravariant
transformation. Writing the components
as the row vector w means the sums with the
Jacobian matrix are down a column but across the rows. Hence, the matrix product
implements the covariant transformation. This inherent distinction between tangent bases and
normal bases induces the distinction between contravariant and covariant. Using column and
row vectors to express this difference is a convenient visual device in classical tensor calculus.
with basis
from
, the direct product of
The tensor is actually the object
In actual practice, one manipulates just the components of the tensor, and almost never explicitly
exhibits the basis objects. However, in the DifferentialGeometry package, vectors and tensors
require an explicit use of the basis objects.
The basis
for
could be entered as
>
>
or could be extracted from Maple with the DGinfo command from the Tools package.
>
>
(To type the underscore in math (2D) mode, press the escape character (\) first. Alternatively,
enter such expressions in text (linear, 1D) mode and convert to math mode via the Context
Menu.)
The reciprocal (or dual) basis
is then
>
>
or
>
>
In actual fact,
is considered a differential form, more in keeping with the modern approach to
differential geometry.
command, the asterisk is the explicit multiplication operator. If this vector had been entered in
math mode, the echo of the asterisk would be a centered dot. The alternative to the asterisk
would be the space.
The covariant vector whose components are
is entered as
>
>
or as
>
>
There does not seem to be a simple way to represent a vector as a column or row vector. The
Tools subpackage provides the DGinfo command with which the components of a vector can be
extracted. Its use is illustrated by
>
>
or by
>
>
>
The construct
, etc.
>
>
The construct
, etc.
>
The components of the rank-two tensor are often represented as the entries of a matrix. If a
matrix is used for such a representation, it is possible to convert the matrix to a
DifferentialGeometry tensor.
>
>
Contraction of Indices
Given two tensors of conformable dimensions, say
and , forming the sum of products
is the operation contraction of indices. Recall that the Einstein summation convention
indicates a sum on the same index when it appears once raised and once lowered. This
operation, implemented in the Tensor package with the command ContractIndices, is illustrated
for the two tensors
>
>
from the previous section. To simplify data entry, we rename the first as T and the second, as
V.
>
>
The four possible contractions that result in a rank-two tensor are given in Table 4, where their
components are displayed as elements of matrices.
Table 4
and
Careful inspection of the four tensors in Table 4 (see especially the rightmost column) shows that
they are all different.
or its
contravariant counterpart
. There is no "calculus" in tensor calculus without first
obtaining this essential tensor. Hence, it is imperative that there be efficient ways to obtain this
tensor. Several of these techniques will be illustrated for the Cartesian plane on which polar
coordinates have been imposed.
Method 1 - Obtain
Define the map
via
>
>
and the radius (position) vector via
>
>
Then, a representation of the basis vectors
is given by
>
>
so that a matrix whose entries are
is
>
>
To convert this to the metric tensor in polar coordinates, we need to define the polar frame with
>
>
in which case we then have
>
>
The covariant form of this metric tensor,
>
>
The matrix representing
>
>
>
Define the transformation from Cartesian to polar coordinates as
>
>
and use it to convert the Euclidean metric to
>
>
or with
respect to the reciprocal basis of gradient basis vectors . Thus, one has
. The
conversion between contravariant and covariant components of V is effected by contraction with
the metric tensor:
or
Example 1
Given the contravariant vector
>
>
the covariant components are given by the RaiseLowerIndices command in the Tensor package.
Thus, we have
>
>
where "g" denotes the covariant metric tensor
>
>
the contravariant components are
>
>
where " " denotes the contravariant metric tensor
>
>
Classical texts in differential geometry use the notation
, or
for Christoffel
Table 5
The closest the Tensor package comes to articulating the Christoffel symbols is
>
>
where the list
maps to
. Thus, the middle index in the list is the raised one, and the
Example 2
For polar coordinates, show that
Thus, show that the derivative of a basis vector can be expressed as a linear combination of
the basis vectors, and that the coefficients of these linear combinations are the Christoffel
symbols.
To show that derivatives of basis vectors can be expressed as linear combinations of basis
vectors, begin by expressing
in terms of
. This is done in Table 6 where the
symbols i and j are introduced explicitly and naming clashes are avoided by introducing the
alternate names
for
.
Table 6
Expressing
in terms of
Table 7, which lists the derivatives of the basis vectors, shows that the Christoffel symbols
indeed are the coefficients in the linear combinations of basis vectors that express the derivatives
of the basis vectors.
=
Table 7
Table 8 provides a formula for computing Christoffel symbols of the second kind from the
components of the metric tensor.
Table 8
. The formula
in Table 8 would be easier to write (and even remember) if this notational device is used.
>
Covariant vector
Mixed tensor
Metric tensor
Table 9
>
respectively, are obtained in the Tensor package with the CovariantDerivative command. It
requires as a second argument the connection coefficients, which can be given either as the
Christoffel symbols (of the second kind)
>
>
or as the connection
>
>
(In the Tensor package, the Christoffel symbols are not separated. The argument to the
Connection command is the same sum of terms that the Tensor package uses to express the
Christoffel symbols.)
The covariant derivative of the contravariant vector is
>
>
more easily read as the array
>
>
The covariant derivative of the covariant vector is
>
>
more easily read as the array
>
>
that arises
the vector is defined. As such, it is the generalization of the gradient vector
when the directional derivative of the scalar function is defined. Just as the directional
derivative of the scalar function requires a dot product with a direction vector, so too does the
directional derivative of the vector. Thus, the directional derivative of the vector in the
direction
is given by
, the contraction of the covariant derivative with the direction
vector.
This calculation is implemented in the Tensor package via the command
DirectionalCovariantDerivative.
Example 3
The derivative of the contravariant vector
>
>
in the direction of the vector
>
>
is given by
>
>
If we write the covariant derivative as the array
>
>
and write the directional covariant derivative as the column vector
>
>
we can more easily see that the sum in
vanishes.
Example 4
In polar coordinates
be given by
>
>
The contravariant vector
>
>
is parallel along
>
>
if
hold. To access the components of this vector and write the individual equations, use
>
>
where the extra syntax isolates the two equations in a unique order. Maple provides a solution
for these equations and the initial conditions
.
>
>
where again, we provide extra syntax for extracting and processing items uniquely. We are
looking for some evidence that along the curve the vector
remains parallel. Since the
polar plane is coincident with the Cartesian plane, we will look for this evidence in Cartesian
coordinates.
We begin by writing the curve
>
>
Then, we form the vector
>
>
Figure 1 is a graph of along with vectors that have been transported parallel to the initial
vector. Even without the graph it's clear from the algebraic expression for the field along that
it's constant in the Euclidean sense, and hence, parallel.
Figure 1
Example 5
The covariant derivative of the vector field
>
>
is, in array form,
>
>
The vanishing of this covariant derivative requires solving a set of four partial differential
equations, the general solution of which is
>
>
For any initial direction of the vector
Cartesian coordinates is
>
>
Hence, we have a constant vector field, parallel in the Euclidean plane.
>
. If the unit tangent
Let be arc length along , the curve defined by
vector along is parallel along , then is a geodesic. The condition that
must satisfy is
Definition 3
Geodesics
Example 6
The equations for geodesic curves in polar coordinates are
>
>
If we use the overdot to express differentiation with respect to , we can write these equations as
These equations are consistent with Definition 3, as we see by recalling the Christoffel symbols
in Table 5. From Definition 3 we have
>
The first solution is a radial line segment; the second, an arbitrary line segment - both in accord
with our expectations for geodesics in the plane.
>
Curvature
The commutator formula for covariant differentiation is
where
and
curvature tensor of the second kind. Other names include curvature tensor, Riemann tensor,
Riemann-Christoffel tensor, and mixed Riemann-Christoffel tensor. Moreover, variations in the
formula itself appear in the literature, especially when the repeated covariant differentiation
is denoted by
or
. There is an inherent reversal of the lexical order with respect to
the operator order. When the reversed lettering is translated to
, a minus sign is introduced
into the definition. The reader is cautioned to be most careful when comparing Maple to the
literature.
The Riemann-Christoffel curvature tensor of the first kind is defined as
and is
sometimes called the covariant curvature tensor, and even the Riemann tensor. Again, great
care must be taken when reading and comparing different texts.
The Riemann curvature tensor (see how easily these phrases creep into one's writing?) measures
the curvature of a space. A space in which this tensor is zero is called flat, and the Cartesian
plane is flat no matter what coordinate system is imposed, as we see from
>
>
the curvature tensor for the plane under polar coordinates.
A more interesting surface is that of the unit sphere centered at the origin. The metric tensor for
this surface is obtained by the following calculations.
>
>
Consequently, the Riemann-Christoffel curvature tensor of the second kind is
>
>
or better yet,
>
>
From this, we construct the explicit representation in Table 10.
Table 10
Nonzero components of
>
or better yet,
>
>
From this, we construct Table 11.
Table 11
Nonzero components of
. Obtained by this
>
For a two-dimensional manifold the Gaussian (or total) curvature is given by
is the determinant of the array representing the metric tensor
,
, where
>
>
Finally, we note that
>
>
so that it vanishes, as we can verify by inspection after obtaining
via
>
>
Since
Legal Notice: Maplesoft, a division of Waterloo Maple Inc. 2009. Maplesoft and Maple are
trademarks of Waterloo Maple Inc. This application may contain errors and Maplesoft is not
liable for any damages resulting from the use of this material. This application is intended for
non-commercial, non-profit use only. Contact Maplesoft for permission if you wish to use this
application in for-profit activities.