Matrix Multiplication: Rows Times Columns

April 13, 2026

Problem

Compute AB for A = [[1,2],[3,4]] and B = [[5,6],[7,8]]. Show each entry as a row-column dot product.

Explanation

The rule

For AA of size m×nm \times n and BB of size n×pn \times p, the product ABAB has size m×pm \times p, with entries (AB)ij=k=1nAikBkj(AB)_{ij} = \sum_{k=1}^{n} A_{ik} B_{kj}

In words: (AB)ij(AB)_{ij} is the dot product of row ii of AA with column jj of BB.

The "inner dimension" nn must match — otherwise the product is undefined.

Step-by-step

Setup: A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}, B=(5678)B = \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}. Both 2×22 \times 2, product is 2×22 \times 2.

Compute each entry:

(AB)11(AB)_{11} = row 1 of AA · column 1 of BB: (1)(5)+(2)(7)=5+14=19(1)(5) + (2)(7) = 5 + 14 = 19

(AB)12(AB)_{12} = row 1 of AA · column 2 of BB: (1)(6)+(2)(8)=6+16=22(1)(6) + (2)(8) = 6 + 16 = 22

(AB)21(AB)_{21} = row 2 of AA · column 1 of BB: (3)(5)+(4)(7)=15+28=43(3)(5) + (4)(7) = 15 + 28 = 43

(AB)22(AB)_{22} = row 2 of AA · column 2 of BB: (3)(6)+(4)(8)=18+32=50(3)(6) + (4)(8) = 18 + 32 = 50

AB=(19224350)\boxed{AB = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix}}

Matrix multiplication is NOT commutative

BA=(5678)(1234)=(23343146)ABBA = \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix} \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} = \begin{pmatrix} 23 & 34 \\ 31 & 46 \end{pmatrix} \ne AB

In general ABBAAB \ne BA. They can even have different shapes (e.g. AA is 2×32 \times 3, BB is 3×23 \times 2: ABAB is 2×22 \times 2, but BABA is 3×33 \times 3).

Properties (what IS true)

  • Associative: A(BC)=(AB)CA(BC) = (AB)C.
  • Distributive: A(B+C)=AB+ACA(B + C) = AB + AC and (A+B)C=AC+BC(A + B)C = AC + BC.
  • Identity: AI=A=IAAI = A = IA with II the appropriately-sized identity matrix.
  • Transpose swap: (AB)T=BTAT(AB)^T = B^T A^T.

Geometric interpretation

Matrix AA represents a linear transformation. The product ABAB represents the composition — first apply BB, then apply AA. This naturally explains why matrix multiplication is associative (composition is) but not commutative (order of transformations matters).

Common mistakes

  • Row-times-row or column-times-column. The rule is row (of AA) times column (of BB), period.
  • Assuming AB=BAAB = BA. Matrix multiplication rarely commutes.
  • Ignoring shape mismatches. A 2×32 \times 3 times a 2×32 \times 3 is not defined — inner dimensions (33 and 22) don't match.
  • Claiming AB=0    A=0AB = 0 \implies A = 0 or B=0B = 0. False in general: two nonzero matrices can multiply to zero (they're "zero divisors").

Try it in the visualization

The row of AA and the column of BB highlight as each entry of ABAB is computed. Their element-wise products add up live to produce each output entry.

Interactive Visualization

Parameters

1.00
2.00
3.00
4.00
5.00
6.00
7.00
8.00
Your turn

Got your own math or physics problem?

Turn any problem into an interactive visualization like this one — powered by AI, generated in seconds. Free to try, no credit card required.

Sign Up Free to Try It30 free visualizations every day
Matrix Multiplication: Rows Times Columns | MathSpin