Matrices and Determinants
A matrix is a rectangular array of numbers. Learn the types of matrices, how to add and multiply them, how to find the determinant of a 2×2 and a 3×3 matrix with the rule of Sarrus and cofactor expansion, how to find the inverse and how to solve systems of equations.
A matrix is a rectangular array of numbers arranged in rows and columns. A matrix with m rows and n columns has the dimensions m × n (read “m by n”). A square matrix also has a number called its determinant; for a 2 × 2 matrix it is ad − bc. For example, A = is a 2 × 2 matrix with determinant 1 · 4 − 2 · 3 = −2. Matrices are used to solve systems of linear equations, to rotate and scale images in computer graphics, and to store data.
What is a matrix? Entries and dimensions
Each number in a matrix is an entry (or element), written aᵢⱼ: the first index is the row, the second the column. A general 2 × 3 matrix looks like this:
Types of matrices
In a square matrix, the main diagonal consists of the entries a₁₁, a₂₂, a₃₃, … from the top left to the bottom right.
| Type | Property | Example |
|---|---|---|
| Row matrix | one row | |
| Column matrix | one column | |
| Square matrix | as many rows as columns | |
| Zero matrix | all entries 0 | |
| Diagonal matrix | square, zeros off the main diagonal | |
| Identity matrix I | diagonal, with 1s on the diagonal | |
| Transpose Aᵀ | rows become columns | has the transpose |
| Symmetric matrix | equal to its transpose: aᵢⱼ = aⱼᵢ | |
| Upper triangular | square, zeros below the main diagonal |
Matrix addition, subtraction and scalar multiplication
You can add or subtract two matrices only if they have the same dimensions: combine the entries in the same position. To multiply a matrix by a number k (a scalar), multiply every entry by k.
Matrix multiplication
The product AB exists when the number of columns of A equals the number of rows of B. If A is m × n and B is n × p, then AB is m × p. Each entry is found “row times column”: to get the entry in row i and column j of AB, multiply the entries of row i of A by the matching entries of column j of B and add.
Matrix multiplication is associative, (AB)C = A(BC), and distributive, A(B + C) = AB + AC. The identity matrix acts like the number 1: AI = IA = A.
The determinant of a matrix
The determinant is a single number computed from a square matrix, written det A or with vertical bars. For a 2 × 2 matrix it is the product of the main diagonal minus the product of the other diagonal:
Geometrically, |det A| is the factor by which the matrix scales areas. The vectors ⟨3, 1⟩ and ⟨1, 2⟩ (the columns of ) span a parallelogram of area |3 · 2 − 1 · 1| = 5. A determinant of 0 means the area collapses to a line.
3 × 3 determinant: the rule of Sarrus
Copy the first two columns to the right of the matrix. Add the products of the three diagonals going down from left to right, then subtract the products of the three diagonals going up from left to right:
3 × 3 determinant: cofactor expansion
The rule of Sarrus works only for 3 × 3 matrices. Cofactor expansion (Laplace expansion) works for any size. The minor Mᵢⱼ is the determinant left after deleting row i and column j; the cofactor is Cᵢⱼ = (−1)i+j Mᵢⱼ, which follows the sign pattern . Pick any row or column, multiply each entry by its cofactor and add.
Useful properties of determinants: a row or column of zeros, or two equal rows, give det = 0; swapping two rows changes the sign; det Aᵀ = det A; det(AB) = det A · det B; and the determinant of a triangular matrix is the product of its diagonal entries.
The inverse of a matrix
The inverse of a square matrix A is the matrix A⁻¹ with AA⁻¹ = A⁻¹A = I. It exists exactly when det A ≠ 0; such a matrix is called invertible (or nonsingular). For a 2 × 2 matrix: swap the diagonal entries, change the signs of the other two, and divide by the determinant.
Inverse of a 3 × 3 matrix
For larger matrices, A⁻¹ = (1/det A) · adj A, where the adjugate adj A is the transpose of the matrix of cofactors. (Gauss-Jordan elimination on [A | I] gives the same result.)
Solving systems of equations with matrices
A system of linear equations can be written as AX = B: A holds the coefficients, X the unknowns and B the right-hand sides. If det A ≠ 0, the system has exactly one solution, X = A⁻¹B. If det A = 0, it has no solution or infinitely many (see number of solutions).
Cramer's rule gives each unknown as a quotient of determinants: x = Dₓ/D and y = Dy/D, where D = det A and Dₓ (or Dy) is D with the x-column (or y-column) replaced by B.
Common mistakes
- Multiplying entry by entry: matrix multiplication is row times column, not position by position.
- Assuming AB = BA: it is usually false, and sometimes only one of the two products exists.
- Adding matrices of different sizes: the sum is not defined.
- Sign errors in the rule of Sarrus: the three upward diagonals are subtracted.
- Forgetting the sign pattern in cofactor expansion: the middle term of row 1 gets a minus.
- Inverting a matrix with det = 0: no inverse exists. And in the 2 × 2 formula, do not forget to divide by the determinant.
Practice problems
Frequently asked questions
What is a matrix in math?
A rectangular table of numbers in rows and columns. An m × n matrix has m rows and n columns, and the entry aᵢⱼ sits in row i and column j.
How do you multiply two matrices?
Multiply each row of the first matrix by each column of the second, entry by entry, and add. This only works if the first matrix has as many columns as the second has rows. See the step-by-step example.
How do you find the determinant of a 3×3 matrix?
Use the rule of Sarrus (add the three downward diagonal products, subtract the three upward ones) or cofactor expansion along a row or column, preferably one with zeros.
How do you find the inverse of a matrix?
For a 2 × 2 matrix: swap the diagonal entries, change the signs of the other two and divide by the determinant. For larger matrices, use the adjugate or Gauss-Jordan elimination. If the determinant is 0, there is no inverse.
What does the determinant tell you?
Whether the matrix is invertible (det ≠ 0), whether a system AX = B has exactly one solution, and by what factor the matrix scales areas (2 × 2) or volumes (3 × 3).
Keep learning
- Previous topic: vectors; the cross product can be written as a 3 × 3 determinant.
- Review: quadratic equations, used in practice problem 9.
- All topics: math step by step.
- In German: Matrizen.
Spotted a mistake or have a request? Send us a short message and we will take care of it.