Matrix Calculator
17 operations · exact fractions · rich step-by-step · 1×1 to 8×8.
Result
Step-by-step
How to use this matrix calculator
Pick the matrix operation you need from the row of tabs — addition, subtraction, multiplication, scalar multiplication, power, transpose, determinant, inverse, adjugate, cofactor, LU decomposition, rank, trace, RREF, null space, column space, or solve Ax = b. The calculator instantly shows the correct input matrices for your chosen operation. Use the row and column stepper to size Matrix A (and Matrix B when a second matrix is required), then type integers, decimals, or fractions such as 3/5 or -1/2 directly into each cell.
Toggle Exact fractions for symbolic answers or switch to 2/4/6-decimal precision. Enable Steps to see rich Gauss-Jordan or cofactor traces. The Heatmap checkbox turns on a color visualization next to the result. Paste a matrix straight from Excel, Google Sheets, or CSV with the Paste button, chain operations with Use as A / B, share the exact problem via the Share link, and undo mistakes with Ctrl + Z.
What is a matrix?
A matrix is a rectangular array of numbers arranged in rows and columns. A matrix with m rows and n columns is called an m × n matrix, and each entry is referenced by its row and column index — A[i, j] or aij. Matrices are the foundational data structure of linear algebra and appear everywhere in modern technology: 3D graphics rendering, machine-learning weight tensors, engineering simulations, control systems, quantum mechanics, economics input-output models, and cryptography (Wikipedia).
A matrix is square when it has the same number of rows and columns; otherwise it's rectangular. Square matrices unlock the most powerful operations — determinant, inverse, eigenvalues, trace, and matrix powers. Special-shape matrices carry names of their own: the identity matrix I has ones on the diagonal and zeros elsewhere; the zero matrix is filled with zeros; a diagonal matrix is nonzero only on the diagonal; and the transpose Aᵀ is what you get when you swap rows for columns. Every operation this calculator performs is defined in terms of these dimensions and shapes.
Every matrix operation this calculator performs
This is a full matrix operations calculator — every function is included, works for any supported size, and returns exact fractions plus rich step-by-step solutions:
| Operation | Requires | Output | Common notation |
|---|---|---|---|
| Addition | A and B same size | Matrix (same size) | A + B |
| Subtraction | A and B same size | Matrix (same size) | A − B |
| Matrix multiplication | cols(A) = rows(B) | Matrix rows(A) × cols(B) | A · B |
| Scalar multiplication | Any matrix + a number | Matrix (same size) | k · A |
| Power | Square matrix, integer n (± ok if invertible) | Matrix (same size) | An |
| Transpose | Any matrix | Matrix n × m | AT |
| Determinant | Square matrix | Scalar (a single number) | det(A) or |A| |
| Inverse | Square, det(A) ≠ 0 | Matrix (same size) | A−1 |
| Adjugate | Square matrix | Matrix (same size) | adj(A) |
| Cofactor matrix | Square matrix | Matrix (same size) | cof(A) |
| LU decomposition | Square matrix | L, U, P (same size each) | P·A = L·U |
| Rank | Any matrix | Non-negative integer | rank(A) |
| Trace | Square matrix | Scalar | tr(A) |
| RREF | Any matrix | Matrix in reduced row echelon form | rref(A) |
| Null space (kernel) | Any matrix | Basis vectors of null(A) | null(A) |
| Column space | Any matrix | Basis vectors of col(A) | col(A) |
| Solve Ax = b | A + vector b of length rows(A) | Solution vector x, or a warning | x = A−1b |
Matrix addition and subtraction
Matrix addition and subtraction are element-wise operations that require both matrices to have the exact same dimensions. If A and B are both m × n, then (A + B)[i, j] = A[i, j] + B[i, j] and (A − B)[i, j] = A[i, j] − B[i, j]. The result is another m × n matrix (Calculator.net).
Both operations are commutative for addition (A + B = B + A) and associative ((A + B) + C = A + (B + C)). Subtraction is neither. If you try to add a 2 × 3 matrix to a 3 × 2 matrix the operation is undefined, and the calculator will show a clear error explaining the dimension mismatch.
Matrix multiplication
Matrix multiplication is defined as the dot product of every row of A with every column of B. If A is m × n and B is n × p, then the product AB is an m × p matrix whose entries are:
The critical rule is the inner dimension must match: A's number of columns must equal B's number of rows. If A is 2 × 3 and B is 3 × 4, the product is defined and is 2 × 4. If A is 2 × 3 and B is 2 × 4, the product is not defined.
Matrix multiplication is associative ((AB)C = A(BC)) and distributive over addition, but it is not commutative — in general AB ≠ BA. This non-commutativity is one of the deepest and most consequential facts in linear algebra, and it's the whole reason quantum mechanics and 3D rotations behave the way they do.
Scalar multiplication and matrix powers
Scalar multiplication multiplies every entry of a matrix by the same number. For a scalar k, (kA)[i, j] = k · A[i, j]. It works on any matrix regardless of shape and preserves the dimensions.
Matrix powers Aⁿ apply only to square matrices. A² means A·A, A³ means A·A·A, and A⁰ is the identity matrix I. This calculator also supports negative integer powers — A⁻ⁿ is defined as (A⁻¹)ⁿ, provided A is invertible. Matrix powers appear in dynamical systems, Markov chains (Pⁿ gives the n-step transition probabilities), and matrix exponentials that solve systems of linear differential equations.
Transpose
The transpose of a matrix flips it over its main diagonal: the rows become columns and the columns become rows. If A is m × n, then Aᵀ is n × m, and Aᵀ[i, j] = A[j, i]. The transpose of a 2 × 3 matrix is a 3 × 2 matrix; the transpose of a square matrix stays square:
Transpose has three vital algebraic properties: (Aᵀ)ᵀ = A, (A + B)ᵀ = Aᵀ + Bᵀ, and (AB)ᵀ = BᵀAᵀ — notice the order reverses. Transpose is fundamental in defining symmetric matrices (A = Aᵀ) which have real eigenvalues and orthogonal eigenvectors.
Determinant
The determinant of a square matrix is a single scalar that encodes deep geometric information: it is the signed volume-scaling factor of the linear transformation the matrix represents, and it tells you whether the matrix is invertible — a matrix is invertible if and only if its determinant is nonzero (Georgia Tech).
For 4×4 and larger matrices, cofactor expansion gets tedious — a 4×4 requires 4 · (3! terms) = 24 multiplications, and an n × n requires n! For efficiency this calculator uses Gaussian elimination with sign tracking: reduce the matrix to upper triangular form using row operations, and the determinant equals the product of the diagonal entries multiplied by (−1)#row swaps. This turns an O(n!) computation into O(n³) while still returning an exact rational answer.
Matrix inverse, adjugate, and cofactor matrix
The inverse of a square matrix A, written A⁻¹, is the matrix such that A · A⁻¹ = A⁻¹ · A = I. An inverse exists only when A is square and its determinant is nonzero — such a matrix is called invertible or non-singular. For a 2 × 2 matrix, the inverse has a closed form:
For 3 × 3 and larger matrices the practical algorithm is Gauss-Jordan elimination: form the augmented matrix [A | I], then use elementary row operations to reduce the left block to the identity. Whatever ends up on the right is A⁻¹. If a zero pivot appears that cannot be swapped away, the matrix is singular and no inverse exists (Penn State). This tool also computes the cofactor matrix — each entry C[i,j] = (−1)i+j · det(minor(A,i,j)) — and its transpose, the adjugate adj(A). They satisfy the identity A · adj(A) = det(A) · I, so A⁻¹ = adj(A) / det(A) whenever the determinant is nonzero.
LU decomposition
LU decomposition factors a square matrix into a lower-triangular L and an upper-triangular U, optionally preceded by a permutation matrix P for numerical stability: P·A = L·U. It is the workhorse behind fast solvers for Ax = b, computing determinants, and inverting matrices, because once you have L and U you can solve any system with the same A almost for free by forward and back substitution. This calculator uses Doolittle's algorithm with partial pivoting and returns L (unit-lower-triangular), U (upper-triangular), and P (permutation) as exact rationals whenever the factorization exists.
Rank and trace
The rank of a matrix is the number of linearly independent rows (equivalently, columns). Rank measures the "dimension of information" in the matrix — a 3 × 3 matrix of rank 3 is invertible; a 3 × 3 matrix of rank 2 collapses 3D space to a plane; a rank-1 matrix collapses everything to a line. Rank equals the number of nonzero rows in the RREF, which is exactly how the calculator computes it.
The trace of a square matrix is simply the sum of its main-diagonal entries: tr(A) = A[1,1] + A[2,2] + … + A[n,n]. Trace is linear (tr(A + B) = tr(A) + tr(B)) and cyclic (tr(AB) = tr(BA)). It equals the sum of the eigenvalues of A, which is why it appears throughout physics, statistics, and machine-learning gradient-based methods.
RREF, null space, column space, and row reduction
The Reduced Row Echelon Form (RREF) is the unique fully-simplified version of a matrix reachable by elementary row operations (swap two rows, multiply a row by a nonzero constant, add a multiple of one row to another). A matrix is in RREF when every leading entry is 1, each pivot is strictly to the right of the pivot in the row above, every pivot column has zeros in all other positions, and all zero rows sit at the bottom.
Once you have the RREF you get several things for free. The null space (kernel) null(A) is the set of all vectors x such that Ax = 0 — the calculator produces an explicit basis by giving each free column one basis vector. The column space col(A) is the span of A's columns — a basis is formed by the original columns that ended up as pivot columns in the RREF. Together, they satisfy the Rank–Nullity Theorem: rank(A) + nullity(A) = number of columns. RREF is the workhorse of linear algebra: it solves linear systems, computes rank, tests linear independence, finds matrix inverses, and determines whether Ax = b has a unique, infinite, or no solution (Wikipedia).
Solving Ax = b (linear systems)
Every system of linear equations can be written in the matrix form Ax = b, where A is the matrix of coefficients, x is the vector of unknowns, and b is the vector of constants. The calculator solves any such system by building the augmented matrix [A | b] and reducing it to RREF. The last column then reads off the solution — or reveals that there is none:
- Unique solution — the RREF has a pivot in every column of A, and the last column gives x directly.
- Infinite solutions — the RREF has fewer pivots than variables. Free variables can be parametrized.
- No solution — a row of the form
[0 0 … 0 | c]appears with c ≠ 0, meaning the system is inconsistent.
For a square system with a nonzero determinant, the answer is equivalent to x = A⁻¹ · b, but Gauss-Jordan on the augmented matrix is both faster and numerically more stable than explicitly inverting A (Paul's Online Notes).
Working with fractions vs decimals
This is a matrix calculator with fractions — every arithmetic step is performed using exact rational numbers under the hood, with big-integer numerators and denominators. That means 1/3 + 1/3 + 1/3 gives you exactly 1, not 0.9999999999999998. Toggle Exact for symbolic answers or pick 2, 4, or 6-decimal precision. Enter values in any of these formats:
- Integers:
7,-42,100 - Decimals:
2.5,-0.125,3.14 - Fractions:
3/5,-1/2,7/4 - Mixed with a leading sign:
-3/4,-0.5
Where matrix operations are used in the real world
- Machine learning & deep learning — neural-network layers are literally matrix multiplications; GPU training is optimized matrix arithmetic at scale.
- 3D graphics & game engines — every 3D transformation (translate, rotate, scale, project) is a 4×4 matrix multiplication.
- Engineering & physics — structural analysis, circuit equations, fluid dynamics, control systems, and quantum mechanics are all matrix problems.
- Data science & statistics — PCA, regression, covariance matrices, singular value decomposition (SVD).
- Cryptography — the Hill cipher and lattice-based post-quantum schemes rely on modular matrix arithmetic.
- Economics — Leontief input-output models describe entire national economies as linear systems Ax = b.
- Search & graph analysis — Google's original PageRank algorithm is the dominant eigenvector of a huge web-link matrix.
Works for 2×2, 3×3, 4×4 and larger matrices
The calculator supports every square and rectangular size from 1×1 up to 8×8. That covers the two most common textbook problem sizes — 2×2 matrix calculator problems (algebra, geometry, statistics) and 3×3 matrix calculator problems (linear algebra, computer graphics rotation) — as well as the 4×4 matrix calculator workflow that dominates 3D graphics and physics engines. Larger 5×5 through 8×8 sizes cover advanced linear-algebra homework, engineering statics, and control-theory state-space models.
Frequently asked questions
What is a matrix calculator?
A matrix calculator is a free online tool that performs all standard matrix operations — addition, subtraction, scalar and matrix multiplication, transpose, determinant, inverse, adjugate, cofactor, LU decomposition, rank, trace, RREF, null space, column space, powers, and solving Ax = b — with exact fractional arithmetic and step-by-step solutions.
How do you multiply two matrices?
Multiply an m × n matrix A by an n × p matrix B by taking the dot product of every row of A with every column of B. Each entry is C[i,j] = A[i,1]·B[1,j] + A[i,2]·B[2,j] + … + A[i,n]·B[n,j]. The result is m × p. The inner dimensions must match.
How do you find the determinant of a 2×2 matrix?
For [[a, b], [c, d]] the determinant is ad − bc. Example: [[1, 2], [3, 4]] has determinant 1·4 − 2·3 = −2.
How do you find the determinant of a 3×3 matrix?
Use cofactor (Laplace) expansion or the Rule of Sarrus. For [[a,b,c],[d,e,f],[g,h,i]] the determinant equals a(ei − fh) − b(di − fg) + c(dh − eg).
How do you find the inverse of a matrix?
For 2×2, use A⁻¹ = (1/det) · [[d, −b], [−c, a]]. For 3×3 and larger, use Gauss-Jordan elimination on [A | I] until the left side is the identity — the right side becomes A⁻¹. An inverse exists only when the determinant is nonzero.
What is the transpose of a matrix?
The transpose Aᵀ flips rows and columns. If A is m × n, Aᵀ is n × m and Aᵀ[i,j] = A[j,i].
What is the rank of a matrix?
The rank is the number of linearly independent rows (or columns). It equals the number of nonzero rows in the RREF of the matrix.
What is the trace of a matrix?
The trace of a square matrix is the sum of its diagonal entries. It also equals the sum of the eigenvalues.
What is RREF used for?
Reduced Row Echelon Form (RREF) is used to solve linear systems, find matrix rank, identify pivot columns, compute inverses, and determine whether Ax = b has a unique, infinite, or no solution.
Can this matrix calculator handle fractions?
Yes. Enter values like 3/5, -1/2, or 2.5. Internally the tool uses exact rational arithmetic with big-integer numerators and denominators, so 1/3 + 1/3 + 1/3 = 1 exactly.
Do I need to sign up to use this matrix calculator?
No. This is a free matrix calculator, no sign-up required. It runs entirely in your browser — nothing is uploaded, stored, or shared.
What is the largest matrix I can enter?
From 1×1 up to 8×8, covering everything from 2×2 and 3×3 homework problems to 4×4 graphics matrices and larger engineering systems.
Sources & methodology
- Wikipedia — Matrix (mathematics) — wikipedia.org
- Wikipedia — Gaussian elimination & Row echelon form — wikipedia.org
- Georgia Tech Interactive Linear Algebra — Determinants & cofactors — textbooks.math.gatech.edu
- Penn State STAT ONLINE — Gauss-Jordan elimination — online.stat.psu.edu
- Calculator.net — Matrix operations reference — calculator.net
- Pearson Channels — Matrix & RREF calculators — pearson.com
All arithmetic uses exact rational numbers (BigInt numerator + denominator, reduced with the Euclidean GCD). Determinants, inverses, RREF, rank, LU, null space, column space, and Ax = b are computed with Gauss-Jordan elimination and partial pivoting to avoid unnecessary zero pivots. Step-by-step traces log every elementary row operation so the solution is fully reproducible by hand.