Skip to content
Glacius
Linear algebraConcept reference

Matrix products

A matrix product contains the dot product of each left-hand row with each right-hand column.

On this page 7 sections
  1. Overview
  2. For C=AB, the entry C_12 uses row 1 of A and column 2 of B
  3. Each left row must have as many entries as each right column
  4. A product entry uses a whole row and column, even when both matrices have the same shape
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01For C=AB, the entry C_12 uses row 1 of A and column 2 of B#

For C=ABC=AB, the entry C12C_{12} uses row 1 of A and column 2 of B. Here they are (1,2)(1,2) and (4,1)(4,-1).

A has rows (1,2) and (3,0). B has rows (2,4) and (1,−1). Highlighted row 1 of A and column 2 of B give entry C12=1×4+2×(−1)=2 in C=AB. Question marks mark other entries not yet computed.A has rows (1,2) and (3,0). B has rows (2,4) and (1,−1). Highlighted row 1 of A and column 2 of B give entry C12=1×4+2×(−1)=2 in C=AB. Question marks mark other entries not yet computed.
Figure 1A has rows (1,2) and (3,0). B has rows (2,4) and (1,−1). Highlighted row 1 of A and column 2 of B give entry C12=1×4+2×(−1)=2 in C=AB. Question marks mark other entries not yet computed.
Link to this figure ↗Download SVGDownload PNG

For C12C_{12}, row (1,2)(1,2) pairs with column (4,1)(4,-1). The matching products are 14=41\cdot4=4 and 2(1)=22\cdot(-1)=-2. Add them for row 1, column 2.

C12=42=2C_{12}=4-2=2
Check your reasoning

A has rows (1,0)(1,0), (2,1)(2,1); B has rows (3,2)(3,2), (1,0)(-1,0). For C=ABC=AB, compute C21C_{21}.

Show answer and explanation
5

Row 2 dots column 1: 23+1(1)=52\cdot3+1\cdot(-1)=5.

02Each left row must have as many entries as each right column#

Each left row must have as many entries as each right column. Thus 2×32\times3 can multiply 3×43\times4. Two left rows paired with four right columns give a 2×42\times4 output.

Check your reasoning

A is 3×23\times2; B is 2×12\times1. A learner says AB is 2×22\times2. Repair its shape.

  1. A2×22\times2
  2. B3×13\times1
  3. C1×31\times3
Show answer and explanation
3×13\times1

Three A rows and one B column give a 3×13\times1 result.

03A product entry uses a whole row and column, even when both matrices have the same shape#

A product entry uses a whole row and column, even when both matrices have the same shape. Multiplying only corresponding entries skips the other products. If the inner dimensions differ, these dot products are undefined.

Check your reasoning

A has score rows P (1,0)(1,0), Q (2,1)(2,-1). B has observation columns U (3,2)(3,2), V (1,4)(1,4). Find score Q for observation V.

Show answer and explanation
-2

Dot Q with V: 24=22-4=-2.

Key takeaway

For entry (i,j), dot row i of the left matrix with column j of the right matrix.

  • Compute the entries of a compatible matrix product.

Sources & further reading

  1. [1]
  2. [2]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Matrix products.” Math behind ML. /learn/la-matmul