gizmobench

Matrix Calculator

Add, subtract, multiply, transpose, invert, reduce and take determinants, ranks and powers of matrices up to 8×8. Every entry is held as an exact fraction of two whole numbers rather than a decimal, so the inverse of [1 2; 3 4] comes back as [-2 1; 3/2 -1/2] instead of a row of rounded digits, and a matrix with no inverse is named as singular rather than answered with enormous numbers.

A2 × 2
RowsColumns
B2 × 2
RowsColumns
1922
4350
Display

Row by column. The columns of A have to match the rows of B, and B × A is usually a different matrix.

  • Determinantnot zero, so A can be inverted
    -2
  • Rank of Athe most a 2×2 matrix can have
    2
  • A × Bexact fractions
    [ 19 22 ] [ 43 50 ]

Each entry is a row of A paired off against a column of B and summed. Matrix multiplication is not commutative, so B × A is usually a different matrix.

Every entry is a fraction, not a decimal. Numbers here are held as one whole number over another and are added, multiplied and divided without rounding at any step, so the inverse of an integer matrix arrives as fractions and stays readable: 1/3 is 1/3, not 0.3333333333. It also fixes the failure that matters most. A singular matrix has determinant exactly 0, but in decimals it usually does not: the determinant of [1 2 3; 4 5 6; 7 8 9] comes out at about 0.00000000000000067, so a calculator that trusts that number inverts the matrix anyway and hands back entries around a thousand trillion. This one gets 0, and says the matrix is singular. Switch the display to Decimal whenever a decimal is what you need: it rounds the same exact values for reading, and never for calculating.

Common questions

Why does this show fractions instead of decimals?
Because the answer usually is a fraction. Inverting an integer matrix divides by its determinant, so [1 2; 3 4] inverts to [-2 1; 3/2 -1/2], and the third of those entries is 3/2 exactly. A calculator working in decimals has to print 1.5 for that one and 0.3333333333 for a third, and you are left guessing which repeating decimal was meant. Here every entry is a pair of whole numbers, added and multiplied with no rounding at any step. The Decimal display switches the same values to a chosen number of places when a decimal is what you want.
When does a matrix have no inverse?
When its determinant is zero, which happens exactly when one row can be built out of the others. Such a matrix is called singular, and no inverse exists at all. This matters more than it sounds: worked out in decimals, the determinant of [1 2 3; 4 5 6; 7 8 9] comes out at about 0.00000000000000067 rather than 0, so a calculator that trusts that number inverts the matrix anyway and hands back entries around a thousand trillion. This tool computes the determinant exactly, gets 0, and says the matrix is singular.
Does the order of matrix multiplication matter?
Yes. A × B and B × A are different matrices in general, and often only one of them is even defined. For A × B the number of columns in A must equal the number of rows in B, and the result has the rows of A and the columns of B. With A = [1 2; 3 4] and B = [5 6; 7 8], A × B is [19 22; 43 50] while B × A is [23 34; 31 46]. When the dimensions do not line up the tool says which two numbers have to match and what to change.
How large a matrix can it handle?
Up to 8×8, for both matrices, with the row and column steppers on each grid. At that size everything except powers is a single pass and answers immediately, however awkward the fractions are. Powers are the one operation that can outgrow the machine: raising a matrix to a power multiplies it into itself over and over, and with fractions whose denominators have nothing in common the entries roughly double in length each time, so a power stops and tells you the size it would have reached once the entries pass 600 digits. Everything runs in your browser, so nothing is uploaded and no account is involved.
How do I type a fraction or a decimal into a cell?
Type it the way you would write it. A cell accepts a whole number, a decimal like 0.5, a fraction like 1/3, exponent notation like 1.5e-2, and the long minus sign that comes with anything pasted out of a PDF or a textbook. Decimals are converted exactly: 0.5 becomes 1/2, and 0.1 becomes 1/10 rather than the binary approximation a computer normally stores. A cell left blank counts as zero, so a mostly empty grid still computes.
What is reduced row echelon form for?
It is the canonical result of Gaussian elimination: each pivot is 1 and is the only non-zero entry in its column. Reading a system of equations off it gives the solution directly, and counting the pivots gives the rank, which is how many rows are genuinely independent. The tool shows the determinant and the rank of A beside every result, so a matrix that is about to fail to invert announces itself before you ask for the inverse.

Exact: matrices are computed in rational arithmetic, so an inverse of an integer matrix is shown as fractions rather than rounded decimals, and a singular matrix is reported as singular instead of producing huge numbers.