Learning goals
This chapter develops the algebra of matrices: matrix-vector multiplication, matrix-matrix multiplication, row-column computation, column interpretation, matrix powers, diagonal and triangular matrices, and the noncommutative nature of matrix multiplication.
Check dimensions
Decide whether products are defined and determine the output size.
Compute products
Use row-column multiplication and the column interpretation.
Understand order
Interpret products as composition of linear processes.
The dimension rule
Interactive dimension checker
Matrix product calculator
Use this lab to compute $AB$ and compare it with $BA$. Entries may be integers, decimals, or fractions.
Use one row per line, for example 1 2 then 3 4.
Column interpretation
If $B=[b_1\;b_2\;\cdots\;b_p]$, then
The product $AB$ is built by applying $A$ to every column of $B$.
Matrix multiplication is not usually commutative
For real numbers, $ab=ba$. For matrices, usually $AB\ne BA$. Sometimes both products are defined but unequal. Sometimes one product is defined and the other is not.
Both defined but unequal
One defined, one not
Identity and zero matrices
Identity matrices
If $A$ is $m\times n$, then
The identity size on the left and right may be different.
Zero matrices
If sizes are compatible, multiplying by a zero matrix gives a zero matrix.
The output size is determined by the outside dimensions.
Matrix powers
If $A$ is square, then $A^2=AA$, $A^3=AAA$, and $A^k$ means repeated application of the same process.
Diagonal matrices
Each coordinate is scaled independently.
Repeated dynamics
This idea appears in Markov chains, ranking algorithms, and dynamical systems.
Diagonal and triangular matrices
Diagonal
Only diagonal entries may be nonzero. Easy to multiply and power.
Upper triangular
All entries below the diagonal are zero. Use back substitution.
Lower triangular
All entries above the diagonal are zero. Use forward substitution.
Composition visualizer: projection and rotation
The product $ABx$ means $B$ acts first, then $A$ acts. Here $P$ is projection onto the $x$-axis and $Q$ is counterclockwise rotation by $90^\circ$. Compare $PQx$ with $QPx$.
The original vector $x$ is shown along with the two results.
Interactive repeated dynamics
Explore $x_{t+1}=Ax_t$. The default matrix is from the chapter's repeated-dynamics example.
Python connection
Matrix multiplication
import numpy as np A = np.array([[1, 2], [3, 4]], dtype=float) B = np.array([[2, 1], [0, -1]], dtype=float) A @ B B @ A
Powers and dynamics
A = np.array([[1, 1], [1, 0]], dtype=float)
np.linalg.matrix_power(A, 5)
x = np.array([100, 0], dtype=float)
for k in range(10):
x = A @ xCommon mistakes
Multiplying entry by entry
Matrix multiplication is row-by-column, not entrywise multiplication.
Ignoring dimensions
Check $(m\times n)(n\times p)=(m\times p)$ before computing.
Assuming $AB=BA$
Matrix multiplication is usually not commutative.
Reversing composition order
In $ABx$, $B$ acts first and $A$ acts second.