Lukas' Notes

linear-algebra

Definition

Einstein Notation

Einstein notation (summation convention) is a notation for tensor operations in which an index that appears twice in a term is implicitly summed over its full range. Indices that appear exactly once are free and determine the output shape.

Indices

Free Indices

Definition

Free Index (Einstein Notation)

A free index is an index that appears exactly once in an Einstein notation term. It is not summed over and becomes an axis of the output.

Link to original

Dummy Indices

Definition

Dummy Index (Einstein Notation)

A dummy index (contracted index) is an index that appears exactly twice in an Einstein notation term. It is implicitly summed over its full range and does not appear in the output.

Link to original

Ill-formed Indices

Definition

Ill-formed Index (Einstein Notation)

In Einstein notation, an index that appears three or more times in a single term is ill-formed. The expression is undefined because the summation is ambiguous — there is no rule for which pairs to contract.

Every index in a well-formed term must be either free (once) or dummy (twice).

Link to original

The Shape Rule

The output of an expression is indexed by its free indices, in the order they appear. Each free index runs over its natural range.

Examples

Let and and .

expressionfree indicesdummy indicesoutput shape
nonevector of length
none matrix
nonenonescalar
none matrix
vector of length
vector of length
matrix
nonescalar

Contraction

A dummy index is contracted: it matched across two factors and summed over.

The sum over the index dimension as its matched across two factors (dummy index), i,e.:

The contraction removes the axis of dummy index , thus, the output shape has fewer axes than matrix .

Precondition

Every dummy index must have the same range wherever it appears.

Example

If has and has , i.e. , then the contraction over is well-defined.

If the ranges differ, the expression is ill-typed.