Skip to content
AZ Tools

Matrix Calculator (exact fractions)

Determinant, inverse, RREF and rank, transpose, product and A x = b for matrices up to 12 × 12, in exact fractions rather than rounded decimals.

One row per line, entries separated by spaces or commas. 0.1, 1/3, -2.5e3 and [[1,2],[3,4]] are all read exactly.
Determinant
Rank
3
Result
3/41/21/4
1/211/2
1/41/23/4

Everything is exact rational arithmetic in the browser — no rounding until you ask for decimals. The matrices are kept in local storage.

How to use

  1. Choose the operation, then type or paste matrix A with one row per line; spaces, commas and pasted [[1,2],[3,4]] brackets all work.
  2. For A × B or A x = b, fill in the second box — a column for b, or a single row with one entry per row of A.
  3. Read the result as exact fractions, or tick show decimals for a rounded view of the same values.
  4. For a singular matrix the determinant is 0 and the rank shows how many rows are independent; RREF shows which ones.
  5. When A x = b has many solutions, add any combination of the free directions to the solution shown to get the others.

About this tool

Show

Paste a matrix and get its determinant, inverse, reduced row echelon form and rank, transpose, a product with a second matrix, or the solution of A x = b. Every step is exact rational arithmetic, which is the difference from a spreadsheet or numpy. Floating-point elimination returns 3.55e-15 as the determinant of [[2, 4, 6], [1, 3, 5], [3, 7, 11]], whose third row is the sum of the first two; here it is 0, and the tool says the matrix has no inverse instead of producing one with entries in the quadrillions. The 6 × 6 Hilbert matrix, the textbook example of an ill-conditioned matrix, has an inverse made entirely of integers — 36, −630, 3360 along its first row — and numpy returns 36.0000000049 for the first of them; here the integers come out as integers, and its determinant as the fraction 1/186313420339200000. Decimals are read exactly too, so 0.1 means one tenth and not the nearest binary fraction to it, and a fraction such as 1/3 can be typed directly. Solving A x = b is classified rather than attempted blindly: one solution when A has full column rank, none when b is outside A's column space — reported as the two ranks that disagree — and, when there are free variables, one particular solution together with a basis of the null space, so every solution is written down. Exact arithmetic has a cost: fractions can grow long on large or awkward matrices, which is why the size is capped at 12 × 12, and a decimal view is one switch away when the fractions are more exact than useful.

Frequently asked questions

Why does this say 0 when my spreadsheet says 3.55e-15?

Because the spreadsheet eliminates in binary floating point, where each division rounds and the rounding errors do not quite cancel. A matrix whose rows are dependent has a determinant of exactly zero, and exact rational arithmetic keeps it that way. A tiny nonzero determinant from a float routine usually means singular, but nothing in the number tells you so; here there is no ambiguity.

Can I enter decimals and fractions?

Yes. Integers, decimals with an optional exponent such as 2.5e-3, and fractions such as -7/12 are all read as exact rationals. A decimal is taken at face value, so 0.1 is exactly one tenth. Results can be shown as fractions or, with the decimals switch, rounded to ten significant digits.

What does RREF tell me?

The reduced row echelon form is unique for a given matrix. Its nonzero rows are a clean basis for the row space, their count is the rank, and the columns that hold a leading 1 are the pivot columns, which identify a set of independent columns in the original matrix. It is also how the inverse and the solution of A x = b are computed here.

How are the solutions of A x = b described when there are infinitely many?

The tool gives one particular solution, found by setting every free variable to zero, and one null-space vector per free variable. Every solution is the particular one plus some combination of those vectors. When A has full column rank there is no null space and the solution is unique; when rank [A | b] exceeds rank A, there is none.

Why is the size limited to 12 × 12?

Exact fractions grow. Elimination on an awkward matrix can produce numerators and denominators with hundreds of digits, and the work grows with them. Twelve by twelve covers coursework, small models and hand-checking a numerical result, while keeping every operation instant. For large numerical problems floating point is the right tool, and this one is the way to check a small case of it.

Related tools