Matrix definition
A matrix (plural matrices) is a rectangular arrangement of numbers in rows and columns. For example:
Each number is an entry or element, named by its position: a₂₁ is the entry in row 2, column 1, which is 5 here. Matrices let you treat a whole table of numbers as one object, so a system of equations, a rotation or a spreadsheet of data can be handled with a few compact rules.
Matrix dimensions
A matrix's size, or order, is rows × columns, always in that order. A matrix with 2 rows and 3 columns is 2 × 3 and has 6 entries. Dimensions decide which operations are allowed, so check them first.
Types of matrices
| Type | Description | Example |
|---|---|---|
| Row matrix | One row | [1 4 7] |
| Column matrix | One column | 3 × 1 |
| Square matrix | Rows = columns | 2 × 2, 3 × 3 |
| Zero matrix | All entries 0 | Acts like 0 in addition |
| Identity matrix (I) | 1s on the diagonal, 0s elsewhere | Acts like 1 in multiplication |
| Diagonal matrix | Non-zero entries only on the diagonal | diag(2, 5, 9) |
| Symmetric matrix | Equal to its transpose | aᵢⱼ = aⱼᵢ |
| Singular matrix | Square with determinant 0 | Has no inverse |
Matrix operations
Addition and subtraction. Only for matrices of the same size; add matching entries. With B = [[1, 4], [2, 0]], A + B = [[3, 5], [7, 3]].
Scalar multiplication. Multiply every entry by the number. 3A = [[6, 3], [15, 9]].
Transpose. Swap rows and columns. Aᵀ = [[2, 5], [1, 3]]. A 2 × 3 matrix becomes 3 × 2.
Matrix multiplication. Entry (i, j) of AB is row i of A dotted with column j of B:
- Row 1 · column 1: 2·1 + 1·2 = 4
- Row 1 · column 2: 2·4 + 1·0 = 8
- Row 2 · column 1: 5·1 + 3·2 = 11
- Row 2 · column 2: 5·4 + 3·0 = 20
So AB = [[4, 8], [11, 20]]. For AB to exist, A's columns must equal B's rows. An m × n matrix times an n × p matrix gives an m × p result.
Key properties
| Property | Holds? |
|---|---|
| A + B = B + A | Yes |
| (AB)C = A(BC) | Yes |
| A(B + C) = AB + AC | Yes |
| AB = BA | Not in general |
| AI = IA = A | Yes |
| (AB)ᵀ = BᵀAᵀ | Yes, note the reversed order |
Inverse of a matrix
A square matrix A has an inverse A⁻¹ if AA⁻¹ = I. It exists only when the determinant is not zero. For a 2 × 2 matrix [[a, b], [c, d]], swap a and d, negate b and c, and divide by ad − bc. For A above, ad − bc = 6 − 5 = 1, so A⁻¹ = [[3, −1], [−5, 2]]. Multiply to check: AA⁻¹ gives the identity.
Solving equations with matrices
The system 2x + y = 7 and x − y = 2 can be written as one matrix equation, AX = B, with A = [[2, 1], [1, −1]], X = [x, y] and B = [7, 2]. Then X = A⁻¹B, giving x = 3, y = 1. Row reduction (Gaussian elimination) does the same job for larger systems and is how computers solve them.
Matrices in the real world
- Computer graphics: every rotation, scaling and camera move in a game is a matrix multiplication.
- Machine learning: neural network layers multiply input vectors by weight matrices.
- Economics: input-output models track how industries supply each other.
- Networks: adjacency matrices record which nodes connect, used in route finding and page ranking.
- Cryptography: the Hill cipher encrypts letters with matrix multiplication.
Matrix vs determinant vs vector
These three words are often confused. A matrix is the whole grid of numbers. A vector is a matrix with a single row or a single column, such as the list of unknowns [x, y]. A determinant is not a grid at all but one number calculated from a square matrix. So a 3 × 3 matrix has nine entries, multiplies a three-entry vector, and has one determinant. Keeping the three separate makes textbook instructions much easier to follow: "find the matrix product" gives a grid, while "evaluate the determinant" gives a number.
A quick example from everyday data
Suppose a café sells 30 coffees and 12 muffins on Monday and 25 coffees and 18 muffins on Tuesday, with coffee at $3 and muffins at $2. Put the sales in a 2 × 2 matrix and the prices in a 2 × 1 column. The product gives Monday's revenue, 30·3 + 12·2 = $114, and Tuesday's, 25·3 + 18·2 = $111, in one step. Spreadsheets do exactly this behind functions such as MMULT.
Row operations, trace and "division"
Three row operations do not change the solutions of the system a matrix represents: swapping two rows, multiplying a row by a non-zero number, and adding a multiple of one row to another. Gaussian elimination uses them to reduce a matrix to a simpler form and solve equations.
The trace of a square matrix is the sum of its main-diagonal entries. For A = [[2, 1], [5, 3]] the trace is 2 + 3 = 5.
There is no matrix division. To "divide" by B, multiply by its inverse B⁻¹, and only if B is square with a non-zero determinant. Because order matters, AB⁻¹ and B⁻¹A are usually different.
Common mistakes
- Writing dimensions as columns × rows.
- Multiplying entry by entry instead of row by column.
- Assuming AB = BA.
- Adding matrices of different sizes.
- Trying to invert a matrix whose determinant is 0.
Try any of these with the matrix calculator, and see matrices basics explained and determinants and inverses explained.