Matrix Multiplication: Row Times Column

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.

Step through it

Watch it

Animated walkthrough

Step by step

Step 1: Check that the shapes fit

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

Step 1: Check that the shapes fit

Step 2: Entry (1, 1): row 1 times column 1

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

Step 2: Entry (1, 1): row 1 times column 1

Step 3: Entry (1, 2): row 1 times column 2

Keep row 1 and move to column 2. The zero in B wipes out the middle term.

1·1 + 0·0 + 2·2 = 5

Step 3: Entry (1, 2): row 1 times column 2

Step 4: Entry (2, 1): row 2 times column 1

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

Step 4: Entry (2, 1): row 2 times column 1

Step 5: Entry (2, 2): row 2 times column 2

The last pair: row 2 times column 2. A negative entry pulls the sum below zero.

1·1 + 1·0 + (-1)·2 = -1

Step 5: Entry (2, 2): row 2 times column 2

Step 6: Read the product

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]]

Step 6: Read the product

All steps at once

Storyboard

Generate it yourself

cd svg-generator
python3 -m svgmath render matrix-multiplication --out /tmp/matrix-multiplication

Source: svgmath/diagrams/matrix_ops.py