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[e, {x, y, z}];
In[3]:= e[y,-z]
Out[3]= dy*.Dz
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]:= XX[-2, 1] + 5 XX[-3, 2]
Out[6]= 5 DX3*.dX2 + DX2*.dX1
: the symbol used to name the natural basis
is the same as that of the respective coordinate system.

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}
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}, e]
Out[13]= -z Dz*.Dz + a Dz*.Dx - 7 Dy*.Dz + Pi Dy*.Dy +
> x Dx*.Dy + 2 Dx*.Dx
In[14]:= IdentityTensor[e, 1, -1] Out[14]= Dz*.dz + Dy*.dy + Dx*.dx
In[2]:= InputCoordinates[e, {x, y, z}];
In[3]:= T = a e[1]*.e[3] + 5 e[2]*.e[3]
Out[3]= a dx*.dz + 5 dy*.dz
In[4]:= Q = x e[-2, -3] - y e[-1]*.e[-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
![]()
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
compute
and
.
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 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
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 0We 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
![]()
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
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[e, {x, y, z}];
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 ![]()
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
![]()
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 XX[1]*^ XX[3] + XX[2]*^XX[3] - 3 XX[{3, 4}]
Out[3]= 2 dX1*^dX3 + dX2*^dX3 - 3 dX3*^dX4
In[4]:= b = - XX[{1, 2, 5}] + 2 XX[{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
Here we define the 1-form
![]()
and the 2-form
![]()
both in a 3-dimensional space and compute their exterior derivative.
In[7]:= InputCoordinates[e, {x, y, z}];
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 This page is maintained by XavierJaén.