BUILT-IN MATHEMATICA SYMBOL

# TensorContract

TensorContract[tensor, {{s11, s12}, {s21, s22}, ...}]
yields the contraction of tensor in the pairs of slots.

## DetailsDetails

• The first argument of TensorContract[tensor, pairs] can be any tensorial object, in particular explicit or symbolic arrays, or combinations like tensor products, transpositions, etc.
• The slots must all be different positive integers, not larger than the rank of the contracted tensor.
• The slots contracted in each pair must all have the same dimensions, but different pairs might be associated to different dimensions.
• For a symbolic tensor in the first argument of TensorContract, the contractions in the second argument are sorted, after sorting the slots in each contraction.
• TensorContract[tensor, {}] returns tensor.

## ExamplesExamplesopen allclose all

### Basic Examples (3)Basic Examples (3)

Contract slots 2 and 3 of a rank-3 array:

 Out[1]=

Perform several contractions in an array:

 Out[2]=

A symbolic array of rank 3:

Slots 1 and 3 can be contracted:

 Out[2]=

Slots 1 and 2 cannot be contracted:

 Out[3]=

## TutorialsTutorials

New in 9
New to Mathematica? Find your learning path »
Have a question? Ask support »