← Back to modules

Matrices

Matrix operations, inverses, and characterizations of invertibility.

A matrix is a rectangular array of numbers. This compact notation encodes systems of equations, linear transformations, data tables, and geometric operations. Everything you do in applied linear algebra involves matrices.

The operations — addition, multiplication, transposition, and inversion — are not arbitrary rules. Each arises from the task of representing and composing linear transformations. Once you understand the motivation, the rules become natural.

This chapter lays the algebraic groundwork for solving systems (Chapter 3), understanding vector spaces (Chapter 4), and computing eigenvalues (Chapter 5).

Matrix notation and basic operations

An m×nm \times n matrix has mm rows and nn columns. The entry in row ii, column jj is AijA_{ij}. A square matrix has m=nm = n.

Matrix addition: (A+B)ij=Aij+Bij(A+B)_{ij} = A_{ij}+B_{ij}. Both matrices must have the same dimensions; you cannot add a 3×23\times 2 to a 2×32\times 3.

Scalar multiplication: (cA)ij=cAij(cA)_{ij} = c\,A_{ij} — every entry is scaled by cc.

The transpose ATA^T is obtained by swapping 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. Key properties: (AB)T=BTAT(AB)^T = B^TA^T (order reverses), (AT)T=A(A^T)^T = A, (A+B)T=AT+BT(A+B)^T = A^T+B^T.

A matrix is symmetric if A=ATA = A^T. Symmetric matrices appear ubiquitously in statistics (covariance matrices), physics (inertia tensors), and optimisation (Hessians). They are always square, and their eigenvalues are always real.

The trace of a square matrix is the sum of its diagonal entries: tr(A)=i=1nAii\text{tr}(A) = \sum_{i=1}^n A_{ii}. It equals the sum of the eigenvalues of AA and satisfies tr(AB)=tr(BA)\text{tr}(AB) = \text{tr}(BA) even when ABBAAB \neq BA.

Helpful?

Matrix multiplication

If AA is m×nm\times n and BB is n×pn\times p, the product ABAB is m×pm\times p. The inner dimensions must match: columns of AA must equal rows of BB.

Each entry is a dot product: (AB)ij=k=1nAikBkj(AB)_{ij} = \sum_{k=1}^{n} A_{ik}\,B_{kj} — row ii of AA dotted with column jj of BB.

Why this definition? It encodes composition of linear transformations. If TA:RnRmT_A: \mathbb{R}^n\to\mathbb{R}^m and TB:RpRnT_B: \mathbb{R}^p\to\mathbb{R}^n, then the composed map TATBT_A \circ T_B is represented by ABAB. The rule (AB)x=A(Bx)(AB)\mathbf{x} = A(B\mathbf{x}) forces this definition.

Matrix multiplication is not commutative: ABBAAB \neq BA in general, even when both products exist and have the same size. It is associative: (AB)C=A(BC)(AB)C = A(BC), and distributive: A(B+C)=AB+ACA(B+C) = AB+AC.

The identity matrix InI_n (ones on the diagonal, zeros elsewhere) satisfies AI=IA=AAI = IA = A. It is the matrix analogue of the number 11.

Column picture: Av=v1a1+v2a2++vnanA\mathbf{v} = v_1\mathbf{a}_1 + v_2\mathbf{a}_2 + \cdots + v_n\mathbf{a}_n, a linear combination of the columns of AA with coefficients from v\mathbf{v}. This column view is the key to understanding column spaces and linear independence.

Helpful?

Determinants

The determinant is a scalar assigned to every square matrix that captures whether it is invertible, how it scales area/volume, and whether it preserves orientation.

For 2×22\times 2: det(abcd)=adbc\det\begin{pmatrix}a&b\\c&d\end{pmatrix} = ad - bc. The main-diagonal product minus the anti-diagonal product.

Geometric meaning: det(A)|\det(A)| is the factor by which the transformation AA multiplies area (n=2n=2) or volume (n=3n=3). det(A)=2\det(A)=2 means areas are doubled; det(A)=0\det(A)=0 means the transformation collapses space to a lower dimension.

Sign of the determinant: det(A)>0\det(A)>0 means orientation is preserved (no reflection). det(A)<0\det(A)<0 means orientation is reversed.

The invertibility theorem: AA is invertible     \iff det(A)0\det(A) \neq 0. A singular matrix (det =0=0) squashes space and cannot be undone — its inverse does not exist. For 3×33\times 3 and larger matrices, cofactor expansion is covered in Chapter 6.

Helpful?

Matrix inverse

The inverse A1A^{-1} of a square matrix AA satisfies AA1=A1A=IAA^{-1} = A^{-1}A = I. It exists if and only if det(A)0\det(A) \neq 0. A matrix without an inverse is called singular.

For 2×22\times 2: A1=1adbc(dbca)A^{-1} = \frac{1}{ad-bc}\begin{pmatrix}d&-b\\-c&a\end{pmatrix}. Swap the main-diagonal entries, negate the off-diagonal entries, and divide by the determinant.

For larger matrices, use Gauss-Jordan elimination: row-reduce the augmented matrix [A    I][A\;|\;I]. When the left block reaches II, the right block is A1A^{-1}.

The inverse solves Ax=bA\mathbf{x}=\mathbf{b} immediately: x=A1b\mathbf{x} = A^{-1}\mathbf{b}. However, computing A1A^{-1} explicitly is costly. Gaussian elimination solves systems more efficiently without forming the inverse.

Key properties: (AB)1=B1A1(AB)^{-1} = B^{-1}A^{-1} (order reverses), (A1)1=A(A^{-1})^{-1}=A, (AT)1=(A1)T(A^T)^{-1}=(A^{-1})^T, det(A1)=1/det(A)\det(A^{-1})=1/\det(A).

Orthogonal matrices satisfy QTQ=IQ^TQ=I, so Q1=QTQ^{-1}=Q^T. For these matrices (rotations and reflections), the inverse is free — just transpose.

Helpful?

Special matrices

Symmetric matrices: A=ATA = A^T. By the Spectral Theorem (Chapter 8), all eigenvalues are real and there exists an orthonormal eigenvector basis. These arise in covariance matrices, Hessians, and physics.

Orthogonal matrices: QTQ=IQ^TQ = I. Columns are orthonormal. det(Q)=±1\det(Q) = \pm 1. They represent rotations (det=+1\det=+1) and reflections (det=1\det=-1). The inverse is simply the transpose: Q1=QTQ^{-1}=Q^T.

Diagonal matrices: nonzero entries only on the main diagonal. Trivial to invert (Dii1=1/DiiD^{-1}_{ii}=1/D_{ii}), multiply ((D1D2)ii=(D1)ii(D2)ii(D_1D_2)_{ii}=(D_1)_{ii}(D_2)_{ii}), and exponentiate. Diagonalisation is the act of finding a basis in which a matrix looks diagonal.

Upper/lower triangular: all entries below/above the diagonal are zero. The determinant equals the product of diagonal entries. Systems Lx=bL\mathbf{x}=\mathbf{b} (lower) are solved by forward substitution; Ux=bU\mathbf{x}=\mathbf{b} (upper) by back substitution. The LU decomposition writes any invertible matrix as A=LUA=LU.

Idempotent matrices: P2=PP^2=P. Projection matrices are idempotent — projecting twice gives the same result. They have eigenvalues 00 and 11 only.

Helpful?