How to use the matrix calculator
Pick an operation first. The calculator loads a small example for it, so you can see the layout before typing your own numbers. Set the number of rows and columns, then fill in the grid. Entries can be whole numbers, decimals or fractions such as 2/5. For a bigger matrix, open “Paste or type A as text” and enter one row per line. You can copy straight from a spreadsheet.
The Zeros, Identity and Random buttons fill a grid in one click. Swap A and B reverses the order for a two-matrix operation. After a calculation, “Use this result as matrix A” lets you chain steps, for example multiply two matrices and then find the inverse of the product.
Every answer is calculated with exact fractions, so 1/3 stays 1/3 instead of becoming 0.333333. Tick “Show fractions as decimals” if you need decimal values for a spreadsheet or a physics problem.
What a matrix is
A matrix is a rectangular grid of numbers, described by its size: rows first, then columns. A 2 × 3 matrix has 2 rows and 3 columns. The entry in row i and column j is written aᵢⱼ. Matrices are a compact way to store several linear equations, a geometric transformation or a table of rates, and to work with all of it at once.
Adding, subtracting and scaling
Two matrices can be added or subtracted only if they are the same size. You combine the entries in matching positions. Multiplying by a single number k, called a scalar, multiplies every entry by k. These operations behave like ordinary arithmetic: A + B = B + A, and k(A + B) = kA + kB.
Matrix multiplication
Multiplication is different. Each entry of A × B is a dot product: go across a row of A and down a column of B, multiply the pairs and add. For this to work, A must have as many columns as B has rows. An m × n matrix times an n × p matrix gives an m × p result.
With A = [2 0 1; 1 3 −1] and B = [1 4; 2 −1; 3 0], the top-left entry of A × B is 2 × 1 + 0 × 2 + 1 × 3 = 5. The full product is [5 8; 4 1].
Order matters. A × B and B × A are usually different, and one may exist when the other does not. The calculator tells you when two square matrices happen to commute.
Powers of a matrix
Aⁿ means A multiplied by itself n times, so it only exists for square matrices. The calculator uses repeated squaring: A², then A⁴, then A⁸, combining only the powers it needs. A⁰ is the identity matrix, and a negative power uses the inverse, so A⁻² = (A⁻¹)².
A neat example is [1 1; 1 0]. Its powers contain the Fibonacci numbers: the fifth power is [8 5; 5 3].
The determinant
The determinant is a single number calculated from a square matrix. For a 2 × 2 matrix [a b; c d] it is ad − bc, so [2 1; 5 3] has determinant 2 × 3 − 1 × 5 = 1.
For a 3 × 3 matrix, the calculator shows a cofactor expansion along the first row. Each entry multiplies the 2 × 2 determinant left after crossing out its row and column, with signs alternating +, −, +. For [1 2 3; 4 5 6; 7 8 10]: 1 × (50 − 48) − 2 × (40 − 42) + 3 × (32 − 35) = 2 + 4 − 9 = −3. Larger matrices are handled by row reduction, which is much faster.
The determinant tells you how the matrix scales area (in 2D) or volume (in 3D). A determinant of −3 triples volumes and flips orientation, like a mirror. A zero determinant flattens the plane onto a line, or space onto a plane, so information is lost and cannot be recovered. That is exactly when the matrix has no inverse.
The inverse
The inverse A⁻¹ undoes A, so A × A⁻¹ = I, the identity matrix. Only square matrices with a nonzero determinant have one. For 2 × 2 matrices there is a shortcut: swap the diagonal entries, negate the other two and divide by the determinant. The inverse of [2 1; 5 3] is therefore [3 −1; −5 2].
For larger matrices, the calculator writes A next to the identity, [A | I], and row-reduces until the left half becomes I. The right half is then A⁻¹, and the check multiplies the two back together. The adjugate option gives another route: A⁻¹ = adj(A) ÷ det(A), where adj(A) is the transposed matrix of cofactors.
RREF, rank and the null space
Row reduction uses three moves that never change the solutions of the underlying equations: swap two rows, multiply a row by a nonzero number, and add a multiple of one row to another. Reduced row echelon form (RREF) is the tidiest result. Every leading entry is 1, it is the only nonzero number in its column, and the leading entries step down to the right.
The number of leading entries, or pivots, is the rank. It counts how many rows carry genuinely new information. In [1 2 3; 2 4 6; 1 0 1], the second row is twice the first, so the rank is 2, not 3. The null space is the set of vectors x with Ax = 0. Its size, the nullity, is the number of columns minus the rank. Here that is 1, and the calculator gives the basis vector (−1, −1, 1).
Solving a system Ax = b
A system of linear equations can be written as one matrix equation. The system x + 2y + z = 0, 2x − y + 3z = 13, −x + y + 2z = 3 becomes Ax = b with A = [1 2 1; 2 −1 3; −1 1 2] and b = (0, 13, 3). Row-reducing the augmented matrix [A | b] gives x = 1, y = −2, z = 3.
There are only three possible outcomes:
- One solution, when every column of A has a pivot. For systems up to 3 × 3, the calculator also shows Cramer’s rule as a cross-check.
- No solution, when row reduction produces a row that says 0 = a nonzero number.
- Infinitely many solutions, when some variables have no pivot. These are free: you can choose them, and the calculator writes the others in terms of t₁, t₂ and so on.
Eigenvalues and eigenvectors
Most vectors change direction when a matrix acts on them. An eigenvector is a special one that only gets stretched or shrunk. The stretch factor is its eigenvalue λ, so Av = λv. To find the eigenvalues, solve the characteristic equation det(λI − A) = 0. Then, for each λ, solve (A − λI)v = 0 for the eigenvectors.
For A = [4 1; 2 3], the characteristic polynomial is λ² − 7λ + 10 = (λ − 2)(λ − 5). The eigenvalue 5 has eigenvector (1, 1): A sends (1, 1) to (5, 5). Two quick checks always hold. The eigenvalues add up to the trace, 4 + 3 = 7, and multiply to the determinant, 10.
Eigenvalues can be irrational or complex. A 90° rotation, [0 −1; 1 0], has eigenvalues i and −i, because no real direction survives a quarter turn unchanged. If an eigenvalue is repeated but has too few eigenvectors, as with [1 1; 0 1], the calculator points out that the matrix cannot be diagonalised.
LU decomposition
LU decomposition splits A into a lower triangular matrix L and an upper triangular matrix U, with A = LU. U is what is left after eliminating below each pivot, and L stores the multipliers used. For [3 1 2; 6 4 5; −3 1 3], the multipliers are 2, −1 and 1, giving U = [3 1 2; 0 2 1; 0 0 4].
It is useful when you need to solve Ax = b for many different right-hand sides. The elimination is done once, and each new b only needs two quick triangular substitutions. If a zero lands in a pivot position, rows are swapped and the swaps are recorded in a permutation matrix P, so that PA = LU.
Where matrices are used
Weather and other Markov chains. Suppose that in some town a sunny day is followed by sun 75% of the time, while a rainy day is followed by sun only half the time. The transition matrix is P = [0.75 0.25; 0.5 0.5]. P² = [0.6875 0.3125; 0.625 0.375] gives the chances two days ahead. In the long run the weather settles at sunny two days in three. That is the eigenvector of the transposed matrix Pᵀ for eigenvalue 1, scaled so its entries add to 1: (2/3, 1/3).
Graphics and games. Rotations, reflections and scaling of shapes are 2 × 2 or 3 × 3 matrices. Combining several moves is a single matrix product, and the determinant tells you whether a transformation flips the picture.
Engineering and science. Electrical circuits, structural frames and chemical mixtures lead to systems of linear equations, which are solved as Ax = b.
Data and search. Principal component analysis finds the main patterns in data from the eigenvectors of a covariance matrix. Early web-search ranking used an eigenvector of a huge link matrix.
Common mistakes
- Multiplying entry by entry. Matrix multiplication is rows times columns.
- Assuming AB = BA. Check both orders before swapping factors.
- Writing (AB)⁻¹ as A⁻¹B⁻¹. The order reverses: (AB)⁻¹ = B⁻¹A⁻¹.
- Expecting det(A + B) to equal det(A) + det(B). It usually does not. Products do work: det(AB) = det(A) × det(B).
- Trying to divide by a matrix. Multiply by its inverse instead, on the correct side.