Matrix Calculator
Determinant, inverse, RREF, rank, transpose, scalar and A×B or A±B for matrices up to 6×6, using exact fractions and showing every row operation.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the Matrix Calculator?
A matrix is a rectangular grid of numbers, and most of linear algebra comes down to a handful of operations on those grids. This matrix calculator does them for matrices up to 6×6: determinant, inverse, reduced row echelon form (RREF), rank, transpose, multiplication by a scalar, matrix multiplication and addition or subtraction. Results update as you edit any cell.
The arithmetic is exact. Cells accept integers, decimals and fractions such as 1/3 or −2/5, and every step is done with whole-number numerators and denominators, so 1/3 stays 1/3 and an inverse that should contain 3/2 shows 3/2, not 1.4999999. A switch shows the same result as decimals when that is easier to read.
The inverse and RREF results come with the row operations that produced them (swap two rows, scale a row, add a multiple of one row to another), each with the matrix after that step, so you can follow or check a hand calculation line by line.
- Determinant, inverse, RREF, rank, transpose, scalar, A×B, A+B and A−B
- Any size from 1×1 to 6×6, including non-square matrices
- Exact rational arithmetic with fraction or decimal display
- Row operations listed with the matrix after each step
- Clear messages for singular matrices and size mismatches
- Copy as rows and shareable links
How to use the Matrix Calculator
- Choose an operation. Single-matrix operations work on A; A×B, A+B and A−B also show matrix B.
- Set the rows and columns of each matrix (1 to 6) and type the entries. Use Identity or Zero to fill a matrix quickly.
- For scalar multiplication, enter the scalar k.
- Read the result, switch between fractions and decimals, and open the row operations to see the working.
- Copy the result as tab-separated rows, or share a link that reopens both matrices.
Worked examples
Inverse of a 3×3 matrix
Input
A = [2 1 1; 1 3 2; 1 0 0]
Output
det A = −1; A⁻¹ = [0 0 1; −2 1 3; 3 −1 −5], found in 9 row operations
A determinant of ±1 with integer entries guarantees an integer inverse. Multiply A by the result to get the identity as a check.
Solving three equations by RREF
Input
Augmented [2 1 −1 8; −3 −1 2 −11; −2 1 2 −3]
Output
RREF [1 0 0 2; 0 1 0 3; 0 0 1 −1], so x = 2, y = 3, z = −1
Enter the coefficients and the right-hand sides as a 3×4 matrix. The last column of the RREF is the solution.
A singular matrix
Input
A = [1 2 3; 4 5 6; 7 8 9], determinant and inverse
Output
det A = 0; rank 2; no inverse
The third row equals twice the second minus the first, so the rows are dependent. The RREF is [1 0 −1; 0 1 2; 0 0 0].
Multiplying a 2×3 by a 3×2
Input
A = [1 2 3; 4 5 6], B = [7 8; 9 10; 11 12]
Output
A×B = [58 64; 139 154]
Each entry is a row of A dotted with a column of B, for example 1·7 + 2·9 + 3·11 = 58. The result is 2×2.
Background and insight
Floating-point arithmetic, the kind a normal calculator and most spreadsheets use, stores 0.1 and 1/3 as approximations. For well-behaved matrices the error is invisible, but for ill-conditioned ones it can swamp the answer. The 3×3 Hilbert matrix, with entries 1/(i + j − 1), has determinant 1/2160 and an inverse made entirely of integers (9, −36, 30 in the first row). Rational arithmetic returns those exactly, while floating point returns values that are slightly off in the last digits. Larger Hilbert matrices fail much worse in floating point.
The determinant is found by Gaussian elimination: reduce to triangular form, multiply the pivots, and flip the sign once for every row swap. That is far quicker than cofactor expansion, which needs n! terms. The inverse comes from Gauss-Jordan elimination on the block [A | I]; when the left half reaches the identity, the right half is A⁻¹. If a column runs out of non-zero pivots, the matrix is singular, its determinant is zero, and the calculator says so along with the rank.
Rank is the number of pivots in the reduced form, which equals the number of linearly independent rows (and columns). A square matrix is invertible exactly when its rank equals its size. Matrix multiplication needs the column count of A to match the row count of B, and A×B is usually not equal to B×A, so the order you enter matters.
Common use cases
Linear algebra courses
Check determinants, inverses and row reductions by hand, step by step, with exact fractions that match textbook answers.
Systems of linear equations
Row-reduce an augmented matrix to solve for unknowns, or see from the rank that a system has no unique solution.
2D and 3D transforms
Multiply rotation, scaling and translation matrices, or invert a transform to map points back.
Small models in economics and engineering
Invert an input-output or stiffness matrix of a few variables exactly before trusting a floating-point solver on a bigger one.
Tips and limitations
- Blank cells count as zero, so you only need to type the non-zero entries of a sparse matrix.
- A×B and B×A are different; use "Swap A and B" to compare them.
- If a determinant is a tiny decimal like 1e-17 in another tool, try it here: exact arithmetic shows whether it is truly zero.
- Decimals are converted exactly (0.1 becomes 1/10), so results with many decimal inputs can have large denominators. Switch to decimal view to read them.
- Only square matrices have determinants and inverses. For a non-square matrix, use rank or RREF.
Frequently asked questions
How do you find the inverse of a matrix?
Write the matrix next to an identity matrix of the same size and row-reduce the left half to the identity. The right half then becomes the inverse. For a 2×2 matrix [a b; c d] there is a shortcut: swap a and d, negate b and c, and divide by ad − bc.
What does it mean when the determinant is zero?
The matrix is singular. Its rows (and columns) are linearly dependent, it has no inverse, and a linear system with that coefficient matrix has either no solution or infinitely many.
What is reduced row echelon form?
It is the form where each non-zero row starts with a 1 (the pivot), each pivot is to the right of the one above, and every other entry in a pivot column is 0. Every matrix has exactly one RREF, which makes it useful for solving systems and finding rank.
When can two matrices be multiplied?
A×B is defined when A has as many columns as B has rows. A 2×3 matrix times a 3×4 matrix gives a 2×4 result. The calculator names the mismatched sizes when the shapes do not fit.
How do you calculate the rank of a matrix?
Row-reduce it and count the pivots, the leading 1s in the RREF. The 3×3 matrix with rows 1 2 3, 4 5 6 and 7 8 9 has rank 2 because its third row is a combination of the first two.
Why does this matrix calculator show fractions instead of decimals?
It uses exact rational arithmetic, so there is no rounding error. 1/3 stays 1/3 and an inverse that should hold 3/2 shows 3/2. Switch to decimals to read the same values as numbers like 1.5.
Does the order of matrix multiplication matter?
Yes. In general A×B is not equal to B×A, and one of them may not even be defined when the matrices are not square. Matrix multiplication is associative, (AB)C = A(BC), but not commutative.
Is there an in-depth guide to the Matrix Calculator?
Yes. “Matrix Operations by Hand: Determinant, Inverse and Row Reduction” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
Related Tools You May Like
Free, in-browser tools that pair well with this one.