Skip to main content
Mathematics
LINEAR ALGEBRA · A ROW MEETS A COLUMN

A row meets a column

Suppose an arrow goes one unit right and two units up from the origin, the point we count from. Its tip has coordinates (1,2)(1,2). Now apply one rule to every point of the plane at once. How can a small table of numbers tell us where the arrow ends up?

The matrices and linear transformations page records the new positions of (1,0)(1,0) and (0,1)(0,1) in two columns. This table is a matrix. A vector is a combination of those two basic directions, so the columns also determine its new position. Each multiplication and addition here must correspond to part of that combination. With two matrices, the question remains: where does each basic direction finally go?

01What does a matrix move?

I =
1001
→
A =
2131

The arrow (1,0)(1,0) becomes (2,3)(2,3), the first column. The arrow (0,1)(0,1) becomes (1,1)(1,1), the second. II is the identity matrix: its columns leave the two arrows where they were.

Here a vector tells us how far to move horizontally and vertically. We draw it as an arrow from the origin. Starting at the origin, (x,y)(x,y) reaches the point with coordinates (x,y)(x,y). Here xx is the horizontal amount and yy the vertical amount. Positive amounts go right or up; negative amounts go left or down. We can build it in two parts: x(1,0)=(x,0)x(1,0)=(x,0) and y(0,1)=(0,y)y(0,1)=(0,y). Adding gives (x,0)+(0,y)=(x,y)(x,0)+(0,y)=(x,y).We now use a rule that preserves these combinations: keep the two multipliers and replace the basic arrows with their new positions. Such a rule is called a linear transformation. The columns tell us those positions. A negative multiplier reverses an arrow; a fraction takes that fraction of its length.

x =
12
→
A x =
45

With x=1x=1 and y=2y=2, the recipe gives (4,5)(4,5): one copy of the first column and two of the second.

First scale the columns: 1(2,3)=(2,3)1(2,3)=(2,3) and 2(1,1)=(2,2)2(1,1)=(2,2). Then add: (2,3)+(2,2)=(4,5)(2,3)+(2,2)=(4,5).

02Why columns, not rows?

Let us name the four entries and write the input vertically:A=(abcd),x=(xy).A=\begin{pmatrix}a&b\\c&d\end{pmatrix},\qquad \mathbf{x}=\begin{pmatrix}x\\y\end{pmatrix}.The bold symbol x\mathbf{x} names the whole vector; plain xx and yy name its two components. Writing the entries vertically makes it a column vector. Turning the column into a row is called taking its transpose, written xT=(x y)\mathbf{x}^{T}=(x\ y).Why use the columns of AA? We chose to put the two new basic arrows in its columns and to write the input as a column. Keeping the same multipliers therefore gives:Ax=x(ac)+y(bd).A\mathbf{x}=x\begin{pmatrix}a\\c\end{pmatrix}+y\begin{pmatrix}b\\d\end{pmatrix}.

Multiply each column by its coefficient. Adding the matching components of those two results gives the output. We can write out both operations.

x(a,c)=(ax,cx)x(a,c)=(ax,cx)y(b,d)=(by,dy)y(b,d)=(by,dy)Each multiplier acts on both entries of its column.

Add matching components: the first components give ax+byax+by, and the second give cx+dycx+dy. Thus (ax,cx)+(by,dy)=(ax+by,cx+dy).(ax,cx)+(by,dy)=(ax+by,cx+dy).

A(2×2)·x(2×1)=b (2×1)
A x =
45

Look at the first output, ax+byax+by. It pairs x,yx,y with a,ba,b, the first row of AA. The second output, cx+dycx+dy, pairs the same x,yx,y with c,dc,d, the second row.Multiplying matching entries and adding the products is called a dot product. For example, (1,2)⋅(2,1)=1×2+2×1=4(1,2)\cdot(2,1)=1\times2+2\times1=4. If the two pairs of entries are (u,v)(u,v) and (s,t)(s,t), we write (u,v)⋅(s,t)=us+vt(u,v)\cdot(s,t)=us+vt. This gives another way to calculate the column combination we just derived. The dot product also has a geometric interpretation; we only need its calculation here.

The sizes must match: if AA has two columns, xx must have two entries. A 2×22×2 matrix times a three-entry vector is not defined; there is no third column to take.

03Lift x above A

We will calculate Ax=bA\mathbf{x}=\mathbf{b} using the same matrix and input as before. The two output entries are b1b_1 and b2b_2, counted from the top.Press Play, or use the arrows and the step slider to inspect one step. The blue-green numbers belong to the input vector, labelled x\mathbf{x}; the other numbers come from AA. The original vector rises and opens into a row above AA. Each component meets an entry of the highlighted row, with a multiplication sign between them. Both numbers move together and become their product. The two products then move together, become their sum, and travel into the output.Before the next row, the input vector returns so we can use it again. Each row stays in its original position until its entries merge. The consumed matrix entries return when both outputs are complete. Pause freezes the movement; the arrows and slider show the end of each separate step. Moving and transposing numbers here is a way to inspect the calculation; the original product is still a matrix times a column vector.

A xStart with A and the column x
1 / 16
Start with A and the column x
1 / 16
A(12)=(??)A\begin{pmatrix}1\\2\end{pmatrix}=\begin{pmatrix}?\\?\end{pmatrix}

The first row gives 1×2+2×1=2+2=41\times2+2\times1=2+2=4. The second gives 1×3+2×1=3+2=51\times3+2\times1=3+2=5. Reading the two sums from top to bottom gives b=(4,5)\mathbf{b}=(4,5).

04The row on the left: xA

What if the vector is on the left? For our 2×22\times2 matrix, a 2×12\times1 column on the left would not fit: its one column cannot match the two rows of AA. In this section, we use the same two numbers in a row instead. We now let x=(x y)\mathbf{x}=(x\ y) name that row vector.Take its entries one at a time. The first entry multiplies the first row of AA, and the second multiplies the second row. Then add the two rows:xA=x(a,b)+y(c,d).\mathbf{x}A=x(a,b)+y(c,d).x(a,b)=(ax,bx),y(c,d)=(cy,dy).x(a,b)=(ax,bx),\qquad y(c,d)=(cy,dy).xA=(ax+cy,  bx+dy).\mathbf{x}A=(ax+cy,\;bx+dy).The first output pairs x,yx,y with the first column (a,c)(a,c); the second pairs them with the second column (b,d)(b,d). So we can again calculate dot products. The output is a row because we added two rows of the same length.Call the output row c=(c1 c2)\mathbf{c}=(c_1\ c_2). The subscripts count its entries from left to right.

x AStart with the row x and A
1 / 16
Start with the row x and A
1 / 16
(12)A=(??)\begin{pmatrix}1&2\end{pmatrix}A=\begin{pmatrix}?&?\end{pmatrix}

In this animation, the input row turns into a column and moves beside each column of AA. Matching entries meet from left and right. Each column of AA stays in place until its entries merge. The products merge vertically, and their sum moves down into the output row. The input returns for the next column; the original matrix and row vector return at the end. This temporary turn only shows the pairs: the input in the original multiplication is still a row. The original multiplication remains a row vector times a matrix. The sums are 1×2+2×3=81\times2+2\times3=8 and 1×1+2×1=31\times1+2\times1=3, so the output row is (8,3)(8,3).So far, a matrix on the left gives one sum for each of its rows; a matrix on the right gives one sum for each of its columns. We can now combine these two readings for two matrices.

05Matrix times matrix

Let AA have mm rows and nn columns, and BB have nn rows and kk columns. We write their product as C=ABC=AB.First take row 1 of AA as a row vector. As we just saw, multiplying it by BB gives one output for each column of BB. These kk numbers form row 1 of CC. Repeat for each of the mm rows of AA: CC has mm rows and kk columns.To find just one entry, choose its row number ii and column number jj. We write this entry as CijC_{ij}. Row ii of AA supplies the row of the answer; column jj of BB supplies its position within that row. Multiply the matching entries and add:

Cij=∑r=1nAirBrjC_{ij}=\sum_{r=1}^{n}A_{ir}B_{rj}

The large symbol ∑\sum means add all the terms. The index rr counts matching positions, from 11 to nn. Written out, the same formula is:Cij=Ai1B1j+Ai2B2j+⋯+AinBnj.C_{ij}=A_{i1}B_{1j}+A_{i2}B_{2j}+\cdots+A_{in}B_{nj}.If n=1n=1, there is only the first product.For example, C21C_{21} uses row 2 of AA and column 1 of BB. Row 2 determines the output row; column 1 picks its first entry.We can also read by columns. Treat column jj of BB as one column vector. Multiplying AA by it gives one output for each row of AA, exactly column jj of CC. Repeating for every column builds the same matrix.Why must the inner sizes match? Each column of BB has nn entries, one multiplier for each of the nn columns of AA. If those counts differ, at least one entry has no partner. In a row dot product, it is the same missing pair.

A =
2131
×
B =
1234
=
C =
5???
Row 1 of A · column 1 of B
2×1+1×3=2+3=52\times1+1\times3=2+3=5
1 / 4
A(m×n)·B(n×k)=C(m×k)

The two inner counts must agree. The outer counts give the output shape. For example, a 2×32\times3 matrix times a 3×43\times4 matrix gives a 2×42\times4 matrix.Order also matters when both products are defined. In our example, (AB)11=2×1+1×3=5(AB)_{11}=2\times1+1\times3=5, but (BA)11=1×2+2×3=8(BA)_{11}=1\times2+2\times3=8. One unequal entry is enough to show AB≠BAAB\ne BA. This is why matrix multiplication is not commutative in general.

One product, three readings

Ax

A column vector meets the rows of A; the output is a column.

xA

A row vector meets the columns of A; the output is a row.

AB

Every row of A meets every column of B; the entries of C are the dot products.

Check yourself

A is 2×32×3 and B is 3×43×4. What is the shape of ABAB, and which entries make C23C_{23}?

There are 2 choices of row from A and 4 choices of column from B, so AB is 2×42\times4. C23C_{23} uses row 2 of A and column 3 of B. Each has three entries, so we add three products:C23=A21B13+A22B23+A23B33.C_{23}=A_{21}B_{13}+A_{22}B_{23}+A_{23}B_{33}.