← Module 01 / Getting started & notation

Lesson 01.4 · §2 Column-vector convention

Let dimensions catch mistakes

Before calculating, check whether the pieces can fit together.

In this lesson 5 ideas
  1. Shapes are a first line of defense
  2. Match the inside. Keep the outside.
  3. Three operations, three checks
  4. Apply the check to a familiar scalar
  5. You can now read the next chapter

Shapes are a first line of defense

Suppose A\mathbf A has 2 rows and 3 columns. It can turn a three-coordinate input into a two-coordinate output. Each output coordinate comes from one row of A\mathbf A paired with all three input coordinates.

[123456]⏟2×3[102]⏟3×1=[716]⏟2×1.\underbrace{\begin{bmatrix}1&2&3\\4&5&6\end{bmatrix}}_{2\times3} \underbrace{\begin{bmatrix}1\\0\\2\end{bmatrix}}_{3\times1} =\underbrace{\begin{bmatrix}7\\16\end{bmatrix}}_{2\times1}.

The first output is 1⋅1+2⋅0+3⋅2=71\cdot1+2\cdot0+3\cdot2=7. The second is 4⋅1+5⋅0+6⋅2=164\cdot1+5\cdot0+6\cdot2=16. Each row needs exactly as many entries as the input provides.

Match the inside. Keep the outside.

Explore it yourself

Can these shapes connect?

Matrix multiplication pairs a row with a column. The two inner dimensions must match.

Preparing interactive controls…

A2 × 3×B3 × 1=AB2 × 1

Inner dimensions agree: 3 = 3. Result: 2 rows, 1 columns.

Try an output entry. Here Aᵢₖ = i + k − 1 and Bₖⱼ = k + j − 1 (indices start at 1).

(AB) at (1, 1) = 1 × 1 + 2 × 2 + 3 × 3 = 14

For matrices A∈Rm×n\mathbf A\in\mathbb R^{m\times n} and B∈Rp×q\mathbf B\in\mathbb R^{p\times q}, the product AB\mathbf A\mathbf B is defined when n=pn=p. Its result then has shape m×qm\times q.

(m×n)⏟A  (n×q)⏟B⟶m×q.\underbrace{(m\times n)}_{\mathbf A}\;\underbrace{(n\times q)}_{\mathbf B} \quad\longrightarrow\quad m\times q.

“Match the inside, keep the outside” is a memory aid. The reason is a row–column dot product: a row with n values must pair with a column with n values. Click the output cells to inspect the actual calculation, not only the shape.

Three operations, three checks

OperationRequirementResult
A+B\mathbf A+\mathbf BSame number of rows and columnsSame shape
αA\alpha\mathbf Aα\alpha is a scalarSame shape as A
AB\mathbf A\mathbf BA’s column count equals B’s row countA’s row count by B’s column count

If A\mathbf A is 2×32\times3 and B\mathbf B is 3×43\times4, then AB\mathbf A\mathbf B exists and is 2×42\times4. The reverse product BA\mathbf B\mathbf A is not defined because 4 and 2 do not match. Even when both orders are defined, their values need not agree.

Matching dimensions does not prove a calculation is correct. It only rules out one kind of mistake. A wrong formula can still have the right shape.

Apply the check to a familiar scalar

For column vectors x,y∈Rn\mathbf x,\mathbf y\in\mathbb R^n, the expression x⊤y\mathbf x^\top\mathbf y multiplies a 1×n1\times n row by an n×1n\times1 column. The result is a scalar:

x⊤y=∑i=1nxiyi.\mathbf x^\top\mathbf y=\sum_{i=1}^{n}x_i y_i.

For x=(2,1)⊤\mathbf x=(2,1)^\top and y=(3,4)⊤\mathbf y=(3,4)^\top, it equals 2⋅3+1⋅4=102\cdot3+1\cdot4=10. Module 2 will connect this calculation to angles and projections.

Make a prediction

A is 3 × 2 and B is 2 × 4. What shape is AB?

You can now read the next chapter

You can distinguish objects, translate notation, and check dimensions. Next comes the deeper question: what makes a collection of vectors a vector space? Modules beyond these foundations are still being developed; the existing vector-scaling sample offers a first preview.