contract the indices of a tensor - Maple Programming Help

Home : Support : Online Help : Mathematics : DifferentialGeometry : Tensor : DifferentialGeometry/Tensor/ContractIndices

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 $\left[\left[{i}_{1},{i}_{2}\right],\left[{i}_{3},{i}_{4}\right],...\right]$ referring to the arguments of T which are to be contracted

Indices2  - a list of pairs of integers $\left[\left[{i}_{1},{i}_{2}\right],\left[{i}_{3},{i}_{4}\right],...\right]$ referring to the arguments of T and S which are to be contracted

Description

 • With the first calling sequence, ContractIndices(T, Indices) will contract from $T$ each pair of indices in the list Indices = $\left[\left[{i}_{1},{i}_{2}\right],\left[{i}_{3},{i}_{4}\right],...\right]$. Each index pair must refer to indices of different valence, for example, if ${i}_{1}$ is a contravariant index, then ${i}_{2}$ must be a covariant index. If $T$ is of type $\left(\genfrac{}{}{0}{}{{r}}{{s}}\right)$ (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 $\left(\genfrac{}{}{0}{}{{r}{-}{k}}{{s}{-}{k}}\right)$.
 • With the second calling sequence, ContractIndices(T, S, Indices), where Indices = $\left[\left[{i}_{1},{i}_{2}\right],\left[{i}_{3},{i}_{4}\right],...\right]$, will contract the ${i}_{1}$ index of $T$ with the ${i}_{2}$ index $S$, the ${i}_{3}$ index of $T$ with the ${i}_{4}$ index $S$ and so on. Each index pair must refer to indices of different valence. If $T$ is of type $\left(\genfrac{}{}{0}{}{r}{s}\right)$, of type $\left(\genfrac{}{}{0}{}{p}{q}\right)$, and if the list Indices2 contains $k$ index pairs, then ContractIndices(T, Indices2) will return a tensor of type $\left(\genfrac{}{}{0}{}{r+p-k}{s+q-k}\right)$.
 • 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.

Examples

 > with(DifferentialGeometry): with(Tensor):

Example 1.

First create a 4 dimensional manifold $M$ and define a type $\left(\genfrac{}{}{0}{}{2}{3}\right)$ tensor $T$ on $M$.

 > DGsetup([x, y, z, w], M):
 M > T := evalDG(a*D_x &t D_x &t dz &t dx &t dz + b*D_x &t D_z &t dz &t dx &t dw);
 ${T}{:=}{\mathrm{_DG}}{}\left(\left[\left[{"tensor"}{,}{M}{,}\left[\left[{"con_bas"}{,}{"con_bas"}{,}{"cov_bas"}{,}{"cov_bas"}{,}{"cov_bas"}\right]{,}\left[\right]\right]\right]{,}\left[\left[\left[{1}{,}{1}{,}{3}{,}{1}{,}{3}\right]{,}{a}\right]{,}\left[\left[{1}{,}{3}{,}{3}{,}{1}{,}{4}\right]{,}{b}\right]\right]\right]\right)$ (2.1)

Contract the 1st and 4th indices of $T$.

 M > ContractIndices(T, [[1, 4]]);
 ${\mathrm{_DG}}{}\left(\left[\left[{"tensor"}{,}{M}{,}\left[\left[{"con_bas"}{,}{"cov_bas"}{,}{"cov_bas"}\right]{,}\left[\right]\right]\right]{,}\left[\left[\left[{1}{,}{3}{,}{3}\right]{,}{a}\right]{,}\left[\left[{3}{,}{3}{,}{4}\right]{,}{b}\right]\right]\right]\right)$ (2.2)

Contract the 1st and 4th indices and the 2nd and 3rd indices of $T$.

 M > ContractIndices(T, [[1, 4], [2, 3]]);
 ${\mathrm{_DG}}{}\left(\left[\left[{"tensor"}{,}{M}{,}\left[\left[{"cov_bas"}\right]{,}\left[\right]\right]\right]{,}\left[\left[\left[{4}\right]{,}{b}\right]\right]\right]\right)$ (2.3)

Example 2.

Define two rank 3 tensors $T$ and $S$.

 M > T := evalDG(a*dx &t D_z &t D_y + b*dx &t D_x &t D_x + c*dw &t D_w &t D_z);
 ${T}{:=}{\mathrm{_DG}}{}\left(\left[\left[{"tensor"}{,}{M}{,}\left[\left[{"cov_bas"}{,}{"con_bas"}{,}{"con_bas"}\right]{,}\left[\right]\right]\right]{,}\left[\left[\left[{1}{,}{1}{,}{1}\right]{,}{b}\right]{,}\left[\left[{1}{,}{3}{,}{2}\right]{,}{a}\right]{,}\left[\left[{4}{,}{4}{,}{3}\right]{,}{c}\right]\right]\right]\right)$ (2.4)
 M > S := evalDG(d*D_x &t D_z &t dy + e*D_y &t D_x &t dz + f*D_w &t D_w &t dw);
 ${S}{:=}{\mathrm{_DG}}{}\left(\left[\left[{"tensor"}{,}{M}{,}\left[\left[{"con_bas"}{,}{"con_bas"}{,}{"cov_bas"}\right]{,}\left[\right]\right]\right]{,}\left[\left[\left[{1}{,}{3}{,}{2}\right]{,}{d}\right]{,}\left[\left[{2}{,}{1}{,}{3}\right]{,}{e}\right]{,}\left[\left[{4}{,}{4}{,}{4}\right]{,}{f}\right]\right]\right]\right)$ (2.5)

Form the tensor product $T\otimes S$ and contract the 1st index of $T$ against the 1st index of $S$.

 M > ContractIndices(T, S, [[1, 1]]);
 ${\mathrm{_DG}}{}\left(\left[\left[{"tensor"}{,}{M}{,}\left[\left[{"con_bas"}{,}{"con_bas"}{,}{"con_bas"}{,}{"cov_bas"}\right]{,}\left[\right]\right]\right]{,}\left[\left[\left[{1}{,}{1}{,}{3}{,}{2}\right]{,}{b}{}{d}\right]{,}\left[\left[{3}{,}{2}{,}{3}{,}{2}\right]{,}{a}{}{d}\right]{,}\left[\left[{4}{,}{3}{,}{4}{,}{4}\right]{,}{c}{}{f}\right]\right]\right]\right)$ (2.6)

Form the tensor product $T\otimes 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$.

 M > ContractIndices(T, S, [[1, 1], [2, 3]]);
 ${\mathrm{_DG}}{}\left(\left[\left[{"tensor"}{,}{M}{,}\left[\left[{"con_bas"}{,}{"con_bas"}\right]{,}\left[\right]\right]\right]{,}\left[\left[\left[{3}{,}{4}\right]{,}{c}{}{f}\right]\right]\right]\right)$ (2.7)

Example 3.

Define a type $\left(\genfrac{}{}{0}{}{1}{3}\right)$ tensor $T$ and evaluate it on the1-form ${\mathrm{α}}_{}$ and the vectors $X,Y,Z$.

 M > T := evalDG(a*D_x &t dx &t dz &t dy + b*D_y &t dx &t dx &t dz + c*D_w &t dx &t dy &t dz);
 ${T}{:=}{\mathrm{_DG}}{}\left(\left[\left[{"tensor"}{,}{M}{,}\left[\left[{"con_bas"}{,}{"cov_bas"}{,}{"cov_bas"}{,}{"cov_bas"}\right]{,}\left[\right]\right]\right]{,}\left[\left[\left[{1}{,}{1}{,}{3}{,}{2}\right]{,}{a}\right]{,}\left[\left[{2}{,}{1}{,}{1}{,}{3}\right]{,}{b}\right]{,}\left[\left[{4}{,}{1}{,}{2}{,}{3}\right]{,}{c}\right]\right]\right]\right)$ (2.8)
 M > alpha := evalDG(dx - dy + dz - 3*dw);
 ${\mathrm{α}}{:=}{\mathrm{_DG}}{}\left(\left[\left[{"form"}{,}{M}{,}{1}\right]{,}\left[\left[\left[{1}\right]{,}{1}\right]{,}\left[\left[{2}\right]{,}{-1}\right]{,}\left[\left[{3}\right]{,}{1}\right]{,}\left[\left[{4}\right]{,}{-3}\right]\right]\right]\right)$ (2.9)
 M > X := D_x: Y := D_y: Z := D_z:
 M > ContractIndices(T, alpha &t X &t Y &t Z, [[1, 1], [2, 2], [3, 3], [4, 4]]);
 ${-}{3}{}{c}$ (2.10)