In multilinear algebra, a tensor contraction is an operation on a tensor that arises from the canonical pairing of a vector space and its dual.

This example with two small matrices (tensors) shows how it works.

<math display="block">

\begin{bmatrix}

1 & 2 \\

3 & 4

\end{bmatrix}

\begin{bmatrix}

5 & 6 \\

7 & 8

\end{bmatrix}

= \begin{bmatrix}

1 \cdot 5 + 2 \cdot 7 & 1 \cdot 6 + 2 \cdot 8 \\

3 \cdot 5 + 4 \cdot 7 & 3 \cdot 6 + 4 \cdot 8 \\

\end{bmatrix}

= \begin{bmatrix}

19 & 22 \\

43 & 50

\end{bmatrix}

</math>

When calculating with matrices or tensors, often it's useful to move the second tensor up, and put the result underneath, just for calculation purposes. That way, each row of the first matrix (1234), and each column of the second matrix (5678), point to the cell of the result that they produce. Of course, these matrices can be larger than 2x2; often 3x3 or 4x4 are used, but any size is allowed.

In simple index notation, this is written <math display=inline>\sum_{j=1}^{2} a_{ij} \times b_{jk} = c_{ik}</math> where i, j and k all range over 1, 2. Notice how the index j, in between, disappears; this is the essence of tensor contraction.

In Einstein notation, this would be <math display=inline>a_i{}^j \times b_j{}^k = c_i{}^k</math> . The superscripts work just like subscripts, with a different meaning. Only repeated, raised and lowered indices are summed over. Objects can have more than two indices, also.

Tensor contraction can be seen as a generalization of the trace.

Abstract formulation

Let V be a vector space over a field k. The core of the contraction operation, and the simplest case, is the canonical pairing of V with its dual vector space V<sup>∗</sup>. The pairing is the linear map from the tensor product of these two spaces to the field k:

<math display="block"> C : V \otimes V^* \rightarrow k </math>

corresponding to the bilinear form

<math display="block"> \langle v, f \rangle = f(v) </math>

where f is in V<sup>∗</sup> and v is in V. The map C defines the contraction operation on a tensor of type , which is an element of <math>V \otimes V^* </math>. Note that the result is a scalar (an element of k). In finite dimensions, using the natural isomorphism between <math>V \otimes V^* </math> and the space of linear maps from V to V, one obtains a basis-free definition of the trace.

In general, a tensor of type (with and ) is an element of the vector space

<math display="block">V \otimes \cdots \otimes V \otimes V^{*} \otimes \cdots \otimes V^{*}</math>

(where there are m factors V and n factors V<sup>∗</sup>). Applying the canonical pairing to the kth V factor and the lth V<sup>∗</sup> factor, and using the identity on all other factors, defines the (k, l) contraction operation, which is a linear map that yields a tensor of type .

<math display="block"> f_\gamma v^\gamma = f_1 v^1 + f_2 v^2 + \cdots + f_n v^n </math>

(where are the components of in a particular basis and are the components of in the corresponding dual basis).

Since a general mixed dyadic tensor is a linear combination of decomposable tensors of the form <math>f \otimes v</math>, the explicit formula for the dyadic case follows: let

<math display="block"> \mathbf{T} = T_{j}^i \mathbf{e}_i \otimes \mathbf{e}^j </math>

be a mixed dyadic tensor. Then its contraction is

<math display="block"> T_{j}^i \mathbf{e}_i \cdot \mathbf{e}^j = T_{j}^i \delta_i {}^j

= T_{j}^j= T_{1}^1 + \cdots + T_{n}^n </math>.

A general contraction is denoted by labeling one covariant index and one contravariant index with the same letter, summation over that index being implied by the summation convention. The resulting contracted tensor inherits the remaining indices of the original tensor. For example, contracting a tensor T of type (2,2) on the second and third indices to create a new tensor U of type (1,1) is written as

<math display="block"> T^{ab} {}_{bc} = \sum_{b}{T^{ab}{}_{bc = T^{a1} {}_{1c} + T^{a2} {}_{2c} + \cdots + T^{an} {}_{nc} = U^a {}_c .</math>

By contrast, let

<math display="block"> \mathbf{T} = \mathbf{e}^i \otimes \mathbf{e}^j </math>

be an unmixed dyadic tensor. This tensor does not contract; if its base vectors are dotted, the result is the contravariant metric tensor,

<math display="block"> g^{ij} = \mathbf{e}^i \cdot \mathbf{e}^j ,</math>

whose rank is 2.

Metric contraction

As in the previous example, contraction on a pair of indices that are either both contravariant or both covariant is not possible in general. However, in the presence of an inner product (also known as a metric) g, such contractions are possible. One uses the metric to raise or lower one of the indices, as needed, and then one uses the usual operation of contraction. The combined operation is known as metric contraction.

Application to tensor fields

Contraction is often applied to tensor fields over spaces (e.g. Euclidean space, manifolds, or schemes). Since contraction is a purely algebraic operation, it can be applied pointwise to a tensor field, e.g. if T is a (1,1) tensor field on Euclidean space, then in any coordinates, its contraction (a scalar field) U at a point x is given by

<math display="block">U(x) = \sum_{i} T^{i}_{i}(x)</math>

Since the role of x is not complicated here, it is often suppressed, and the notation for tensor fields becomes identical to that for purely algebraic tensors.

Over a Riemannian manifold, a metric (field of inner products) is available, and both metric and non-metric contractions are crucial to the theory. For example, the Ricci tensor is a non-metric contraction of the Riemann curvature tensor, and the scalar curvature is the unique metric contraction of the Ricci tensor.

One can also view contraction of a tensor field in the context of modules over an appropriate ring of functions on the manifold see the discussion at the end of this article.

Tensor divergence

As an application of the contraction of a tensor field, let V be a vector field on a Riemannian manifold (for example, Euclidean space). Let <math> V^\alpha {}_{\beta}</math> be the covariant derivative of V (in some choice of coordinates). In the case of Cartesian coordinates in Euclidean space, one can write

<math display="block"> V^\alpha {}_{\beta} = {\partial V^\alpha \over \partial x^\beta}. </math>

Then changing index β to α causes the pair of indices to become bound to each other, so that the derivative contracts with itself to obtain the following sum:

<math display="block"> V^\alpha {}_{\alpha} = V^0 {}_{0} + \cdots + V^n {}_{n}, </math>

which is the divergence div V. Then

<math display="block"> \operatorname{div} V = V^\alpha {}_{\alpha} = 0 </math>

is a continuity equation for V.

In general, one can define various divergence operations on higher-rank tensor fields, as follows. If T is a tensor field with at least one contravariant index, taking the covariant differential and contracting the chosen contravariant index with the new covariant index corresponding to the differential results in a new tensor of rank one lower than that of T.