Maths

Matrix Calculator

Add, multiply, invert and find determinants of matrices up to 8 × 8, in exact fractions.

By Nitin Raturi · Last reviewed

Your matrices

How to use the Matrix Calculator

Add, multiply, invert or find the determinant of matrices, with exact fractions.

  1. Choose the operation.
  2. Type matrix A, one row per line.
  3. If the operation needs it, type matrix B.
  4. Read the answer, then the row operations used for a determinant or inverse.

Good to know

  • A determinant of 0 means the matrix has no inverse.
  • Use fractions like 1/3 instead of 0.333 to keep the answer exact.

Operation

What to do with the matrices.

How to fill it in

  • Add, subtract or multiply works on A and B.
  • Determinant, inverse or transpose works on A only.

Keep in mind: A × B is usually not equal to B × A, so the order matters.

Matrix A

The first matrix. Determinant, inverse and transpose use A alone.

How to fill it in

  • Type one row per line, or separate rows with a semicolon.
  • Separate entries with spaces or commas.
  • Entries can be whole numbers, decimals or fractions like 7/4; up to 8 × 8.

Example

1 2 on one line and 3 4 on the next has determinant −2 and inverse [−2 1; 3/2 −1/2].

Tip: Fractions stay exact, so the inverse shows 3/2 rather than a rounded decimal.

One row per line; entries like 3, −2.5 or 7/4.

Matrix B is not used for this operation.

Matrix B

The second matrix, used only to add, subtract or multiply.

How to fill it in

  • Enter it the same way as A.
  • To add or subtract, B must be the same size as A.
  • To multiply, B needs as many rows as A has columns.

Example

A 2 × 3 matrix times a 3 × 2 matrix gives a 2 × 2 result, here [58 64; 139 154].

Determinant of 3 × 3 matrix A

det(A) = −9

The determinant of A is −9.

Row operations:

  1. R3 → R3 − 1/2·R1
  2. R3 → R3 + 3/2·R2

Exact fractions throughout. Found by row reduction to triangular form: the product of the pivots, with the sign flipped for each row swap.

How this calculator works

  1. Step 1Readrows and entriesEach entry becomes an exact fraction.
  2. Step 2Reducerow operationsElimination for determinants and inverses.
  3. Step 3Showanswer and stepsEvery row operation is listed.

Each entry is stored as an exact fraction, so 1/3 never becomes 0.333. Adding, subtracting and multiplying follow the usual definitions.

For a determinant, the calculator reduces A to triangular form with row operations. The determinant is the product of the pivots, with the sign flipped for each row swap.

Worked example: a 3 × 3 determinant

Determinant of A = [2 1 3; 0 −1 4; 1 2 0]
det(A)
product of the pivots after elimination
  1. Step 1R3 → R3 − 1/2·R1
  2. Step 2R3 → R3 + 3/2·R2
  3. det(A)product of the pivots−9

The same answer, −9, comes from cofactor expansion along the first row: 2 × (−8) − 1 × (−4) + 3 × 1.

Inverse and product

  • Inverse of [1 2; 3 4][−2 1; 3/2 −1/2]The determinant is −2, so the inverse exists.
  • A × B (default)[5 7 7; −3 7 4; 7 2 2]Row of A times column of B, summed.

A 2 × 3 matrix times a 3 × 2 matrix gives a 2 × 2 result: [58 64; 139 154]. The inner sizes must match.

Read the result

A determinant of 0 means no inverse. The matrix [1 2; 2 4] has determinant 0: its second row is twice the first.

The inverse is found by Gauss-Jordan elimination on A placed beside the identity. When the left half becomes the identity, the right half is the inverse.

What the calculator accepts

  • Up to 8 × 8Rows on new lines or separated by semicolons.
  • Exact fractionsWhole numbers, decimals and fractions like 7/4.
  • No symbolsLetters, variables and complex numbers are rejected.
  • Size checksMismatched sizes are explained, not guessed.

Matrices solve many equations at once and describe directions in space.

To solve linear equations with each elimination step, use the system of equations calculator. For dot and cross products of 3D vectors, try the vector calculator.

Common mistakes

  • Mistake: Assuming A × B equals B × A.

    Instead: Matrix multiplication depends on order.

  • Mistake: Multiplying matching entries.

    Instead: Each result entry is a row of A times a column of B.

  • Mistake: Inverting a matrix with determinant 0.

    Instead: Check the determinant first; such a matrix has no inverse.

  • Mistake: Typing 0.333 for one third.

    Instead: Type 1/3 so the answer stays exact.

Checking the method

A separate script re-works every golden value with cofactor expansion and the adjugate formula in exact fractions, without row reduction.

Read how we test our calculators, or browse more maths calculators.

Frequently asked questions

What is the determinant of [2 1 3; 0 −1 4; 1 2 0]?

It is −9, found by row reduction and confirmed by cofactor expansion.

What is the inverse of [1 2; 3 4]?

It is [−2 1; 3/2 −1/2]. The determinant is −2, which is not zero, so the inverse exists.

When does a matrix have no inverse?

When its determinant is 0. For example [1 2; 2 4] has determinant 0 because one row is a multiple of the other.

Which matrices can be multiplied?

A × B needs A’s column count to equal B’s row count. A 2 × 3 times a 3 × 2 gives [58 64; 139 154].

Why does the answer show fractions?

Every entry is kept as an exact fraction, so inverses are not rounded. Type 1/3 rather than 0.333.

Sources and methodology

The formulas are standard time-value-of-money results. We check every figure against golden values worked out independently, by closed form and by month-by-month simulation; see the methodology.

Written and maintained by Nitin Raturi, a software engineer (about the author). Last reviewed 4 Nov 2026; next review due by . Found an error? Tell us.

Changelog

  • : Initial release.