Tensor Contraction and the Trace

Tensor algebra is built from exactly two operations. The tensor product raises rank, gluing a type-(p,q)(p,q) tensor and a type-(r,s)(r,s) tensor into a type-(p+r,q+s)(p+r,q+s) 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 ⟨ei,ej⟩=δij\langle e^{i},e_{j}\rangle=\delta^{i}{}_{j}, summing over the shared label, and returning a tensor of type (p−1,q−1)(p-1,q-1). 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 Λ\Lambda and a lower index by its inverse Λ−1\Lambda^{-1}; when you set one upper index equal to one lower index and sum, Λ\Lambda meets Λ−1\Lambda^{-1} 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 ΛTΛ\Lambda^{\mathsf T}\Lambda, not the identity, so the result depends on the basis you happened to choose. The trace is the smallest non-trivial contraction. A type-(1,1)(1,1) tensor is a linear operator, and its unique full contraction AiiA^{i}{}_{i} is the trace — a scalar equal to the sum of the eigenvalues, invariant under similarity, and cyclic: tr(AB)=tr(BA)\mathrm{tr}(AB)=\mathrm{tr}(BA). 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.

Key takeaways
  • Contraction sets one upper index equal to one lower index and sums, sending a type-(p,q)(p,q) tensor to type-(p−1,q−1)(p-1,q-1) — the rank-lowering complement of the tensor product.
  • It is basis-independent for one precise reason: the upper transformation Λ\Lambda and lower transformation Λ−1\Lambda^{-1} meet on the summed index and collapse to δ\delta, so the free indices transform correctly.
  • The trace tr A=Aii\mathrm{tr}\,A=A^{i}{}_{i} is the unique total contraction of a (1,1)(1,1) tensor: a similarity invariant equal to the sum of eigenvalues, cyclic under tr(AB)=tr(BA)\mathrm{tr}(AB)=\mathrm{tr}(BA), with tr 1n=δii=n\mathrm{tr}\,\mathbb{1}_{n}=\delta^{i}{}_{i}=n.
  • One index-pairing reproduces the dot product ωivi\omega_{i}v^{i}, matrix product AikBkjA^{i}{}_{k}B^{k}{}_{j}, divergence ∇iVi\nabla_{i}V^{i}, and the curvature invariants Rμν=RλμλνR_{\mu\nu}=R^{\lambda}{}_{\mu\lambda\nu}, R=gμνRμνR=g^{\mu\nu}R_{\mu\nu}.
  • 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 δij\delta^{i}{}_{j}; 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 (1,1)(1,1) 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 RμνR_{\mu\nu} and RR 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 Z=tr e−βHZ=\mathrm{tr}\,e^{-\beta H}, a thermal average is a normalized trace, and the cyclicity tr(AB)=tr(BA)\mathrm{tr}(AB)=\mathrm{tr}(BA) 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 (1,1)(1,1) 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.

Figure
Contraction as wiring — a type (1,1) tensor A has one upper leg (a vector slot, carrying Λ) and one lower leg (a covector slot, carrying Λ⁻¹); joining them sums the shared index into the trace Aⁱᵢ, a scalar with no free legs, and the identity operator gives δⁱᵢ = n
Joining a plug to a socket sums the shared index — the (1,1) tensor becomes a scalar before: one free up, one free down after: no free legs — a scalar A i (Λ) j (Λ⁻¹) Aⁱⱼ contract set i = j, sum A i = j tr A = Aⁱᵢ Λ·Λ⁻¹ = δ, so δⁱᵢ = n

The wiring picture also explains why the variance must be opposite. Rotate the basis: the plug is re-expressed with Λ\Lambda and the socket with Λ−1\Lambda^{-1}, and only when a plug plugs into a socket do the two sit on the same summed index and multiply to Λ−1Λ=δ\Lambda^{-1}\Lambda=\delta, cancelling exactly. Wire a plug to another plug and you get ΛΛ\Lambda\Lambda 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 δij\delta^{i}{}_{j}. 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 θ\theta has eigenvalues 1,eiθ,e−iθ1,e^{i\theta},e^{-i\theta}, so its trace is 1+2cos⁡θ1+2\cos\theta — 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 1+2cos⁡θ1+2\cos\theta; the off-diagonal entries reshuffle but the contraction does not budge.

Figure
The trace is basis-independent — a 3×3 rotation by angle θ has trace 1 + 2cos θ whatever axis it turns about; the z-rotation by 60° gives tr = 2, and the 120° cyclic rotation has an all-zero diagonal yet tr = 0, both matching 1 + 2cos θ exactly
tr(rotation) = 1 + 2cos θ — the same number in every basis z-rotation, θ = 60° 0.5−0.870 0.870.50 001 tr = 0.5 + 0.5 + 1 = 2 1 + 2cos 60° = 2 120° rotation about (1,1,1) 001 100 010 tr = 0 + 0 + 0 = 0 1 + 2cos 120° = 0 Different bases, different entries, even a zero diagonal — the contraction Aⁱᵢ returns the same eigenvalue sum 1 + 2cos θ every time. eigenvalues of any 3D rotation: 1, e^{iθ}, e^{−iθ}

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.

C:  Ti1…a…ipj1…a…jq  ⟼  ∑aTi1…a…ipj1…a…jq(1)C:\; T^{i_1\dots a \dots i_p}{}_{j_1\dots a \dots j_q}\;\longmapsto\; \sum_{a} T^{i_1\dots a \dots i_p}{}_{j_1\dots a \dots j_q} \qquad (1)

where: TT — a type-(p,q)(p,q) tensor with pp upper and qq lower indices; aa — the repeated (summed) index, one chosen upper slot equated to one chosen lower slot; CC — the contraction map, whose output is type (p−1,q−1)(p-1,q-1). Reading: pick a plug and a socket, wire them together, sum; the degree drops by two. The trace is the case p=q=1p=q=1, the total contraction of an operator. There is only one pair to contract, so the trace is unique and produces a pure number.

tr A=Aii=∑i=1nAii(2)\mathrm{tr}\,A = A^{i}{}_{i} = \sum_{i=1}^{n} A^{i}{}_{i} \qquad (2)

where: AijA^{i}{}_{j} — components of a linear operator on an nn-dimensional space VV; nn — the dimension of VV. 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.

tr(AB)=tr(BA),tr 1n=n(3)\mathrm{tr}(AB) = \mathrm{tr}(BA), \qquad \mathrm{tr}\,\mathbb{1}_{n} = n \qquad (3)

where: A,BA,B — operators (square matrices) on VV; 1n\mathbb{1}_{n} — the n×nn\times n identity, with tr 1n=δii=n\mathrm{tr}\,\mathbb{1}_{n}=\delta^{i}{}_{i}=n. Reading: you may cycle factors inside a trace but not arbitrarily permute them, and tr(ABC)=tr(BCA)=tr(CAB)\mathrm{tr}(ABC)=\mathrm{tr}(BCA)=\mathrm{tr}(CAB). 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.

δij=⟨ei,ej⟩,δii=n(4)\delta^{i}{}_{j} = \langle e^{i}, e_{j}\rangle, \qquad \delta^{i}{}_{i} = n \qquad (4)

where: eje_{j} — a basis vector of VV; eie^{i} — the dual basis covector of V∗V^{*}; ⟨⋅,⋅⟩\langle\cdot,\cdot\rangle — the canonical, metric-free pairing. Reading: δij\delta^{i}{}_{j} is the only (1,1)(1,1) 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 gijg_{ij} lowers its index, and gijgjkg_{ij}g^{jk} returns the delta. This is where inner products and index gymnastics enter as contractions.

gij uivj=⟨u,v⟩,Vi=gijVj,gij gjk=δik(5)g_{ij}\,u^{i}v^{j} = \langle u,v\rangle,\qquad V_{i}=g_{ij}V^{j},\qquad g_{ij}\,g^{jk}=\delta_{i}{}^{k} \qquad (5)

where: gijg_{ij} — the metric (type (0,2)(0,2)); gjkg^{jk} — its inverse (type (2,0)(2,0)); ui,vj,Vju^{i},v^{j},V^{j} — vector components; ViV_{i} — the covariant version obtained by contracting with gg. Reading: raising and lowering indices is nothing but contraction with gijg^{ij} or gijg_{ij}, 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.

Rμν=Rλμλν,R=gμνRμν=Rμμ(6)R_{\mu\nu}=R^{\lambda}{}_{\mu\lambda\nu},\qquad R=g^{\mu\nu}R_{\mu\nu}=R^{\mu}{}_{\mu} \qquad (6)

where: RλμλνR^{\lambda}{}_{\mu\lambda\nu} — the Riemann curvature tensor with its first upper index contracted against its third (lower) index; RμνR_{\mu\nu} — the Ricci tensor; RR — 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.

∇k ⁣(Tii)=δij ∇kTji(7)\nabla_{k}\!\left(T^{i}{}_{i}\right)=\delta^{i}{}_{j}\,\nabla_{k}T^{j}{}_{i} \qquad (7)

where: ∇k\nabla_{k} — the covariant derivative; TjiT^{j}{}_{i} — a (1,1)(1,1) tensor field. Reading: the connection acts on an upper index with +Γ+\Gamma and on a lower index with −Γ-\Gamma, so on a contracted pair the two Christoffel terms cancel and the derivative passes straight through the contraction.

Derivation AInvariance of the trace under a change of basis

The goal is to prove that the single number AiiA^{i}{}_{i} 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 (1,1)(1,1) tensor's components change under a transformation Λ\Lambda: the upper index is carried by Λ\Lambda, the lower by Λ−1\Lambda^{-1}, so A~ij=Λik (Λ−1)lj Akl\tilde A^{i}{}_{j}=\Lambda^{i}{}_{k}\,(\Lambda^{-1})^{l}{}_{j}\,A^{k}{}_{l}. 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 j=ij=i and summing: A~ii=Λik (Λ−1)li Akl\tilde A^{i}{}_{i}=\Lambda^{i}{}_{k}\,(\Lambda^{-1})^{l}{}_{i}\,A^{k}{}_{l}. Why: contraction is what puts Λ\Lambda and Λ−1\Lambda^{-1} on the same summed label — the only place they can meet.

Step 3. Collapse the matched pair: summing (Λ−1)li Λik(\Lambda^{-1})^{l}{}_{i}\,\Lambda^{i}{}_{k} over ii is the matrix product Λ−1Λ=1\Lambda^{-1}\Lambda=\mathbb{1} in index form, (Λ−1)li Λik=δlk(\Lambda^{-1})^{l}{}_{i}\,\Lambda^{i}{}_{k}=\delta^{l}{}_{k}. Why: this is the whole trick — Λ−1Λ=1\Lambda^{-1}\Lambda=\mathbb{1} turns two basis-dependent matrices into a basis-independent delta.

Step 4. Substitute back: A~ii=δlk Akl=Akk\tilde A^{i}{}_{i}=\delta^{l}{}_{k}\,A^{k}{}_{l}=A^{k}{}_{k}, 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 Λ−1Λ=1\Lambda^{-1}\Lambda=\mathbb{1}. Carrying extra free indices along untouched, the same lines prove that any single up-down contraction of a type-(p,q)(p,q) tensor is a genuine type-(p−1,q−1)(p-1,q-1) tensor.*

Go deeper · Derivation B · 1 minWhy two indices of the same variance cannot be contracted
Derivation BWhy 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 (2,0)(2,0) 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 (2,0)(2,0) tensor, whose two contravariant indices are both carried by Λ\Lambda: T~ij=Λim Λjn Tmn\tilde T^{ij}=\Lambda^{i}{}_{m}\,\Lambda^{j}{}_{n}\,T^{mn}. Why: both indices are of the same type, so both pick up Λ\Lambda and neither supplies the inverse Λ−1\Lambda^{-1} that a clean cancellation needs.

Step 2. Set j=ij=i and sum: T~ii=Λim Λin Tmn\tilde T^{ii}=\Lambda^{i}{}_{m}\,\Lambda^{i}{}_{n}\,T^{mn}, whose summed pair is ∑iΛimΛin=(ΛTΛ)mn\sum_{i}\Lambda^{i}{}_{m}\Lambda^{i}{}_{n}=(\Lambda^{\mathsf T}\Lambda)_{mn} — the identity only if Λ\Lambda is orthogonal. Why: with no inverse in the product, the leftover ΛTΛ\Lambda^{\mathsf T}\Lambda is basis-dependent, so T~ii≠Tmm\tilde T^{ii}\neq T^{mm} — the "trace" is a fiction.

Step 3. Repair it with the metric: lower one index, Tij=gjkTikT^{i}{}_{j}=g_{jk}T^{ik}, then contract the now-opposite pair, gijTij=Tiig_{ij}T^{ij}=T^{i}{}_{i}. Why: the metric supplies two factors of Λ−1\Lambda^{-1}, one to pair with each stray Λ\Lambda, restoring the up-against-down structure.

Step 4. Check it is a scalar: with g~ij=(Λ−1)pi(Λ−1)qj gpq\tilde g_{ij}=(\Lambda^{-1})^{p}{}_{i}(\Lambda^{-1})^{q}{}_{j}\,g_{pq}, one gets gijTij~=gpqTpq\widetilde{g_{ij}T^{ij}}=g_{pq}T^{pq}. Why: now every Λ\Lambda finds a Λ−1\Lambda^{-1} to annihilate, which is why gijuivjg_{ij}u^{i}v^{j} is a legitimate inner product while uiviu^{i}v^{i} is not. *In an orthonormal basis under orthogonal Λ\Lambda, ΛTΛ=1\Lambda^{\mathsf T}\Lambda=\mathbb{1} 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
Derivation CThe trace as the sum of the eigenvalues

The aim is to connect the index-level definition AiiA^{i}{}_{i} 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 A=P D P−1A=P\,D\,P^{-1} with D=diag(λ1,…,λn)D=\mathrm{diag}(\lambda_1,\dots,\lambda_n), and use cyclicity to rotate P−1P^{-1} to the front: tr(P D P−1)=tr(P−1P D)\mathrm{tr}(P\,D\,P^{-1})=\mathrm{tr}(P^{-1}P\,D). Why: cyclicity moves the similarity matrices next to their inverses, and is itself just a relabelling of the summed index.

Step 2. Cancel P−1P=1P^{-1}P=\mathbb{1} to reach the diagonal form: tr(P−1P D)=tr D=Dkk\mathrm{tr}(P^{-1}P\,D)=\mathrm{tr}\,D=D^{k}{}_{k}. 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: Dkk=∑k=1nλkD^{k}{}_{k}=\sum_{k=1}^{n}\lambda_{k}. Why: the contraction reads off the spectrum, so tr A=λ1+⋯+λn\mathrm{tr}\,A=\lambda_1+\dots+\lambda_n in any basis. *Equivalently, tr A\mathrm{tr}\,A is the coefficient of (−t)n−1(-t)^{n-1} in det⁡(A−t1)\det(A-t\mathbb{1}), making it the first elementary symmetric function of the eigenvalues. A 3D rotation's eigenvalues 1,eiθ,e−iθ1,e^{i\theta},e^{-i\theta} sum to 1+2cos⁡θ1+2\cos\theta, 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:

CaseResultMeaning
Trace of a matrixAii=tr AA^{i}{}_{i}=\mathrm{tr}\,ATotal contraction of a (1,1)(1,1) tensor; the sum of eigenvalues, invariant under similarity.
Dual pairing / inner productωivi=⟨ω,v⟩\omega_{i}v^{i}=\langle\omega,v\rangleContracting a covector with a vector; with a metric, gijuivjg_{ij}u^{i}v^{j} is the inner product.
Matrix multiplication(AB)ij=AikBkj(AB)^{i}{}_{j}=A^{i}{}_{k}B^{k}{}_{j}Contract one index between two operators; the two surviving indices label the product.
Divergence of a vector field∇iVi=1∣g∣∂i ⁣(∣g∣ Vi)\nabla_{i}V^{i}=\tfrac{1}{\sqrt{\vert g\vert}}\partial_{i}\!\big(\sqrt{\vert g\vert}\,V^{i}\big)Contracting the derivative index of ∇iVj\nabla_i V^j against the field's upper index gives a scalar.
Ricci from RiemannRμν=RλμλνR_{\mu\nu}=R^{\lambda}{}_{\mu\lambda\nu}Contract Riemann's first upper with its third lower index; a second contraction gives R=gμνRμνR=g^{\mu\nu}R_{\mu\nu}.
Kronecker delta, self-contractedδii=n\delta^{i}{}_{i}=nThe full contraction of the identity counts the dimension; it seeds the nn in gijgij=ng^{ij}g_{ij}=n.

Worked examples

1 · The trace of a rotation is a genuine invariant (fully worked)

A proper rotation R∈SO(3)R\in SO(3) turns space about some axis by angle θ\theta. Show that tr R=1+2cos⁡θ\mathrm{tr}\,R=1+2\cos\theta 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 11), and being real has conjugate pairs e±iθe^{\pm i\theta} — so the spectrum is {1,eiθ,e−iθ}\{1,e^{i\theta},e^{-i\theta}\} for every axis. By Derivation 3, tr R=1+eiθ+e−iθ=1+2cos⁡θ\mathrm{tr}\,R=1+e^{i\theta}+e^{-i\theta}=\mathbf{1+2\cos\theta}, with no reference to the axis.

Step 2. Test it on a rotation with a friendly diagonal. Rotating by θ=60∘\theta=60^{\circ} about the zz-axis gives RzR_{z} with diagonal (cos⁡60∘,cos⁡60∘,1)=(0.5,0.5,1)(\cos60^{\circ},\cos60^{\circ},1)=(0.5,0.5,1), so tr Rz=0.5+0.5+1=2\mathrm{tr}\,R_{z}=0.5+0.5+1=\mathbf{2}. The formula predicts 1+2cos⁡60∘=1+2(0.5)=21+2\cos60^{\circ}=1+2(0.5)=2. They agree.

Step 3. Test it on a rotation with a hostile diagonal. The cyclic permutation x→y→z→xx\to y\to z\to x is the matrix with rows (0,0,1),(1,0,0),(0,1,0)(0,0,1),(1,0,0),(0,1,0) — a rotation by 120∘120^{\circ} about the body diagonal (1,1,1)(1,1,1), with det⁡=+1\det=+1, so it lies in SO(3)SO(3). Its diagonal is all zeros, so tr=0+0+0=0\mathrm{tr}=0+0+0=\mathbf{0}, while the formula gives 1+2cos⁡120∘=1+2(−0.5)=01+2\cos120^{\circ}=1+2(-0.5)=0. 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 RiiR^{i}{}_{i} returns the invariant 1+2cos⁡θ1+2\cos\theta 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 aa has metric gθθ=a2g_{\theta\theta}=a^{2}, gϕϕ=a2sin⁡2θg_{\phi\phi}=a^{2}\sin^{2}\theta (diagonal). Its single independent Riemann component corresponds to Gaussian curvature K=1/a2K=1/a^{2}, so the Ricci tensor is Rμν=K gμνR_{\mu\nu}=K\,g_{\mu\nu}. Contract twice to find the scalar curvature.

Step 1. Build the Ricci tensor from the maximally symmetric relation Rμν=K gμν=1a2gμνR_{\mu\nu}=K\,g_{\mu\nu}=\tfrac{1}{a^{2}}g_{\mu\nu}. Component-wise, Rθθ=1a2⋅a2=1R_{\theta\theta}=\tfrac{1}{a^{2}}\cdot a^{2}=\mathbf{1} and Rϕϕ=1a2⋅a2sin⁡2θ=sin⁡2θR_{\phi\phi}=\tfrac{1}{a^{2}}\cdot a^{2}\sin^{2}\theta=\mathbf{\sin^{2}\theta}. This Ricci tensor is itself the first contraction Rμν=RλμλνR_{\mu\nu}=R^{\lambda}{}_{\mu\lambda\nu} of the Riemann tensor.

Step 2. Assemble the inverse metric needed for the second contraction: because gg is diagonal, gθθ=1/a2g^{\theta\theta}=1/a^{2} and gϕϕ=1/(a2sin⁡2θ)g^{\phi\phi}=1/(a^{2}\sin^{2}\theta).

Step 3. Contract Ricci with the inverse metric, R=gμνRμν=gθθRθθ+gϕϕRϕϕR=g^{\mu\nu}R_{\mu\nu}=g^{\theta\theta}R_{\theta\theta}+g^{\phi\phi}R_{\phi\phi}. Substituting, R=1a2⋅1+1a2sin⁡2θ⋅sin⁡2θ=1a2+1a2=2a2R=\dfrac{1}{a^{2}}\cdot 1+\dfrac{1}{a^{2}\sin^{2}\theta}\cdot\sin^{2}\theta=\dfrac{1}{a^{2}}+\dfrac{1}{a^{2}}=\mathbf{\dfrac{2}{a^{2}}}.

Step 4. Sanity-check. The result is a pure number times a−2a^{-2}, as a curvature must be, positive and constant as it should be for a round sphere; the unit sphere a=1a=1 gives R=2R=\mathbf{2}, and it reproduces R=2KR=2K in two dimensions. Contracting Riemann twice has collapsed the entire curvature of the sphere into the single invariant 2/a22/a^{2} — the smaller the sphere, the larger its curvature.

3 · Cyclicity and the Frobenius norm (compact check)

For A=(1234)A=\left(\begin{smallmatrix}1&2\\3&4\end{smallmatrix}\right), B=(0110)B=\left(\begin{smallmatrix}0&1\\1&0\end{smallmatrix}\right): verify cyclicity and read the Frobenius norm as a contraction. Here AB=(2143)AB=\left(\begin{smallmatrix}2&1\\4&3\end{smallmatrix}\right) and BA=(3412)BA=\left(\begin{smallmatrix}3&4\\1&2\end{smallmatrix}\right) share no entries, yet tr(AB)=2+3=5=3+2=tr(BA)\mathrm{tr}(AB)=2+3=\mathbf{5}=3+2=\mathrm{tr}(BA) — cyclicity confirmed. And the full double contraction tr(ATA)=∑i,jAijAij=1+4+9+16=30\mathrm{tr}(A^{\mathsf T}A)=\sum_{i,j}A_{ij}A_{ij}=1+4+9+16=\mathbf{30} is the squared length of AA read as a vector, the same pattern that makes gijuivjg_{ij}u^{i}v^{j} 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
GR
Gregorio Ricci-Curbastro
1853–1925 · founder of the absolute differential calculus (tensor calculus) and the contraction that bears his name

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 Rμν=RλμλνR_{\mu\nu}=R^{\lambda}{}_{\mu\lambda\nu} and again to form R=gμνRμνR=g^{\mu\nu}R_{\mu\nu}, 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.

History
1858
— Cayley's memoir on matrices founds the algebra in which the trace lives
1868
— Riemann's 1854 essay on curvature is published, defining the tensor later contracted to Ricci
1869
— Christoffel formulates covariant differentiation and the Riemann-Christoffel tensor
1900
— Ricci-Curbastro and Levi-Civita codify the absolute differential calculus
1916
— Einstein's general relativity uses the Ricci contraction and introduces the summation convention

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 Λ−1Λ=δ\Lambda^{-1}\Lambda=\delta cancellation underlying each invariance proof; the cyclicity check tr(AB)=tr(BA)=5\mathrm{tr}(AB)=\mathrm{tr}(BA)=5 for the given matrices; the rotation traces 1+2cos⁡60∘=21+2\cos60^{\circ}=2 and 1+2cos⁡120∘=01+2\cos120^{\circ}=0; and the sphere scalar curvature R=gθθRθθ+gϕϕRϕϕ=2/a2R=g^{\theta\theta}R_{\theta\theta}+g^{\phi\phi}R_{\phi\phi}=2/a^{2}.

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-(p,q)(p,q) and a type-(r,s)(r,s) tensor and builds a type-(p+r,q+s)(p+r,q+s) 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 AikBljA^{i}{}_{k}B^{l}{}_{j} followed by contracting kk against ll. 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 (1,1)(1,1) 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 ii in AiiA^{i}{}_{i} is carried by Λ\Lambda and the lower ii by Λ−1\Lambda^{-1}; sharing the summed label, they multiply to δ\delta 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 1+2cos⁡θ1+2\cos\theta, 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 ⟨ei,ej⟩=δij\langle e^{i},e_{j}\rangle=\delta^{i}{}_{j} is built into the definition of a vector space and its dual, so ωivi\omega_{i}v^{i} and AiiA^{i}{}_{i} 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 gijg_{ij}. That is exactly what an inner product gijuivjg_{ij}u^{i}v^{j} 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 δij\delta^{i}{}_{j} — or equivalently gijgijg^{ij}g_{ij} — you get the dimension nn, because you are tracing the identity operator. That fact seeds the factors of nn (or 44 in spacetime) that pepper field theory: gμνgμν=4g^{\mu\nu}g_{\mu\nu}=4, the dimensional factors in Einstein-tensor manipulations, and the counting of degrees of freedom in index sums. When a stray nn appears in a tensor calculation, it almost always came from a δii\delta^{i}{}_{i}.

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 AiiA^{i}{}_{i} rather than ∑iAii\sum_{i}A^{i}{}_{i}. 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, Rμν=RλμλνR_{\mu\nu}=R^{\lambda}{}_{\mu\lambda\nu}, gives the Ricci tensor — the part of curvature that couples to matter — and contracting again, R=gμνRμνR=g^{\mu\nu}R_{\mu\nu}, gives the scalar curvature. Einstein's tensor Gμν=Rμν−12gμνRG_{\mu\nu}=R_{\mu\nu}-\tfrac12 g_{\mu\nu}R is built entirely from these, and its contracted Bianchi identity ∇μGμν=0\nabla^{\mu}G_{\mu\nu}=0 forces energy-momentum conservation. Because contraction commutes with the covariant derivative, every step is coordinate-free — the whole point of general relativity.

Before this

Where this leads