A matrix is a rectangular array of numbers arranged in rows and columns. That simple definition understates how powerful matrices are. They are the language of linear transformations—the mathematical objects that describe rotation, scaling, and reflection in 2D and 3D graphics; that power the weights in neural networks; that represent systems of simultaneous equations; and that compress data in techniques like principal component analysis. Before any of that depth, though, are the basic operations—and those are completely accessible.
Matrix Addition: Element-Wise, Same Dimensions Required
Matrix addition is the simplest operation. Add two matrices by adding the corresponding elements at each position. The requirement: both matrices must have the same dimensions (same number of rows and same number of columns).
Example: A = [[1, 3], [2, 5]] and B = [[4, 1], [0, 6]]. Then A + B = [[(1+4), (3+1)], [(2+0), (5+6)]] = [[5, 4], [2, 11]]. You cannot add a 2×3 matrix to a 3×2 matrix—the dimensions don't match.
Scalar Multiplication
Multiplying a matrix by a scalar (a single number) is even simpler: multiply every element in the matrix by that scalar. If k = 3 and A = [[2, −1], [4, 0]], then 3A = [[6, −3], [12, 0]]. Scalar multiplication scales the entire matrix uniformly and is used constantly in transformations (scaling a 3D model up by a factor of 2, for instance, means multiplying its coordinate matrix by 2).
Matrix Multiplication: Row × Column Dot Products
Matrix multiplication is more involved—and more powerful. To multiply matrix A (m×n) by matrix B (n×p), the number of columns in A must equal the number of rows in B. The result is an m×p matrix. Each entry in the result is the dot product of a row from A with a column from B.
Concretely: the entry at row i, column j of the product AB is computed by multiplying each element of row i of A by the corresponding element of column j of B, then summing all those products.
Example: A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]]. The entry at row 1, column 1 of AB: (1×5) + (2×7) = 5 + 14 = 19. Row 1, col 2: (1×6) + (2×8) = 6 + 16 = 22. Row 2, col 1: (3×5) + (4×7) = 15 + 28 = 43. Row 2, col 2: (3×6) + (4×8) = 18 + 32 = 50. So AB = [[19, 22], [43, 50]]. Use our Matrix Calculator to verify and explore matrix multiplication for larger matrices.
Why Order Matters: AB ≠ BA
Matrix multiplication is not commutative. AB and BA are generally not equal—and sometimes one is defined while the other isn't. This matters enormously in applications: applying rotation first and then scaling produces a different result than scaling first and then rotating. The order of matrix operations encodes the order of transformations.
The Determinant: A Number That Summarizes a Matrix
The determinant is a single number associated with a square matrix (same number of rows and columns). It encodes crucial information about the matrix—particularly whether an inverse exists.
Determinant of a 2×2 Matrix
For a 2×2 matrix A = [[a, b], [c, d]], the determinant is det(A) = ad − bc. Example: A = [[3, 2], [1, 4]]. det(A) = (3×4) − (2×1) = 12 − 2 = 10.
Geometrically, the determinant of a 2×2 matrix equals the area of the parallelogram formed by its two row vectors. A determinant of 10 means the transformation encoded by this matrix scales areas by a factor of 10.
Determinant of a 3×3 Matrix via Cofactor Expansion
For a 3×3 matrix A = [[a, b, c], [d, e, f], [g, h, i]], expand along the first row: det(A) = a(ei−fh) − b(di−fg) + c(dh−eg). The three 2×2 determinants (ei−fh, di−fg, dh−eg) are called minors, and the pattern of signs (+, −, +) is called cofactor expansion. For larger matrices, this process continues recursively, though software handles it far more efficiently—see our Statistics Calculator for matrix-based statistical computations.
What It Means When the Determinant Is Zero
A matrix with a determinant of zero is called a singular matrix. A singular matrix has two defining properties that matter enormously in practice:
- It has no inverse. Every invertible (non-singular) matrix A has a matrix A⁻¹ such that A × A⁻¹ = I (the identity matrix). If det(A) = 0, no such inverse exists.
- Its rows (or columns) are linearly dependent. At least one row can be written as a linear combination of the others. The matrix encodes redundant information.
- It maps space to a lower dimension. A singular 3×3 matrix collapses 3D space into a plane or a line—any volume becomes zero. Geometrically, the transformation is irreversible.
The Inverse of a 2×2 Matrix
For a 2×2 matrix A = [[a, b], [c, d]] with det(A) = ad − bc ≠ 0, the inverse is: A⁻¹ = (1/det(A)) × [[d, −b], [−c, a]]. The steps are: swap the main diagonal elements (a and d), negate the off-diagonal elements (b and c), and divide the whole matrix by the determinant.
Example: A = [[3, 2], [1, 4]], det(A) = 10. A⁻¹ = (1/10) × [[4, −2], [−1, 3]] = [[0.4, −0.2], [−0.1, 0.3]]. You can verify: A × A⁻¹ should give the identity matrix [[1, 0], [0, 1]].
Real-World Application: Solving Systems of Equations with Cramer's Rule
A system of linear equations can be written in matrix form as Ax = b, where A is the coefficient matrix, x is the unknown vector, and b is the constant vector. If det(A) ≠ 0, the unique solution is x = A⁻¹b.
Cramer's Rule provides explicit formulas: for each unknown xᵢ, replace column i of A with the vector b, compute the determinant of the modified matrix, and divide by det(A). For two equations with two unknowns, this produces the same result as solving by substitution—but it generalizes cleanly to any size system. The Quadratic Formula Calculator solves the specific case of second-degree polynomial equations, which can also be expressed in matrix form through companion matrices.
Matrix operations are the backbone of modern computational mathematics. Once you understand addition (element-wise), multiplication (row × column dot products), and the determinant (the invertibility test), you have the foundation to understand how 3D game engines transform geometry, how machine learning models store learned parameters, and how statisticians decompose data into interpretable components. The arithmetic is mechanical; the insight comes from recognizing what each operation represents geometrically.
