Physics
Universitymathematical-methods

Tensor Calculus: Covariant and Contravariant Indices

In Cartesian coordinates a vector is just a vector — but the moment the coordinate grid itself is allowed to curve, two different kinds of vector-like object peel apart, and only one carefully built structure transforms correctly between any two coordinate systems at all.

Before this, you should know:

Take two objects that both look like ordinary vectors. The first is a tiny displacement, dxidx^i, an arrow from one nearby point to another. The second is the gradient of some scalar field, ϕ/xi\partial\phi/\partial x^i, built in vector calculus as the object whose dot product with a direction gives the rate of change that way. Both have components labeled by an index ii running over the coordinate directions. Both were treated, on every page of this site so far, as thoroughly interchangeable — you could dot one against the other, add them, rotate them by the same rotation matrix, and nothing ever went wrong.

Nothing ever went wrong because every calculation on this site so far has stayed inside Cartesian coordinates, related to each other only by rotations. Now change the setup: describe the same plane using polar coordinates instead, or imagine a coordinate grid painted onto a curved surface, where there is no way to lay down a single straight Cartesian grid over the whole thing at all. Ask how dxidx^i and ϕ/xi\partial\phi/\partial x^i transform when you switch from one coordinate system to another, and something that was invisible in Cartesian coordinates suddenly matters enormously: they transform by inverse rules. Treat them as interchangeable in a general coordinate system and you get the wrong physics — a computed force, a computed curvature, an entire computed law that silently depends on which coordinate grid you happened to draw, which is precisely the one thing a real physical law must never do. This matters for more than bookkeeping: general relativity describes gravity as the geometry of a spacetime that is actually curved, with no global Cartesian coordinate patch covering it at all — a story for a later topic, but the reason tensor calculus exists as a subject rather than a footnote to linear algebra.

Two transformation laws, told apart

Let xix^i denote a set of coordinates (the superscript is a label, not an exponent — this index-upstairs notation is used everywhere from here on), and let xix'^i denote a different coordinate system covering the same space, related to the first by some smooth, invertible map xi=xi(x1,,xn)x'^i=x'^i(x^1,\ldots,x^n). Differentiating that relationship gives the transformation rule for an ordinary displacement:

dxi=jxixjdxj.dx'^i = \sum_j \frac{\partial x'^i}{\partial x^j}\,dx^j.

Any object ViV^i that transforms this same way under a change of coordinates,

Vi=jxixjVj,V'^i = \sum_j\frac{\partial x'^i}{\partial x^j}V^j,

is called a contravariant vector. The name is not important; what matters is which Jacobian matrix — xi/xj\partial x'^i/\partial x^j, built from the new coordinates differentiated with respect to the old — appears in the rule.

Now do the same for the gradient. The chain rule gives, for any scalar field ϕ\phi,

ϕxi=jϕxjxjxi.\frac{\partial\phi}{\partial x'^i} = \sum_j\frac{\partial\phi}{\partial x^j}\frac{\partial x^j}{\partial x'^i}.

Any object ωi\omega_i that transforms this way,

ωi=jxjxiωj,\omega'_i = \sum_j\frac{\partial x^j}{\partial x'^i}\,\omega_j,

is called a covariant vector, and is conventionally written with the index downstairs. The Jacobian matrix here — xj/xi\partial x^j/\partial x'^i, the old coordinates differentiated with respect to the new — is generally a completely different matrix from the one that governed ViV^i.

Why did this distinction never matter before? Restrict to Cartesian coordinates related only by a rotation RR. The Jacobian matrix xi/xj\partial x'^i/\partial x^j is then simply the constant matrix RR, and — as already shown when linear algebra verified that a rotation matrix satisfies RTR=IR^TR=I — its inverse equals its own transpose. The two transformation rules above, built from a matrix and from that same matrix's inverse-transpose, become numerically identical for an orthogonal RR. Contravariant and covariant components coincide, and the distinction is invisible. Switch to polar coordinates, where the Jacobian varies from point to point and is not even a square rotation of constant vectors, and the two rules genuinely diverge. That divergence is the entire subject of this topic.

Tensors and the Einstein summation convention

A tensor generalizes both of these at once. A tensor of type (p,q)(p,q) is a multilinear object with pp upper (contravariant) indices and qq lower (covariant) indices,

T       j1jqi1ip,T^{i_1\cdots i_p}_{\ \ \ \ \ \ \ j_1\cdots j_q},

transforming under a coordinate change with one factor of xi/xj\partial x'^i/\partial x^j for every upper index and one factor of xj/xi\partial x^j/\partial x'^i for every lower index. A scalar is a (0,0)(0,0) tensor — unchanged by any coordinate transformation, which is exactly what makes a scalar physically meaningful independent of how it's described. A contravariant vector is a (1,0)(1,0) tensor; a covariant vector is a (0,1)(0,1) tensor. "Multilinear" means the object is linear separately in each index it carries — feed it one covector and q1q-1 vectors at a time, say, and it responds linearly to each — the direct generalization of the linear maps already built in linear algebra.

Expressions like the ones above are cluttered with summation signs, and one of Einstein's genuine contributions to notation — not just to physics — was to notice that in every sum that actually shows up, the repeated index always appears once upstairs and once downstairs. The Einstein summation convention simply agrees to drop the \sum sign whenever an index is repeated once up and once down in the same expression:

AiBiiAiBi.A^iB_i \equiv \sum_i A^iB_i.

From here on, a repeated upper-lower index pair is understood to be summed, and an index that is not repeated is a free index, taking on the same value on both sides of an equation. This is not merely a shorthand; the convention only ever pairs an upper index with a lower one because that is precisely the combination that transforms consistently, as the next section makes explicit.

The metric tensor

Contravariant and covariant vectors both describe "vectors" in some sense, but they are different objects living in different spaces, related by different transformation rules. What converts one into the other? The metric tensor gijg_{ij}, a (0,2)(0,2) tensor defined so that the invariant squared distance between two infinitesimally separated points is

ds2=gijdxidxj.ds^2 = g_{ij}\,dx^i\,dx^j.

In ordinary Cartesian coordinates in the plane, gij=δijg_{ij}=\delta_{ij} (that is, g11=g22=1, g12=g21=0g_{11}=g_{22}=1,\ g_{12}=g_{21}=0), reproducing the familiar ds2=dx2+dy2ds^2=dx^2+dy^2. But gijg_{ij} is defined in any coordinate system, and away from Cartesian coordinates it generally is not the identity — which is exactly the tool the worked example below puts to use.

The metric does more than measure distance: it is the tensor that lowers an index, converting a contravariant vector into its covariant counterpart,

Vi=gijVj,V_i = g_{ij}V^j,

and its matrix inverse gijg^{ij} (defined by gijgjk=δkig^{ij}g_{jk}=\delta^i_k, the mixed Kronecker delta, which is 11 if i=ki=k and 00 otherwise) raises an index back:

Vi=gijVj.V^i = g^{ij}V_j.

This is the precise machinery that quietly makes "displacement" and "gradient" into a single unified object once a metric is in play, even though they transform by different rules in isolation.

Two panels comparing basis vectors in different coordinate systems. Left panel: a Cartesian grid with identical unit basis arrows repeated at several points. Right panel: a polar grid of concentric circles and radial spokes, with a short radial basis arrow of constant length at two different points, but a tangential basis arrow that is visibly longer at the larger radius than at the smaller radius.

In Cartesian coordinates the basis vectors are the same arrow everywhere. In polar coordinates the radial basis vector stays unit length, but the tangential basis vector grows with the radius — exactly the position-dependence encoded in the angular-angular component of the metric, which equals the radius squared.

Worked example

Derive the metric tensor for polar coordinates (r,θ)(r,\theta) in the plane, find its inverse, verify the contraction gijgjk=δkig^{ij}g_{jk}=\delta^i_k explicitly, and use the metric to compute the invariant squared speed gijx˙ix˙jg_{ij}\dot x^i\dot x^j of a moving particle. (click to reveal the solution)

Setting up: polar coordinates relate to Cartesian coordinates by

x=rcosθ,y=rsinθ.x = r\cos\theta, \qquad y = r\sin\theta.

Differentiating,

dx=cosθdrrsinθdθ,dy=sinθdr+rcosθdθ.dx = \cos\theta\,dr - r\sin\theta\,d\theta, \qquad dy = \sin\theta\,dr + r\cos\theta\,d\theta.

Deriving the metric components: substitute into the Cartesian line element ds2=dx2+dy2ds^2=dx^2+dy^2:

ds2=(cosθdrrsinθdθ)2+(sinθdr+rcosθdθ)2.ds^2 = (\cos\theta\,dr - r\sin\theta\,d\theta)^2 + (\sin\theta\,dr + r\cos\theta\,d\theta)^2.

Expanding the first square,

cos2θdr22rsinθcosθdrdθ+r2sin2θdθ2,\cos^2\theta\,dr^2 - 2r\sin\theta\cos\theta\,dr\,d\theta + r^2\sin^2\theta\,d\theta^2,

and the second,

sin2θdr2+2rsinθcosθdrdθ+r2cos2θdθ2.\sin^2\theta\,dr^2 + 2r\sin\theta\cos\theta\,dr\,d\theta + r^2\cos^2\theta\,d\theta^2.

The cross terms are equal and opposite, and cancel. Adding what remains,

ds2=(cos2θ+sin2θ)dr2+r2(sin2θ+cos2θ)dθ2=dr2+r2dθ2.ds^2 = (\cos^2\theta+\sin^2\theta)\,dr^2 + r^2(\sin^2\theta+\cos^2\theta)\,d\theta^2 = dr^2 + r^2\,d\theta^2.

Comparing with ds2=gijdxidxjds^2=g_{ij}dx^idx^j where (x1,x2)=(r,θ)(x^1,x^2)=(r,\theta), read off

grr=1,gθθ=r2,grθ=gθr=0.g_{rr}=1,\qquad g_{\theta\theta}=r^2,\qquad g_{r\theta}=g_{\theta r}=0.

As a matrix,

gij=(100r2).g_{ij} = \begin{pmatrix}1&0\\0&r^2\end{pmatrix}.

Finding the inverse metric: since gijg_{ij} is diagonal, its inverse is just the matrix of reciprocals of the diagonal entries:

gij=(1001/r2),that is,grr=1,gθθ=1r2,grθ=gθr=0.g^{ij} = \begin{pmatrix}1&0\\0&1/r^2\end{pmatrix}, \qquad\text{that is,}\qquad g^{rr}=1,\qquad g^{\theta\theta}=\frac{1}{r^2},\qquad g^{r\theta}=g^{\theta r}=0.

Verifying the contraction gijgjk=δkig^{ij}g_{jk}=\delta^i_k explicitly: this is just the statement that the matrices gijg^{ij} and gjkg_{jk} are inverses of one another, checked directly by matrix multiplication:

gijgjk=(1001/r2)(100r2)=(11+0010+0r201+1r2000+1r2r2)=(1001).g^{ij}g_{jk} = \begin{pmatrix}1&0\\0&1/r^2\end{pmatrix}\begin{pmatrix}1&0\\0&r^2\end{pmatrix} = \begin{pmatrix}1\cdot1+0\cdot0 & 1\cdot0+0\cdot r^2\\ 0\cdot1+\frac{1}{r^2}\cdot0 & 0\cdot0+\frac{1}{r^2}\cdot r^2\end{pmatrix} = \begin{pmatrix}1&0\\0&1\end{pmatrix}.

The result is exactly the identity matrix, whose entries are the mixed Kronecker delta δki\delta^i_k (11 on the diagonal, 00 off it). The contraction gijgjk=δkig^{ij}g_{jk}=\delta^i_k holds, confirming that gijg^{ij} really is the matrix inverse the raising-and-lowering machinery requires it to be.

Computing the invariant squared speed: a particle moving through the plane has contravariant velocity components x˙i=(r˙,θ˙)\dot x^i=(\dot r,\dot\theta) — the rates of change of the coordinates themselves, which transform exactly like the dxidx^i that opened this topic. Its invariant squared speed is the scalar built by contracting these components with the metric, gijx˙ix˙jg_{ij}\dot x^i\dot x^j. Writing out the sum over both ii and jj (there are four terms, but the off-diagonal ones vanish since grθ=0g_{r\theta}=0):

gijx˙ix˙j=grrr˙2+gθθθ˙2=r˙2+r2θ˙2.g_{ij}\dot x^i\dot x^j = g_{rr}\dot r^2 + g_{\theta\theta}\dot\theta^2 = \dot r^2 + r^2\dot\theta^2.

This is exactly the familiar formula for the squared speed of a particle in polar coordinates. It was not derived here from a picture of perpendicular radial and tangential velocity components; it fell directly out of contracting the coordinate velocity with the metric tensor computed above — the same formula, produced by a completely general piece of machinery that works in any coordinate system once you know gijg_{ij}, not just in the one you happen to already have a geometric picture for.

Where this leads

The metric tensor did more work in that worked example than it may have looked: it converted the bare coordinate velocity x˙i\dot x^i, which by itself carries no notion of length at all, into a single physically meaningful number, the speed. That is the entire point of building tensors in the first place — physical quantities like speed, curvature, or energy density must come out the same regardless of which coordinate grid was used to compute them, and a quantity assembled by fully contracting tensor indices (upper against lower, exactly as the summation convention insists) is guaranteed to do exactly that, in any coordinate system whatsoever, curved or flat.

That guarantee is precisely why tensors, and no lesser structure, are the language general relativity is written in: spacetime there is genuinely curved, with no single Cartesian grid covering it globally, so a law of physics had better be built entirely out of objects that transform correctly between any two of its coordinate patches. This topic developed exactly that machinery, in the tamest possible curved-coordinate setting — polar coordinates on a flat plane — as the warm-up act for a much bigger stage still to come.