Chapter 2 · Matrices

2.1 Matrix Operations

Matrices can be added, scaled and multiplied: the product $A\mathbf{x}$ is a linear combination of the columns of $A$, and $(AB)_{ij}$ is row $i$ of $A$ times column $j$ of $B$ — but $AB\ne BA$ in general.

In Chapter 1 a matrix was a convenient way of writing down a linear system without copying out $x_1$, $x_2$, $x_3$ again and again. But a rectangular table of numbers is useful far beyond that. A spreadsheet of daily sales in several shops is a matrix; so is a table of prices and costs, a list of the pixels in a greyscale photo, the table of which airports have direct flights to which, and the recipe that moves every point of a computer-game scene to its new position on screen. Once we have so many tables, we want to compute with them — add two months of sales, scale prices by an inflation factor, and combine a sales table with a price table to get revenue.

This section builds that arithmetic. Addition and scalar multiples work entry by entry, exactly as you would guess. Multiplication is the surprise: it is not done entry by entry, but by combining rows of the first matrix with columns of the second. That rule looks strange at first, yet it is precisely what is needed so that a matrix equation $A\mathbf{x}=\mathbf{b}$ means the same thing as a linear system, and so that doing one matrix "transformation" after another corresponds to a single product. The price is that some familiar rules of algebra fail: in general $AB\ne BA$, and $AB=O$ does not force $A=O$ or $B=O$.

Matrices: Size, Entries and Equality

📘 Definition 2.1 — Matrix, size and entries

An $m\times n$ matrix is a rectangular array of real numbers with $m$ rows and $n$ columns; $m\times n$ (read "$m$ by $n$") is its size. The number in row $i$ and column $j$ is the $(i,j)$ entry, written $a_{ij}$, and we write $A=\left[a_{ij}\right]$: $$A=\begin{bmatrix}a_{11}&a_{12}&\cdots&a_{1n}\\a_{21}&a_{22}&\cdots&a_{2n}\\\vdots&\vdots&&\vdots\\a_{m1}&a_{m2}&\cdots&a_{mn}\end{bmatrix}.$$ The set of all $m\times n$ real matrices is $M_{m\times n}$. Special cases:

  • a square matrix has $m=n$; its entries $a_{11},a_{22},\dots,a_{nn}$ form the main diagonal;
  • an $n\times1$ matrix is a column vector (a vector in $\mathbb{R}^n$), and a $1\times n$ matrix is a row vector;
  • the zero matrix $O$ has every entry $0$;
  • the identity matrix $I_n$ (or just $I$) is the $n\times n$ matrix with $1$s on the main diagonal and $0$s elsewhere, e.g. $I_3=\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}$.

Two matrices are equal, $A=B$, when they have the same size and every pair of corresponding entries is equal: $a_{ij}=b_{ij}$ for all $i$ and $j$.

We will often list a matrix by its columns. If $\mathbf{a}_1,\dots,\mathbf{a}_n$ are the columns of $A$ (each a vector in $\mathbb{R}^m$), we write $A=\begin{bmatrix}\mathbf{a}_1&\mathbf{a}_2&\cdots&\mathbf{a}_n\end{bmatrix}$. Always quote the size as rows × columns — in that order.

✏️ Example 1 — Size, entries and equality
(a) For $A=\begin{bmatrix}3&-1&0\\2&5&-4\end{bmatrix}$ give the size, $a_{12}$ and $a_{23}$.
(b) Find $x$ and $y$ so that $\begin{bmatrix}x+y&2\\3&x-y\end{bmatrix}=\begin{bmatrix}7&2\\3&1\end{bmatrix}$.
(a) Size $A$ has $2$ rows and $3$ columns, so it is $2\times3$.
(a) Entries Row first, then column: $a_{12}=-1$ (row 1, column 2) and $a_{23}=-4$ (row 2, column 3). Note that $a_{32}$ does not exist — there is no third row.
(b) Match entries Both matrices are $2\times2$, so they are equal exactly when corresponding entries agree. The $(1,2)$ and $(2,1)$ entries already agree; the diagonal gives $x+y=7$ and $x-y=1$.
(b) Solve Adding, $2x=8$, so $x=4$ and $y=3$. Check: $x+y=7$ ✓, $x-y=1$ ✓.

Adding Matrices and Multiplying by Scalars

📘 Definition 2.2 — Sum and scalar multiple
Let $A=\left[a_{ij}\right]$ and $B=\left[b_{ij}\right]$ be matrices of the same size $m\times n$, and let $c$ be a real number (a scalar).
  • The sum $A+B$ is the $m\times n$ matrix with entries $a_{ij}+b_{ij}$.
  • The scalar multiple $cA$ is the $m\times n$ matrix with entries $c\,a_{ij}$.
  • We write $-A=(-1)A$ and $A-B=A+(-B)$.
Matrices of different sizes cannot be added.
📐 Theorem 2.1 — Rules for addition and scalar multiples
For any matrices $A$, $B$, $C$ of the same size and any scalars $c$, $d$: $$\begin{aligned}&A+B=B+A, &&(A+B)+C=A+(B+C), &&A+O=A, &&A+(-A)=O,\\ &c(A+B)=cA+cB, &&(c+d)A=cA+dA, &&c(dA)=(cd)A, &&1A=A.\end{aligned}$$

Each rule holds because it holds for every single entry, where it is just a rule of ordinary arithmetic. In practice this means you can rearrange sums of matrices and collect terms just as you do with numbers — for instance, to solve $2X+A=B$ for an unknown matrix $X$, subtract $A$ and halve: $X=\tfrac12(B-A)$.

✏️ Example 2 — A combination of matrices
Let $A=\begin{bmatrix}1&-2\\0&3\\4&1\end{bmatrix}$ and $B=\begin{bmatrix}2&0\\-1&1\\3&-2\end{bmatrix}$. Compute $2A-3B$.
Sizes Both matrices are $3\times2$, so $2A-3B$ is defined and is $3\times2$.
Scale $2A=\begin{bmatrix}2&-4\\0&6\\8&2\end{bmatrix}$ and $3B=\begin{bmatrix}6&0\\-3&3\\9&-6\end{bmatrix}$.
Subtract entry by entry $$2A-3B=\begin{bmatrix}2-6&-4-0\\0-(-3)&6-3\\8-9&2-(-6)\end{bmatrix}=\begin{bmatrix}-4&-4\\3&3\\-1&8\end{bmatrix}.$$
Check One entry directly: the $(3,2)$ entry is $2(1)-3(-2)=8$ ✓.

Multiplying a Matrix by a Vector

In Chapter 1 we wrote the system $x_1+2x_2-x_3=-3$, $3x_1+4x_3=18$ as an augmented matrix. We now want to write it as a single equation $A\mathbf{x}=\mathbf{b}$, with $A$ the coefficient matrix. Look at the left-hand sides column by column: $$\begin{bmatrix}x_1+2x_2-x_3\\3x_1+0x_2+4x_3\end{bmatrix}=x_1\begin{bmatrix}1\\3\end{bmatrix}+x_2\begin{bmatrix}2\\0\end{bmatrix}+x_3\begin{bmatrix}-1\\4\end{bmatrix}.$$ The left side is a linear combination of the columns of $A$, with the unknowns as weights. That is the definition of $A\mathbf{x}$.

📘 Definition 2.3 — The product $A\mathbf{x}$
Let $A=\begin{bmatrix}\mathbf{a}_1&\cdots&\mathbf{a}_n\end{bmatrix}$ be an $m\times n$ matrix and $\mathbf{x}$ a vector in $\mathbb{R}^n$ with entries $x_1,\dots,x_n$. The product $A\mathbf{x}$ is the vector in $\mathbb{R}^m$ $$A\mathbf{x}=x_1\mathbf{a}_1+x_2\mathbf{a}_2+\cdots+x_n\mathbf{a}_n .$$ It is defined only when the number of columns of $A$ equals the number of entries of $\mathbf{x}$.

Row–vector rule. Entry $i$ of $A\mathbf{x}$ is the sum of products of row $i$ of $A$ with $\mathbf{x}$: $(A\mathbf{x})_i=a_{i1}x_1+a_{i2}x_2+\cdots+a_{in}x_n$.

📐 Theorem 2.2 — Three ways to write a linear system

Let $A=\begin{bmatrix}\mathbf{a}_1&\cdots&\mathbf{a}_n\end{bmatrix}$ be $m\times n$ and $\mathbf{b}$ in $\mathbb{R}^m$. The following have exactly the same solutions $x_1,\dots,x_n$:

  1. the linear system with augmented matrix $\left[\begin{array}{c|c}A&\mathbf{b}\end{array}\right]$;
  2. the matrix equation $A\mathbf{x}=\mathbf{b}$;
  3. the vector equation $x_1\mathbf{a}_1+\cdots+x_n\mathbf{a}_n=\mathbf{b}$.

In particular, $A\mathbf{x}=\mathbf{b}$ has a solution if and only if $\mathbf{b}$ is a linear combination of the columns of $A$. Moreover, for all $\mathbf{u},\mathbf{v}$ in $\mathbb{R}^n$ and scalars $c$: $A(\mathbf{u}+\mathbf{v})=A\mathbf{u}+A\mathbf{v}$ and $A(c\mathbf{u})=c\,(A\mathbf{u})$.

✏️ Example 3 — $A\mathbf{x}$ two ways
Let $A=\begin{bmatrix}1&2&-1\\3&0&4\end{bmatrix}$ and $\mathbf{x}=\begin{bmatrix}2\\-1\\3\end{bmatrix}$. Compute $A\mathbf{x}$ using columns and using rows, and write the system $x_1+2x_2-x_3=-3$, $3x_1+4x_3=18$ as a matrix equation. Is the given $\mathbf{x}$ a solution?
Sizes $A$ is $2\times3$ and $\mathbf{x}$ has $3$ entries, so $A\mathbf{x}$ is defined and lies in $\mathbb{R}^2$.
Column view $$A\mathbf{x}=2\begin{bmatrix}1\\3\end{bmatrix}-1\begin{bmatrix}2\\0\end{bmatrix}+3\begin{bmatrix}-1\\4\end{bmatrix}=\begin{bmatrix}2-2-3\\6-0+12\end{bmatrix}=\begin{bmatrix}-3\\18\end{bmatrix}.$$
Row view Row 1: $1(2)+2(-1)+(-1)(3)=-3$. Row 2: $3(2)+0(-1)+4(3)=18$. Same answer ✓.
Matrix equation The system is $$\begin{bmatrix}1&2&-1\\3&0&4\end{bmatrix}\begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix}=\begin{bmatrix}-3\\18\end{bmatrix},$$ i.e. $A\mathbf{x}=\mathbf{b}$ with $\mathbf{b}=\begin{bmatrix}-3\\18\end{bmatrix}$. We just computed $A\mathbf{x}=\mathbf{b}$ for $\mathbf{x}=(2,-1,3)$, so this $\mathbf{x}$ is a solution. (It is not the only one: the system has $3$ unknowns but only $2$ equations, so it has a free variable.)
Interactive 1 — $A\mathbf{x}$ as a Combination of the Columns

The columns $\mathbf{a}_1$ (red) and $\mathbf{a}_2$ (blue) of a $2\times2$ matrix are drawn dashed. The weights $x_1$, $x_2$ stretch them, and the stretched vectors are placed tip to tail: their sum is $A\mathbf{x}=x_1\mathbf{a}_1+x_2\mathbf{a}_2$ (purple). Press Play to wander through different weights, or set them yourself and try to land exactly on the target $\mathbf{b}$ (orange ring) — that solves $A\mathbf{x}=\mathbf{b}$.

weights $\mathbf{x}$—
$x_1\mathbf{a}_1$—
$x_2\mathbf{a}_2$—
$A\mathbf{x}$—
distance to $\mathbf{b}$—

Matrix Multiplication

Suppose a vector $\mathbf{x}$ is first multiplied by $B$ and the result is then multiplied by $A$: $\mathbf{x}\mapsto B\mathbf{x}\mapsto A(B\mathbf{x})$. Is there one matrix that does both steps at once? If $B=\begin{bmatrix}\mathbf{b}_1&\cdots&\mathbf{b}_p\end{bmatrix}$, then $B\mathbf{x}=x_1\mathbf{b}_1+\cdots+x_p\mathbf{b}_p$, and by Theorem 2.2 $$A(B\mathbf{x})=x_1(A\mathbf{b}_1)+\cdots+x_p(A\mathbf{b}_p).$$ This is the matrix with columns $A\mathbf{b}_1,\dots,A\mathbf{b}_p$ applied to $\mathbf{x}$. So that matrix should be the product $AB$.

📘 Definition 2.4 — Matrix product

Let $A$ be $m\times n$ and $B=\begin{bmatrix}\mathbf{b}_1&\cdots&\mathbf{b}_p\end{bmatrix}$ be $n\times p$. The product $AB$ is the $m\times p$ matrix $$AB=\begin{bmatrix}A\mathbf{b}_1&A\mathbf{b}_2&\cdots&A\mathbf{b}_p\end{bmatrix}.$$ Row–column rule. The $(i,j)$ entry of $AB$ combines row $i$ of $A$ with column $j$ of $B$: $$(AB)_{ij}=a_{i1}b_{1j}+a_{i2}b_{2j}+\cdots+a_{in}b_{nj}=\sum_{k=1}^{n}a_{ik}b_{kj}.$$ Size rule. $AB$ is defined only when the number of columns of $A$ equals the number of rows of $B$: $\ (m\times \underline{n})(\underline{n}\times p)\to m\times p$. The inner sizes must match; the outer sizes give the size of the product.

Row view. Row $i$ of $AB$ equals (row $i$ of $A$)$\,B$ — a combination of the rows of $B$.

🧭 Problem-solving strategy — computing a product $AB$
  1. Write the sizes side by side, $(m\times n)(n'\times p)$. If $n\ne n'$, stop: the product is undefined.
  2. Draw an empty $m\times p$ answer grid.
  3. For each entry $(i,j)$, run along row $i$ of $A$ and down column $j$ of $B$, multiply matching entries and add.
  4. Check one column with the column view: column $j$ of $AB$ must be $A\mathbf{b}_j$, a combination of the columns of $A$.
✏️ Example 4 — Revenue and cost for a café chain
A café chain has two branches. Matrix $Q$ gives the daily sales of coffee, sandwiches and cakes; matrix $P$ gives the selling price and the cost of making each item, in dollars: $$Q=\begin{array}{c}\text{Branch 1}\\\text{Branch 2}\end{array}\!\begin{bmatrix}120&45&30\\90&60&25\end{bmatrix},\qquad P=\begin{bmatrix}3&1\\6&4\\4&2\end{bmatrix}\begin{array}{l}\text{coffee}\\\text{sandwich}\\\text{cake}\end{array}\ \ (\text{columns: price, cost}).$$ Compute $QP$ and interpret it. Is $PQ$ defined, and does it mean anything?
Sizes $(2\times3)(3\times2)$: the inner sizes match, so $QP$ is $2\times2$ — one row per branch, one column per (price, cost).
Row 1 $(1,1)$: $120(3)+45(6)+30(4)=360+270+120=750$. $(1,2)$: $120(1)+45(4)+30(2)=120+180+60=360$.
Row 2 $(2,1)$: $90(3)+60(6)+25(4)=270+360+100=730$. $(2,2)$: $90(1)+60(4)+25(2)=90+240+50=380$. $$QP=\begin{bmatrix}750&360\\730&380\end{bmatrix}.$$
Interpret Branch 1 takes in $\$750$ a day at a cost of $\$360$ (profit $\$390$); Branch 2 takes in $\$730$ at a cost of $\$380$ (profit $\$350$). Each entry is "units $\times$ dollars per unit, summed over the products" — exactly the row–column rule.
$PQ$? $(3\times2)(2\times3)$ is defined and gives a $3\times3$ matrix, but its entries mix a price with Branch 1's sales and a cost with Branch 2's sales — meaningless. Even when both orders are defined, they can be completely different objects.
Interactive 2 — Product Explorer: Row Meets Column

The second factor $B$ sits above the answer, the first factor $A$ to its left, so every entry of $AB$ lies where a row of $A$ and a column of $B$ cross. Press Play to fill the product one entry at a time, or drag the slider to pick an entry. Compare the two orders of the same pair, and try a pair whose sizes do not fit.

sizes—
entry—
row · column—
value—
⚠️ Matrix multiplication is not like multiplying numbers

1. Order matters. In general $AB\ne BA$. One may be defined and the other not; both may be defined but of different sizes (Example 4); and even for square matrices of the same size they usually differ. "Multiply $A$ on the left by $B$" ($BA$) and "on the right" ($AB$) are different instructions.

2. Zero products. $AB=O$ can happen with $A\ne O$ and $B\ne O$. You cannot conclude "one of them is zero".

3. No cancelling. $AC=AD$ does not imply $C=D$, even if $A\ne O$. (Cancelling will be allowed when $A$ is invertible — Section 2.2.)

4. Do not multiply entry by entry. The product of $\begin{bmatrix}1&2\\3&4\end{bmatrix}$ and $\begin{bmatrix}5&6\\7&8\end{bmatrix}$ is $\begin{bmatrix}19&22\\43&50\end{bmatrix}$, not $\begin{bmatrix}5&12\\21&32\end{bmatrix}$.

✏️ Example 5 — Three surprises
(a) Compare $AB$ and $BA$ for $A=\begin{bmatrix}1&2\\3&4\end{bmatrix}$, $B=\begin{bmatrix}0&1\\1&0\end{bmatrix}$.
(b) Let $A=\begin{bmatrix}1&1\\2&2\end{bmatrix}$ and $B=\begin{bmatrix}1&-1\\-1&1\end{bmatrix}$. Compute $AB$ and $BA$.
(c) With the same $A$, let $C=\begin{bmatrix}1&2\\3&4\end{bmatrix}$ and $D=\begin{bmatrix}2&3\\2&3\end{bmatrix}$. Compute $AC$ and $AD$.
(a) $$AB=\begin{bmatrix}1(0)+2(1)&1(1)+2(0)\\3(0)+4(1)&3(1)+4(0)\end{bmatrix}=\begin{bmatrix}2&1\\4&3\end{bmatrix},\qquad BA=\begin{bmatrix}3&4\\1&2\end{bmatrix}.$$ Multiplying by $B$ on the right swaps the columns of $A$; on the left it swaps the rows. So $AB\ne BA$.
(b) $$AB=\begin{bmatrix}1-1&-1+1\\2-2&-2+2\end{bmatrix}=\begin{bmatrix}0&0\\0&0\end{bmatrix}=O,\qquad BA=\begin{bmatrix}1-2&1-2\\-1+2&-1+2\end{bmatrix}=\begin{bmatrix}-1&-1\\1&1\end{bmatrix}\ne O.$$ Two non-zero matrices with a zero product — and the product in the other order is not even zero. (Each column of $B$ is a solution of $A\mathbf{x}=\mathbf{0}$, which is why $AB=O$.)
(c) $$AC=\begin{bmatrix}1+3&2+4\\2+6&4+8\end{bmatrix}=\begin{bmatrix}4&6\\8&12\end{bmatrix},\qquad AD=\begin{bmatrix}2+2&3+3\\4+4&6+6\end{bmatrix}=\begin{bmatrix}4&6\\8&12\end{bmatrix}.$$ So $AC=AD$ although $C\ne D$: we cannot cancel $A$.
Why $AC=AD$ means $A(C-D)=O$, and $C-D=\begin{bmatrix}-1&-1\\1&1\end{bmatrix}$ is a non-zero matrix whose columns solve $A\mathbf{x}=\mathbf{0}$ — part (b) again in disguise.

Rules for Products, and Powers

Although order matters, the other familiar laws do survive.

📐 Theorem 2.3 — Properties of matrix multiplication
Let $A$ be $m\times n$, and let $B$, $C$ have sizes for which the sums and products below are defined; let $r$ be a scalar. Then
  1. $A(BC)=(AB)C$ (associative law);
  2. $A(B+C)=AB+AC$ and $(B+C)A=BA+CA$ (distributive laws — keep each factor on its own side);
  3. $r(AB)=(rA)B=A(rB)$;
  4. $I_mA=A=AI_n$ (the identity matrix behaves like the number $1$).

The associative law is exactly what the motivation above promised: applying $C$, then $B$, then $A$ gives the same as applying the single matrix $ABC$, however we group the work. Because of it, we may write $ABC$ without brackets.

For a square matrix $A$ we define powers $A^k=AA\cdots A$ ($k$ factors) and $A^0=I$. The usual rules $A^rA^s=A^{r+s}$ and $\left(A^r\right)^s=A^{rs}$ hold. But expansions that secretly swap factors do not: $(A+B)^2=A^2+AB+BA+B^2$, which equals $A^2+2AB+B^2$ only when $AB=BA$.

The Transpose and Symmetric Matrices

📘 Definition 2.5 — Transpose
The transpose of an $m\times n$ matrix $A$ is the $n\times m$ matrix $A^{T}$ whose rows are the columns of $A$: $\left(A^{T}\right)_{ij}=a_{ji}$. For example, $$\begin{bmatrix}1&2&0\\-1&3&4\end{bmatrix}^{T}=\begin{bmatrix}1&-1\\2&3\\0&4\end{bmatrix}.$$
📐 Theorem 2.4 — Properties of the transpose
For matrices whose sizes make each expression defined, and any scalar $c$: $$\left(A^{T}\right)^{T}=A,\qquad (A+B)^{T}=A^{T}+B^{T},\qquad (cA)^{T}=cA^{T},\qquad (AB)^{T}=B^{T}A^{T}.$$

The reversal in $(AB)^{T}=B^{T}A^{T}$ is forced by sizes: if $A$ is $m\times n$ and $B$ is $n\times p$, then $B^{T}$ is $p\times n$ and $A^{T}$ is $n\times m$, so only $B^{T}A^{T}$ fits. Entry by entry, $$\left((AB)^{T}\right)_{ij}=(AB)_{ji}=\sum_k a_{jk}b_{ki}=\sum_k\left(B^{T}\right)_{ik}\left(A^{T}\right)_{kj}=\left(B^{T}A^{T}\right)_{ij}.$$ A useful special case: for column vectors $\mathbf{u}$, $\mathbf{v}$ in $\mathbb{R}^n$, the $1\times1$ product $\mathbf{u}^{T}\mathbf{v}=u_1v_1+\cdots+u_nv_n$ is the dot product $\mathbf{u}\cdot\mathbf{v}$ of Chapter 4.

📘 Definition 2.6 — Symmetric matrix
A square matrix $A$ is symmetric if $A^{T}=A$, that is, $a_{ij}=a_{ji}$ for all $i,j$: the matrix is a mirror image of itself across the main diagonal. Example: $\begin{bmatrix}2&-1&5\\-1&0&3\\5&3&7\end{bmatrix}$.
✏️ Example 6 — Powers and transposes
(a) Let $A=\begin{bmatrix}1&1\\0&1\end{bmatrix}$. Compute $A^2$ and $A^3$, and guess a formula for $A^n$.
(b) Let $B=\begin{bmatrix}1&2&0\\-1&3&4\end{bmatrix}$. Compute $BB^{T}$ and $B^{T}B$, and explain why both are symmetric.
(a) Powers $$A^2=\begin{bmatrix}1&1\\0&1\end{bmatrix}\begin{bmatrix}1&1\\0&1\end{bmatrix}=\begin{bmatrix}1&2\\0&1\end{bmatrix},\qquad A^3=A^2A=\begin{bmatrix}1&3\\0&1\end{bmatrix}.$$ Each multiplication by $A$ adds $1$ to the top-right entry, so $A^n=\begin{bmatrix}1&n\\0&1\end{bmatrix}$. (A proof by induction: $\begin{bmatrix}1&n\\0&1\end{bmatrix}\begin{bmatrix}1&1\\0&1\end{bmatrix}=\begin{bmatrix}1&n+1\\0&1\end{bmatrix}$.)
(b) Sizes $B$ is $2\times3$, so $BB^{T}$ is $(2\times3)(3\times2)=2\times2$ and $B^{T}B$ is $(3\times2)(2\times3)=3\times3$.
(b) Compute $$BB^{T}=\begin{bmatrix}1+4+0&-1+6+0\\-1+6+0&1+9+16\end{bmatrix}=\begin{bmatrix}5&5\\5&26\end{bmatrix},\qquad B^{T}B=\begin{bmatrix}2&-1&-4\\-1&13&12\\-4&12&16\end{bmatrix}.$$ (Entry $(i,j)$ of $B^{T}B$ is column $i$ of $B$ times column $j$ of $B$; e.g. $(2,3)$: $2(0)+3(4)=12$.)
(b) Why symmetric By Theorem 2.4, $\left(BB^{T}\right)^{T}=\left(B^{T}\right)^{T}B^{T}=BB^{T}$, and likewise $\left(B^{T}B\right)^{T}=B^{T}B$. This works for every matrix $B$; such products appear again in least squares (Chapter 8).

Exercises

I
Size, equality, sums and scalar multiples. Let $A=\begin{bmatrix}2&-1\\0&3\\4&1\end{bmatrix}$, $B=\begin{bmatrix}1&5\\-2&0\\3&-3\end{bmatrix}$, $C=\begin{bmatrix}1&0&2\\-1&4&3\end{bmatrix}$.
  • 1 Give the sizes of $A$ and $C$, and the entries $a_{31}$ and $c_{23}$.
  • 2 Compute $A+B$.
  • 3 Compute $3A-2B$.
  • 4 Is $A+C$ defined? Explain.
  • 5 Find the matrix $X$ with $2X+A=B$.
  • 6 Find $a,b,c,d$ so that $\begin{bmatrix}a+b&2c\\a-b&c+d\end{bmatrix}=\begin{bmatrix}5&8\\1&10\end{bmatrix}$.
  • 7 Write out the $3\times3$ matrix with entries $a_{ij}=i-2j$.
  • 8 Retail. Two shops sell three products. January's sales are $J=\begin{bmatrix}40&25&10\\35&30&15\end{bmatrix}$ and February's are $F=\begin{bmatrix}45&20&12\\30&35&20\end{bmatrix}$ (rows: shops, columns: products). Find the total sales over the two months, and the forecast for March if every figure is expected to be $20\%$ above January's.
1 $A$ is $3\times2$ and $C$ is $2\times3$; $a_{31}=4$, $c_{23}=3$.
2 $A+B=\begin{bmatrix}3&4\\-2&3\\7&-2\end{bmatrix}$.
3 $3A-2B=\begin{bmatrix}6-2&-3-10\\0+4&9-0\\12-6&3+6\end{bmatrix}=\begin{bmatrix}4&-13\\4&9\\6&9\end{bmatrix}$.
4 No: $A$ is $3\times2$ and $C$ is $2\times3$. Sums need equal sizes.
5 $X=\tfrac12(B-A)=\tfrac12\begin{bmatrix}-1&6\\-2&-3\\-1&-4\end{bmatrix}=\begin{bmatrix}-\tfrac12&3\\-1&-\tfrac32\\-\tfrac12&-2\end{bmatrix}$. Check: $2X+A=\begin{bmatrix}-1&6\\-2&-3\\-1&-4\end{bmatrix}+A=B$ ✓.
6 $a+b=5$, $a-b=1$ give $a=3$, $b=2$; $2c=8$ gives $c=4$; $c+d=10$ gives $d=6$.
7 $\begin{bmatrix}-1&-3&-5\\0&-2&-4\\1&-1&-3\end{bmatrix}$ (e.g. $a_{12}=1-4=-3$, $a_{31}=3-2=1$).
8 Total: $J+F=\begin{bmatrix}85&45&22\\65&65&35\end{bmatrix}$ units. March forecast: $1.2J=\begin{bmatrix}48&30&12\\42&36&18\end{bmatrix}$ units.
II
Products. Let $P=\begin{bmatrix}1&2\\-1&3\end{bmatrix}$, $Q=\begin{bmatrix}2&0&1\\1&-1&4\end{bmatrix}$, $R=\begin{bmatrix}3&1\\0&2\\-1&5\end{bmatrix}$, $\mathbf{u}=\begin{bmatrix}2\\-1\end{bmatrix}$. Compute each product that is defined; if it is not defined, say why.
  • 1 $P\mathbf{u}$, by the column view and by the row view
  • 2 $Q\mathbf{v}$ for $\mathbf{v}=(1,2,-1)$, written as a combination of the columns of $Q$
  • 3 $PQ$
  • 4 $QR$
  • 5 $RQ$
  • 6 $QP$
  • 7 $P^2$
  • 8 $RP$
  • 9 Write the system $2x_1-x_2+5x_3=4$, $x_1+3x_3=-1$ as $A\mathbf{x}=\mathbf{b}$ and as a vector equation.
  • 10 Write $x_1\begin{bmatrix}1\\2\end{bmatrix}+x_2\begin{bmatrix}3\\-1\end{bmatrix}=\begin{bmatrix}5\\3\end{bmatrix}$ as a matrix equation and solve it.
  • 11 Without computing all of $RQ$, find its $(2,1)$ entry and its third column.
Check: step through your product entry by entry
sizes—
entry—
row · column—
value—
1 Columns: $2\begin{bmatrix}1\\-1\end{bmatrix}-1\begin{bmatrix}2\\3\end{bmatrix}=\begin{bmatrix}0\\-5\end{bmatrix}$. Rows: $1(2)+2(-1)=0$, $-1(2)+3(-1)=-5$. So $P\mathbf{u}=\begin{bmatrix}0\\-5\end{bmatrix}$.
2 $Q\mathbf{v}=1\begin{bmatrix}2\\1\end{bmatrix}+2\begin{bmatrix}0\\-1\end{bmatrix}-1\begin{bmatrix}1\\4\end{bmatrix}=\begin{bmatrix}1\\-5\end{bmatrix}$.
3 $(2\times2)(2\times3)\to2\times3$: $PQ=\begin{bmatrix}4&-2&9\\1&-3&11\end{bmatrix}$.
4 $(2\times3)(3\times2)\to2\times2$: $QR=\begin{bmatrix}6+0-1&2+0+5\\3+0-4&1-2+20\end{bmatrix}=\begin{bmatrix}5&7\\-1&19\end{bmatrix}$.
5 $(3\times2)(2\times3)\to3\times3$: $RQ=\begin{bmatrix}7&-1&7\\2&-2&8\\3&-5&19\end{bmatrix}$. Compare part 4: $QR$ and $RQ$ are not even the same size.
6 $(2\times3)(2\times2)$: inner sizes $3\ne2$, so $QP$ is not defined.
7 $P^2=\begin{bmatrix}1-2&2+6\\-1-3&-2+9\end{bmatrix}=\begin{bmatrix}-1&8\\-4&7\end{bmatrix}$ — not the matrix of squared entries.
8 $(3\times2)(2\times2)\to3\times2$: $RP=\begin{bmatrix}3-1&6+3\\0-2&0+6\\-1-5&-2+15\end{bmatrix}=\begin{bmatrix}2&9\\-2&6\\-6&13\end{bmatrix}$.
9 $\begin{bmatrix}2&-1&5\\1&0&3\end{bmatrix}\begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix}=\begin{bmatrix}4\\-1\end{bmatrix}$, or $x_1\begin{bmatrix}2\\1\end{bmatrix}+x_2\begin{bmatrix}-1\\0\end{bmatrix}+x_3\begin{bmatrix}5\\3\end{bmatrix}=\begin{bmatrix}4\\-1\end{bmatrix}$. (Note the $0$ coefficient of $x_2$ in the second equation.)
10 $\begin{bmatrix}1&3\\2&-1\end{bmatrix}\begin{bmatrix}x_1\\x_2\end{bmatrix}=\begin{bmatrix}5\\3\end{bmatrix}$. From $2x_1-x_2=3$, $x_2=2x_1-3$; then $x_1+6x_1-9=5$ gives $x_1=2$, $x_2=1$. Check: $2(1,2)+1(3,-1)=(5,3)$ ✓.
11 $(2,1)$ entry: row 2 of $R$ times column 1 of $Q$: $0(2)+2(1)=2$. Third column: $R\begin{bmatrix}1\\4\end{bmatrix}=1\begin{bmatrix}3\\0\\-1\end{bmatrix}+4\begin{bmatrix}1\\2\\5\end{bmatrix}=\begin{bmatrix}7\\8\\19\end{bmatrix}$. Both agree with part 5 ✓.
III
Transposes, symmetric matrices and powers ($Q$ and $R$ as in II).
  • 1 Write down $Q^{T}$ and $R^{T}$.
  • 2 Compute $R^{T}Q^{T}$ and check that it equals $(QR)^{T}$. Is $Q^{T}R^{T}$ defined, and what is it equal to?
  • 3 Compute $QQ^{T}$ and $Q^{T}Q$ and confirm both are symmetric.
  • 4 Find $x,y,z$ so that $\begin{bmatrix}1&x&3\\4&2&y\\z&-5&0\end{bmatrix}$ is symmetric.
  • 5 Let $F=\begin{bmatrix}1&1\\1&0\end{bmatrix}$. Compute $F^2,F^3,F^4,F^5$. Which famous sequence appears?
  • 6 Let $N=\begin{bmatrix}0&1\\0&0\end{bmatrix}$. Compute $N^2$. What does this say about the rule "$a^2=0\Rightarrow a=0$" for matrices?
  • 7 Prove that $B^{T}B$ and $BB^{T}$ are symmetric for every matrix $B$, and that $A+A^{T}$ is symmetric for every square $A$.
  • 8 Challenge. Let $A$ and $B$ be symmetric $n\times n$ matrices. Prove that $AB$ is symmetric if and only if $AB=BA$.
1 $Q^{T}=\begin{bmatrix}2&1\\0&-1\\1&4\end{bmatrix}$, $R^{T}=\begin{bmatrix}3&0&-1\\1&2&5\end{bmatrix}$.
2 $R^{T}Q^{T}$ is $(2\times3)(3\times2)=2\times2$: $\begin{bmatrix}5&-1\\7&19\end{bmatrix}$, which is the transpose of $QR=\begin{bmatrix}5&7\\-1&19\end{bmatrix}$ ✓. $Q^{T}R^{T}$ is $(3\times2)(2\times3)=3\times3$ and equals $(RQ)^{T}$ — a different matrix altogether.
3 $QQ^{T}=\begin{bmatrix}5&6\\6&18\end{bmatrix}$ and $Q^{T}Q=\begin{bmatrix}5&-1&6\\-1&1&-4\\6&-4&17\end{bmatrix}$; each equals its own mirror image across the diagonal.
4 Need $a_{12}=a_{21}$: $x=4$; $a_{23}=a_{32}$: $y=-5$; $a_{31}=a_{13}$: $z=3$.
5 $F^2=\begin{bmatrix}2&1\\1&1\end{bmatrix}$, $F^3=\begin{bmatrix}3&2\\2&1\end{bmatrix}$, $F^4=\begin{bmatrix}5&3\\3&2\end{bmatrix}$, $F^5=\begin{bmatrix}8&5\\5&3\end{bmatrix}$: the Fibonacci numbers $1,1,2,3,5,8,\dots$ In fact $F^n=\begin{bmatrix}f_{n+1}&f_n\\f_n&f_{n-1}\end{bmatrix}$.
6 $N^2=\begin{bmatrix}0&0\\0&0\end{bmatrix}=O$ although $N\ne O$. So for matrices $A^2=O$ does not imply $A=O$.
7 $\left(B^{T}B\right)^{T}=B^{T}\left(B^{T}\right)^{T}=B^{T}B$ and $\left(BB^{T}\right)^{T}=\left(B^{T}\right)^{T}B^{T}=BB^{T}$, using $(XY)^{T}=Y^{T}X^{T}$ and $\left(X^{T}\right)^{T}=X$. Also $\left(A+A^{T}\right)^{T}=A^{T}+A$.
8 $(AB)^{T}=B^{T}A^{T}=BA$ because $A$, $B$ are symmetric. Hence $AB$ is symmetric $\iff(AB)^{T}=AB\iff BA=AB$.
IV
Algebra with care, and modelling.
  • 1 For $A=\begin{bmatrix}1&0\\0&0\end{bmatrix}$ and $B=\begin{bmatrix}0&1\\0&0\end{bmatrix}$, compute $(A+B)^2$ and $A^2+2AB+B^2$. Explain the difference.
  • 2 Find all matrices $X=\begin{bmatrix}a&b\\c&d\end{bmatrix}$ with $XK=KX$, where $K=\begin{bmatrix}1&1\\0&1\end{bmatrix}$.
  • 3 True or false (give a reason or a counterexample): (a) if $AB$ and $BA$ are both defined then $A$ and $B$ are square; (b) if $A$ is $m\times n$ then $AA^{T}$ is defined; (c) $(A+B)(A-B)=A^2-B^2$ for all square $A$, $B$ of the same size.
  • 4 The trace $\operatorname{tr}A$ of a square matrix is the sum of its main-diagonal entries. Show that $\operatorname{tr}(AB)=\operatorname{tr}(BA)$ for all $2\times2$ matrices, and deduce that no $2\times2$ matrices satisfy $AB-BA=I$.
  • 5 Manufacturing. A workshop makes chairs, tables and desks. The resource matrix $R=\begin{bmatrix}2&4&3\\3&5&6\end{bmatrix}$ gives the wood (m², row 1) and labour (hours, row 2) needed per item. An order is $\mathbf{x}=(10,4,6)$ chairs, tables, desks. Compute $R\mathbf{x}$ and interpret it.
  • 6 In part 5, wood costs $\$15$ per m² and labour $\$20$ per hour, so let $\mathbf{c}^{T}=\begin{bmatrix}15&20\end{bmatrix}$. Compute $\mathbf{c}^{T}R$ (the cost of each item) and the total cost $\mathbf{c}^{T}R\mathbf{x}$ of the order in two ways, using associativity.
1 $A+B=\begin{bmatrix}1&1\\0&0\end{bmatrix}$ and $(A+B)^2=\begin{bmatrix}1&1\\0&0\end{bmatrix}$. But $A^2=A$, $AB=B$, $B^2=O$, so $A^2+2AB+B^2=\begin{bmatrix}1&2\\0&0\end{bmatrix}$. The correct expansion is $A^2+AB+BA+B^2$, and here $BA=O\ne AB$, so the "$2AB$" is wrong.
2 $XK=\begin{bmatrix}a&a+b\\c&c+d\end{bmatrix}$, $KX=\begin{bmatrix}a+c&b+d\\c&d\end{bmatrix}$. Equal iff $c=0$ and $a=d$: $X=\begin{bmatrix}a&b\\0&a\end{bmatrix}$ for any $a,b$.
3 (a) False: $A$ $2\times3$ and $B$ $3\times2$ give both products. (b) True: $(m\times n)(n\times m)$. (c) False: $(A+B)(A-B)=A^2-AB+BA-B^2$; with $A$, $B$ from part 1 this is $A^2-AB+BA-B^2=\begin{bmatrix}1&-1\\0&0\end{bmatrix}\ne A^2-B^2=\begin{bmatrix}1&0\\0&0\end{bmatrix}$.
4 With $A=\begin{bmatrix}p&q\\r&s\end{bmatrix}$, $B=\begin{bmatrix}e&f\\g&h\end{bmatrix}$: $\operatorname{tr}(AB)=pe+qg+rf+sh=\operatorname{tr}(BA)$. Then $\operatorname{tr}(AB-BA)=0$, but $\operatorname{tr}I=2$, so $AB-BA=I$ is impossible.
5 $R\mathbf{x}=10\begin{bmatrix}2\\3\end{bmatrix}+4\begin{bmatrix}4\\5\end{bmatrix}+6\begin{bmatrix}3\\6\end{bmatrix}=\begin{bmatrix}54\\86\end{bmatrix}$: the order needs $54$ m² of wood and $86$ hours of labour.
6 $\mathbf{c}^{T}R=\begin{bmatrix}90&160&165\end{bmatrix}$: a chair costs $\$90$, a table $\$160$, a desk $\$165$. Total: $(\mathbf{c}^{T}R)\mathbf{x}=900+640+990=\$2530$, and $\mathbf{c}^{T}(R\mathbf{x})=15(54)+20(86)=810+1720=\$2530$ ✓.
🔬 Research–Teaching NexusResearch-tutored · optional, about 30 minutes

Research question. How can matrix powers tell an airline, a transport planner or an epidemiologist how well a network is connected — and how quickly something can spread through it?

Why it matters. Networks of airports, railway stations, computers or people are stored as an adjacency matrix $A$, with $a_{ij}=1$ if there is a direct link from $i$ to $j$ and $0$ otherwise. By the row–column rule, $(A^2)_{ij}=\sum_k a_{ik}a_{kj}$ counts the routes $i\to k\to j$ with exactly one stop. Network scientists use powers of $A$ to measure how central a hub is and how fast a delay or a virus can travel.

What to do.

  1. Four airports — Dubai (DXB), Mumbai (BOM), London (LHR) and Nairobi (NBO), in that order — have direct flights DXB–BOM, DXB–LHR, DXB–NBO, BOM–LHR and LHR–NBO (both directions). Write down the $4\times4$ adjacency matrix $A$ and check that it is symmetric. Why must it be?
  2. Compute $A^2$. How many one-stop routes are there from Mumbai to Nairobi, and through which hubs? What do the diagonal entries of $A^2$ count?
  3. Compute $A+A^2$. Explain why "every entry of $A+A^2$ is positive" means every airport can reach every other with at most one change of plane.
  4. Compute $A^3$ and interpret $(A^3)_{11}$. Which airport is best connected? Suggest a single measure built from $A$, $A^2$, $A^3$.

Tools: Paper and pencil, then a spreadsheet (MMULT) or Python/NumPy to check.

Hand in: Half a page with the matrices $A$, $A^2$, $A^3$, your interpretation of three chosen entries, and your proposed "connectedness score" for each airport.

Going further. Find a small real network (a metro map of your city, a football passing network from match data, or a contact network from a public-health case study) and repeat the analysis. Look up "Katz centrality", which adds up all powers $A^k$ with decreasing weights.

Instructor note: $A=\begin{bmatrix}0&1&1&1\\1&0&1&0\\1&1&0&1\\1&0&1&0\end{bmatrix}$, $A^2=\begin{bmatrix}3&1&2&1\\1&2&1&2\\2&1&3&1\\1&2&1&2\end{bmatrix}$ (BOM to NBO: $2$ routes, via DXB and via LHR; the diagonal counts the direct links of each airport), $A+A^2$ has all entries $\ge2$, and $A^3=\begin{bmatrix}4&5&5&5\\5&2&5&2\\5&5&4&5\\5&2&5&2\end{bmatrix}$; $(A^3)_{11}=4$ counts round trips DXB→·→·→DXB. DXB and LHR tie as the best-connected hubs.

🧪 Self-check quiz

0/5 correct

Q1. If $A$ is $3\times4$ and $B$ is $4\times2$, then $AB$ is

Q2. $\begin{bmatrix}1&2\\3&4\end{bmatrix}\begin{bmatrix}1\\-1\end{bmatrix}=$

Q3. Which statement is true for all matrices of suitable sizes?

Q4. $(AB)^{T}$ equals

Q5. The $(2,3)$ entry of $AB$ is computed from