Vectors, Matrices & Linear Maps

Vectors encode states and directions, while matrices encode linear input–output rules. This chapter derives matrix multiplication from composition, explains rows, columns, units, order, and linear systems, and separates the mathematical operation from algorithms that compute it.

Vectors and matrices are not special kinds of tables. A vector is a state, direction, or collection of quantities described in a declared coordinate system. A matrix is a rule that turns one vector into another while preserving addition and scaling. Its entries acquire meaning only after the input order, output order, basis, and units are named.

Matrix multiplication looks arbitrary when taught as a recipe, but it is forced by one requirement: the matrix for two rules composed in sequence must produce the same result as running those rules one after another.

Vectors need semantics and units #

A coordinate vector

x=[x1x2⋮xn]x=\begin{bmatrix}x_1\\x_2\\\vdots\\x_n\end{bmatrix}

is an ordered list only after its coordinates have been declared. The same array [3,2]T[3,2]^{\mathsf T} could mean a point at three metres east and two metres north, three units of product A and two of product B, or two sensor readings. Those are different vectors in different models even though the stored numbers match.

Vector addition combines like coordinates:

x+y=[x1+y1⋮xn+yn].x+y= \begin{bmatrix}x_1+y_1\\\vdots\\x_n+y_n\end{bmatrix}.

Multiplication by a positive scalar changes magnitude without changing direction or coordinate proportions. A negative scalar reverses direction, and zero collapses the vector to the zero vector. These operations are meaningful only when the coordinate systems and units are compatible. Adding a position vector to a temperature vector is not repaired by the fact that both arrays have length three.

Dot products are weighted totals and alignment #

For vectors a,b∈Rna,b\in\mathbb R^n, their dot product is

aTb=∑k=1nakbk.a^{\mathsf T}b=\sum_{k=1}^n a_kb_k.

It has two complementary meanings.

  • As a weighted total, aka_k is the weight applied to input bkb_k.
  • For nonzero vectors, as alignment, aTb=∥a∥ ∥b∥cos⁡θa^{\mathsf T}b=\|a\|\,\|b\|\cos\theta measures how much one vector points along the other.

For example, if quantities are q=(3,2)q=(3,2) units and unit prices are p=(4,20)p=(4,20) euros per unit, then

pTq=4(3)+20(2)=52 euros.p^{\mathsf T}q=4(3)+20(2)=52\ \text{euros}.

The multiplication pairs corresponding coordinates; the addition accumulates their contributions into one output. Matrix multiplication repeats this same weighted-total mechanism for many outputs at once.

A matrix is a linear map #

An m×nm\times n matrix AA accepts an nn-coordinate input and produces an mm-coordinate output:

y=Ax,yi=∑j=1naijxj.y=Ax, \qquad y_i=\sum_{j=1}^n a_{ij}x_j.

Each row of AA is the weighted recipe for one output coordinate. Each column is the output produced by one input basis vector. This second view follows because

Ax=x1A:1+x2A:2+⋯+xnA:n.Ax=x_1A_{:1}+x_2A_{:2}+\cdots+x_nA_{:n}.

The map is linear because it preserves combinations:

A(x+y)=Ax+Ay,A(αx)=αAx.A(x+y)=Ax+Ay, \qquad A(\alpha x)=\alpha Ax.

For example,

R=[0−110]R=\begin{bmatrix}0&-1\\1&0\end{bmatrix}

rotates the plane by 90∘90^\circ counterclockwise. Its first column says where the input basis vector (1,0)(1,0) goes; its second says where (0,1)(0,1) goes. Thus

R[31]=3[01]+1[−10]=[−13].R\begin{bmatrix}3\\1\end{bmatrix} =3\begin{bmatrix}0\\1\end{bmatrix} +1\begin{bmatrix}-1\\0\end{bmatrix} =\begin{bmatrix}-1\\3\end{bmatrix}.

Translation is not linear because it does not keep the zero vector fixed. A rule x↦Ax+bx\mapsto Ax+b is affine; homogeneous coordinates let graphics and robotics package that extra offset into a larger matrix.

Why multiplication is row by column #

Let B∈Rp×nB\in\mathbb R^{p\times n} turn nn inputs into pp intermediate quantities, and let A∈Rm×pA\in\mathbb R^{m\times p} turn those quantities into mm outputs. If y=Bxy=Bx and z=Ayz=Ay, then

zi=∑kaikyk=∑kaik∑jbkjxj=∑j(∑kaikbkj)xj.z_i=\sum_k a_{ik}y_k =\sum_k a_{ik}\sum_j b_{kj}x_j =\sum_j\left(\sum_k a_{ik}b_{kj}\right)x_j.

Therefore the one matrix that performs the combined map is ABAB, with

(AB)ij=∑k=1paikbkj.(AB)_{ij}=\sum_{k=1}^{p}a_{ik}b_{kj}.

The shared index kk is not bookkeeping: it names the intermediate channels created by BB and consumed by AA. Along each path j→k→ij\to k\to i, effects multiply; parallel paths add. That wiring is why the rule is row by column. An elementwise product cannot represent composition.

Equivalently, column jj of ABAB is AA applied to column jj of BB:

(AB):j=A(B:j).(AB)_{:j}=A(B_{:j}).

The dimensions encode the same contract:

(m×p)(p×n)=(m×n).(m\times p)(p\times n)=(m\times n).

The two occurrences of pp are the common intermediate coordinate system.

A product–resource–cost pipeline #

Suppose

x=[32]x=\begin{bmatrix}3\\2\end{bmatrix}

means three units of product A and two of product B. Let

B=[2113]B=\begin{bmatrix}2&1\\1&3\end{bmatrix}

describe kilograms of material per product unit in its first row and labour-hours per product unit in its second. Then

Bx=[8 kg9 h].Bx=\begin{bmatrix}8\ \mathrm{kg}\\9\ \mathrm h\end{bmatrix}.

If material costs €4/kg and labour costs €20/h, use

cT=[420].c^{\mathsf T}=\begin{bmatrix}4&20\end{bmatrix}.

The composed row, measured in euros per product unit, is

cTB=[2864],c^{\mathsf T}B=\begin{bmatrix}28&64\end{bmatrix},

so

cTBx=28(3)+64(2)=212 EUR.c^{\mathsf T}Bx=28(3)+64(2)=212\ \mathrm{EUR}.

The row-by-column rule has composed two real pipelines: products into resources, then resources into cost. Shapes and units expose a reversed or meaningless multiplication before arithmetic begins.

Matrix multiplication as composition A product vector passes through a resource matrix and a cost row to produce total cost. Below, stretching then rotating a point and rotating then stretching it produce different coordinates. Composition connects compatible quantities Products → resources → cost x = (3, 2) product A, B units B resources per product Bx = (8, 9) kg material labour-hours cᵀ €/kg €/hour €212 total cᵀB = (€28, €64) per product Order changes the composed map The rightmost matrix acts first RSx x = (1, 2) S: stretch (2, 2) R: rotate (−2, 2) SRx x = (1, 2) R: rotate (−2, 1) S: stretch (−4, 1) same input different output
Matrix multiplication composes compatible channels: products flow through resource use into cost, while a stretch and rotation give different coordinates when their order is reversed.

Composition order matters #

Let

S=[2001],R=[0−110],x=[12].S=\begin{bmatrix}2&0\\0&1\end{bmatrix}, \qquad R=\begin{bmatrix}0&-1\\1&0\end{bmatrix}, \qquad x=\begin{bmatrix}1\\2\end{bmatrix}.

Stretching horizontally and then rotating gives

RSx=R[22]=[−22].RSx=R\begin{bmatrix}2\\2\end{bmatrix} =\begin{bmatrix}-2\\2\end{bmatrix}.

Rotating first and then stretching gives

SRx=S[−21]=[−41].SRx=S\begin{bmatrix}-2\\1\end{bmatrix} =\begin{bmatrix}-4\\1\end{bmatrix}.

In RSxRSx, the rightmost map SS acts first. Matrix multiplication is generally not commutative because resizing and rotating an image, calibrating and mixing sensor channels, or passing through two physical stages depends on order. It is associative:

(AB)C=A(BC),(AB)C=A(BC),

because either parenthesization represents the same three-stage composition.

The operation and its algorithms are different objects #

For A∈Rm×pA\in\mathbb R^{m\times p} and B∈Rp×nB\in\mathbb R^{p\times n}, the direct three-loop algorithm performs mnpmnp scalar multiplications plus a comparable number of additions, so its arithmetic work scales as O(mnp)O(mnp). Reordering loops or multiplying blocks can greatly improve memory locality without changing the definition of ABAB. Special algorithms may reduce arithmetic for sufficiently large matrices, but they still owe the same mathematical product, subject to floating-point rounding.

This distinction recurs throughout mathematics: a formula specifies the object; an algorithm specifies the steps, work, storage, and numerical path used to obtain it. The DFT and FFT are a particularly clear example.

Linear systems are inverse questions #

Forward multiplication asks: given the input xx, what output b=Axb=Ax follows? A linear system asks the inverse question: which input could have produced an observed output bb?

Suppose x1x_1 standard and x2x_2 premium tickets satisfy

x1+x2=7,2x1+x2=11.x_1+x_2=7, \qquad 2x_1+x_2=11.

In matrix form,

[1121][x1x2]=[711].\begin{bmatrix}1&1\\2&1\end{bmatrix} \begin{bmatrix}x_1\\x_2\end{bmatrix} =\begin{bmatrix}7\\11\end{bmatrix}.

Subtracting the first equation from the second gives x1=4x_1=4, then x2=3x_2=3. The matrix records two measurement rules; solving reconciles both at once.

A square matrix has an inverse only when different inputs cannot collapse to the same output. More generally, a system may have no solution, one solution, or infinitely many. Elimination exposes which case applies and is normally preferable to explicitly forming A−1A^{-1} in numerical work.

Where the same operation appears #

Model Vector means Matrix means Composition means
graphics and camera geometry point or direction coordinates rotate, scale, or act on homogeneous coordinates before perspective division combine stages into one transform
sensor calibration raw channels gains and cross-channel mixing raw readings to calibrated outputs
production planning product quantities resource use per product products to resources to total cost
linear ODEs and control system state instantaneous coupling between state variables state evolution and coordinate changes
Fourier analysis samples or coefficients correlations with basis waves transform and reconstruct coordinates
neural-network layer feature activations learned weighted combinations linear maps separated by nonlinearities

Matrices recur because all these models use weighted sums and composable linear channels. This does not mean every rectangular dataset is intrinsically a linear map. The interpretation, units, and chosen input/output spaces create the mathematics.

Diagnostic checklist #

  • Name every vector's coordinate order, basis, and units.
  • For AxAx, verify that the number of columns of AA matches the input length.
  • Read rows as output recipes and columns as basis-vector images.
  • For ABAB, say which map acts first and name the intermediate space.
  • Use a tiny vector to test composition order; do not assume AB=BAAB=BA.
  • Distinguish matrix multiplication from elementwise multiplication.
  • Treat Ax=bAx=b as a question about existence and uniqueness, not as an order to compute an inverse blindly.
  • Separate the mathematical operation from the algorithm, data layout, and floating-point implementation used to compute it.
  • Check whether an offset makes the model affine rather than linear.

The row-by-column rule becomes memorable only after its job is clear: it is the unique bookkeeping that makes a composed chain of linear input–output rules behave like the chain itself.

Sources

  1. docsMIT OpenCourseWare 18.06SC — Multiplication and Inverse Matrices
  2. docsMIT OpenCourseWare 18.06SC — Linear Transformations and Their Matrices
  3. docsOpenCV — Affine Transformations

Searches titles, aliases, headings, summaries, and full text.↑↓ move ↵ open esc close