← Back to Math Roadmap

Tensor Analysis

Multilinear algebra and geometry — the mathematical language of general relativity, continuum mechanics, and deep learning.

What Are Tensors? Beyond Scalars, Vectors, and Matrices

▼
A tensor generalizes the familiar objects of linear algebra to arbitrary dimensions and coordinate transformations. A scalar (a single number like temperature) is a rank-0 tensor — it has the same value in every coordinate system. A vector (like velocity with 3 components) is a rank-1 tensor. A matrix (like the stress on a material with 9 components in 3D) is a rank-2 tensor. But tensors go further: a rank-3 tensor has 27 components (like the piezoelectric tensor relating electric field to mechanical strain), rank-4 has 81 (like the elasticity tensor in continuum mechanics). The defining property of a tensor is its transformation law: when you change coordinates, tensor components transform in a precise multilinear way that ensures physical laws look the same in every reference frame. This is Einstein's principle of general covariance.
Transformation law for a rank-2 covariant tensor. The partial derivatives are the Jacobian of the coordinate change. Indices with Greek letters run over dimensions (0,1,2,3 in spacetime).

Covariant vs Contravariant: The Two Flavors of Indices

▼
Tensor indices come in two types with profound geometric meaning. Contravariant components (superscripts like x^μ) transform OPPOSITELY to basis vectors. They represent vectors like displacement and velocity — quantities you can picture as arrows. Covariant components (subscripts like p_μ) transform the SAME way as basis vectors. They represent covectors (dual vectors) like gradients and momenta — quantities that naturally pair with vectors to produce scalars. The metric tensor g_{μν} converts between the two: it lowers indices (contravariant → covariant), and its inverse g^{μν} raises indices. In flat Euclidean space, the metric is the identity matrix. In curved spacetime, the metric encodes the gravitational field.
The line element. The metric tensor g determines the squared distance between infinitesimally separated points. Summation over repeated upper-lower index pairs (Einstein convention) is implied.

The Einstein Summation Convention

▼
Tensor equations use a brilliant shorthand invented by Einstein: when an index appears twice in a term — once as a superscript and once as a subscript — summation over all its values is IMPLIED. You never write the summation sign! This makes tensor equations elegantly compact. The dot product of two vectors becomes simply u_μ v^μ (implicitly summed over μ from 1 to n). The matrix product C = AB becomes C^μ_ν = A^μ_λ B^λ_ν. Linear algebra operations that take pages in matrix form collapse to single lines in tensor form. This is why tensor analysis is the preferred language of theoretical physics.

Applications: From General Relativity to Deep Learning

▼
Einstein's field equations of general relativity are a tensor equation: G_{μν} = (8πG/c⁴) T_{μν}, where G_{μν} (the Einstein tensor) describes spacetime curvature and T_{μν} (the stress-energy tensor) describes matter and energy. In continuum mechanics, the elasticity tensor C_{ijkl} (81 components, reduced to 21 by symmetry) relates stress to strain. In deep learning, the gradient of a loss function with respect to weight tensors drives training. PyTorch and TensorFlow are named after tensors because neural network operations are fundamentally tensor contractions. The attention mechanism in transformers computes QK^T/√(d_k) — pure tensor algebra.

Tensor Rank Visualizer

▼
Explore how functions change under parameter transformations. While we cannot easily draw rank-3 tensors, the function plotter shows how basis transformations affect shapes — the same principle that governs tensor component transformations.