Euler Hall — free maths guides

Compute one entry of a product AB

Say that entry (i,j) of AB is row i of A dotted with column j of B. The idea in plain words, a worked example, and a check with the answers shown — part of the free Linear Algebra guides.

One entry, one dot product

Entry(i,j)(i,j) ofABAB is rowii ofAA dotted with columnjj ofBB:

(AB)ij=∑kAikBkj.(AB)_{ij}=\sum_k A_{ik}B_{kj}.

Row 1 ofAA is(1,2,3)(1,2,3); column 2 ofBB is(0,1,1)(0,1,1). Multiply matching entries and add:0+2+3=50+2+3=5. The answer is filed in row 1, column 2.

The indices split for a reason. The row index isAA's, becauseAA is the thing doing the acting. The column index isBB's, because columnjj ofABAB isAA times columnjj ofBB. Neither index ever moves to the other matrix.

The sizes make this possible. A row ofAA has exactly as many entries as a column ofBB — that is what "the inner dimensions match" buys you. If they did not, the dot product would not exist.

Why a row and a column, not two rows

Columnjj ofABAB isAA times columnjj ofBB. That single fact generates the whole multiplication rule: to get one column of the product, feed one column ofBB intoAA.

Feeding a vector intoAA means, by the row picture, taking one dot product per row ofAA. So columnjj ofABAB has, in rowii, the dot product of rowii ofAA with that column ofBB. That is the rule, derived rather than memorised.

Run the same argument with a column of the answer instead of a single entry and you get the column picture: each output column is a weighted sum ofAA's columns. Both pictures describe the same arithmetic; the row picture is faster by hand and the column picture explains more.

Worked example, in the shape the exam asks

Question. For

compute entries(1,2)(1,2) and(2,1)(2,1) ofABAB.

Step 1 — record the shapes.AA is2×32\times3 andBB is3×23\times2, soABAB is2×22\times2 and both required positions exist.

Step 2 — entry(1,2)(1,2): row 1 ofAA with column 2 ofBB. Row 1 ofAA is(2,−1,3)(2,-1,3); column 2 ofBB is(2,0,5)(2,0,5). Dot:2⋅2+(−1)⋅0+3⋅5=4+0+15=192\cdot2+(-1)\cdot0+3\cdot5=4+0+15=19.

Step 3 — entry(2,1)(2,1): row 2 ofAA with column 1 ofBB. Row 2 ofAA is(0,4,1)(0,4,1); column 1 ofBB is(1,3,−1)(1,3,-1). Dot:0⋅1+4⋅3+1⋅(−1)=0+12−1=110\cdot1+4\cdot3+1\cdot(-1)=0+12-1=11.

Step 4 — answer.(AB)1,2=19(AB)_{1,2}=19 and(AB)2,1=11(AB)_{2,1}=11.

Step 5 — check by a different route. Column 2 ofABAB is

, which is2(2,0)+5(3,1)=(4+15, 0+5)=(19,5)2(2,0)+5(3,1)=(4+15,\,0+5)=(19,5). The first entry matches1919 ✓ — and the second entry,55, is(AB)2,2(AB)_{2,2}, which we did not ask for but now know.

By the end you can
  • Say that entry (i,j) of AB is row i of A dotted with column j of B
  • Compute one entry correctly for a rectangular pair
  • Name the slot a computed dot product belongs in
  • Reject column-of-A-times-row-of-B as the rule
Check yourself

A=[102−131]A=\begin{bmatrix}1&0&2\\-1&3&1\end{bmatrix} andB=[21034−1]B=\begin{bmatrix}2&1\\0&3\\4&-1\end{bmatrix}. Compute entry(2,2)(2,2) ofABAB, and then all ofABAB if you can.

Answer

Entry(2,2)(2,2) is row 2 ofAA with column 2 ofBB:(−1)⋅1+3⋅3+1⋅(−1)=−1+9−1=7(-1)\cdot1+3\cdot3+1\cdot(-1) =-1+9-1=7.

The whole product is2×22\times2:

Check one entry by the column route: column 1 ofABAB isA(2,0,4)T=2(1,−1)+4(2,1)=(2+8, −2+4)=(10,2)A(2,0,4)^{\mathsf T} =2(1,-1)+4(2,1)=(2+8,\,-2+4)=(10,2) ✓, which is the first column above.

Work out where to start — free, no accountAnswer six real questions — free, no account