Skip to content
mlmentorship

Matrices as linear maps

A matrix sends input basis vectors to its columns. Weight those columns to find any output and identify directions that collapse.

Published · 6 min read ·Core ·Foundation
Reading depth

Summary

A matrix describes a linear map. Its columns say where the input basis vectors land. The same weights that build an input also combine its column images.

Consider and the nonzero input . Can its output be zero? Can we predict that output from the two column arrows?

The geometry

Let and be the input basis vectors. Their images are columns and . The second column is twice the first. Both point along one output line.

Learning objective

A nonzero input can collapse to zero when matrix columns are dependent

Dependent columns can cancel a nonzero inputIf both matrix columns are (1,1), input coefficients (1,-1) produce zero. A nonzero input need not survive the linear map.A nonzero input can travel out andbackOne column contribution cancels theother(1,-1) in. Zero out.
Derivation
A rank-one matrix maps basis vectors to its columns and collapses a nonzero input The matrix has rows (1, 2) and (1, 2). Basis vectors map to columns a1 = (1, 1) and a2 = (2, 2). The nonzero input x = (2, -1) equals twice e1 minus e2. Its output is twice a1 minus a2, which is zero. Both columns lie on the output line y = x. 1 · Read x in the input basis x = (2, −1) = 2e₁ − e₂ e₁ axis e₂ axis e₁ e₂ x ≠ 0 2 · Use the same weights on A's columns A = [[1, 2], [1, 2]] · Ae₁ = a₁ · Ae₂ = a₂ range(A): y = x a₁ = (1, 1) a₂ = (2, 2) = 2a₁ then subtract a₂ Ax = 2a₁ − a₂ = (0, 0) x is in null(A)
Read it this way: use the input's weights on the column arrows. Twice the first column equals the second, so subtraction reaches zero. The input was nonzero; this map loses one direction.
Check: How can x be nonzero while 2a1-a2 is zero? What does that reveal about A?
Read it this way: If both matrix columns are (1,1), input coefficients (1,-1) produce zero. A nonzero input need not survive the linear map.
Can a nonzero coefficient vector disappear under dependent columns?

Original coordinate construction checked against MIT 18.022, Peter Selinger's CC BY 4.0 Matrix Theory and Linear Algebra, and Boyd and Vandenberghe's Introduction to Applied Linear Algebra.

Work one output

Write . Linearity gives

For any input , the output is . Thus the range is the line spanned by . The null space contains every multiple of . Check : column weighting and ordinary multiplication both give .

General form and shapes

With input coordinates and output coordinates, and . Linearity means for inputs and scalar weights . Since , we get .

  • The column space, or range, contains all outputs. It lies in .
  • Each row computes one output coordinate as a linear functional. The row space lies in .
  • The null space, or kernel, is . These input directions disappear.
  • Rank is the column-space dimension, equal to the row-space dimension.

Rank plus null-space dimension equals . Here . Independent columns prevent input information loss. A square matrix with independent columns is also onto and invertible.

Change the map

1. Produce three coordinates

New task: send the same two input coordinates to a three-coordinate output.

Picture and change: choose columns and . Keep the input weights .

Check: . The columns are independent, so no nonzero input collapses. The map is not onto all of .

Use when: a layer changes feature count. Inputs count columns; outputs count rows.

2. Add an output offset

New task: compute with .

Picture and change: combine columns as before, then translate the result by . The complete map is affine, not linear.

Check: and . Its values at basis vectors are no longer simply the columns of .

Use when: a fixed bias displaces the origin.

Composition and multiplication

For of shape and of shape , applying then gives . The result has shape . Associativity follows from composition: . Reversing the maps generally changes the result.

A projection need not be perpendicular

Let . It satisfies , but sends to . Its kernel is the line spanned by , not the perpendicular complement of its range. For an orthogonal projection, also require .

Try reversing two maps

Let and . Compare with .

Check your answer

, so . But , so . The order changes the output.

Special families

MatrixGeometric action
Orthogonal ()Rotation or reflection (preserves length and angle)
DiagonalIndependent scaling along each axis
SymmetricHas real eigenvalues; orthogonal eigenvector basis
Positive definiteSymmetric + all eigenvalues > 0; defines an inner product
PermutationReorders coordinates
Projection ()Maps onto its range along its kernel; orthogonal only when also symmetric

Common pitfalls

  • Treating matrix multiplication as element-wise. Use Hadamard () for element-wise; matrix multiplication is composition.
  • Forgetting that shapes determine the map. is a map , not the other way around.
  • Confusing column space with row space. Both have dimension = rank, but they live in different spaces ( vs ).

A fixed-weight dense operation is linear. Adding bias makes it affine; applying a nonlinear activation changes the map again. Neural networks and input-dependent attention are not generally linear functions of their inputs.