Category: Linear Algebra Level: 301
(AB)ij = row i of A · column j of B
Each entry of a product matrix is one row of the left matrix times one column of the right matrix: multiply matching entries and add.
A is 2 by 3 and B is 3 by 2. The inner sizes match (3 and 3), so the product exists. The outer sizes give its shape: 2 by 2.
(2 × 3)(3 × 2) → 2 × 2
Slide along row 1 of A and down column 1 of B. Multiply the pairs and add them up.
1·2 + 0·1 + 2·1 = 4
Keep row 1 and move to column 2. The zero in B wipes out the middle term.
1·1 + 0·0 + 2·2 = 5
Drop to row 2 of A and go back to column 1. The entry lands where the row and column meet.
1·2 + 1·1 + (-1)·1 = 2
The last pair: row 2 times column 2. A negative entry pulls the sum below zero.
1·1 + 1·0 + (-1)·2 = -1
All four entries are filled in. Each one came from one row and one column. Try BA: it comes out 3 by 3, a different matrix entirely.
AB = [[4, 5], [2, -1]]
cd svg-generator python3 -m svgmath render matrix-multiplication --out /tmp/matrix-multiplication
Source: svgmath/diagrams/matrix_ops.py