Discord

INAIO Guide Stage 1 11Matrices and Linear Transformations

11.2 Matrix operations

Check matrix shapes before adding, multiplying, or transposing, and compute products row by column.

In Module 11.1, a matrix was a labelled grid of numbers. Now we want to combine such grids. Adding matching entries combines two measurements of the same layout. Multiplying can connect two stages of a calculation: the first stage makes intermediate values, and the second stage uses them to make final values. The shapes tell us whether those intermediate values match up.

This is intermediate linear algebra. Work through OpenStax's matrix-operation examples after learning dimensions and indexing.

A basic idea: match the shapes

You may add two matrices only when they have the same shape, adding entries in matching positions. To multiply ABAB, imagine BB taking a vector with pp entries and producing nn intermediate values. Then AA turns those nn values into mm outputs. So AA has shape m×nm\times n, BB has shape n×pn\times p, and ABAB has shape m×pm\times p. The two inner dimensions must match because every intermediate value needs a corresponding weight.

A highlighted row of a two-by-three matrix meets a highlighted column of a three-by-two matrix, producing one entry of a two-by-two product.A highlighted row of a two-by-three matrix meets a highlighted column of a three-by-two matrix, producing one entry of a two-by-two product.
One product entry comes from one row and one column.

A quick tour of formulas

For equal-shaped matrices, (A+B)ij=aij+bij(A+B)_{ij}=a_{ij}+b_{ij}. In a product, choose the row for the output and the column for the input. Multiply entries in matching intermediate positions and add them. For a valid product,

(AB)ij=∑k=1naikbkj.(AB)_{ij}=\sum_{k=1}^{n}a_{ik}b_{kj}.

The transpose ATA^{\mathsf T} swaps rows and columns, so an m×nm\times n matrix becomes n×mn\times m and (AT)ij=aji(A^{\mathsf T})_{ij}=a_{ji}. This is useful when the same data need to be grouped by columns instead of rows. In general AB≠BAAB\ne BA; reversing the stages can change the result, or even make the product undefined.

Application 1: add and transpose data grids

Two 2×22\times2 measurement grids are A=[1234]A=\begin{bmatrix}1&2\\3&4\end{bmatrix} and B=[5012]B=\begin{bmatrix}5&0\\1&2\end{bmatrix}. Their sum is

A+B=[6246],AT=[1324].A+B=\begin{bmatrix}6&2\\4&6\end{bmatrix},\qquad A^{\mathsf T}=\begin{bmatrix}1&3\\2&4\end{bmatrix}.

Addition combines matching cells; transposition changes the orientation of the data.

Application 2: two operations in sequence

A matrix can also describe a rule that changes every point in the plane; Module 11.4 develops this view. Let R=[0−110]R=\begin{bmatrix}0&-1\\1&0\end{bmatrix} rotate a vector a quarter-turn anticlockwise, and D=[2001]D=\begin{bmatrix}2&0\\0&1\end{bmatrix} stretch its horizontal component. Then

DR=[0−210],RD=[0−120].DR=\begin{bmatrix}0&-2\\1&0\end{bmatrix},\qquad RD=\begin{bmatrix}0&-1\\2&0\end{bmatrix}.

For (1,0)(1,0), DR(1,0)=(0,1)DR(1,0)=(0,1) while RD(1,0)=(0,2)RD(1,0)=(0,2). The rightmost operation acts first, so changing order changes the result.

Resources

SourceTitleWhy read it
OpenStaxMatrices and matrix operationsPractise addition, products, and transposes.

Finished this module? Mark it done.

Comments

Stuck on something, spotted a mistake, or found a resource that helped you? Tell us below.

Loading comments