Tensor[ContractIndices] - contract the indices of a tensor
Calling Sequences
ContractIndices(T, Indices1)
ContractIndices(T, S, Indices2)
Parameters
T - a tensor
S - (optional) a tensor
Indices1 - a list of pairs of integers i1,i2,i3,i4,... referring to the arguments of T which are to be contracted
Indices2 - a list of pairs of integers i1,i2,i3,i4,... referring to the arguments of T and S which are to be contracted
Description
Examples
With the first calling sequence, ContractIndices(T, Indices) will contract from T each pair of indices in the list Indices = i1,i2,i3,i4,.... Each index pair must refer to indices of different valence, for example, if i1 is a contravariant index, then i2 must be a covariant index. If T is of type rs (contravariant rank r and covariant rank s) and the list Indices1 contains k index pairs, then ContractIndices(T, Indices1) will return a tensor of type r−ks−k.
With the second calling sequence, ContractIndices(T, S, Indices), where Indices = i1,i2,i3,i4,..., will contract the i1 index of T with the i2 index S, the i3 index of T with the i4 index S and so on. Each index pair must refer to indices of different valence. If T is of type rs, S of type pq, and if the list Indices2 contains k index pairs, then ContractIndices(T, Indices2) will return a tensor of type r+p−ks+q−k.
This command is part of the DifferentialGeometry:-Tensor package, and so can be used in the form ContractIndices(...) only after executing the command with(DifferentialGeometry) and with(Tensor) in that order. It can always be used in the long form DifferentialGeometry:-Tensor:-ContractIndices.
with⁡DifferentialGeometry:with⁡Tensor:
Example 1.
First create a 4 dimensional manifold M and define a type 23 tensor T on M.
DGsetup⁡x,y,z,w,M:
T≔evalDG⁡a⁢D_x&tD_x&tdz&tdx&tdz+b⁢D_x&tD_z&tdz&tdx&tdw
T:=a⁢D_x⁢D_x⁢dz⁢dx⁢dz+b⁢D_x⁢D_z⁢dz⁢dx⁢dw
Contract the 1st and 4th indices of T.
ContractIndices⁡T,1,4
a⁢D_x⁢dz⁢dz+b⁢D_z⁢dz⁢dw
Contract the 1st and 4th indices and the 2nd and 3rd indices of T.
ContractIndices⁡T,1,4,2,3
b⁢dw
Example 2.
Define two rank 3 tensors T and S.
T≔evalDG⁡a⁢dx&tD_z&tD_y+b⁢dx&tD_x&tD_x+c⁢dw&tD_w&tD_z
T:=b⁢dx⁢D_x⁢D_x+a⁢dx⁢D_z⁢D_y+c⁢dw⁢D_w⁢D_z
S≔evalDG⁡d⁢D_x&tD_z&tdy+e⁢D_y&tD_x&tdz+f⁢D_w&tD_w&tdw
S:=d⁢D_x⁢D_z⁢dy+e⁢D_y⁢D_x⁢dz+f⁢D_w⁢D_w⁢dw
Form the tensor product T⊗S and contract the 1st index of T against the 1st index of S.
ContractIndices⁡T,S,1,1
b⁢d⁢D_x⁢D_x⁢D_z⁢dy+a⁢d⁢D_z⁢D_y⁢D_z⁢dy+c⁢f⁢D_w⁢D_z⁢D_w⁢dw
Form the tensor product T⊗S and contract the 1st index of T against the 1st index of S and the 2nd index of T against the 3rd index of S.
ContractIndices⁡T,S,1,1,2,3
c⁢f⁢D_z⁢D_w
Example 3.
Define a type 13 tensor T and evaluate it on the1-form α and the vectors X,Y,Z.
T≔evalDG⁡a⁢D_x&tdx&tdz&tdy+b⁢D_y&tdx&tdx&tdz+c⁢D_w&tdx&tdy&tdz
T:=a⁢D_x⁢dx⁢dz⁢dy+b⁢D_y⁢dx⁢dx⁢dz+c⁢D_w⁢dx⁢dy⁢dz
α≔evalDG⁡dx−dy+dz−3⁢dw
α:=dx−dy+dz−3⁢dw
X≔D_x:Y≔D_y:Z≔D_z:
ContractIndices⁡T,α&tX&tY&tZ,1,1,2,2,3,3,4,4
−3⁢c
See Also
DifferentialGeometry
Tensor
RaiseLowerIndices
Download Help Document