Tensor Contraction and the Trace
Tensor algebra is built from exactly two operations. The tensor product raises rank, gluing a type- tensor and a type- tensor into a type- one. Contraction is its opposite and its complement: it lowers rank, pairing a single upper (contravariant) index against a single lower (covariant) index through the natural dual pairing , summing over the shared label, and returning a tensor of type . Every product you already trust — the dot product of two vectors, the multiplication of two matrices, the divergence of a vector field, the trace of an operator — is a single instance of this one move. The reason contraction earns a place beside the tensor product is invariance. Under a change of basis an upper index is carried by a matrix and a lower index by its inverse ; when you set one upper index equal to one lower index and sum, meets and collapses to a Kronecker delta, so the summed object transforms cleanly with only its free indices. That single cancellation is why the rule "always contract an up index against a down index" is a theorem, not a convention: pair two indices of the same variance and the surviving factor is , not the identity, so the result depends on the basis you happened to choose. The trace is the smallest non-trivial contraction. A type- tensor is a linear operator, and its unique full contraction is the trace — a scalar equal to the sum of the eigenvalues, invariant under similarity, and cyclic: . Push the same operation onto a curved manifold and it commutes with the covariant derivative, so contracting the Riemann tensor gives the Ricci tensor, contracting again gives the scalar curvature, and Einstein's equations become a statement about traces of curvature.
- Contraction sets one upper index equal to one lower index and sums, sending a type- tensor to type- — the rank-lowering complement of the tensor product.
- It is basis-independent for one precise reason: the upper transformation and lower transformation meet on the summed index and collapse to , so the free indices transform correctly.
- The trace is the unique total contraction of a tensor: a similarity invariant equal to the sum of eigenvalues, cyclic under , with .
- One index-pairing reproduces the dot product , matrix product , divergence , and the curvature invariants , .
- Same-variance summation (two up or two down) is not invariant; a metric must first convert one index — the job of raising and lowering.
- Key idea: contraction sums a paired upper and lower index against the dual pairing ; the inverse transformation matrices cancel, so the result is a genuine tensor of rank lowered by two — and the trace is just the unique total contraction of a tensor.
Where this lives today
Contraction is the arithmetic primitive of every large tensor computation being run right now. In numerical general relativity, codes that model colliding black holes evaluate and as literal contractions of a discretized Riemann tensor at billions of grid points, and the LIGO-Virgo-KAGRA waveform templates that matched the 2015 gravitational-wave detection came from exactly this pipeline. In quantum many-body physics and quantum chemistry, tensor-network methods — matrix product states, PEPS, tensor trains — represent a wavefunction as a graph whose every edge is a contracted index, and the feasibility of a simulation is decided entirely by the order in which those contractions are performed. The same operation is the einsum call at the heart of modern machine-learning frameworks, where the attention mechanism of a transformer is a chain of contractions over sequence and feature indices. And in statistical and quantum field theory the trace is inescapable: a partition function is , a thermal average is a normalized trace, and the cyclicity is the algebraic root of the Kubo-Martin-Schwinger condition defining thermal equilibrium. One index-pairing rule, proven invariant by a single Kronecker delta, runs from a first tensor-algebra lecture to the frontier of computation.
The physical picture
Read an upper index as a plug — an outgoing vector slot — and a lower index as a socket, an incoming covector slot. A tensor is a little machine with some plugs and some sockets sticking out; the tensor product parks two machines side by side and keeps all their legs, while contraction takes one plug and feeds it back into one of the machine's own sockets and sums over the connection. What comes out no longer mentions that particular leg: it has been wired shut. The trace is the extreme case — a tensor has exactly one plug and one socket, and joining them leaves a machine with no external legs at all, which is precisely what a scalar is.
The wiring picture also explains why the variance must be opposite. Rotate the basis: the plug is re-expressed with and the socket with , and only when a plug plugs into a socket do the two sit on the same summed index and multiply to , cancelling exactly. Wire a plug to another plug and you get with no inverse in sight — the number changes when you turn your head, so it was never a property of the tensor. This is the geometric content of "you need a metric to dot two vectors": two vectors live in the same space with no built-in pairing, whereas a vector and a covector pair for free through . The single sharpest illustration that the trace is a real invariant, not an artifact of the diagonal you happen to see, is the rotation matrix. A rotation about any axis by angle has eigenvalues , so its trace is — regardless of the axis. Turn the same physical rotation into a basis where its matrix has an all-zero diagonal and the trace is still ; the off-diagonal entries reshuffle but the contraction does not budge.
The core equations
Contraction is defined on components: choose one upper slot and one lower slot, set their labels equal, and sum over that repeated label. The map lowers both the contravariant and covariant degree by one.
where: — a type- tensor with upper and lower indices; — the repeated (summed) index, one chosen upper slot equated to one chosen lower slot; — the contraction map, whose output is type . Reading: pick a plug and a socket, wire them together, sum; the degree drops by two. The trace is the case , the total contraction of an operator. There is only one pair to contract, so the trace is unique and produces a pure number.
where: — components of a linear operator on an -dimensional space ; — the dimension of . Reading: the trace sums the diagonal, but because it is a contraction it is basis-free — the diagonal you sum is not. Two identities make the trace usable. Cyclicity follows from relabelling dummy indices, and the trace of the identity counts dimensions.
where: — operators (square matrices) on ; — the identity, with . Reading: you may cycle factors inside a trace but not arbitrarily permute them, and . The engine underneath every contraction is the dual pairing, whose components are the Kronecker delta — the identity on indices, whose own full contraction is the dimension.
where: — a basis vector of ; — the dual basis covector of ; — the canonical, metric-free pairing. Reading: is the only tensor with the same components in every basis, which is why it is the kernel that survives a contraction. When no covector is available, a metric supplies one: contracting a vector with lowers its index, and returns the delta. This is where inner products and index gymnastics enter as contractions.
where: — the metric (type ); — its inverse (type ); — vector components; — the covariant version obtained by contracting with . Reading: raising and lowering indices is nothing but contraction with or , which is why a metric is the missing ingredient for same-variance contraction. The payoff on a manifold is curvature. Contracting the Riemann tensor once gives the Ricci tensor; contracting it again with the inverse metric gives the scalar curvature — the two invariants from which Einstein built gravity.
where: — the Riemann curvature tensor with its first upper index contracted against its third (lower) index; — the Ricci tensor; — the Ricci (scalar) curvature. Reading: the whole chain from curvature to Einstein's equations is a sequence of contractions. Finally, contraction commutes with the covariant derivative — the property that makes contracted tensor fields, and hence conservation laws, well defined on curved space.
where: — the covariant derivative; — a tensor field. Reading: the connection acts on an upper index with and on a lower index with , so on a contracted pair the two Christoffel terms cancel and the derivative passes straight through the contraction.
The goal is to prove that the single number is genuinely a scalar — the same in every basis — and to see that the proof rests on one algebraic fact and nothing else: the transformation matrix of an upper index is the exact inverse of that of a lower index. The identical cancellation, with extra free indices carried along, then proves invariance for a contraction inside a tensor of any rank, which is why this short calculation is the load-bearing wall of the whole subject.
Step 1. Write how a tensor's components change under a transformation : the upper index is carried by , the lower by , so . Why: an operator eats a vector and returns a vector, so one slot transforms like a vector and the other like a covector — opposite variances are forced.
Step 2. Form the trace in the new basis by setting and summing: . Why: contraction is what puts and on the same summed label — the only place they can meet.
Step 3. Collapse the matched pair: summing over is the matrix product in index form, . Why: this is the whole trick — turns two basis-dependent matrices into a basis-independent delta.
Step 4. Substitute back: , the same in both bases, so it is a scalar. Why: with the delta doing the summation, every reference to the basis has vanished, leaving a number intrinsic to the operator. *The entire argument reduces to the single algebraic fact . Carrying extra free indices along untouched, the same lines prove that any single up-down contraction of a type- tensor is a genuine type- tensor.*
Go deeper · Derivation B · 1 minWhy two indices of the same variance cannot be contracted
The goal here is to show by direct computation that the up-against-down rule is a hard requirement, not a stylistic preference: "tracing" a tensor by summing its two upper indices produces a quantity that changes with the basis and is therefore not a tensor at all. The same calculation reveals the cure — insert a metric to convert one index — which is exactly why raising and lowering indices is a prerequisite for contracting like-variance slots.
Step 1. Take a tensor, whose two contravariant indices are both carried by : . Why: both indices are of the same type, so both pick up and neither supplies the inverse that a clean cancellation needs.
Step 2. Set and sum: , whose summed pair is — the identity only if is orthogonal. Why: with no inverse in the product, the leftover is basis-dependent, so — the "trace" is a fiction.
Step 3. Repair it with the metric: lower one index, , then contract the now-opposite pair, . Why: the metric supplies two factors of , one to pair with each stray , restoring the up-against-down structure.
Step 4. Check it is a scalar: with , one gets . Why: now every finds a to annihilate, which is why is a legitimate inner product while is not. *In an orthonormal basis under orthogonal , and the distinction between same-variance and opposite-variance contraction collapses — exactly why Cartesian-tensor treatments may write all indices down, and why general-tensor calculus cannot.*
Go deeper · Derivation C · 1 minThe trace as the sum of the eigenvalues
The aim is to connect the index-level definition to the spectral fact every linear-algebra course states — that the trace equals the sum of the eigenvalues — using nothing more than the cyclic property proven above. This is the concrete face of basis-independence: the eigenvalues do not care about the basis, so any quantity equal to their sum cannot either.
Step 1. Diagonalize as with , and use cyclicity to rotate to the front: . Why: cyclicity moves the similarity matrices next to their inverses, and is itself just a relabelling of the summed index.
Step 2. Cancel to reach the diagonal form: . Why: the similarity leaves the trace untouched — the abstract statement that the trace is a similarity invariant.
Step 3. Contract the diagonal, which sums its entries: . Why: the contraction reads off the spectrum, so in any basis. *Equivalently, is the coefficient of in , making it the first elementary symmetric function of the eigenvalues. A 3D rotation's eigenvalues sum to , matching the figure.*
Limiting cases
Contraction is not one operation among many — it is the operation that most familiar products turn out to be. Reading a bilinear expression as "which index is summed against which" identifies it instantly:
| Case | Result | Meaning |
|---|---|---|
| Trace of a matrix | Total contraction of a tensor; the sum of eigenvalues, invariant under similarity. | |
| Dual pairing / inner product | Contracting a covector with a vector; with a metric, is the inner product. | |
| Matrix multiplication | Contract one index between two operators; the two surviving indices label the product. | |
| Divergence of a vector field | Contracting the derivative index of against the field's upper index gives a scalar. | |
| Ricci from Riemann | Contract Riemann's first upper with its third lower index; a second contraction gives . | |
| Kronecker delta, self-contracted | The full contraction of the identity counts the dimension; it seeds the in . |
Worked examples
1 · The trace of a rotation is a genuine invariant (fully worked)
A proper rotation turns space about some axis by angle . Show that independent of the axis, and check it on two rotations whose matrices look nothing alike.
Step 1. Fix the eigenvalues. A real rotation preserves lengths (unit-modulus eigenvalues), fixes its axis (eigenvalue ), and being real has conjugate pairs — so the spectrum is for every axis. By Derivation 3, , with no reference to the axis.
Step 2. Test it on a rotation with a friendly diagonal. Rotating by about the -axis gives with diagonal , so . The formula predicts . They agree.
Step 3. Test it on a rotation with a hostile diagonal. The cyclic permutation is the matrix with rows — a rotation by about the body diagonal , with , so it lies in . Its diagonal is all zeros, so , while the formula gives . They agree again, even though not a single diagonal entry survived.
Step 4. The moral: the two matrices share no entries and one has an empty diagonal, yet returns the invariant both times, because it equals the basis-blind eigenvalue sum. The trace is a property of the rotation, not of the array you wrote to represent it.
2 · Curvature by double contraction: the scalar curvature of a sphere (fully worked)
A 2-sphere of radius has metric , (diagonal). Its single independent Riemann component corresponds to Gaussian curvature , so the Ricci tensor is . Contract twice to find the scalar curvature.
Step 1. Build the Ricci tensor from the maximally symmetric relation . Component-wise, and . This Ricci tensor is itself the first contraction of the Riemann tensor.
Step 2. Assemble the inverse metric needed for the second contraction: because is diagonal, and .
Step 3. Contract Ricci with the inverse metric, . Substituting, .
Step 4. Sanity-check. The result is a pure number times , as a curvature must be, positive and constant as it should be for a round sphere; the unit sphere gives , and it reproduces in two dimensions. Contracting Riemann twice has collapsed the entire curvature of the sphere into the single invariant — the smaller the sphere, the larger its curvature.
3 · Cyclicity and the Frobenius norm (compact check)
For , : verify cyclicity and read the Frobenius norm as a contraction. Here and share no entries, yet — cyclicity confirmed. And the full double contraction is the squared length of read as a vector, the same pattern that makes an inner product.
Physics of the portrait
Contraction and the trace look like linear-algebra bookkeeping until you follow them onto a curved manifold, where they become the machinery that turns raw curvature into the invariants of gravity. The man who built that machinery — the absolute differential calculus, in which contraction is a named, coordinate-free operation — is the mathematician whose contraction of the Riemann tensor still carries his name.
Origins · 1 minGregorio Ricci-Curbastro and how this was discovered
Gregorio Ricci-Curbastro spent most of his career at the University of Padua developing what he called the "absolute differential calculus" — the systematic study of quantities whose meaning is independent of the coordinates used to describe them. Building on Riemann's 1854 essay on curvature and Christoffel's 1869 work on covariant differentiation, he isolated the operations that act invariantly on tensors: covariant differentiation, the raising and lowering of indices with a metric, and above all contraction, the summation of a paired upper and lower index that lowers rank while preserving tensor character. Where earlier writers had summed indices by hand and hoped the result meant something, he proved which sums are invariant and why. In 1900 he and his former student Tullio Levi-Civita published the founding synthesis, "Méthodes de calcul différentiel absolu et leurs applications," in Mathematische Annalen. For fifteen years it was admired by geometers and ignored by physicists, until Einstein, guided by Marcel Grossmann, seized on it as the only language capable of expressing general relativity. When Einstein contracted the Riemann tensor to form and again to form , he was using Ricci-Curbastro's operation on Ricci-Curbastro's calculus; the first of those contractions has been called the Ricci tensor ever since. A quiet, devout professor, he never saw his invariants as anything but pure geometry — yet the trace of curvature he taught the world to take is the left-hand side of the equation that governs the universe.
Going further
Texts. Stone & Goldbart, Mathematics for Physics (2009), Ch. 10 (Vectors and Tensors) · Arfken, Weber & Harris, Mathematical Methods for Physicists, 7th ed., Ch. 4 (Tensors) · Hassani, Mathematical Physics, 2nd ed., Chs. 25–26 · Nakahara, Geometry, Topology and Physics, 2nd ed., Ch. 5 · Misner, Thorne & Wheeler, Gravitation, Ch. 3 · Byron & Fuller, Mathematics of Classical and Quantum Physics, Ch. 2. The key numerical results in this article are: the cancellation underlying each invariance proof; the cyclicity check for the given matrices; the rotation traces and ; and the sphere scalar curvature .
Builds on: Tensor Algebra and the Tensor Product · Covariant and Contravariant Tensors · The Metric Tensor. Leads to: Raising and Lowering Indices · The Covariant Derivative · The Riemann Curvature Tensor · The Hodge Star and the Codifferential.
Ask the tutor: Ask me to contract any tensor expression you meet — a matrix product, a divergence, or the Riemann-to-Ricci step — and I will show you which index pairs with which and why the result is invariant.
What is the difference between contraction and the tensor product?
They are inverse moves on the ladder of rank. The tensor product takes a type- and a type- tensor and builds a type- tensor, keeping all indices side by side — it never sums. Contraction goes the other way: it pairs one upper index with one lower index on a single tensor, sums over that label, and returns a tensor with one fewer upper and one fewer lower index. Most operations combine the two — matrix multiplication is the tensor product followed by contracting against . The product supplies raw rank; contraction spends it.
Why is the trace independent of the basis when it is "just the sum of the diagonal"?
Because summing the diagonal of a tensor is secretly contracting an upper index against a lower one, and those indices transform by inverse matrices that cancel. Under a basis change the upper in is carried by and the lower by ; sharing the summed label, they multiply to and the basis dependence vanishes. The rotation figure is the cleanest demonstration — a basis can make a rotation's diagonal entirely zero, yet its trace is still , because the trace equals the eigenvalue sum and eigenvalues ignore the basis. The visible diagonal is a basis artifact; the contraction extracts the part that is not.
Do I always need a metric to contract two indices?
No — and beginners often invert this. Contracting one upper against one lower index needs no metric: the dual pairing is built into the definition of a vector space and its dual, so and are always available. You need a metric only to contract two indices of the same variance — two vectors, say — because then there is no canonical pairing and you must borrow one from . That is exactly what an inner product does: it lowers one index so an ordinary up-down contraction can proceed.
What is so important about "the trace of the identity is n"?
It is the fingerprint of a full Kronecker-delta contraction, and it appears everywhere. Whenever you fully contract — or equivalently — you get the dimension , because you are tracing the identity operator. That fact seeds the factors of (or in spacetime) that pepper field theory: , the dimensional factors in Einstein-tensor manipulations, and the counting of degrees of freedom in index sums. When a stray appears in a tensor calculation, it almost always came from a .
How does contraction relate to the Einstein summation convention?
The convention is a notation built precisely around valid contractions. Einstein's rule is that a repeated index — once up, once down in a single term — is automatically summed, so one writes rather than . It fires only on an up-down pair, which is exactly the invariant combination. If you ever want to sum a repeated index that is both up or both down, the convention is warning you — correctly — that the expression is not a tensor until a metric intervenes.
Why is contraction the key to the curvature invariants of gravity?
Because the Riemann tensor carries four indices and far too much information to serve directly as a field equation, and contraction distills it. Contracting once, , gives the Ricci tensor — the part of curvature that couples to matter — and contracting again, , gives the scalar curvature. Einstein's tensor is built entirely from these, and its contracted Bianchi identity forces energy-momentum conservation. Because contraction commutes with the covariant derivative, every step is coordinate-free — the whole point of general relativity.