Tensors and forms

Sections in this chapter:

Introduction
Tensors
Inputs and outputs of tensors
Type of a tensor
Components of tensors
The Kronecker delta
Tensor operations
Tensor product
Interior product
ApplyTensor
Symmetrization and antisymmetrization
Lie derivative
Exterior differential forms
Inputs and outputs of forms
Exterior product
Exterior derivative

For other chapters go to Index

Introduction

This chapter explains how to deal with tensors and forms. First, the necessary notations to express the basis elements of tensors and forms are introduced and then the operations between them are discussed.

Tensors

As we have stressed in the Introduction a tensor in TTC is handled as a single (geometric) object, so, in addition to the components, one has to input also the basis elements. This section is devoted to introduce the suitable notation to do this and to discuss some others questions as the important concept of type of a tensor.

Inputs and outputs of tensors

The notation for tensors follows a rather straigthforward generalization of the notation for vectors and 1-forms that we have seen in the previous chapter. Thus, given a coordinate system named coords, with symbols xi, the natural basis also is named coords and we have the following correspondence for the basis elements of contravariant tensors

coords[-i,-j,...]

coords[-xi,- xj,]

and this one for covariant tensors

coords[i, j,...]

coords[xi, xj,]

being obvious the generalization to (p,q) tensors. Moreover, as we have said previously, the minus sign before an argument is associated with the lower position of the index.

In[2]:= InputCoordinates[cart, {x, y, z}];

In[3]:= e = ZZ[cart];

In[4]:= e[2, -3]

Out[4]= dy*.Dz

In[5]:= f e[-x, 2] + g e[-2, z]

Out[5]= g Dy*.dz + f Dx*.dy

In[6]:= ZZ[-2, 1] + 5 ZZ[-3, 2]

Out[6]= 5 DX3*.dX2 + DX2*.dX1
REMEMBER: the symbol used to name the natural basis is the same as that of the respective coordinate system.

Type of a tensor

Saying that a tensor is p--contravariant, q--covariant is ambiguous in the sense that this does not establish completely the type of the tensor. For instance, a tensor (1,2) can be any of the following three:

The package has to be free of this type of ambiguities and, thus, a more rigorous notation has been established for the type of tensor. For instance we will say that the type of the above second tensor is (-,+,-), and that the type of

is (-,-,+,+) because their components are of the form . TensorType applied to a tensor gives its type.

In[7]:= T = 2 e[1, 2, -3, -2]

Out[7]= 2 dx*.dy*.Dz*.Dy

In[8]:= TensorType[T]

Out[8]= {-1, -1, 1, 1}

Components of tensors

Although TTC deals with tensors as a whole it is often necessary to get a particular component or to have all of them in matrix form. The corresponding operators to perform these tasks are TensorComponent and TensorToMatrix. When converting a tensor into a matrix one loses two pieces of information: the type of the tensor and the basis in which it was expanded. This is precisely the information that has to be provided when inverting the process with the operator MatrixToTensor.

Here, we define a tensor Q of type (-,+), get the component , put the tensor in matrix form (losing information) and build a new tensor of type (+,+) from the matrix.

In[9]:= Q = 2 e[1, -1] + x e[1, -2] + Pi e[2, -2] - 7 e[2, -3] +
            a e[3, -1] - z e[3, -3]

Out[9]= x dx*.Dy + 2 dx*.Dx - 7 dy*.Dz + Pi dy*.Dy -

>    z dz*.Dz + a dz*.Dx

In[10]:= TensorComponent[Q][-1, y]

Out[10]= x

In[11]:= mQ = TensorToMatrix[Q]

Out[11]= {{2, x, 0}, {0, Pi, -7}, {a, 0, -z}}

In[12]:= mQ // MatrixForm

Out[12]//MatrixForm= 2    x    0

                     0    Pi   -7

                     a    0    -z
In[13]:= MatrixToTensor[mQ, {1,1}, Cart3]

Out[13]= -z Dz*.Dz + a Dz*.Dx - 7 Dy*.Dz + Pi Dy*.Dy +

>    x Dx*.Dy + 2 Dx*.Dx

The Kronecker delta

A second rank tensor that appears frequently is the one that has identity matrix. IdentityTensor just gives this tensor. You have to input the basis and the type of the tensor. The Kronecker delta can be obtained this way.
In[14]:= IdentityTensor[cart, 1, -1]

Out[14]= Dz*.dz + Dy*.dy + Dx*.dx

Tensor operations

In this section we shall describe the intrinsic way to define operations between tensors. Most of these operations can also be performed using index notation and in some cases this is the best way. In fact, contractions of more than two index are so hardly performed in intrinsec notation that we have deferred them until Index notation

Tensor product

OuterProduct is the operator to perform the outer or tensor product of two or more tensors. The basis elements of tensors represented by ZZ have an implicit outer product inside them. The symbol *. that appears in the output can also be used for the inputs. Here, we define the tensors T and Q and compute in two distinct ways.
In[2]:= InputCoordinates[cart, {x, y, z}]; e = ZZ[cart];

In[3]:= T = a e[1, 3] + 5 e[2, 3]

Out[3]= a dx*.dz + 5 dy*.dz

In[4]:= Q = x e[-2, -3] - y e[-1, -1]

Out[4]= x Dy*.Dz - y Dx*.Dx

In[5]:= OuterProduct[T, Q]

Out[5]= a x dx*.dz*.Dy*.Dz - a y dx*.dz*.Dx*.Dx +

>    5 x dy*.dz*.Dy*.Dz - 5 y dy*.dz*.Dx*.Dx

In[6]:= T *. Q

Out[6]= a x dx*.dz*.Dy*.Dz - a y dx*.dz*.Dx*.Dx +

>    5 x dy*.dz*.Dy*.Dz - 5 y dy*.dz*.Dx*.Dx

Interior product

The interior product of a vector v with a q-form or, in general, with a q-covariant tensor T is defined by:

or in component form

InteriorContraction generalizes ( See Abraham for a different generalization) the interior product and it is useful to perform operations as the following (the only basic condition is that the indices can be contracted):

InteriorContraction keeps on contracting indices until those of one of the tensors are exhausted. Next, we define v, t and T and computeand .

In[7]:= v = x e[-1] - y e[-2] + z e[-3]

Out[7]= z Dz - y Dy + x Dx

In[8]:= t = (x - y) e[3, -2] + z^2 e[1, -1]

         2
Out[8]= z  dx*.Dx + (x - y) dz*.Dy

In[9]:= T = a e[1, -1, -2] + b e[2, -3, -3]

Out[9]= a dx*.Dx*.Dy + b dy*.Dz*.Dz

In[10]:= InteriorContraction[v, T]

Out[10]= -(b y) Dz*.Dz + a x Dx*.Dy

In[11]:= InteriorContraction[t, T]

                           2
Out[11]= b (x - y) Dz + a z  Dy

ApplyTensor

A tensor can be viewed as a multilinear machine that, when acting upon a set of vectors and forms, gives a scalar. For instance, if T is a tensor of type (-,-,+), u and v are vectors and w is a 1-form, we have

ApplyTensor implements this definition and generalizes it in such a way that there can be empty slots and that the arguments can also be a more general tensor. For instance, if T and S are tensors of type (-,-,+,+,-) and (+,+), respectively,

can be computed as follows

In[12]:= T = x e[1, 2, -3, -1, 2] +
             y e[2, 3, -2, -3, 1]

Out[12]= x dx*.dy*.Dz*.Dx*.dy + y dy*.dz*.Dy*.Dz*.dx

In[13]:= S = e[-2, -3]

Out[13]= Dy*.Dz

In[14]:= ApplyTensor[T][S, , e[3], e[-1]]

Out[14]= y Dy

Symmetrization and antisymmetrization

The symmetrization S and antisymmetrization A operators acting upon a q-covariant tensor T are defined as follows:

If we denote the components of ST by and those of AT by we obtain:

The symmetrization and antisymmetrization of a p-contravariant tensor is defined in analogous way. Symmetric and Antisymmetric perform these operations.

Next, we define a tensor t without symmetries and get its symmetric St and antisymmetric At parts.

In[15]:= t = 2 a e[1, 2] + 2 b e[3, 1];

In[16]:= TensorToMatrix[t] // MatrixForm

Out[16]//MatrixForm= 0     2 a   0

                     0     0     0

                     2 b   0     0

In[17]:= St = Symmetric[t]

Out[17]= a dx*.dy + b dx*.dz + a dy*.dx + b dz*.dx

In[18]:= TensorToMatrix[St] // MatrixForm

Out[18]//MatrixForm= 0   a   b

                     a   0   0

                     b   0   0

In[19]:= At = Antisymmetric[t]

Out[19]= a dx*.dy - b dx*.dz - a dy*.dx + b dz*.dx

In[20]:= TensorToMatrix[At] // MatrixForm

Out[20]//MatrixForm= 0    a    -b

                     -a   0    0

                     b    0    0
We can proof that for a rank 2 tensor the sum of the symmetric and antisymmetric parts gives the original tensor. On the other hand, the antisymmetrization of a symmetric tensor yields a null result and the same happens when symmetrizing an antisymmetric tensor.
In[21]:= St + At

Out[21]= 2 a dx*.dy + 2 b dz*.dx

In[22]:= Antisymmetric[St]

Out[22]= 0

Lie derivative

The Lie derivative of one tensor T with respect to one vector v (which is denoted by LvT is implemented by LieD. Moreover, because of the relation

the Lie bracket of two vector fields can also be computed using LieD.

For instance, if 

In[23]:= v = (1+y) e[-1] + z e[-2]

Out[23]= z Dy + (1 + y) Dx

In[24]:= w = z e[-x] - (1+y) e[-y]

Out[24]= (-1 - y) Dy + z Dx

In[25]:= T = x (1 + z) e[-2, 3]

Out[25]= x (1 + z) Dy*.dz

In[26]:= LieD[v][T]

Out[26]= (1 + y + z + y z) Dy*.dz - x (1 + z) Dx*.dz

In[27]:= LieD[v, w]

Out[27]= -z Dy - (-1 - y) Dx

Exterior differential forms

Tensors of type (0, q) which are antisymmetrics on all q indices are called exterior q-forms. TTC uses a special notation for this kind of tensors and implements the current operations between them.

Inputs and outputs of forms

TTC includes also the tools to work in the exterior algebra of k-forms.The notation for the basis elements is the same as that of the tensors with the only difference that the indices are closed between curly braces . With coords being the cooridnate system name:

coords[{i, j,...}]

coords[{xi, xj,...}]

In the outputs, the symbol is represented by *^. For example, the forms

and

are entered as follows.

In[2]:= InputCoordinates[cart, {x, y, z}]; e = ZZ[cart];

In[3]:= omega = e[{1, 2}] + e[{2, 3}] + e[{3, 1}]

Out[3]= dx*^dy - dx*^dz + dy*^dz

In[4]:= eta = e[{1, 3, 1}]

Out[4]= 0
As we can see, TTC recognizes that is a null form. On the other hand, sometimes, it is convenient to translate an exterior form like

expressed in terms of the wedge product into the equivalent tensor

expressed in terms of tensorial products. ExteriorToOuter makes this

kind of transformations and OuterToExterior does the opposite.

In[5]:= w = e[{1, 2, 3}]

Out[5]= dx*^dy*^dz

In[6]:= ExteriorToOuter[w]

Out[6]= dx*.dy*.dz - dx*.dz*.dy - dy*.dx*.dz + dy*.dz*.dx +

>    dz*.dx*.dy - dz*.dy*.dx

In[7]:= OuterToExterior[%]

Out[7]= dx*^dy*^dz

Exterior product

The definition used for the exterior product of a k-form and an l-form is

where A is the antisymmetrization operator defined above. ExteriorProduct is the function that computes the exterior product of two or more forms (the symbol *^ can also be used).

In[2]:= InputCoordinates[XX, 5];

In[3]:= a = 2 ZZ[{1, 3}] + ZZ[{2, 3}] - 3 ZZ[{3, 4}]

Out[3]= 2 dX1*^dX3 + dX2*^dX3 - 3 dX3*^dX4

In[4]:= b = - ZZ[{1, 2, 5}] + 2 ZZ[{1, 3, 4}]

Out[4]= -dX1*^dX2*^dX5 + 2 dX1*^dX3*^dX4

In[5]:= a *^ b

Out[5]= 3 dX1*^dX2*^dX3*^dX4*^dX5

In[6]:= a *^ b

Out[6]= 3 dX1*^dX2*^dX3*^dX4*^dX5

Exterior derivative

The exterior derivative of a k-form is implemented by ExteriorD.

Here we define the 1-form

and the 2-form

both in a 3-dimensional space and compute their exterior derivative.

In[7]:= InputCoordinates[cart, {x, y, z}]; e = ZZ[cart];

In[8]:= alpha = y e[1] + (z Cos[y z] + x) e[2] + y Cos[y z] e[3]

Out[8]= y dx + (x + z Cos[y z]) dy + y Cos[y z] dz

In[9]:= ExteriorD[alpha]

Out[9]= 0

In[10]:= omega = x e[{2, 3}] + y e[{3, 1}] + z e[{1, 2}]

Out[10]= z dx*^dy - y dx*^dz + x dy*^dz

In[11]:= ExteriorD[omega]

Out[11]= 3 dx*^dy*^dz
The exterior derivative of the 1-form is zero, which means that the curl operator of the field (y, x+z cos(y z), y cos(y z)) is null. Likewise, we have, that is to say, the divergence of (x, y, z) is 3.

This page is maintained by XavierJaén.