Multiply two matrices
Compute every entry of a product by hand for small matrices. The idea in plain words, a worked example, and a check with the answers shown — part of the free Linear Algebra guides.
To multiply, compute one entry at a time: entry is row of dotted with column of. Write it down in position immediately.
Four entries, four dot products, each of three products. That is multiplications — the number again.
Two checks catch almost every slip.
1. Shape. times is. If your answer is not that shape, stop and find the error before checking a single number. 2. One entry by a different route. Column 2 of is, which matches the second column above. A second route that agrees is real evidence; a second look at the same working is not.
Multiplying entrywise is the classic wrong answer, and it produces a matrix of the right shape, so shape does not catch it. in a row is not the product of anything.
And order matters. and need not even be the same size — with of size and of size, is while is.
An times an gives entries. Each entry is a dot product over terms, so multiplications each. Total:.
The same count comes out of the column picture: there are columns in the answer, each computed as times a vector, and each of those costs. Again — the arithmetic cannot care which way you organise it.
And the four ways all agree. Entry by entry, a column at a time, a row at a time, or as a sum of rank-one pieces: four organisations of the same multiplications. That is why you are free to pick the one that suits the question. Row-by-column is fastest by hand; column-at-a-time explains the most; rank-one pieces explain rank.
Question. Compute for
Step 1 — shapes. is, is, so is. It exists.
Step 2 — entry. Row 1 of is; column 1 of is. Dot:.
Step 3 — entry. Row 1 with column 2:.
Step 4 — entry. Row 2 is with column 1:.
Step 5 — entry. Row 2 with column 2:.
Answer.
Step 6 — check by column. Column 1 of should be
✓, which is the first column above.
Step 7 — the reverse order, for contrast. is, so it is not even the same size: is decided before any arithmetic.
- Compute every entry of a product by hand for small matrices
- Verify a computed product by recomputing one entry a second way
- Compute both AB and BA and decide whether they agree
- Reject the entrywise product and the transposed answer
Compute and, and say whether they are equal.
Answer
Working: entry is; is; is; is.
entry is; is; is; is.
They are not equal: three of the four entries differ. Note that happens to agree in both — which is exactly why one matching entry proves nothing and a full comparison is needed.