Matrix Calculator

Type a matrix one row per line to get its determinant, inverse, RREF, rank, eigenvalues and more, in exact fractions or decimals, or multiply, add and subtract two matrices.

Runs in your browser; nothing you type is sent anywhere. · Updated

How to use the matrix calculator

Type each row on its own line, with entries separated by spaces or commas. Whole numbers, decimals (0.25) and fractions (3/4) all work, and results stay exact: the inverse of a matrix of whole numbers comes back in fractions rather than rounded decimals. Switch to decimals if you prefer. Matrices up to 10×10 are supported.

How to calculate a determinant

2×2: for [[a, b], [c, d]], det = ad − bc. The matrix 1 2 / 3 4 has determinant 1×4 − 2×3 = −2.

3×3: expand along the first row. For rows a b c / d e f / g h i:

det = a(ei − fh) − b(di − fg) + c(dh − eg)

For 2 1 1 / 1 3 2 / 1 0 0: 2(3×0 − 2×0) − 1(1×0 − 2×1) + 1(1×0 − 3×1) = 0 + 2 − 3 = −1.

4×4 and larger: cofactor expansion gets long fast, so row-reduce instead. Swapping two rows flips the sign, scaling a row scales the determinant, and adding a multiple of one row to another changes nothing. Once the matrix is triangular, the determinant is the product of the diagonal.

Property Rule
det(AB) det(A) × det(B)
det(Aᵀ) det(A)
det(A⁻¹) 1 ÷ det(A)
det(kA), n×n kⁿ × det(A)
A row of zeros, or two equal rows det = 0

How to find the inverse of a matrix

A matrix has an inverse only if its determinant isn’t 0.

2×2: A⁻¹ = (1 ÷ (ad − bc)) × [[d, −b], [−c, a]]. For 1 2 / 3 4: (1 ÷ −2) × [[4, −2], [−3, 1]] = [[−2, 1], [3/2, −1/2]].

3×3 and larger: write [A | I] and row-reduce until the left side is the identity; the right side is then A⁻¹. The inverse of 2 1 1 / 1 3 2 / 1 0 0 is 0 0 1 / −2 1 3 / 3 −1 −5. You can check any inverse by multiplying: A × A⁻¹ should give the identity.

Row echelon form and rank

Reduced row echelon form (RREF) has a leading 1 in each nonzero row, zeros above and below every leading 1, and each leading 1 to the right of the one above. The number of nonzero rows is the rank. The matrix 1 2 3 / 4 5 6 / 7 8 9 reduces to 1 0 −1 / 0 1 2 / 0 0 0, so its rank is 2 and its determinant is 0.

RREF is how you solve a system of linear equations: put the coefficients and the constants in one augmented matrix. For a step-by-step solver, use the system of equations calculator.

Matrix multiplication

A × B works only when A has as many columns as B has rows; an m×n matrix times an n×p matrix gives an m×p result. Entry (i, j) is row i of A times column j of B, multiplied entry by entry and added. Order matters: A × B usually isn’t B × A.

Addition and subtraction need matrices of the same size and work entry by entry.

Eigenvalues

The eigenvalues of a square matrix are the roots of its characteristic polynomial, det(λI − A) = 0. For 2 0 0 / 0 3 4 / 0 4 9 the polynomial is λ³ − 14λ² + 35λ − 22, with roots 11, 2 and 1. Two quick checks: the eigenvalues add up to the trace (2 + 3 + 9 = 14) and multiply to the determinant (22). Some real matrices have complex eigenvalues: the rotation matrix 0 −1 / 1 0 has ±i.

Frequently asked questions

Why does my matrix have no inverse?

Its determinant is 0, which means its rows (and columns) are linearly dependent: one row can be built from the others.

How do I do this in Python?

With NumPy: numpy.linalg.det(A), numpy.linalg.inv(A), A @ B for multiplication and numpy.linalg.eigvals(A). NumPy works in floating point, so expect tiny rounding like −0.9999999999 where this calculator shows −1.

What’s the transpose?

Rows become columns: entry (i, j) moves to (j, i), so a 2×3 matrix becomes 3×2.