Matrix Calculator

Add, subtract and multiply matrices, or find the determinant, inverse, transpose, rank, RREF and powers. Exact fraction answers up to 6×6.

A×

Type whole numbers, decimals or fractions such as -3, 2.5 or 1/3. Empty cells count as 0.

Result

Matrices show up everywhere once you start looking: in linear algebra homework, in physics and engineering problems, in computer graphics, statistics and economics.

The arithmetic behind them isn’t hard, but it’s long, and one slip in the middle of a 3×3 inverse can ruin the whole answer. This matrix calculator does that arithmetic for you and shows how it got there.

It works with matrices of any size from 1×1 up to 6×6.

You can find the determinant, inverse, transpose, rank, reduced row echelon form (RREF), trace and powers of a single matrix, multiply it by a number, or add, subtract and multiply two matrices.

Every result is worked out with exact fractions, so you get 7/12 rather than 0.583333 unless you ask for decimals.

How to Use the Matrix Calculator

  • Choose a tab. Use One matrix for the determinant, inverse and other single-matrix operations, or Two matrices (A & B) for addition, subtraction and multiplication.
  • Set the size. Pick the number of rows and columns from the drop-downs next to each matrix. Values you’ve already typed stay in place when you resize.
  • Type the entries. Whole numbers, negatives, decimals and fractions are all fine, so -4, 0.75 and 2/3 all work. A blank cell counts as zero. If an entry can’t be read, its box turns red.
  • Pick an operation. The answer updates as soon as you click or type. Switch between Fractions and Decimals above the result at any time.

There are also buttons to clear a matrix, fill it with random whole numbers for practice, and swap A and B so you can see how A × B compares with B × A.

What Each Operation Means

Determinant

The determinant is a single number worked out from a square matrix. For a 2×2 matrix [a b; c d] it’s ad − bc. For a 3×3 matrix the calculator expands along the first row:

det = a(ei − fh) − b(di − fg) + c(dh − eg)

For 4×4 and larger it uses row reduction instead, because cofactor expansion gets slow very quickly. The determinant tells you two useful things. If it’s zero, the matrix is singular and has no inverse.

Its absolute value is also the factor by which the matrix scales area (in 2D) or volume (in 3D).

Inverse

The inverse A⁻¹ is the matrix that gives the identity when you multiply it by A, so A × A⁻¹ = I. Only square matrices with a non-zero determinant have one.

For a 2×2 matrix the shortcut is to swap a and d, change the signs of b and c, and divide everything by the determinant.

For bigger matrices the calculator runs Gauss-Jordan elimination on [A | I], then multiplies the answer back by A to confirm it really does give the identity.

Transpose

The transpose Aᵀ flips the matrix over its main diagonal, so rows become columns. A 2×3 matrix turns into a 3×2 matrix.

You’ll need transposes for things like the normal equations in least-squares regression, and for checking whether a matrix is symmetric (A = Aᵀ).

Rank and RREF

Reduced row echelon form is what you get after row-reducing a matrix as far as it will go. Every pivot is 1, and every other entry in a pivot column is 0.

The rank is the number of pivots, which equals the number of linearly independent rows. The calculator also shows the pivot columns and the nullity (number of columns minus rank).

RREF is the standard way to solve a system of linear equations: put the coefficients and the right-hand side into one augmented matrix and read the solution off the reduced form.

Trace, powers and scalar multiples

The trace is the sum of the entries on the main diagonal. A power Aⁿ multiplies A by itself n times. A⁰ is defined as the identity, and the calculator handles powers up to 20.

Scalar multiplication (k × A) multiplies every entry by the same number, which can be a fraction such as 1/2.

Adding, subtracting and multiplying two matrices

You can only add or subtract matrices of the same size, and you do it entry by entry. Multiplication is different.

To find A × B, the number of columns of A must equal the number of rows of B.

Each entry of the answer is a row of A multiplied term by term with a column of B, then summed. A 2×3 matrix times a 3×2 matrix gives a 2×2 result.

Order matters too: A × B and B × A are usually different, and sometimes only one of them exists.

Worked Examples

Example 1: determinant and inverse of a 2×2 matrix

Take A = [4 7; 2 6]. The determinant is 4 × 6 − 7 × 2 = 24 − 14 = 10. Because it isn’t zero, the inverse exists:

A⁻¹ = (1/10) × [6 −7; −2 4] = [3/5 −7/10; −1/5 2/5], or [0.6 −0.7; −0.2 0.4] in decimals.

Example 2: a 3×3 determinant

For A = [2 1 −1; −3 −1 2; −2 1 2], expanding along the top row gives 2(−2 − 2) − 1(−6 + 4) + (−1)(−3 − 2) = −8 + 2 + 5 = −1.

That’s the default example in the calculator, and its inverse comes out as whole numbers: [4 3 −1; −2 −2 1; 5 4 −1].

Example 3: a singular matrix

The matrix [1 2 3; 4 5 6; 7 8 9] looks harmless, but its determinant is 0. The third row equals twice the second minus the first, so the rows aren’t independent. The rank is 2 and there’s no inverse.

Example 4: multiplying a 2×3 by a 3×2 matrix

With A = [1 2 3; 4 5 6] and B = [7 8; 9 10; 11 12], the top-left entry of A × B is 1×7 + 2×9 + 3×11 = 58.

The full product is [58 64; 139 154]. Swap the order and B × A is a 3×3 matrix instead, with a determinant of 0.

Why Exact Fractions Matter

Most online matrix tools work in floating-point decimals. That’s fine for quick checks, but rounding errors build up during elimination.

A matrix that should be singular can end up with a determinant like 6.66e-16 instead of 0, and an inverse that should hold neat fractions fills up with long decimals.

This calculator stores every entry as an exact fraction from start to finish, so a zero really is zero. Decimals you type, such as 0.25, are turned into fractions (1/4) before any working starts.

That makes the answers safe to copy straight into homework or a report.

Where Matrices Are Used

Students meet matrices in algebra, further maths, A-level, IB and university linear algebra courses.

Outside the classroom, they solve systems of equations in engineering and economics, rotate and scale shapes in computer graphics and games, and drive Markov chains in probability and the regression models used in statistics and data science.

If your problem involves a set of linear equations, there’s a matrix behind it.

Frequently Asked Questions

What size matrices can I use?

Any size from 1×1 to 6×6. Matrices don’t have to be square for addition, subtraction, multiplication, transpose, rank or RREF. The determinant, inverse, trace and powers need a square matrix.

Why does it say my matrix has no inverse?

Its determinant is zero, so at least one row can be built from the others. Check the rank: if it’s less than the number of rows, the matrix is singular.

Can I enter fractions and decimals?

Yes. Type fractions as 3/4 or -5/2 and decimals as 0.5 or -1.25. Results can be shown as exact fractions or rounded to six decimal places.

How do I solve a system of equations with this?

Write the coefficients and constants as an augmented matrix. For example, 2x + y = 5 and x − y = 1 becomes [2 1 5; 1 −1 1].

Choose RREF, and the last column gives x = 2 and y = 1.

Is A × B the same as B × A?

Usually not. Matrix multiplication isn’t commutative, so use the B × A button to compare the two.

If your matrix comes from a set of linear equations, the System of Equations Calculator solves them directly by elimination, substitution, Cramer’s rule or Gauss-Jordan, with every step shown.

More free tools from our Math Calculators collection:

Tahir Mehmood

About the author

Tahir Mehmood

Tahir Mehmood is the founder of Digital Designs SEO LTD, a UK company, with five years of hands-on experience in SEO, content writing and web development. He builds and maintains the calculators on All in Calculators and keeps them up to date. Spotted an error? Contact us and we will fix it.

Last updated: 27 November 2026