Systems and matrices · Definition

Matrix multiplication

linear algebramatrices

Before you start you need to know

The matrix product combines rows with columns and corresponds to applying one transformation after another.

Definition

The product \(AB\) of two matrices \(A\) and \(B\), when \(A\) has as many columns as \(B\) has rows, is the matrix whose \((i,j)\) entry combines row \(i\) of \(A\) with column \(j\) of \(B\).

\[(AB)_{ij}=\sum_{k=1}^{n}a_{ik}b_{kj}\]

The definition of the matrix product looks arbitrary the first time: why «row times column»? The reason is that it must correspond to composition of transformations. If \(B\) turns vectors of \(\mathbb R^p\) into vectors of \(\mathbb R^n\) and \(A\) carries them from \(\mathbb R^n\) to \(\mathbb R^m\), then \(AB\) is the machine that performs both steps in a row. The row-by-column rule is exactly what makes this work.

From this come the size conditions: the columns of \(A\) must match the rows of \(B\), since the output of \(B\) has to fit the input of \(A\). It also explains why in general \(AB\neq BA\): doing a rotation first and then a reflection is not the same as doing them the other way around. What is preserved is associativity, \((AB)C=A(BC)\), because composing functions is associative.

A guiding example: with \(A=\begin{pmatrix}1&2\\0&1\end{pmatrix}\) and \(B=\begin{pmatrix}0&1\\1&0\end{pmatrix}\), we get \(AB=\begin{pmatrix}2&1\\1&0\end{pmatrix}\) but \(BA=\begin{pmatrix}0&1\\1&2\end{pmatrix}\). A typical mistake is to multiply entry by entry; that is a different operation (the Hadamard product). This product underlies the inverse matrix and elimination in matrix form. In general the product is not commutative: \(AB\neq BA\), although it is associative and distributive.

Think about it

If \(AB=0\), does it follow that \(A=0\) or \(B=0\)?

No. For example, \(\begin{pmatrix}0&1\\0&0\end{pmatrix}^2=0\) although the matrix is not zero.

Exercises 10

References

  • Gilbert Strang, Introduction to Linear Algebra, 6th edition, Wellesley-Cambridge Press, 2023. §2.4
  • Sheldon Axler, Linear Algebra Done Right, 4th edition, Springer, 2024. §3.C