CompoundPage

Matrix Calculator

Type a matrix, pick an operation, and the matrix calculator answers in exact fractions with the work shown. Where the answer is 1/3, it says 1/3, not 0.333333.

Rows separated by semicolons, entries by spaces or commas. Whole numbers, decimals and fractions like 3/4. Up to 4x4.

Only used when the operation needs a second matrix.

Inverse of A[3/4 1/2 1/4; 1/2 1 1/2; 1/4 1/2 3/4]

A^-1 Exact. Each entry is a fraction over a divisor of det(A), which is why a determinant of 4 gives quarters.
[3/4 1/2 1/4; 1/2 1 1/2; 1/4 1/2 3/4]
det(A) Non-zero, so the inverse exists.
4
Start Row-reduce A to the identity, doing the same operations to I alongside it. When the left side is I, the right side is A^-1.
[A | I] = [2 -1 0 | 1 0 0; -1 2 -1 | 0 1 0; 0 -1 2 | 0 0 1]
Step 1: R1 -> R1 / 2
[1 -1/2 0 | 1/2 0 0; -1 2 -1 | 0 1 0; 0 -1 2 | 0 0 1]
Step 2: R2 -> R2 + R1
[1 -1/2 0 | 1/2 0 0; 0 3/2 -1 | 1/2 1 0; 0 -1 2 | 0 0 1]
Step 3: R2 -> (2/3)R2
[1 -1/2 0 | 1/2 0 0; 0 1 -2/3 | 1/3 2/3 0; 0 -1 2 | 0 0 1]
Step 4: R1 -> R1 + (1/2)R2
[1 0 -1/3 | 2/3 1/3 0; 0 1 -2/3 | 1/3 2/3 0; 0 -1 2 | 0 0 1]
Step 5: R3 -> R3 + R2
[1 0 -1/3 | 2/3 1/3 0; 0 1 -2/3 | 1/3 2/3 0; 0 0 4/3 | 1/3 2/3 1]
Step 6: R3 -> (3/4)R3
[1 0 -1/3 | 2/3 1/3 0; 0 1 -2/3 | 1/3 2/3 0; 0 0 1 | 1/4 1/2 3/4]
Step 7: R1 -> R1 + (1/3)R3
[1 0 0 | 3/4 1/2 1/4; 0 1 -2/3 | 1/3 2/3 0; 0 0 1 | 1/4 1/2 3/4]
Step 8: R2 -> R2 + (2/3)R3
[1 0 0 | 3/4 1/2 1/4; 0 1 0 | 1/2 1 1/2; 0 0 1 | 1/4 1/2 3/4]
Check Multiplied back out exactly. With exact fractions this either holds or the inverse is wrong; there is no rounding to excuse.
A x A^-1 = I
A^-1 as decimals Rounded to six significant figures, for reference. The fractions are the answer.
[0.75 0.5 0.25; 0.5 1 0.5; 0.25 0.5 0.75]
Matrix A as read Check this against what you meant to type. Decimals are read as exact fractions, so 0.25 is 1/4.
3x3: [2 -1 0; -1 2 -1; 0 -1 2]
A^-1, exact
Column 1Column 2Column 3
Row 13/41/21/4
Row 21/211/2
Row 31/41/23/4
  • Every entry is held as an exact fraction and every operation is exact, so 1/3 stays 1/3. Floating-point elimination can turn a singular matrix into one with a huge, meaningless inverse; exact arithmetic cannot.
  • Matrices up to 4x4. Rows are separated by semicolons or new lines, entries by spaces or commas.

How the Matrix Calculator works

Type a matrix one row at a time, with semicolons between rows: 1 2; 3 4 is the 2x2 matrix with first row 1, 2 and second row 3, 4. Commas work between entries as well as spaces, so does the bracketed [[1,2],[3,4]], and entries can be whole numbers, decimals or fractions like 3/4. The page always shows what it read, so check that line first.

The determinant is a single number that says whether a square matrix can be undone. For a 2x2 with rows (a, b) and (c, d) it is ad - bc. For anything larger it is a cofactor expansion. Pick a row or column, and for each entry delete its row and column, take the determinant of the smaller matrix left behind (its minor), and multiply. Then add the results with alternating signs in a checkerboard pattern, + - + - along the first row. Any row or column gives the same answer, so the sensible choice is the one with the most zeros. A zero entry's term vanishes and its minor never needs working out, which is what this calculator does.

Geometrically, the determinant is the factor by which the matrix scales area (2x2) or volume (3x3). A negative determinant also flips orientation, like a mirror. A determinant of zero means the matrix squashes space flat: some direction is collapsed to nothing, and nothing can recover it. That is why a zero determinant and "no inverse" are the same statement.

The inverse is computed by Gauss-Jordan elimination. Write A next to the identity matrix as [A | I], then use row operations to turn the left side into I: swap two rows, scale a row, or add a multiple of one row to another. Do every operation to both halves. When the left side is I, the right side is the inverse. Each step is written out above, so the inverse matrix calculator can be checked line by line against working on paper. For a 2x2 there is a shortcut: swap the diagonal entries, negate the other two, and divide by ad - bc.

Matrix multiplication is rows into columns. The entry in row i, column j of A x B is row i of A dotted with column j of B. That only works when A has as many columns as B has rows, and the result takes A's row count and B's column count, so a 2x3 times a 3x4 is a 2x4. Order matters. A x B and B x A are usually different, and often only one of them exists. Addition and subtraction are entry by entry and need two matrices of the same size.

Reduced row echelon form is where Gauss-Jordan ends up when it is run to completion. Every pivot is 1, every other entry in a pivot's column is 0, and each pivot sits to the right of the one above it. The RREF of a matrix is unique, so it is a reliable check on working done another way. The number of pivots is the rank: how many rows are independent, or equivalently how many dimensions the matrix's output fills. A square matrix is invertible exactly when its rank is full. For a system of equations, the rank decides between one solution, none and infinitely many.

The trace is the sum of the main diagonal. It looks too simple to matter, but it equals the sum of the eigenvalues, and it does not change under a change of basis.

Everything here is computed in exact fractions. That matters more for matrices than almost anywhere else. In floating-point elimination a pivot that should be exactly zero comes out as something like 1e-17, so a singular matrix looks invertible and gets an inverse full of entries in the quadrillions. Exact arithmetic either finds the zero or it does not. The decimals shown under an inverse are rounded for reference; the fractions are the answer.

Matrix Calculator FAQ

How do you find the inverse of a matrix?

Row-reduce the augmented matrix [A | I] until the left half is the identity; the right half is then A^-1. For a 2x2 with rows (a, b) and (c, d), the inverse is 1/(ad - bc) times the matrix with rows (d, -b) and (-c, a). If the determinant is zero there is no inverse, and row reduction will produce a row of zeros on the left to say so.

How do you calculate a 3x3 determinant?

Expand along any row or column. For each entry, cross out its row and column, take the 2x2 determinant of what is left, multiply by the entry, and combine with the signs + - + in a checkerboard. Choosing the row or column with the most zeros saves work, because each zero removes a whole term.

When can two matrices be multiplied?

When the first has as many columns as the second has rows. A 2x3 times a 3x4 is defined and gives a 2x4; a 3x4 times a 2x3 is not defined. Even when both orders are defined, A x B and B x A are usually different.

What does it mean if the determinant is zero?

The matrix is singular. Its rows (and its columns) are linearly dependent, it has no inverse, its rank is less than full, and a system of equations with it as the coefficient matrix has either no solution or infinitely many, never exactly one.

What is the rank of a matrix?

The number of linearly independent rows, which always equals the number of linearly independent columns. In practice it is the number of pivots in the reduced row echelon form. A square matrix is invertible exactly when its rank equals its size.

Related calculators

Embed this calculator
<div id="compoundpage-matrix-calculator"></div>
<script src="https://compoundpage.com/embed/matrix-calculator.js" async></script>

The same calculation as JSON