C1, C2 - Calculating with matrices

C1, C2 - Calculating with matrices

A matrix keeps several numbers in a fixed arrangement, so that you can calculate with the whole arrangement at once. C1 introduces matrix size, addition, subtraction and scalar multiplication; C2 introduces the zero and identity matrices. You will see why the positions of the numbers matter just as much as their values.

Dimensions and conformability

Can two lists containing the same six numbers represent different matrices? Compare these arrangements:

A=(123456),B=(123456)\mathbf{A}=\begin{pmatrix}1&2&3\\4&5&6\end{pmatrix}, \qquad \mathbf{B}=\begin{pmatrix}1&2\\3&4\\5&6\end{pmatrix}

The first has two horizontal rows and three vertical columns. The second has three rows and two columns. They are different matrices: the number 3 even occupies a different position.

Matrix and order

A matrix is a rectangular array of entries. Its order or dimensions are m×nm\times n: number of rows first, number of columns second. A square matrix has the same number of rows and columns. A 1×n1\times n matrix is a row matrix; an m×1m\times1 matrix is a column matrix.

Thus A\mathbf{A} has order 2×32\times3, while B\mathbf{B} has order 3×23\times2. The notation aija_{ij} means the entry of A\mathbf{A} in row ii, column jj. Here a23=6a_{23}=6, but a32a_{32} does not exist. A matrix need not contain only integers: fractions, negative numbers and algebraic expressions can all be entries.

Two matrices are equal when their dimensions agree and every pair of corresponding entries is equal. For example,

(p2−1q)=(32−15)⟹p=3, q=5\begin{pmatrix}p&2\\-1&q\end{pmatrix} = \begin{pmatrix}3&2\\-1&5\end{pmatrix} \quad\Longrightarrow\quad p=3,\ q=5

To add or subtract matrices, each entry needs a partner in exactly the same position. The matrices must therefore have the same dimensions. Such matrices are conformable for addition or subtraction. Having the same total number of entries is insufficient: A+B\mathbf{A}+\mathbf{B} above is undefined. Conformability depends on the operation; multiplication will have a different size rule.

Watch out

A 2×32\times3 matrix has two rows, not two columns. Matrix order records an arrangement, not the product 2×3=62\times3=6.

Use both dimensions in this check.

Addition, subtraction and scalar multiplication

Matrix addition acts entry by entry. For example, the top-right entry of a sum is the sum of the two top-right entries. Multiplying a matrix by a number, called a scalar, multiplies every entry by that number:

(1−230)+(41−15)=(5−125),3(1−230)=(3−690)\begin{pmatrix}1&-2\\3&0\end{pmatrix} + \begin{pmatrix}4&1\\-1&5\end{pmatrix} = \begin{pmatrix}5&-1\\2&5\end{pmatrix}, \qquad 3\begin{pmatrix}1&-2\\3&0\end{pmatrix} = \begin{pmatrix}3&-6\\9&0\end{pmatrix}

Subtraction means adding the negative of every entry in the second matrix. These operations leave the dimensions unchanged. Because they use ordinary arithmetic in corresponding positions, A+B=B+A\mathbf{A}+\mathbf{B}=\mathbf{B}+\mathbf{A} and k(A+B)=kA+kBk(\mathbf{A}+\mathbf{B})=k\mathbf{A}+k\mathbf{B} whenever the sums are defined.

Worked example 1: a linear combination

Question. Find 2A+B2\mathbf{A}+\mathbf{B}, where

A=(2−103),B=(14−25)\mathbf{A}=\begin{pmatrix}2&-1\\0&3\end{pmatrix},\qquad \mathbf{B}=\begin{pmatrix}1&4\\-2&5\end{pmatrix}

Plan. Multiply every entry of A\mathbf{A} by 2, then add corresponding entries.

2A+B=(4−206)+(14−25)scale first=(52−211)add in each position\begin{aligned} 2\mathbf{A}+\mathbf{B} &=\begin{pmatrix}4&-2\\0&6\end{pmatrix} +\begin{pmatrix}1&4\\-2&5\end{pmatrix} && \text{scale first}\\ &=\begin{pmatrix}5&2\\-2&11\end{pmatrix} && \text{add in each position} \end{aligned}

Answer. (52−211)\begin{pmatrix}5&2\\-2&11\end{pmatrix}.

Check. Subtracting B\mathbf{B} from the answer gives (4−206)=2A\begin{pmatrix}4&-2\\0&6\end{pmatrix}=2\mathbf{A}, recovering the scaled matrix.

Keep both matrices and the scalar fixed. Change only addition to subtraction, so the signs in the second matrix become the important difference.

Worked example 2: subtracting a matrix

Question. For the same A\mathbf{A} and B\mathbf{B}, find 2A−B2\mathbf{A}-\mathbf{B}.

Plan. Scale A\mathbf{A}, then subtract each entry of B\mathbf{B}, including its negative entry.

2A−B=(4−1−2−40−(−2)6−5)subtract corresponding entries=(3−621)simplify\begin{aligned} 2\mathbf{A}-\mathbf{B} &=\begin{pmatrix}4-1&-2-4\\0-(-2)&6-5\end{pmatrix} && \text{subtract corresponding entries}\\ &=\begin{pmatrix}3&-6\\2&1\end{pmatrix} && \text{simplify} \end{aligned}

Answer. (3−621)\begin{pmatrix}3&-6\\2&1\end{pmatrix}.

Check. Adding B\mathbf{B} back gives (4−206)\begin{pmatrix}4&-2\\0&6\end{pmatrix}. Its entries are exactly twice those of A\mathbf{A}.

The calculation is a collection of familiar arithmetic steps, but all positions must be retained.

Watch out

Wrong: multiply only the diagonal entries by the scalar. Correct: every entry is multiplied. Likewise, a minus sign before a matrix changes every sign.

Try another subtraction with a scalar.

Zero and identity matrices

Ordinary arithmetic has special numbers: adding zero leaves a number unchanged, while multiplying by one leaves it unchanged. Matrices have corresponding special arrays, with dimensions built into their definitions.

Zero matrix

A zero matrix, written 0\mathbf{0}, has every entry zero. It can have any dimensions. For an m×nm\times n matrix A\mathbf{A}, the matching m×nm\times n zero matrix satisfies A+0=A\mathbf{A}+\mathbf{0}=\mathbf{A} and A−A=0\mathbf{A}-\mathbf{A}=\mathbf{0}.

For example,

02×3=(000000)\mathbf{0}_{2\times3}=\begin{pmatrix}0&0&0\\0&0&0\end{pmatrix}

The dimensions are often clear from context and the subscript is omitted. The scalar zero and a zero matrix are different kinds of object, although both are written with a zero symbol. Multiplying every entry of any matrix by the scalar zero produces a zero matrix of the same dimensions.

A different special array is square:

I2=(1001),I3=(100010001)\mathbf{I}_2=\begin{pmatrix}1&0\\0&1\end{pmatrix},\qquad \mathbf{I}_3=\begin{pmatrix}1&0&0\\0&1&0\\0&0&1\end{pmatrix}

Identity matrix

The identity matrix In\mathbf{I}_n is the n×nn\times n square matrix with 1 in every position on the main diagonal and 0 elsewhere. The main diagonal runs from top left to bottom right. The identity acts like 1 under matrix multiplication.

There is one identity matrix for each square size. A matrix filled entirely with ones is not an identity matrix. Nor does A+I\mathbf{A}+\mathbf{I} leave A\mathbf{A} unchanged: addition increases its diagonal entries by 1. For example,

(25−14)+I2=(35−15)\begin{pmatrix}2&5\\-1&4\end{pmatrix}+\mathbf{I}_2 =\begin{pmatrix}3&5\\-1&5\end{pmatrix}

You will verify the multiplication property in the next lesson, once multiplication has been defined. Already, the opening puzzle is resolved: putting the same entries in a different arrangement can change the matrix's dimensions, the operations allowed and the meaning of the result.

Quick Recap

  • Dimensions mean rows followed by columns; equal matrices have equal corresponding entries.
  • Add and subtract only matrices of the same dimensions. A scalar multiplies every entry.
  • A zero matrix has all entries zero; an identity matrix is square with diagonal ones and other entries zero.

An arrangement is part of a matrix's identity: the same six numbers can form different matrices.