You are on page 1of 26

Classroom Tips and Techniques: Tensor Calculus with the Differential Geometry Package

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

9

Library

4

LieAlgebras
Table 1

33

Subpackages in the DifferentialGeometry package

The complexity of mastering the DifferentialGeometry package is further increased when
subpackages such as GroupActions themselves have subpackages (MovingFrames). A
comprehensive tutorial in the complete DifferentialGeometry package would require more than a
textbook, so clearly, this is not our ambition here. Fortunately, the package itself contains two

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
>
>

>

Declaring the Frame in DifferentialGeometry
Before a vector or tensor can be entered, a frame must be declared by stating its variables and
giving it a name. For example, to declare
as the Cartesian space with variables and ,
execute
>
>
The default behavior for DifferentialGeometry is that from this point onward, the prompt would
be modified to display the frame name for as long as that frame were the active one. Thus,
without our having suspended this default with the Preferences command in the Initializations
section, the prompt following the DGsetup command would be the one shown in Table 2.
R2 >
Table 2

The default modification of the prompt

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

respectively.) Finally. covariant and contravariant.prompts.they cannot be removed by any Maple command. Texts also denote the new coordinate system bu the use of an overbar on the component. that must be faced. Thus. Only a "new" prompt will display the new frame name. and not at prompts. or a prime on the left side of the variable. The Contravariant/Covariant Paradigms Anyone who had taken even a perfunctory dip into the waters of tensor calculus knows there are two words. we will not have frame names visible in our prompts. one raised and one lowered. It only modifies new prompts. We will not be able to enter a tensor in the Tensor package without making the distinction between these two terms. of the . Vector Type Basis Type Transformation Law Contravariant Tangents to coordinate curves Covariant Gradients (Normal to coordinate surfaces) Table 3 Contravariant and covariant vectors In the rightmost column of Table 3 uses the notation and for components expressed in the -coordinate system. the modified prompt is a worksheet paradigm that does not carry through all of Maple usage. They have to be removed by deletion. For all these reasons. Table 3 defines contravariant and covariant vectors. Second. (The Maple interface command that modifies prompts does not cascade the change through existing prompts. these modified prompts are persistent . Using the Einstein summation convention (repeated indices. Such misplaced prompts have to be deleted manually if they are not to provide incorrect information. but and for components in the -coordinate system. are summed). if the commands are executed in Document Blocks. a new frame is defined. the subsequent prompts that show the earlier name do not change to show the new name. The components and are the contravariant and covariant components. there will be no visible prompt to modify. The result is a worksheet with prompts showing different frame names where they might not be relevant.

the matrix product implements the contravariant transformation. There are even mixed tensors that transform contravariantly in one index but covariantly in another. This inherent distinction between tangent bases and normal bases induces the distinction between contravariant and covariant. vectors and tensors require an explicit use of the basis objects. and almost never explicitly exhibits the basis objects. is the mapping from If to via functions of the form are the columns of the Jacobian matrix . having doubly-indexed basis objects . In actual practice. then the tangent vectors . the matrix product implements the covariant transformation. The Tensor as a Multilinear Object If is a vector space. as a column index. so that . The basis vectors and are reciprocal. with basis from . Using column and row vectors to express this difference is a convenient visual device in classical tensor calculus. the are the contravariant components of the tensor. and the lower index . say. Thus. Hence. an orthonormal basis is self-reciprocal. However. linear in both indices. there would be the equivalent covariant components. the direct product of The tensor is actually the object . .vector V. 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. Of course. and just as for vectors. where the upper index is interpreted as a row index. one manipulates just the components of the tensor. Hence. If is the mapping from to via functions of the form are the rows of the Jacobian matrix . Writing the components as the row vector w means the sums with the Jacobian matrix are down a column but across the rows. Bases and Their Duals . That is why the distinction between contravariant and covariant basis does not matter in Cartesian spaces. then a rank-two tensor is a multilinear object with itself. then the gradient vectors . To facilitate the implementation of the contravariant transformation law. in the DifferentialGeometry package.

When using the evalDG . 1D) mode and convert to math mode via the Context Menu. Alternatively. enter such expressions in text (linear. is considered a differential form. press the escape character (\) first. more in keeping with the modern approach to differential geometry. the contravariant vector whose components are is given by > > or by > > The evalDG and the DGzip commands are two of the simpler ways to create an object whose data structure is intrinsic to the DifferentialGeometry package.The basis for could be entered as > > or could be extracted from Maple with the DGinfo command from the Tools package.) The reciprocal (or dual) basis is then > > or > > In actual fact. Representing Vectors as DifferentialGeometry Objects In the DifferentialGeometry package. > > (To type the underscore in math (2D) mode.

The Tools subpackage provides the DGinfo command with which the components of a vector can be extracted. The alternative to the asterisk would be the space. If this vector had been entered in math mode. 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.command. the echo of the asterisk would be a centered dot. the asterisk is the explicit multiplication operator. Its use is illustrated by > > or by > > Representing Tensors as DifferentialGeometry Objects A rank-two contravariant tensor would be entered as > > The construct corresponds to the dyadic basis element A rank-two covariant tensor would be entered as . . etc.

implemented in the Tensor package with the command ContractIndices. This operation. > > The components of the rank-two tensor are often represented as the entries of a matrix. Recall that the Einstein summation convention indicates a sum on the same index when it appears once raised and once lowered. > . The components of a tensor can be recovered with the DGinfo command > > or with the convert command.> > The construct corresponds to the dyadic basis element . To simplify data entry. etc. > > Contraction of Indices Given two tensors of conformable dimensions. say and . as V. If a matrix is used for such a representation. is illustrated for the two tensors > > from the previous section. we rename the first as T and the second. forming the sum of products is the operation contraction of indices. it is possible to convert the matrix to a DifferentialGeometry tensor.

Table 4 Four rank-two tensors formed by contraction of and Careful inspection of the four tensors in Table 4 (see especially the rightmost column) shows that they are all different. The Metric Tensor The geometry of a manifold is first captured in the covariant metric tensor or its contravariant counterpart .> The four possible contractions that result in a rank-two tensor are given in Table 4. 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. . There is no "calculus" in tensor calculus without first obtaining this essential tensor. where their components are displayed as elements of matrices. Hence.

Obtain Define the map as a Matrix and Convert to a Tensor with equations of the form 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.Method 1 . we need to define the polar frame with > > in which case we then have > .

one has .> The covariant form of this metric tensor. . > Method 2 . can be obtained with > > The matrix representing is the inverse of the matrix representing . Thus. The conversion between contravariant and covariant components of V is effected by contraction with the metric tensor: or Example 1 Given the contravariant vector > .Transform the Cartesian Metric Tensor Begin with the contravariant metric tensor on the Cartesian space : > > Define the transformation from Cartesian to polar coordinates as > > and use it to convert the Euclidean metric to > > Raising and Lowering Indices The same vector V can be given with respect to the natural tangent basis vectors or with respect to the reciprocal basis of gradient basis vectors .

we will obtain those via > > Classical texts in differential geometry use the notation . or for Christoffel symbols of the second kind. we have > > where "g" denotes the covariant metric tensor . . they are called the Christoffel symbols of the first kind or the second kind. given the covariant vector > > the contravariant components are > > where " " denotes the contravariant metric tensor . > The Connection Coefficients Once the metric tensor is known. . painstakingly and laboriously. The coefficients of these linear combinations are called the connection coefficients. It turns out that the rate of change of the basis vectors can be expressed as linear combinations of these same vectors. Consequently. Since there is a built-in command that provides the Christoffel symbols of the second kind. the way the basis vectors change from point to point can be determined. Thus. in Table 5.> the covariant components are given by the RaiseLowerIndices command in the Tensor package. Depending on the form used for these symbols. Alternatively. the correct interpretation of the output of the Christoffel command is captured. or the Christoffel symbols. and or for Christoffel symbols of the first kind.

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 5 Christoffel symbols of the second kind for polar coordinates The closest the Tensor package comes to articulating the Christoffel symbols is > > where the list maps to . show that Thus. the middle index in the list is the raised one. begin by expressing in terms of . . Example 2 For polar coordinates. and the first and third are the lower ones. show that the derivative of a basis vector can be expressed as a linear combination of the basis vectors. Thus. To show that derivatives of basis vectors can be expressed as linear combinations of basis vectors. and that the coefficients of these linear combinations are the Christoffel symbols.

= Table 7 Differentiation of basis vectors in polar coordinates Table 8 provides a formula for computing Christoffel symbols of the second kind from the components of the metric tensor. . 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 6 Expressing in terms of Table 7. which lists the derivatives of the basis vectors.

note how starting with a scalar function . a rank-two tensor. The gradient vector arises naturally from the calculation of the derivative which is how the directional derivative is defined when . and the metric tensor. this calculation extends to higher dimensions. Contravariant vector Covariant vector Mixed tensor . and the desired directional derivative is a dot product of this gradient vector with the direction vector. the vector quantity must be defined. a mixed tensor. In particular. from defining a directional derivative of a vector. that is.Table 8 Christoffel symbols in terms of the metric tensor A practical notational shortcut is the use of for the differentiation operator . and . The covariant derivative arises in much the same way. But more important. and the actual rate of change of the vector in a given direction is the "dot product" of this new tensor with a vector specifying the direction. Table 9 gives the expressions for the covariant derivative of contravariant and covariant vectors. > The Covariant Derivative In calculus. The formula in Table 8 would be easier to write (and even remember) if this notational device is used. is the directional derivative of the scalar function taken in the direction of the unit vector u. Of course. The new object that must be created is the covariant derivative. .

the Christoffel symbols are not separated.Metric tensor Table 9 Formulas for covariant derivatives In polar coordinates.) The covariant derivative of the contravariant vector is > > more easily read as the array . It requires as a second argument the connection coefficients. The argument to the Connection command is the same sum of terms that the Tensor package uses to express the Christoffel symbols. which can be given either as the Christoffel symbols (of the second kind) > > or as the connection > > (In the Tensor package. are obtained in the Tensor package with the CovariantDerivative command. covariant derivatives of the contravariant and covariant vectors > > respectively.

so too does the directional derivative of the vector. it is the generalization of the gradient vector when the directional derivative of the scalar function is defined. the directional derivative of the vector in the direction is given by . Thus. As such. the contraction of the covariant derivative with the direction .> > The covariant derivative of the covariant vector is > > more easily read as the array > > The Directional Covariant Derivative The covariant derivative is the rank-two tensor that arises when the directional derivative of that arises the vector is defined. Just as the directional derivative of the scalar function requires a dot product with a direction vector.

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 > . This calculation is implemented in the Tensor package via the command DirectionalCovariantDerivative.vector.

Parallelism along a curve The ParallelTransportEquations command in the Tensor package generates the equations implied by Definition 1. Example 4 In polar coordinates . > Parallelism and Geodesics The contravariant vector defined along . is said to be parallel along vanishes. let the curve be given by > > The contravariant vector > > is parallel along > > if the equations implied by if .> we can more easily see that the sum in is well modeled by the product of the matrix with the direction vector. the curve the absolute (or intrinsic) derivative along Definition 1 .

To access the components of this vector and write the individual equations. Since the polar plane is coincident with the Cartesian plane.hold. > > where again. We begin by writing the curve in radius (position) vector form: > > Then. Maple provides a solution for these equations and the initial conditions . we provide extra syntax for extracting and processing items uniquely. we form the vector > > and evaluate it along . use > > where the extra syntax isolates the two equations in a unique order. . We are looking for some evidence that along the curve the vector remains parallel. we will look for this evidence in Cartesian coordinates.

and hence. Even without the graph it's clear from the algebraic expression for the field along that it's constant in the Euclidean sense. Parallel vector field .Figure 1 is a graph of along with vectors that have been transported parallel to the initial vector. parallel. Figure 1 Parallel field along the curve The contravariant vector Definition 2 represents a parallel vector field if its covariant derivative vanishes.

Example 5 The covariant derivative of the vector field > > is. then is a geodesic. If the unit tangent Let be arc length along . the curve defined by vector along is parallel along . The condition that must satisfy is . the equivalent vector in > > Hence. in array form. > . we have a constant vector field. the general solution of which is > > For any initial direction of the vector Cartesian coordinates is as a vector in polar coordinates. parallel in the Euclidean plane. > > The vanishing of this covariant derivative requires solving a set of four partial differential equations.

and the other Christoffel symbols are zero. The general solution of the geodesic equations in polar coordinates is > > . and the remaining Christoffel symbols are zero. as we see by recalling the Christoffel symbols in Table 5.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 . in the second. From Definition 3 we have In the first equation. we can write these equations as These equations are consistent with Definition 3.

the second. > . a minus sign is introduced into the definition. as we see from > > the curvature tensor for the plane under polar coordinates. Riemann-Christoffel tensor. and the Cartesian plane is flat no matter what coordinate system is imposed. variations in the formula itself appear in the literature. The mixed rank-four tensor is generally called the Riemann-Christoffel curvature tensor of the second kind. Again.both in accord with our expectations for geodesics in the plane. and mixed Riemann-Christoffel tensor. The reader is cautioned to be most careful when comparing Maple to the literature. > Curvature The commutator formula for covariant differentiation is where and . and even the Riemann tensor. especially when the repeated covariant differentiation is denoted by or . great care must be taken when reading and comparing different texts.The first solution is a radial line segment. A space in which this tensor is zero is called flat. The Riemann-Christoffel curvature tensor of the first kind is defined as and is sometimes called the covariant curvature tensor. an arbitrary line segment . Moreover. A more interesting surface is that of the unit sphere centered at the origin. When the reversed lettering is translated to . There is an inherent reversal of the lexical order with respect to the operator order. The metric tensor for this surface is obtained by the following calculations. The Riemann curvature tensor (see how easily these phrases creep into one's writing?) measures the curvature of a space. Other names include curvature tensor. Riemann tensor.

the Riemann-Christoffel curvature tensor of the second kind is > > or better yet.> Consequently. we construct the explicit representation in Table 10. > > From this. Table 10 Nonzero components of for the sphere The Riemann-Christoffel curvature tensor of the first kind is > > or better yet. > .

and this component is generally taken as . In general. but for there are 20. this tensor is > > We see that the tensor is the same under either computation. so for there 6. the tensor is > > Obtained with the RicciTensor command. In the DifferentialGeometry package. Obtained by this . we construct Table 11. given by > > is defined as > . a definition we can test via . The Ricci scalar. Table 11 Nonzero components of for the sphere Notice that for a space of dimension there is just one distinct component needed to describe the complete tensor.> From this. the Ricci tensor is defined as definition. there are distinct components of the Riemann curvature tensor of the first kind.

. is the zero matrix.> For a two-dimensional manifold the Gaussian (or total) curvature is given by is the determinant of the array representing the metric tensor . Since for the sphere can be computed in the Tensor package via > > Finally. this tensor is > > so that it vanishes. as we can verify by inspection after obtaining via > > Since . and the array form of is the identity matrix. Contact Maplesoft for permission if you wish to use this application in for-profit activities. we note that is the Einstein tensor. a division of Waterloo Maple Inc. non-profit use only. This application is intended for non-commercial. where . 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. . Legal Notice: © Maplesoft. 2009. For the sphere.