4: Matrix Operations

Matrices aren’t just grids of numbers,they’re objects with their own arithmetic. Matrix addition and scalar multiplication work entry-by-entry, but matrix multiplication is 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 cRc \in \mathbb{R} and matrix AA:

(cA)ij=cAij(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: 1A=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.

Am×nBn×p=ABm×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[b1b2bp]=[Ab1Ab2Abp]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=[a1Ta2TamT]B=[a1TBa2TBamTB]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)

In general, ABBAAB \neq BA.

Reasons:

  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 xRn\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=AAAk 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 A1A^{-1} such that:

AA1=A1A=InAA^{-1} = A^{-1}A = I_n

The matrix A1A^{-1} is called the inverse of AA.

Interpretation: If AA represents a transformation, then A1A^{-1} is the transformation that undoes it. Applying AA then A1A^{-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)=adbc0\det(A) = ad - bc \neq 0:

A1=1adbc[dbca]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=165[3152]=[3152]\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 [AI][A \mid I]
  2. Row reduce until the left side becomes II
  3. The right side becomes A1A^{-1}
[AI]row ops[IA1][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]R23R1[12100131]R12R2[10720131]\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=[7231]\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. (A1)1=A(A^{-1})^{-1} = A
  2. (AB)1=B1A1(AB)^{-1} = B^{-1}A^{-1} (note the order reversal!)
  3. (AT)1=(A1)T(A^T)^{-1} = (A^{-1})^T
  4. (cA)1=1cA1(cA)^{-1} = \frac{1}{c}A^{-1} for c0c \neq 0
  5. (Ak)1=(A1)k(A^k)^{-1} = (A^{-1})^k

The reversal in (AB)1=B1A1(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=A1b\mathbf{x} = A^{-1}\mathbf{b}

Proof: Multiply both sides of Ax=bA\mathbf{x} = \mathbf{b} by A1A^{-1}:

A1(Ax)=A1b    Ix=A1b    x=A1bA^{-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 A1A^{-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 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.