Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Open In Colab Binder

This tool presents four geometric views of the matrix product AB\mathbf{AB}.
Choose the matrix size (2×22\times 2 or 3×33\times 3), enter the matrix entries, switch between views, and follow the computation step by step.

How to Use the Tool

ControlFunction
2×2 / 3×3 buttonsSwitch the matrix size and load the default example automatically
Matrix entry boxesEdit any entry of A\mathbf{A} or B\mathbf{B} directly; the figure updates immediately
View selectorSwitch among the four views; each view highlights the rows/columns involved in the computation in different colors
← →Step through the computation of the current view
Computation panelShows the full formula for the current step

Highlight colors: blue border = the row taking part in the inner product, the coefficient vector of the column combination, and the rows of B\mathbf{B} in the row combination and the outer-product expansion; violet border = the column taking part in the inner product, the coefficient vector of the row combination, and the columns of A\mathbf{A} in the column combination and the outer-product expansion; teal border = the position of the result of the current step.

✓ Color constants loaded
✓ Utility functions defined
✓ Highlighting logic of the four views defined
✓ Formula text functions defined
✓ Main plotting function defined
Default matrices (2×2):
A =
[[1. 2.]
 [0. 3.]]
B =
[[2. 1.]
 [1. 4.]]
AB =
[[ 4.  9.]
 [ 3. 12.]]

Default matrices (3×3):
A =
[[1. 2. 0.]
 [3. 1. 2.]
 [0. 1. 4.]]
B =
[[2. 0. 1.]
 [1. 3. 2.]
 [0. 2. 1.]]
AB =
[[ 4.  6.  5.]
 [ 7.  7.  7.]
 [ 1. 11.  6.]]
Loading...
✓ Interactive interface started

Part 2: Observation and Reflection

Answer the following four questions, explaining your conclusions with what you actually did in the interactive tool.
We suggest switching to the 3×3 size first and then entering the matrices as each question instructs.


Question 1: What Is Special about the Identity Matrix

Set B\mathbf{B} to the 3×33\times 3 identity matrix

B=[100010001]\mathbf{B} = \begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}

Keep A\mathbf{A} an arbitrary matrix, and follow the computation of AB\mathbf{AB} step by step in each of the four views.

(a) (Inner-product view) When (AB)ij(\mathbf{AB})_{ij} is computed, what does column jj of B\mathbf{B} contribute to the inner product? Why does every (AB)ij(\mathbf{AB})_{ij} equal the corresponding entry of A\mathbf{A}?

(b) (Column-combination view) Each column of AB\mathbf{AB} is a linear combination of the columns of A\mathbf{A}; look at the coefficient vectors. What is special about the coefficient vectors when B\mathbf{B} is the identity matrix?

(c) (Outer-product expansion view) Three rank-one matrices appear one after another and are added up, and the final result is A\mathbf{A} itself. Describe the structure of each rank-one matrix, and explain why the sum of the three rank-one matrices recovers exactly A\mathbf{A}.

(d) Putting these observations together, explain in one sentence: why does AI=A\mathbf{AI} = \mathbf{A} hold for every matrix A\mathbf{A}?


Question 2: The Equivalence of the Views

Take the 3×33\times 3 size and set

A=[120312014],B=[100010001]\mathbf{A} = \begin{bmatrix}1&2&0\\3&1&2\\0&1&4\end{bmatrix}, \quad \mathbf{B} = \begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}

First use the inner-product view to compute all 9 entries of AB\mathbf{AB} step by step, and record the results.
Then switch to the row-combination view and look at the computation of row 0.

(a) When the inner-product view computes (AB)00(\mathbf{AB})_{00}, which row of A\mathbf{A} and which column of B\mathbf{B} are highlighted? Write out the formula.

(b) Switch to the row-combination view; step 0 shows row 0 of AB\mathbf{AB}. Look at the formula panel: it writes row 0 as a linear combination of the rows of B\mathbf{B} with coefficients A[0,:]\mathbf{A}[0,:]. Expand the formula and verify that (AB)00(\mathbf{AB})_{00} agrees with the result of (a).

(c) Switch to the column-combination view; step 0 shows column 0 of AB\mathbf{AB}. Expand the formula again and verify that (AB)00(\mathbf{AB})_{00} is still the same.

(d) The four views compute the same result matrix. Starting from this observation, explain the relationship between “the variety of ways to define” matrix multiplication and “the uniqueness of the result.”


Question 3: The Outer-Product Expansion and the “Rank-One Decomposition” of a Matrix

Switch to the 3×33\times 3 size, use the outer-product expansion view, enter each of the following two pairs of matrices, and watch the three rank-one matrices pile up.

Case I:

A=[100010001],B=[123456789]\mathbf{A} = \begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix},\quad \mathbf{B} = \begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix}

Case II:

A=[100200300],B=[111000000]\mathbf{A} = \begin{bmatrix}1&0&0\\2&0&0\\3&0&0\end{bmatrix},\quad \mathbf{B} = \begin{bmatrix}1&1&1\\0&0&0\\0&0&0\end{bmatrix}

(a) In Case I, what is the rank-one matrix for k=0k=0? How is it related to row 0 of B\mathbf{B}?

(b) In Case II, look at the three rank-one matrices: which of them are zero matrices? Why? (Hint: look at columns 1 and 2 of A\mathbf{A}.)

(c) What is the final product AB\mathbf{AB} in Case II? Explain it directly from the outer-product expansion, without computing.

(d) Based on these observations, complete the statement: “If column kk of A\mathbf{A} is entirely zero, then the kk-th term of the outer-product expansion ________, so computing AB\mathbf{AB} is equivalent to using only the ________ terms.”


Question 4: The Noncommutativity of Matrix Multiplication

With the 2×22\times 2 size, compute each of the following two products, and observe them in at least two different views.

A=[1203],B=[2114]\mathbf{A} = \begin{bmatrix}1&2\\0&3\end{bmatrix},\quad \mathbf{B} = \begin{bmatrix}2&1\\1&4\end{bmatrix}

(a) First compute AB\mathbf{AB} (the default order). Switch to the column-combination view and describe how column 0 of AB\mathbf{AB} is formed from the columns of A\mathbf{A}.

(b) Swap A\mathbf{A} and B\mathbf{B} (enter the original B\mathbf{B} into the boxes for A\mathbf{A}, and vice versa) and compute BA\mathbf{BA}. Switch to the row-combination view and describe how the coefficients of the combination for row 0 of BA\mathbf{BA} differ from those for row 0 of AB\mathbf{AB}.

(c) Record the results for AB\mathbf{AB} and BA\mathbf{BA}, and confirm that AB≠BA\mathbf{AB} \neq \mathbf{BA}.
Then try the diagonal matrices A=[2003]\mathbf{A} = \begin{bmatrix}2&0\\0&3\end{bmatrix}, B=[5007]\mathbf{B} = \begin{bmatrix}5&0\\0&7\end{bmatrix}. Does AB\mathbf{AB} equal BA\mathbf{BA} this time?

(d) Using the column-combination and row-combination views, explain why AB≠BA\mathbf{AB} \neq \mathbf{BA} in general: the former says “each column of AB\mathbf{AB} is a combination of the columns of A\mathbf{A},” and the latter says “each row of BA\mathbf{BA} is a combination of the rows of A\mathbf{A}.” Which matrix supplies the coefficients in each case?