Matrix Calculator

A matrix calculator that works in exact fractions from entry to answer, so an inverse comes back as 3/2 rather than 1.5000001. It adds, subtracts and multiplies matrices with dimension checks, transposes, and finds the determinant, inverse, rank, reduced row echelon form, cofactor matrix and adjugate, solves systems A x = b (with Cramer’s rule shown where it applies, and the full parametric solution when there are infinitely many), and computes eigenvalues and eigenvectors for 2×2 matrices, including the diagonalization when one exists.

Matrix A
Matrix B

Entries may be integers, decimals, or fractions like 3/4; they are stored and computed exactly. Sizes run from 1×1 to 4×4. Swap A and B exchanges the two matrices, which is the quick way to run an A-operation on B.

How to use this calculator

  1. Pick the operation. The B panel appears for add, subtract and multiply; the b vector appears for solving; the scalar box appears for scalar multiplication.
  2. Set the sizes, then type entries. Resize first: changing a size rebuilds the grid and clears its entries.
  3. Calculate. Dimension mistakes (adding a 2×3 to a 2×2, multiplying with mismatched inner dimensions, asking for the determinant of a rectangle) are refused with the two sizes named, not silently reshaped.
  4. Read the steps: multiplication shows every entry’s dot product; RREF lists each row operation; solving shows the augmented form and, where Cramer’s rule applies, the determinant quotients.

The method

Exact arithmetic throughout

Every entry is parsed into a fraction (3/4 stays 3/4, 0.1 becomes 1/10) and all operations run on fractions with whole-number numerators and denominators. Determinants, inverses and RREF are therefore exact: a singular matrix has determinant exactly 0, not 10−17, and singularity is a fact here, not a rounding judgement.

The core algorithms

Determinant: elimination to triangular form; det = (sign from row swaps) × product of the diagonal.   Inverse: Gauss–Jordan on [A | I].   Rank: number of pivots in the RREF.   Solve: RREF of [A | b].

Multiplication is the defining operation: the (i, j) entry of AB is the dot product of row i of A with column j of B, which is why the inner dimensions must agree and why AB and BA are usually different matrices. The transpose flips a matrix over its diagonal; the inverse, when it exists, is the matrix that undoes A, verified here by multiplying A by its computed inverse and showing the identity.

Cofactors, adjugate, Cramer

The cofactor Cij is (−1)i+j times the determinant of the minor left by deleting row i and column j. The adjugate is the transpose of the cofactor matrix, and A−1 = adj(A) / det(A), which the inverse operation cross-checks against Gauss–Jordan. For a square system, Cramer’s rule gives each unknown as a ratio of two determinants, shown alongside the elimination solution for systems up to 3×3.

Eigenvalues for 2×2

For A = [[a, b], [c, d]], the eigenvalues are the roots of λ² − (trace)λ + det = 0, given exactly when the discriminant is a perfect square and in simplified radical form for integer matrices otherwise (decimals alongside). Each eigenvector solves (A − λI) v = 0. With two distinct real eigenvalues the diagonalization A = P D P−1 is shown in full.

Worked examples

Example 1: add and multiply the defaults

A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]]: A + B = [[6, 8], [10, 12]] entry by entry. A × B = [[19, 22], [43, 50]]: the top-left entry is 1·5 + 2·7 = 19, and the steps show all four dot products. Note B × A = [[23, 34], [31, 46]], different, as matrix multiplication usually is.

Example 2: determinant and inverse of A

det(A) = 1·4 − 2·3 = −2. Non-zero, so the inverse exists: A−1 = [[−2, 1], [3/2, −1/2]], and the tool multiplies A by it to show the identity, as every claimed inverse should be made to prove itself.

Example 3: cofactors and adjugate

For the same A: the cofactor matrix is [[4, −3], [−2, 1]] (checkerboard signs applied to the four minors), the adjugate is its transpose [[4, −2], [−3, 1]], and adj(A)/det(A) reproduces the inverse of Example 2 exactly.

Example 4: a singular matrix, honestly reported

A = [[1, 2], [2, 4]] has determinant 0 and rank 1: its RREF is [[1, 2], [0, 0]]. There is no inverse, and the tool says so with the reason, rather than returning enormous numbers. A² is still fine: [[5, 10], [10, 20]].

Example 5: solving, by elimination and by Cramer

2x + y = 5 and x + 3y = 5 (A = [[2, 1], [1, 3]], b = [5, 5]): det = 5, Cramer gives x = (15 − 5)/5 = 2 and y = (10 − 5)/5 = 1, and elimination agrees, as it must.

Example 6: infinitely many solutions, in full

A = [[1, 2], [2, 4]] with b = [3, 6]: the augmented RREF is [[1, 2 | 3], [0, 0 | 0]], so y is free and the solution set is x = (3, 0) + t·(−2, 1) for any t. With b = [3, 7] instead, the last row reads 0 = 1: no solution. Both outcomes are reported in words, not error codes.

Example 7: a 3×3 determinant

[[1, 2, 3], [0, 1, 4], [5, 6, 0]] has determinant 1, so its inverse is exactly its adjugate: [[−24, 18, 5], [20, −15, −4], [−5, 4, 1]], whole numbers throughout, which the inverse operation returns and verifies.

Example 8: eigenvalues of the default A

Trace 5, determinant −2: λ² − 5λ − 2 = 0 gives λ = (5 ± √33)/2 ≈ 5.372281 and −0.372281, with eigenvectors (2, λ − 1) in direction, and P, D, P−1 shown since the eigenvalues are distinct.

Reading your results

Fractions are the exactness guarantee. An entry shown as 3/2 is exactly three halves. When a result is genuinely irrational (eigenvalues), it is labelled with decimals or a simplified radical, never dressed up as a terminating decimal that pretends to be exact.

The RREF is the system’s X-ray. Pivot columns are the determined variables, free columns are the parameters, and a row of zeros facing a non-zero constant is an inconsistency. Rank counts the pivots: for a square matrix, full rank and non-zero determinant and invertible are three phrasings of one fact, and the tool’s answers agree across operations because they share the same elimination.

Steps are the audit trail. Row operations are listed in order with the standard notation (R2 ← R2 − 2R1 means row 2 was replaced by itself minus twice row 1), so any result can be replayed by hand. Long operations cap the list and say how many more of the same kind followed.

Common mistakes

  • Assuming AB = BA. Matrix multiplication is not commutative: with the defaults, AB = [[19, 22], [43, 50]] but BA = [[23, 34], [31, 46]]. Order is part of the question; the Swap button exists for exactly this check.
  • Dividing matrices. There is no matrix division. “A/B” means A × B−1 (or B−1 × A, a different thing), and only when B is invertible.
  • Expecting an inverse for every square matrix. Determinant zero means no inverse exists, full stop. Near-singular is a separate numerical concern; with exact fractions, singularity here is exact, and the tool names the zero determinant as the reason.
  • Confusing the transpose with the inverse. The transpose mirrors entries over the diagonal and always exists; the inverse undoes the matrix and often does not. They coincide only for orthogonal matrices.
  • Sign errors in cofactors. The checkerboard starts with + at (1, 1) and alternates; the (1, 2) and (2, 1) cofactors of the default A are negative (−3, −2) even though both minors (3 and 2) are positive. Forgetting the sign is the classic cofactor error.
  • Reading a free variable as an error. A system with a free variable has infinitely many solutions forming a line or plane, which is a complete answer, given parametrically; it is not the solver failing.

Limitations

  • Sizes run to 4×4, which covers hand and coursework matrices. Cofactors and adjugate are offered to 3×3 (the 4×4 cofactor grid is 64 minor determinants; the inverse operation still handles 4×4 by Gauss–Jordan).
  • Eigen work is 2×2: characteristic quadratics solve exactly, while 3×3 and larger eigenvalues are genuinely numerical (iterative QR) and belong to the numerical Eigenvalue workflow rather than this exact engine; entering a larger matrix in eigen mode explains this instead of faking it.
  • Entries are exact rationals (integers, decimals, a/b fractions). Symbolic entries (x, π, √2 as text) are not accepted; decimals are converted to their exact fraction, so 0.1 is 1/10, not a floating approximation.
  • Gram–Schmidt orthogonalization, matrix norms, decompositions (LU, QR, SVD) and least-squares fitting are separate workflows not folded into this page; the operations here are the ones the method section lists.
  • Fraction entries keep arithmetic exact, but very large numerators from repeated operations on big fractions can make results hard to read; the numbers remain correct.

Frequently asked questions

Why do I get fractions when the inputs were whole numbers?

Because matrix answers often are fractions: the inverse of [[1, 2], [3, 4]] contains 3/2 and −1/2, and any decimal display would be an approximation of them. This tool treats fractions as the answer, not as a formatting problem. Decimal entries are converted exactly too: 0.1 is stored as 1/10.

What does it mean when a matrix has no inverse?

Its determinant is zero, its rows (or columns) are redundant (one is a combination of the others), and it flattens space onto a line or plane, which cannot be undone. Here singularity is exact: the elimination either finds every pivot or reports the zero determinant as the reason for refusal.

How is Cramer’s rule different from elimination?

Cramer’s rule is a formula: each unknown is a ratio of two determinants, elegant for 2×2 and 3×3 by hand and hopeless for large systems (the determinant count explodes). Elimination (Gaussian, via RREF) is the algorithm that scales. This tool shows both for small square systems so the formula and the algorithm can be checked against each other.

When does a system have infinitely many solutions?

When the RREF has fewer pivots than unknowns, leaving free variables. The solution is then a point plus a combination of direction vectors (the null space directions), given parametrically here: x = xp + t·v1 + s·v2. Setting the parameters to zero recovers one concrete solution; the directions span all the others.

Why are eigenvalues here only 2×2?

Because a 2×2 characteristic equation is a quadratic, solvable exactly, which suits this page’s exact engine. Larger characteristic polynomials are cubics and beyond, and practical eigenvalue computation is iterative (the QR algorithm), a numerical workflow of its own. The mode explains this for larger matrices instead of printing plausible-looking wrong values.

What is the adjugate used for?

It is the inverse in waiting: A−1 = adj(A)/det(A). It also appears wherever inverses must be differentiated or kept polynomial (the adjugate’s entries are polynomials in A’s entries, with no division), which is why it earns its own operation here.

Related calculators

Method: all arithmetic is exact rational arithmetic on parsed entries (integers, decimals and a/b fractions). Determinant by elimination to triangular form; inverse and RREF by Gauss–Jordan with the row operations listed; rank by pivot count; systems from the augmented RREF with Cramer’s rule shown for square systems up to 3×3; cofactors from signed minor determinants; 2×2 eigenvalues from the characteristic quadratic, exactly where possible. Last reviewed: 21 October 2026.

Disclaimer: This calculator gives estimates for general information only. It is not financial, medical or other professional advice.