Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

Matrix Multiplication: How the Row and Column Readings Fit Together

How to use
  1. Three tabs, one product. By both rows and columns is the definition: one row of AA against one column of BB, one entry of ABAB per step. By columns of B and By rows of A each build ABAB a whole slice at a time. What each tab does
  2. Switching tabs restarts at step 00, because a step number means a different thing in each reading. Why the step counts differ
  3. Run plays from the current step and becomes Pause. Step and Back move one step at a time. More about the controls
  4. The Steps pips and the counter show the position. The number of steps changes with the tab, because the readings take different routes to the same product. More about the step counter
  5. Reset returns to step 00 with the numbers unchanged, which is the empty bracket.
  6. Generate random numbers rolls a fresh AA and BB. No slice of ABAB is allowed to land on the origin, so every column and every row of the product stays drawable. What the generator enforces
  7. Colour marks the role in the current reading, never the letter. In the slice tabs, blue is whatever is supplying directions and amber whatever is supplying amounts; the two swap between the columns tab and the rows tab, and that swap is the lesson. In the both tab, blue is the row of AA and amber the column of BB in play — the two operands of one dot product. More about the colour swap

Matrix by matrix

The same product, read two ways. Neither reading is half of it — each one builds the whole of AB\textcolor{#0b2f77}{AB}, out of different pieces. Watch which colour lands on which matrix when you switch: the left operand always gives up its columns, the right one always gives up its rows.
row ii of A\textcolor{#1450c8}{A}column jj of B\textcolor{#b45309}{B}the entry they produce
A
2-112
2×2
B
2113
2×2
=
AB
????
2×2
In the plane
-4-224-2-11234
Nothing computed yet. Each step puts one row of A and one column of B in the plane and reads off the number they make.
The definition, with both readings inside it. Every entry of AB\textcolor{#0b2f77}{AB} is one dot product: a row of A\textcolor{#1450c8}{A} against a column of B\textcolor{#b45309}{B}. 2 rows, 2 columns — 2 times 2 steps. Press Run. Nothing is committed yet, and the plane is empty to match. Learn more about the empty bracket · All three tabs
StepsStep0 / 4






What this page is for

This page does not teach a way of multiplying. It shows how the two ways fit together.

There is one product ABAB, and there are two honest decompositions of it. One builds it a column at a time out of the columns of AA. The other builds it a row at a time out of the rows of BB. Both compute every entry, both reach the same matrix, and neither is a shortcut or a special case of the other.

The reason there are exactly two is that a product has two sides and they play different parts. The factor on the left gives up its columns. The factor on the right gives up its rows. Whichever side you stand on, the other supplies the weights.

A vector product shows only one half of this at a time, because one of its sides is a vector. With two matrices both halves are visible at once, and the figure here is arranged so you can watch the roles change hands rather than take the statement on trust.

If the question is how to compute, either sibling page answers it. If the question is why the same numbers can be assembled two different ways, this is the page.

The three tabs

All three tabs run the same component on the same pair of matrices and differ only in the route.

By both rows and columns, the tab that opens first, is the definition itself. Each step takes one whole row of AA and one whole column of BB, pairs them term by term, adds, and lands one entry of ABAB. Two rows, two columns, four entries, four steps. Both readings are present in every step: the row belongs to AA and the column belongs to BB, and neither is a piece or a weight — they are the two operands of one dot product.

By columns of B builds ABAB one column at a time. Column jj is a weighted sum of the columns of AA, with the weights taken from column jj of BB. When the run ends, every column of the product has been assembled from the same fixed set of directions.

By rows of A builds ABAB one row at a time. Row ii is a weighted sum of the rows of BB, with the weights taken from row ii of AA. Again the directions are fixed across the whole run; only the weights change from slice to slice, and the finished rows show it.

All three open on the empty bracket, and the step count differs between tabs. That is expected: the routes group the same multiplications differently, so they take a different number of moves to arrive at an identical matrix.

The empty bracket

Every tab opens on the same thing: a bracket for ABAB with nothing in it, and a plane with nothing drawn.

That is worth a moment rather than a click past. The bracket already has its shape — two rows and two columns, because AA has two rows and BB has two columns — before a single entry is known. The shape of a product is settled by the shapes of its factors, not by their contents.
-4-22468-22468
Step 0, frozen

Axes, and nothing else. The bracket holds no entry yet, so there is no arrow to draw — and the plane stays this way in all three tabs, because step 0 means the same thing in every reading.

The plane is empty for a stricter reason. An arrow needs both of its coordinates before it can be drawn, and at step 00 neither exists. This is the honest state of the computation: not a small answer, but no answer.

Pressing Reset at any point returns here with the same numbers on screen. Generate random numbers also returns here, but with a fresh AA and BB — see generating new numbers for what it is allowed to roll.

What happens on the next step depends entirely on which tab you are in, and that is the whole subject of the three tabs.

The colour swap

Colour on this page means the role a quantity plays in the current reading, never which letter it belongs to.

Blue marks the pieces being combined. Amber marks the weights that choose how much of each piece to take. Navy marks ABAB itself, which belongs to neither factor and is drawn behind a doubled bracket.

In the column reading, blue sits on AA and amber on BB. In the row reading they exchange places: blue moves to BB, amber to AA. Switch between the two slice tabs and watch the legend change with them.

That swap is the entire content of the page compressed into one visual event. The letters did not change and the matrices did not move. What changed is which side is being asked for directions, and the answer depends only on which side of the product it sits.

The both tab uses the same two colours for a different pair: blue is the row of AA in play, amber the column of BB. There the two are not pieces and weights but the two operands of one dot product, and they are paired term by term. Run the two slice tabs first if the swap reads as instability rather than as a claim; it is easier to see once each route is familiar on its own.

One row, one column, one entry

In the both tab every step holds a row of AA and a column of BB on screen at once. They meet at a single entry, and that entry is the crux of the page.

Entry cijc_{ij} is row ii of AA dotted with column jj of BB. It belongs to row ii of the product and to column jj of the product. The column reading produces it as part of a weighted sum of the columns of AA; the row reading produces it as part of a weighted sum of the rows of BB. Two different assemblies, one number — and the definition computes it once, not twice.

That is what rules out the tempting misreading that each route builds half the product and the halves are glued together. Every entry is claimed by both readings, and they agree everywhere.

In the plane, the step draws the row of AA and the column of BB from the origin and drops the row onto the column. The signed length of that projection, times the length of the column, is the entry. A negative entry is a projection that points against the column.
-3-2-11234-2-11234row 1 of Acol 1 of B-3-2-11234-2-11234row 1 of Acol 2 of B
Both tab, a positive and a negative entry, frozen

Blue is row 1 of A, amber a column of B, and the dashed line drops the row onto the column. Above: the projection runs with the column and the entry is +3. Below: against it, and the entry is −1. The sign of an entry is the direction of that drop, nothing more.

The projection is worth reading carefully, because it is the geometric content of a dot product and it is easy to accept as decoration. Dropping the row onto the column asks: how much of this row points along that column? Multiply that amount by the column's own length and you have aiTbj\mathbf{a}_i^{T}\mathbf{b}_j, the entry. When the two are perpendicular the drop lands on the origin and the entry is zero — which is what an entry of zero in a product actually means.

Four steps cover the whole product, one per entry, because a 2×22 \times 2 result has four of them. Nothing is grouped and nothing is regrouped; this tab is the definition with no rearrangement at all.

That makes it the right place to start and the wrong place to stop. It shows what every entry is, and it shows nothing about what the product *does* — for that you have to watch whole slices assemble, in building a column and building a row.

Building a column of AB

In the columns tab each step lays down one piece of one column of the product.

Column jj of ABAB is AbjA\mathbf{b}_j — the matrix AA applied to column jj of BB — and by the column reading that is a weighted sum of the columns of AA. So the step multiplies one column of AA by one entry of that column of BB and lays the result on the end of what is already there.
-4-22468-22468
Columns tab, first piece, frozen

One column of A, scaled by one entry of the column of B being used. The slice is not finished: only when the second piece is laid on this one does an arrow reach a column of AB.

The picture is a walk, not a jump. After the first piece the arrow is nowhere meaningful: it is a partial sum, one term short of a column of ABAB. That is the difference between this route and the entry-by-entry one — here every intermediate point is a genuine vector, even though it is not yet the answer.

Two things stay fixed for the whole run. The directions are the columns of AA, and they never move. Only the weights change, and they change because a different column of BB is being read. Watch the second slice start and you see the same two directions walked again with different amounts, which is exactly what the finished figure shows.

The mirror step in the other slice tab is building a row.

The finished product by columns

At the end of the columns run both columns of ABAB stand in the plane, each at the end of its own two-piece walk.

AB=[Ab1Ab2]AB = \begin{bmatrix} A\mathbf{b}_1 & A\mathbf{b}_2 \end{bmatrix}


The general statement the board shows at the second-to-last step and the completed product at the last step are the same picture: the plane does not change between them, only the algebra above it does.
-4-22468-22468col 1col 2
Columns tab, both columns assembled, frozen

Two navy arrows, col 1 and col 2 of AB, each reached by walking the same two blue directions with different amounts. The directions are fixed by A; only the weights change from slice to slice.

Read the figure as a claim about reach. Both navy arrows were built from the same two blue directions — the columns of AA — and differ only in how much of each was taken. Any other column of BB would produce another arrow in the same family. That family is the set of all weighted sums of the columns of AA, and it is what a column reading is ultimately about.

Note what is not on screen: the rows of ABAB. They exist, they are correct, and this route never drew them. That is not an omission but the nature of a slicing, which is the point neither reading is half makes in full.

The same product assembled the other way is the finished product by rows.

Building a row of AB

The rows tab is the mirror image, and it is worth running immediately after the columns tab so the symmetry is fresh.

Row ii of ABAB is aiTB\mathbf{a}_i^{T}B — row ii of AA applied to BB — and that is a weighted sum of the rows of BB. So the step multiplies one row of BB by one entry of that row of AA and lays it on the end of the walk.
-4-22468-22468
Rows tab, first piece, frozen

The mirror of the column case: one row of B, scaled by one entry of the row of A being used. Same picture, other factor.

Everything structural is identical to building a column: the same tail-to-head walk, the same partial sums that are real vectors, the same two fixed directions reused with different amounts.

One thing is not identical, and it is the thing to notice. The fixed directions here belong to BB, not to AA. Blue has moved to the other factor. Nothing about the matrices changed when you switched tabs — what changed is which side is being asked for directions, and the colour swap is where that is argued.

The finished product by rows

At the end of the rows run both rows of ABAB stand in the plane.

AB=[a1TBa2TB]AB = \begin{bmatrix} \mathbf{a}_1^{T}B \\ \mathbf{a}_2^{T}B \end{bmatrix}


As in the columns tab, the general statement and the finished product share one figure; the plane is complete a step before the algebra finishes describing it.
-4-22468-22468row 1row 2
Rows tab, both rows assembled, frozen

Two navy arrows, row 1 and row 2 of AB, built from the same two directions — but the directions here are rows of B, not columns of A. Same product, different decomposition.

Put this figure beside the finished product by columns and the two look alike — four navy arrows in total, two from each run, all built from two fixed directions. But they are not four different things. They are two slicings of one 2×22 \times 2 matrix: the first cut it vertically, this one cut it horizontally, and every entry appears in both.

The entry step makes that concrete rather than asserted: one row, one column, one entry shows a single number being claimed by a row and a column at the same time.

Why two by two

The matrices here are 2×22 \times 2, and the choice is forced by what has to be drawn.

A product of an m×km \times k matrix with a k×nk \times n matrix costs mknm \cdot k \cdot n multiplications. At 2×22 \times 2 that is eight, which is enough to see structure and few enough to follow. A 3×33 \times 3 product is twenty-seven, and the figure stops being readable well before the argument lands.

The shape also has to keep both readings drawable at once. With two rows and two columns in the product, every column of ABAB is a plane vector and so is every row; and every row of AA and every column of BB is a plane vector too, which is what lets the both tab draw a row against a column and read the entry off as a projection. Change either outer dimension and one of the two families leaves the plane.

Random generation enforces the rest: no entry of ABAB grows past a readable size, and no column or row of the product is allowed to be entirely zero, since a slice at the origin has no direction to draw. These are constraints on the picture. The algebra is indifferent to them.

Neither reading is half

It is worth stating plainly what the two decompositions are and are not.

Write BB by its columns. Then

AB=[Ab1Ab2]AB = \begin{bmatrix} A\mathbf{b}_1 & A\mathbf{b}_2 \end{bmatrix}


and each AbjA\mathbf{b}_j is a weighted sum of the columns of AA. Now write AA by its rows. Then

AB=[a1TBa2TB]AB = \begin{bmatrix} \mathbf{a}_1^{T}B \\ \mathbf{a}_2^{T}B \end{bmatrix}


and each aiTB\mathbf{a}_i^{T}B is a weighted sum of the rows of BB.

Both expressions are the whole matrix. The first slices it vertically, the second horizontally, and a slicing is not a share. Expanding either one gives the same eight products the definition asks for, grouped differently.

The practical consequence is that you may choose the grouping to suit the question. Nothing is lost by reading a product as columns when columns are what matters, and nothing is gained by trying to combine the two routes into one procedure — they are the same procedure, read from two sides.

Running the tool

The control bar sits at the same height in every tab and on every step, so nothing jumps as the figure changes.

Run plays forward from wherever you are and becomes Pause while it is playing. It advances roughly twice a second, which is fast enough to see the shape of a route and too fast to follow an individual step.

Step and Back move exactly one step. These are the controls that matter: the regrouping and entry steps are arguments, and an argument is easier to check held still than in motion.

Reset returns to step 00the empty bracket — without changing the numbers. It restarts the route, not the example.

Steps and the step counter

The pips under the figure are position markers, not controls: they show how far along the run you are, and a pip is not clickable. The counter beside them reads the same position as a number.

The step count is not the same in every tab, and the difference is informative. By both rows and columns takes four steps, one per entry of ABAB — two rows times two columns. The two slice tabs take six: four steps to lay down pieces, then one for the general statement and one for the finished product.

Generating new numbers

Generate random numbers rolls a fresh AA and BB and returns to step 00. The pair is re-rolled until it is drawable, rather than being drawn once and patched afterwards.

Three constraints are enforced. No entry of either factor is zero. No entry of ABAB exceeds sixteen in size, so the plot keeps a readable scale. No column of ABAB and no row of ABAB is entirely zero, because a slice sitting at the origin has no direction to draw and no arrow to label.

The invariant in four products

The rule this series is built on fits in one sentence: matrix multiplication never operates on single entries; it operates on whole rows or whole columns, and which one depends only on which side the other factor sits.

Four products state it from four angles.

AvA\mathbf{v}AA contributes its columns, v\mathbf{v} supplies the weights.

vTA\mathbf{v}^{T}AAA contributes its rows, v\mathbf{v} supplies the weights.

ABAB read by columns — AA contributes its columns, a column of BB supplies the weights.

ABAB read by rows — BB contributes its rows, a row of AA supplies the weights.

The left operand always gives up columns; the right operand always gives up rows. The two vector products each show one half of that, because a vector has only one interesting direction to be read in. The matrix product shows both halves simultaneously, which is why it appears on all three pages of this series rather than on a page of its own.

Nothing beyond the plain definition is used to reach any of the four.

Which reading answers which question

The two routes are equally valid and not equally useful. Which one to reach for depends on what is being asked.

Read by columns when the question is about reach. The set of all weighted sums of the columns of AA is its column space, so questions about which right-hand sides are attainable, whether Ax=bA\mathbf{x} = \mathbf{b} can be solved, what the span of a set of vectors covers and how many independent directions a matrix carries are all column questions.

Read by rows when the question is about elimination. Row operations replace a row by a weighted sum of rows, so they are left multiplications, and elementary matrices, row equivalence and the factorisations that come out of Gaussian elimination all live on the row side.

Read the definition itself, cell by cell, when the question is about cost or about a single entry. That route is the one that makes the price of a product visible.

A useful habit: before multiplying, ask which factor you care about. If it is the left one, read columns. If it is the right one, read rows.

Where this leads

Two directions open from here, and they are the reason the series exists.

The first is the decomposition that contains both readings. Write the product as a sum over the shared dimension, AB=papbpTAB = \sum_p \mathbf{a}_p \mathbf{b}_p^{T}, where ap\mathbf{a}_p is column pp of AA and bpT\mathbf{b}_p^{T} is row pp of BB. Each term is a rank-one matrix. Take a column of that sum and the column reading falls out; take a row and the row reading does. Outer products are where the two pictures are visibly the same object.

The second is transformations. Feeding a standard basis vector into the column reading keeps exactly one column and discards the rest, so the columns of a matrix are the images of the basis vectors. Building a rotation, a reflection or a projection then becomes a question of deciding where the basis should land and writing those images down as columns, rather than recalling a formula.

Both are natural next steps once the two readings are no longer competing for the same slot in your head.