| |

4: Matrix Operations

Matrices arenโ€™t just grids of numbersโ€”theyโ€™re objects with their own arithmetic.

Three Types of Operations

  • Addition & Scalar Multiplication: Work entry-by-entry (simple)
  • Matrix Multiplication: Something stranger and more powerfulโ€”itโ€™s function composition in disguise

Matrix Addition

(Matrix Addition)

Two matrices AA and BB can be added if and only if they have the same dimensions. If AA and BB are both mร—nm \times n, their sum is defined entry-by-entry:

(A+B)ij=Aij+Bij(A + B)_{ij} = A_{ij} + B_{ij}

Example:

[1234]+[5678]=[681012]\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} + \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} = \begin{bmatrix} 6 & 8 \\ 10 & 12 \end{bmatrix}

(Properties of Matrix Addition)

For matrices AA, BB, CC of the same size:

  1. Commutativity: A+B=B+AA + B = B + A
  2. Associativity: (A+B)+C=A+(B+C)(A + B) + C = A + (B + C)
  3. Identity: A+O=AA + O = A where OO is the zero matrix
  4. Inverse: A+(โˆ’A)=OA + (-A) = O

Matrix addition inherits all the nice properties of real number addition.


Scalar Multiplication

(Scalar Multiplication)

For a scalar cโˆˆRc \in \mathbb{R} and matrix AA:

(cA)ij=cโ‹…Aij(cA)_{ij} = c \cdot A_{ij}

Every entry gets multiplied by cc.

Example:

3[1234]=[36912]3 \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} = \begin{bmatrix} 3 & 6 \\ 9 & 12 \end{bmatrix}

(Properties of Scalar Multiplication)

For scalars c,dc, d and matrices A,BA, B:

  1. Associativity: c(dA)=(cd)Ac(dA) = (cd)A
  2. Distributivity over matrix addition: c(A+B)=cA+cBc(A + B) = cA + cB
  3. Distributivity over scalar addition: (c+d)A=cA+dA(c + d)A = cA + dA
  4. Identity: 1โ‹…A=A1 \cdot A = A

Matrix Multiplication

Matrix multiplication is where things get interesting. Unlike addition, itโ€™s not entry-by-entry,it encodes something deeper.

(When Can You Multiply?)

You can compute ABAB if and only if:

(columnsย ofย A)=(rowsย ofย B)\text{(columns of } A) = \text{(rows of } B)

If AA is mร—nm \times n and BB is nร—pn \times p, then ABAB is mร—pm \times p.

AโŸmร—nโ‹…BโŸnร—p=ABโŸmร—p\underbrace{A}_{m \times n} \cdot \underbrace{B}_{n \times p} = \underbrace{AB}_{m \times p}

The inner dimensions must match; the outer dimensions give the result size.


(The Entry Formula)

The (i,j)(i, j) entry of ABAB is computed as:

(AB)ij=โˆ‘k=1nAikBkj=Ai1B1j+Ai2B2j+โ‹ฏ+AinBnj(AB)_{ij} = \sum_{k=1}^{n} A_{ik} B_{kj} = A_{i1}B_{1j} + A_{i2}B_{2j} + \cdots + A_{in}B_{nj}

This is the dot product of row ii of AA with column jj of BB.

Example:

[1234][5678]=[1(5)+2(7)1(6)+2(8)3(5)+4(7)3(6)+4(8)]=[19224350]\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} = \begin{bmatrix} 1(5) + 2(7) & 1(6) + 2(8) \\ 3(5) + 4(7) & 3(6) + 4(8) \end{bmatrix} = \begin{bmatrix} 19 & 22 \\ 43 & 50 \end{bmatrix}

Three Ways to See Matrix Multiplication

The entry formula is correct but unilluminating. Here are three better perspectives.

(View 1: Column Combinations)

Each column of ABAB is AA times the corresponding column of BB:

AB=A[b1โˆฃb2โˆฃโ‹ฏโˆฃbp]=[Ab1โˆฃAb2โˆฃโ‹ฏโˆฃAbp]AB = A[\mathbf{b}_1 \mid \mathbf{b}_2 \mid \cdots \mid \mathbf{b}_p] = [A\mathbf{b}_1 \mid A\mathbf{b}_2 \mid \cdots \mid A\mathbf{b}_p]

Interpretation: BB tells you how to take linear combinations of AAโ€˜s columns.


(View 2: Row Combinations)

Each row of ABAB is the corresponding row of AA times BB:

AB=[a1Ta2Tโ‹ฎamT]B=[a1TBa2TBโ‹ฎamTB]AB = \begin{bmatrix} \mathbf{a}_1^T \\ \mathbf{a}_2^T \\ \vdots \\ \mathbf{a}_m^T \end{bmatrix} B = \begin{bmatrix} \mathbf{a}_1^T B \\ \mathbf{a}_2^T B \\ \vdots \\ \mathbf{a}_m^T B \end{bmatrix}

Interpretation: AA tells you how to take linear combinations of BBโ€˜s rows.


(View 3: Function Composition)

If TA(x)=AxT_A(\mathbf{x}) = A\mathbf{x} and TB(x)=BxT_B(\mathbf{x}) = B\mathbf{x}, then:

TA(TB(x))=A(Bx)=(AB)x=TAB(x)T_A(T_B(\mathbf{x})) = A(B\mathbf{x}) = (AB)\mathbf{x} = T_{AB}(\mathbf{x})

Matrix multiplication is function composition.

The matrix ABAB represents โ€œfirst apply BB, then apply AA.โ€ This is why multiplication isnโ€™t commutative,the order of transformations matters.


(View 4: Outer Product Sum)

ABAB can be written as a sum of rank-1 matrices:

AB=โˆ‘k=1n(columnย kย ofย A)โ‹…(rowย kย ofย B)AB = \sum_{k=1}^{n} (\text{column } k \text{ of } A) \cdot (\text{row } k \text{ of } B)

Each term is an outer product,a column times a row,giving a rank-1 matrix. The sum builds up the full product.


Matrix Multiplication is NOT Commutative

(Non-Commutativity)

Critical Fact: ABโ‰ BAAB \neq BA

Why order matters:

  1. ABAB might exist when BABA doesnโ€™t (dimension mismatch)
  2. Even when both exist, they may have different sizes
  3. Even when both are the same size, the entries usually differ

Example:

[1200][0034]=[6800]\begin{bmatrix} 1 & 2 \\ 0 & 0 \end{bmatrix} \begin{bmatrix} 0 & 0 \\ 3 & 4 \end{bmatrix} = \begin{bmatrix} 6 & 8 \\ 0 & 0 \end{bmatrix} [0034][1200]=[0036]\begin{bmatrix} 0 & 0 \\ 3 & 4 \end{bmatrix} \begin{bmatrix} 1 & 2 \\ 0 & 0 \end{bmatrix} = \begin{bmatrix} 0 & 0 \\ 3 & 6 \end{bmatrix}

Same matrices, different order, different result.

Intuition: โ€œRotate then reflectโ€ is not the same as โ€œreflect then rotate.โ€


Properties of Matrix Multiplication

(What DOES Hold)

For matrices of compatible sizes:

  1. Associativity: (AB)C=A(BC)(AB)C = A(BC)
  2. Distributivity: A(B+C)=AB+ACA(B + C) = AB + AC and (A+B)C=AC+BC(A + B)C = AC + BC
  3. Scalar compatibility: c(AB)=(cA)B=A(cB)c(AB) = (cA)B = A(cB)
  4. Identity: ImA=A=AInI_m A = A = A I_n for AA of size mร—nm \times n

Associativity is remarkable,it says we can chain transformations without worrying about grouping. This is why we can write ABCABC without parentheses.


(The Identity Matrix)

The identity matrix InI_n is the nร—nn \times n matrix with 11s on the diagonal and 00s elsewhere:

I3=[100010001]I_3 = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}

Property: Inx=xI_n \mathbf{x} = \mathbf{x} for all xโˆˆRn\mathbf{x} \in \mathbb{R}^n.

The identity matrix is the โ€œdo nothingโ€ transformation.


The Transpose

(Transpose)

The transpose of AA, denoted ATA^T, swaps rows and columns:

(AT)ij=Aji(A^T)_{ij} = A_{ji}

If AA is mร—nm \times n, then ATA^T is nร—mn \times m.

Example:

[123456]T=[142536]\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}^T = \begin{bmatrix} 1 & 4 \\ 2 & 5 \\ 3 & 6 \end{bmatrix}

(Properties of Transpose)

  1. (AT)T=A(A^T)^T = A
  2. (A+B)T=AT+BT(A + B)^T = A^T + B^T
  3. (cA)T=cAT(cA)^T = cA^T
  4. (AB)T=BTAT(AB)^T = B^T A^T (note the order reversal!)

The transpose reversal (AB)T=BTAT(AB)^T = B^T A^T mirrors how function composition reverses: to undo โ€œfirst BB, then AA,โ€ you undo AA first, then BB.


(Symmetric Matrices)

A matrix is symmetric if AT=AA^T = A.

This means Aij=AjiA_{ij} = A_{ji},the matrix equals its mirror across the diagonal.

Example:

[123245356]\begin{bmatrix} 1 & 2 & 3 \\ 2 & 4 & 5 \\ 3 & 5 & 6 \end{bmatrix}

Symmetric matrices have special properties: their eigenvalues are real, and they can be orthogonally diagonalized.


Matrix Powers

(Powers of Square Matrices)

For a square matrix AA and positive integer kk:

Ak=Aโ‹…Aโ‹ฏAโŸkย timesA^k = \underbrace{A \cdot A \cdots A}_{k \text{ times}}

By convention, A0=IA^0 = I.

Interpretation: AkA^k represents applying the transformation AA a total of kk times.


(Example: Powers Reveal Structure)

A=[0100]A = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}

Then A2=[0000]A^2 = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix}.

This matrix is nilpotent,some power of it is zero. Geometrically, applying it twice collapses everything.


Matrix Inverses

(Inverse Matrix)

An nร—nn \times n matrix AA is invertible (or nonsingular) if there exists a matrix Aโˆ’1A^{-1} such that:

AAโˆ’1=Aโˆ’1A=InAA^{-1} = A^{-1}A = I_n

The matrix Aโˆ’1A^{-1} is called the inverse of AA.

Interpretation: If AA represents a transformation, then Aโˆ’1A^{-1} is the transformation that undoes it. Applying AA then Aโˆ’1A^{-1} (or vice versa) returns you to where you started.


(Uniqueness)

If AA is invertible, its inverse is unique.

Proof: Suppose BB and CC are both inverses of AA. Then:

B=BI=B(AC)=(BA)C=IC=CB = BI = B(AC) = (BA)C = IC = C

(2ร—2 Inverse Formula)

For A=[abcd]A = \begin{bmatrix} a & b \\ c & d \end{bmatrix} with detโก(A)=adโˆ’bcโ‰ 0\det(A) = ad - bc \neq 0:

Aโˆ’1=1adโˆ’bc[dโˆ’bโˆ’ca]A^{-1} = \frac{1}{ad - bc} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix}

Swap the diagonal entries, negate the off-diagonal entries, and divide by the determinant.

Example:

[2153]โˆ’1=16โˆ’5[3โˆ’1โˆ’52]=[3โˆ’1โˆ’52]\begin{bmatrix} 2 & 1 \\ 5 & 3 \end{bmatrix}^{-1} = \frac{1}{6-5} \begin{bmatrix} 3 & -1 \\ -5 & 2 \end{bmatrix} = \begin{bmatrix} 3 & -1 \\ -5 & 2 \end{bmatrix}

(Computing Inverses via Row Reduction)

For larger matrices, use the augmented matrix method:

  1. Form the augmented matrix [AโˆฃI][A \mid I]
  2. Row reduce until the left side becomes II
  3. The right side becomes Aโˆ’1A^{-1}
[AโˆฃI]โ†’rowย ops[IโˆฃAโˆ’1][A \mid I] \xrightarrow{\text{row ops}} [I \mid A^{-1}]

If AA cannot be reduced to II (a row of zeros appears on the left), then AA is not invertible.

Example:

[12103701]โ†’R2โˆ’3R1[121001โˆ’31]โ†’R1โˆ’2R2[107โˆ’201โˆ’31]\left[\begin{array}{cc|cc} 1 & 2 & 1 & 0 \\ 3 & 7 & 0 & 1 \end{array}\right] \xrightarrow{R_2 - 3R_1} \left[\begin{array}{cc|cc} 1 & 2 & 1 & 0 \\ 0 & 1 & -3 & 1 \end{array}\right] \xrightarrow{R_1 - 2R_2} \left[\begin{array}{cc|cc} 1 & 0 & 7 & -2 \\ 0 & 1 & -3 & 1 \end{array}\right]

So [1237]โˆ’1=[7โˆ’2โˆ’31]\begin{bmatrix} 1 & 2 \\ 3 & 7 \end{bmatrix}^{-1} = \begin{bmatrix} 7 & -2 \\ -3 & 1 \end{bmatrix}.


(When is a Matrix Invertible?)

For an nร—nn \times n matrix AA, the following are equivalent:

  1. AA is invertible
  2. detโก(A)โ‰ 0\det(A) \neq 0
  3. rank(A)=n\text{rank}(A) = n
  4. rref(A)=In\text{rref}(A) = I_n
  5. The columns of AA are linearly independent
  6. The columns of AA span Rn\mathbb{R}^n
  7. Ax=bA\mathbf{x} = \mathbf{b} has exactly one solution for every b\mathbf{b}
  8. Ax=0A\mathbf{x} = \mathbf{0} has only the trivial solution
  9. kerโก(A)={0}\ker(A) = \{\mathbf{0}\}

These are all ways of saying AA doesnโ€™t collapse any dimension.


(Properties of Inverses)

For invertible matrices AA and BB:

  1. (Aโˆ’1)โˆ’1=A(A^{-1})^{-1} = A
  2. (AB)โˆ’1=Bโˆ’1Aโˆ’1(AB)^{-1} = B^{-1}A^{-1} (note the order reversal!)
  3. (AT)โˆ’1=(Aโˆ’1)T(A^T)^{-1} = (A^{-1})^T
  4. (cA)โˆ’1=1cAโˆ’1(cA)^{-1} = \frac{1}{c}A^{-1} for cโ‰ 0c \neq 0
  5. (Ak)โˆ’1=(Aโˆ’1)k(A^k)^{-1} = (A^{-1})^k

The reversal in (AB)โˆ’1=Bโˆ’1Aโˆ’1(AB)^{-1} = B^{-1}A^{-1} makes sense: to undo โ€œfirst BB, then AA,โ€ you must undo AA first, then undo BB.


(Solving Systems with Inverses)

If AA is invertible, the system Ax=bA\mathbf{x} = \mathbf{b} has the unique solution:

x=Aโˆ’1b\mathbf{x} = A^{-1}\mathbf{b}

Proof: Multiply both sides of Ax=bA\mathbf{x} = \mathbf{b} by Aโˆ’1A^{-1}:

Aโˆ’1(Ax)=Aโˆ’1bโ€…โ€ŠโŸนโ€…โ€ŠIx=Aโˆ’1bโ€…โ€ŠโŸนโ€…โ€Šx=Aโˆ’1bA^{-1}(A\mathbf{x}) = A^{-1}\mathbf{b} \implies I\mathbf{x} = A^{-1}\mathbf{b} \implies \mathbf{x} = A^{-1}\mathbf{b}

Note: In practice, row reduction is more efficient than computing Aโˆ’1A^{-1} explicitly.


(Singular Matrices)

A matrix that is not invertible is called singular.

Singular matrices have detโก(A)=0\det(A) = 0, meaning they collapse at least one dimension. Thereโ€™s no way to โ€œuncollapseโ€,information is lost, so no inverse exists.

Example:

A=[1224]A = \begin{bmatrix} 1 & 2 \\ 2 & 4 \end{bmatrix}

The columns are linearly dependent (second is twice the first), detโก(A)=0\det(A) = 0, and AA maps all of R2\mathbb{R}^2 onto a line. No inverse exists.


Why Matrix Multiplication Works This Way

The Deep Reason

The definition of matrix multiplication seems arbitrary until you realize itโ€™s forced by the requirement that matrices represent linear transformations.

If we want (AB)x=A(Bx)(AB)\mathbf{x} = A(B\mathbf{x}) to hold for all x\mathbf{x}, thereโ€™s only one possible definition for ABAB.

The entry formula, the column view, and all the properties follow inevitably.

Matrix multiplication is function compositionโ€”the rest is just computing what that means entry-by-entry.