Foundations to Frontier
Tests
A. Mathematical Foundations › A2 Linear Algebra › Vectors and spaces

Linear Maps and Their Matrices

Functions that keep straight lines straight and the origin fixed. Every one of them is a matrix, and every neural-network layer, camera projection and robot Jacobian is built from them.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

A stretchy rubber sheet

Draw a grid of squares on a rubber sheet. Now stretch it, turn it, or slant it, but keep three rules:

  1. the centre pin stays where it is;
  2. straight lines stay straight;
  3. evenly spaced lines stay evenly spaced.

Any change that follows these rules is a linear map. A photocopier zooming to 200%, a picture rotated on your phone, and a shadow cast on the floor are all examples.

The secret: just watch two arrows

Here’s the magic. To know what happens to every point, you only need to know where two arrows go: “one step right” and “one step up”. Everything else follows. Try the presets, then drag the sliders:

Linear map visualiser: a matrix warps the grid
A = [[1.0, 1.0], [0.0, 1.0]]
det A = 1.00 (area scale) · rank = 2
Ae₁Ae₂
The first column of A is where e₁ = (1, 0) lands; the second column is where e₂ = (0, 1) lands. The orange square is the image of the unit square: its area is |det A|.
Why AI cares

Every layer of a neural network starts with a linear map: it stretches, turns and squashes the data’s grid, before a simple bend (the activation function) is applied.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A photocopier at 200% turns a 3 cm line into…
  2. 2. Which is NOT linear?
  3. 3. To know what a linear map does in the plane, you need to know where how many arrows go?

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

Matrix times vector

A 2×22\times2 matrix acts on a vector like this:

(abcd)(xy)=(ax+bycx+dy)\begin{pmatrix} a & b \\ c & d\end{pmatrix}\begin{pmatrix} x \\ y\end{pmatrix} = \begin{pmatrix} ax + by \\ cx + dy\end{pmatrix}

Each output entry is a dot product of a row with the vector. Example. (1101)(12)=(32)\begin{pmatrix}1&1\\0&1\end{pmatrix}\begin{pmatrix}1\\2\end{pmatrix} = \begin{pmatrix}3\\2\end{pmatrix}.

The columns tell you everything

Multiply by e1=(1,0)\mathbf e_1 = (1,0): you get the first column (a,c)(a, c). Multiply by e2=(0,1)\mathbf e_2 = (0,1): you get the second column (b,d)(b, d). So the columns of a matrix are where the basis vectors land. That’s the “two arrows” secret from Level 0.

Map Matrix Where (1,0) goes Where (0,1) goes
Stretch (2003)\begin{pmatrix}2&0\\0&3\end{pmatrix} (2, 0) (0, 3)
Rotate 90° (0−110)\begin{pmatrix}0&-1\\1&0\end{pmatrix} (0, 1) (−1, 0)
Reflect in y-axis (−1001)\begin{pmatrix}-1&0\\0&1\end{pmatrix} (−1, 0) (0, 1)
Shear (1101)\begin{pmatrix}1&1\\0&1\end{pmatrix} (1, 0) (1, 1)
Project onto x-axis (1000)\begin{pmatrix}1&0\\0&0\end{pmatrix} (1, 0) (0, 0)
📝 Quick check (Level 1)
0/3 answered
  1. 1. [[2, 0], [0, 3]] · (1, 1) = ?
  2. 2. [[0, −1], [1, 0]] · (2, 1) = ?
  3. 3. A map sends (1, 0) to (4, 5) and (0, 1) to (1, 2). Its first column is…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.

The definition

Definition

T:V→WT: V \to W is linear if T(au+bv)=aT(u)+bT(v)T(a\mathbf u + b\mathbf v) = aT(\mathbf u) + bT(\mathbf v) for all vectors u,v\mathbf u, \mathbf v and scalars a,ba, b.

Consequences: T(0)=0T(\mathbf 0) = \mathbf 0, lines map to lines (or points), and parallel lines stay parallel.

Every linear map ℝⁿ → ℝᵐ is a matrix

Write x=∑jxjej\mathbf x = \sum_j x_j\mathbf e_j. Linearity gives T(x)=∑jxjT(ej)T(\mathbf x) = \sum_j x_jT(\mathbf e_j). So

T(x)=Ax,A=[ T(e1)  T(e2) ⋯ T(en) ]∈Rm×n.T(\mathbf x) = A\mathbf x, \qquad A = \big[\,T(\mathbf e_1)\ \ T(\mathbf e_2)\ \cdots\ T(\mathbf e_n)\,\big] \in \mathbb{R}^{m\times n}.

AA has mm rows (the output dimension) and nn columns (the input dimension).

Composition is matrix multiplication

“Do BB first, then AA” is the map x↦A(Bx)=(AB)x\mathbf x \mapsto A(B\mathbf x) = (AB)\mathbf x. The product ABAB is defined by (AB)ij=∑kAikBkj(AB)_{ij} = \sum_k A_{ik}B_{kj} (A1-3) precisely so that this works. Two warnings:

  • The order reads right to left: in ABxAB\mathbf x, BB acts first.
  • Order matters: AB≠BAAB \ne BA in general. Rotating then stretching differs from stretching then rotating.
🐍 Exercise 1: build and compose transformations
Write rotation, scale and shear matrices, and first_then(A, B) for the map 'apply A, then B'. The tests show that order matters.

Not everything is linear

Translation x↦x+t\mathbf x\mapsto\mathbf x + \mathbf t isn’t linear, because it moves the origin. Maps of the form Ax+bA\mathbf x + \mathbf b are called affine. Two common ways to handle them:

  • Neural networks: a dense layer computes Wx+bW\mathbf x + \mathbf b, which is affine. The bias lets the layer shift its decision boundary away from the origin.
  • Robotics and graphics: homogeneous coordinates turn affine maps into linear ones in one more dimension: (Rt0⊤1)(x1)=(Rx+t1)\begin{pmatrix}R & \mathbf t\\ \mathbf 0^\top & 1\end{pmatrix}\begin{pmatrix}\mathbf x\\1\end{pmatrix} = \begin{pmatrix}R\mathbf x + \mathbf t\\ 1\end{pmatrix}. Robot poses are then 4×44\times4 matrices that compose by multiplication (R2).

Linear maps everywhere

Where Linear map
Neural networks Dense layers WxW\mathbf x, attention projections WQ,WK,WVW_Q, W_K, W_V, convolutions
Data science Linear regression predictions XβX\boldsymbol\beta, PCA projections, feature standardization (affine)
Robotics Rotations RR. The Jacobian JJ maps joint speeds to hand velocity, x˙=Jq˙\dot{\mathbf x} = J\dot{\mathbf q}
Vision The camera projection matrix in homogeneous coordinates
📝 Quick check (Level 2)
0/3 answered
  1. 1. Is T(x, y) = (x + 1, y) linear?
  2. 2. A maps ℝ⁵ → ℝ³. Its shape is…
  3. 3. A dense layer from 128 inputs to 64 outputs, with bias, has how many parameters?

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

A linear map is decided by a basis

Theorem

Let b1,…,bn\mathbf b_1, \dots, \mathbf b_n be a basis of VV, and w1,…,wn\mathbf w_1,\dots,\mathbf w_n any vectors in WW. There is exactly one linear map with T(bj)=wjT(\mathbf b_j) = \mathbf w_j for all jj.

Proof. Every x\mathbf x is uniquely ∑cjbj\sum c_j\mathbf b_j, so define T(x)=∑cjwjT(\mathbf x) = \sum c_j\mathbf w_j. Uniqueness of coordinates makes this well defined, and it’s linear because coordinates are linear in x\mathbf x. Any linear T′T' with the same values on the basis agrees with TT on every combination of the basis vectors, which is everything. ∎

Why matrix multiplication is composition

Theorem

If S(x)=BxS(\mathbf x) = B\mathbf x and T(y)=AyT(\mathbf y) = A\mathbf y, then (T∘S)(x)=(AB)x(T\circ S)(\mathbf x) = (AB)\mathbf x with (AB)ij=∑kAikBkj(AB)_{ij} = \sum_k A_{ik}B_{kj}.

Proof. (A(Bx))i=∑kAik(Bx)k=∑kAik∑jBkjxj=∑j(∑kAikBkj)xj(A(B\mathbf x))_i = \sum_k A_{ik}(B\mathbf x)_k = \sum_k A_{ik}\sum_j B_{kj}x_j = \sum_j\big(\sum_k A_{ik}B_{kj}\big)x_j. Associativity of matrix multiplication, (AB)C=A(BC)(AB)C = A(BC), is then just associativity of composing functions. ∎

The space of linear maps

The linear maps V→WV\to W form a vector space L(V,W)\mathcal{L}(V, W). With bases chosen, it’s the same as the space of m×nm\times n matrices, so dim⁡L(V,W)=dim⁡V⋅dim⁡W\dim\mathcal{L}(V,W) = \dim V\cdot\dim W.

Change of basis

If TT has matrix AA in the standard basis, then in the basis given by the columns of PP its matrix is P−1APP^{-1}AP. The same map can look complicated in one basis and simple (diagonal!) in another. That’s the motivation for eigenvectors (A2.3).

Exercise 3.1: T(1,0) = (3,1) and T(0,1) = (−1,2). Find T(2,3).

By linearity, T(2,3)=2T(1,0)+3T(0,1)=(6,2)+(−3,6)=(3,8)T(2,3) = 2T(1,0) + 3T(0,1) = (6,2) + (-3,6) = (3,8).

Exercise 3.2: Show that the shear S = [[1, k], [0, 1]] satisfies Sⁿ = [[1, nk], [0, 1]]

By induction: (1nk01)(1k01)=(1(n+1)k01)\begin{pmatrix}1&nk\\0&1\end{pmatrix}\begin{pmatrix}1&k\\0&1\end{pmatrix} = \begin{pmatrix}1&(n+1)k\\0&1\end{pmatrix}.

📝 Quick check (Level 3)
0/3 answered
  1. 1. dim 𝓛(ℝ³, ℝ²) = ?
  2. 2. In ABx, which matrix acts first?
  3. 3. A linear map is completely determined by…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Deep linear networks: one matrix, but not simple learning

Stacking linear layers without activations, W3W2W1xW_3W_2W_1\mathbf x, can only ever compute one linear map, so depth adds no expressive power. Yet Saxe, McClelland and Ganguli (2014) showed that gradient descent on deep linear networks has rich, nonlinear dynamics: plateaus, sudden drops, and learning of the strongest data directions first. Deep linear networks remain a key “solvable model” for understanding how real networks learn (B4). It’s also why a nonlinearity between layers is essential: without it, a 100-layer network collapses to a single matrix.

Convolution is a structured linear map

A 1-D convolution layer multiplies the input by a banded Toeplitz matrix. Each row holds the same kernel, shifted. Weight sharing makes it shift-equivariant: shifting the input shifts the output. Translation symmetry built into a linear map is the core idea of CNNs (E7). Equivariant networks extend it to rotations and other symmetries (E18).

🐍 Exercise 2 (research): a convolution is a matrix
Build the matrix of a 'valid' 1-D convolution (cross-correlation) with a given kernel, check it against np.correlate, and check shift-equivariance.

Linear maps for nonlinear dynamics: the Koopman operator

Koopman (1931) observed that even a nonlinear system xt+1=f(xt)\mathbf x_{t+1} = f(\mathbf x_t) acts linearly on functions of the state (“observables”): (Kg)(x)=g(f(x))(\mathcal{K}g)(\mathbf x) = g(f(\mathbf x)). The catch is that this space of functions is infinite-dimensional. Modern data-driven methods such as dynamic mode decomposition and deep Koopman networks look for a finite set of observables where the dynamics are approximately linear. That enables linear prediction and control of fluids, robots and power grids (J5).

The Jacobian: a robot’s local linear map

For a robot arm, the map from joint angles to hand position is nonlinear. But near any pose, the small changes are related linearly: Δx≈J(q) Δq\Delta\mathbf x \approx J(\mathbf q)\,\Delta\mathbf q. Whitney’s resolved-motion rate control (1969) inverts this linear map to command joint speeds that produce a desired hand velocity, which is the basis of most arm teleoperation and servoing today (R3, S5). At a singular pose (for example, a fully stretched arm), JJ loses rank and some hand directions become impossible (A2.1-6).

References

  1. A. Cayley (1858). “A memoir on the theory of matrices.” Philosophical Transactions of the Royal Society, 148.
  2. B. O. Koopman (1931). “Hamiltonian systems and transformation in Hilbert space.” PNAS, 17(5).
  3. D. Whitney (1969). “Resolved motion rate control of manipulators and human prostheses.” IEEE Transactions on Man-Machine Systems, 10(2).
  4. A. Saxe, J. McClelland, S. Ganguli (2014). “Exact solutions to the nonlinear dynamics of learning in deep linear neural networks.” ICLR.
  5. M. Bronstein, J. Bruna, T. Cohen, P. Veličković (2021). “Geometric deep learning: Grids, groups, graphs, geodesics, and gauges.” arXiv:2104.13478.
  6. S. Axler (2024). Linear Algebra Done Right, 4th ed. Chapter 3.