returns a sorted list of all possible full contractions of expr over its free indices.
AllContractions[expr, frees]
returns all possible contractions of expr that have frees as free indices.
AllContractions[expr, frees, sym]
returns all possible contractions of expr with the symmetry sym imposed on the free indices frees.
  • The first argument can also be a list, in which case AllContractions returns the union of all contractions for each of the members of the list.
  • AllContractions returns {} if it is not possible to take contractions, or throws an exception if it encounters an error.
  • The indices in the second argument have to be given as an IndexList or as a List.
  • The input expression expr cannot have dummy indices.
  • The number of free indices of expr plus those in frees has to be even.
  • The free indices of the input have to belong to the same tangent bundle.
  • The metric of that tangent bundle has to be symmetric.
  • AllContractions does not take multi-term symmetries into account, only mono-term symmetries.
  • Specifying free indices with the second argument is equivalent to adding an auxiliary tensor with indices frees to expr, computing all contractions, and varying with respect to the auxiliary tensor afterwards.
  • The following options can be given:
VerboseFalsedisplay information while computing
ParallelizationTruewhether or not to distribute the computation over all available kernels
SymmetrizeMethodImposeSymmetryhow to symmetrize the free indices
UncontractedIndicesNonehow many indices should not be contracted
FreeMetricsAllcontractions with this many of free metrics will be included
AuxiliaryTensorDefaultname of the auxiliary tensor used internally
  • Possible settings for Verbose include:
Falsedon't display any information while computing
Truedisplay status information while computing
  • Possible settings for SymmetrizeMethod include:
ImposeSymmetryexplicity symmetrize the free indices
ImposeSymimplicitly symmetrize the free indices
Nonedo not symmetrize the free indices, but instead keep the auxiliary tensor
  • Possible settings for UncontractedIndices include:
Nonecontract over all indices (i.e. all indices of the input expression and additionally specified free indices)
ndo not contract n of the indices, where n is an integer between 0 and the total number of indices.
  • Parallelization only works for Mathematica version 7 and higher.
  • When UncontractedIndices is greater than 0, the uncontracted indices are treated equal, and AllContractions returns only one item for all contractions whose uncontracted index configurations are equal up to permutations.
  • Possible settings for FreeMetrics include:
Allcontractions with any number of free metrics will be included
Noneonly contractions without free metrics will be included
nonly contractions with 0 to n number of free metrics will be included
{m,n}only contractions with m to n number of free metrics will be included
  • Possible settings for AuxiliaryTensor include:
Defaultautomatically generate a name for the internally used auxiliary tensor
headthe symbol head will be used as the auxiliary tensor
  • If the auxiliary tensor is specified via the option AuxiliaryTensor, it must either be non-existing beforehand (in which case it will be defined afterwards), or it must have the exact same index structure and symmetry of the free indices specified in the second and third argument of AllContractions.
  • AllContractions uses a semi brute-force algorithm. In the worst case scenario (i.e. when the underlying expression has no symmetry) its efficiency is exponential in the number of free indices.
AllContractions doesn't take multi-term symmetries like the Bianchi identities into account.
The last two contractions in the above are related by a factor of 2:
The efficiency of AllContractions is exponential in the number of free indices:
The symmetrization of the free indices is by default explicit:
The symmetrization can be made implicit by specifying SymmetrizeMethod → ImposeSym.
Alternatively, the auxiliary tensor may be kept with SymmetrizeMethod → None.
The name of the auxiliary tensor, if kept by specifying SymmetrizeMethod → None, can be changed as follows:
By specifying UncontractedIndices all indices are no longer contracted:
This is in fact different than giving free indices in the second argument, because the command above doesn't take the different ordering of the free indices into account.
Only contractions with a given number of free metrics are returned when FreeMetrics is specified: