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.
[ 1 2 3 4 ] [ 5 6 7 8 ] = [ 1 ⋅ 5 + 2 ⋅ 7 1 ⋅ 6 + 2 ⋅ 8 3 ⋅ 5 + 4 ⋅ 7 3 ⋅ 6 + 4 ⋅ 8 ] = [ 19 22 43 50 ] {\displaystyle {\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}}}
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 ∑ j = 1 2 a i j × b j k = c i k {\textstyle \sum _{j=1}^{2}a_{ij}\times b_{jk}=c_{ik}} 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 a i
j × b j
k = c i
k {\textstyle a_{i}{}^{j}\times b_{j}{}^{k}=c_{i}{}^{k}} . 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∗. The pairing is the linear map from the tensor product of these two spaces to the field k:
C : V ⊗ V ∗ → k {\displaystyle C:V\otimes V^{*}\rightarrow k}
corresponding to the bilinear form
⟨ v , f ⟩ = f ( v ) {\displaystyle \langle v,f\rangle =f(v)}
where f is in V∗ and v is in V. The map C defines the contraction operation on a tensor of type (1, 1), which is an element of V ⊗ V ∗ {\displaystyle V\otimes V^{*}} . Note that the result is a scalar (an element of k). In finite dimensions, using the natural isomorphism between V ⊗ V ∗ {\displaystyle V\otimes V^{*}} 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 (m, n) (with m ≥ 1 and n ≥ 1) is an element of the vector space
V ⊗ ⋯ ⊗ V ⊗ V ∗ ⊗ ⋯ ⊗ V ∗ {\displaystyle V\otimes \cdots \otimes V\otimes V^{*}\otimes \cdots \otimes V^{*}}
(where there are m factors V and n factors V∗). Applying the canonical pairing to the kth V factor and the lth V∗ 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 (m − 1, n − 1). By analogy with the (1, 1) case, the general contraction operation is sometimes called the trace.
… excerpt ends here. Continue reading the full article.
