Home/Math/Matrix Calculator

Matrix Calculator

Add, subtract, multiply, transpose, and find the determinant, inverse, rank, trace, RREF and eigenvalues — with the row operations shown.

Quick Answer: What Is a Matrix Calculator?

A matrix calculator performs linear-algebra operations on rectangular arrays of numbers. Enter your matrix below, choose an operation, and it returns the result with the working. It handles addition, subtraction, multiplication, transpose, determinant, inverse, rank, trace, reduced row echelon form and 2×2 eigenvalues, for matrices up to 6×6 — including non-square ones, which many calculators refuse.

Matrix Calculator

Matrix A

Matrix B

Result
A × B
Matrix multiplication is not commutative. A × B and B × A usually give different answers, and often one of them does not even exist. The number of columns in A must match the number of rows in B — this calculator checks and tells you exactly which dimensions clash.

What Is a Matrix?

A matrix is a rectangular array of numbers arranged in rows and columns. Its order is written rows × columns, so a 2×3 matrix has 2 rows and 3 columns. Each entry is identified by its position, written aij for the value in row i and column j.

Matrices store and transform data compactly. A system of linear equations, a rotation in 3D graphics, and the weights of a neural-network layer are all matrices, which is why linear algebra sits under so much of modern engineering and computing.

Matrix Calculator Formula Reference

addition: (A + B)ᵢⱼ = aᵢⱼ + bᵢⱼ — same order required
multiplication: (AB)ᵢⱼ = Σ aᵢₖ bₖⱼ — A columns must equal B rows
2×2 determinant: ad − bc
2×2 inverse: 1/det × [[d, −b], [−c, a]]
transpose: (Aᵀ)ᵢⱼ = aⱼᵢ

What the symbols mean. aij is the entry in row i, column j. The Σ in the multiplication rule means you run across a row of A and down a column of B, multiplying pairs and adding the results — which is why the inner dimensions must match.

How to Use the Matrix Calculator

Pick an operation, set the dimensions, then type your values. The B matrix appears only for operations that need it, and its dimensions adjust automatically where they are forced — for A + B both must match, and for A × B the rows of B follow the columns of A. Use Identity, Random or Zero to fill a matrix quickly, then press Calculate. Results include the row operations for RREF and inverse, so you can follow the method rather than just copy the answer.

Matrix Addition and Subtraction

Add or subtract matrices entry by entry. Both must have exactly the same order — a 2×3 cannot be added to a 3×2. For example, [[1,2],[3,4]] + [[5,6],[7,8]] = [[6,8],[10,12]].

Matrix Multiplication

To multiply A × B, take each row of A against each column of B: multiply corresponding entries and add. The number of columns in A must equal the number of rows in B, and the answer has A's rows and B's columns. So a 2×3 times a 3×2 gives a 2×2.

Worked example — 2×3 × 3×2

A = [[1,2,3],[4,5,6]] · B = [[7,8],[9,10],[11,12]]
Top-left entry: 1×7 + 2×9 + 3×11 = 7 + 18 + 33 = 58
Result: [[58,64],[139,154]]

Order matters. AB and BA are usually different, and swapping them can make the multiplication impossible.

Determinant

The determinant is a single number describing how a square matrix scales area or volume. A determinant of 2 doubles areas; a determinant of 0 collapses them flat, which is exactly why such a matrix has no inverse.

2×2 and 3×3

det[[1,2],[3,4]] = (1×4) − (2×3) = 4 − 6 = −2
det[[6,1,1],[4,−2,5],[2,8,7]] = −306

This calculator uses LU decomposition with partial pivoting rather than cofactor expansion. Cofactor expansion is fine on paper but becomes both slow and numerically unstable beyond about 4×4.

Inverse Matrix

The inverse A⁻¹ undoes what A does: A × A⁻¹ gives the identity matrix. Only square matrices with a non-zero determinant have one. A matrix with determinant 0 is called singular and cannot be inverted.

Worked example

A = [[4,7],[2,6]], det = 24 − 14 = 10
A⁻¹ = 1/10 × [[6,−7],[−2,4]]
= [[0.6,−0.7],[−0.2,0.4]]

Transpose, Rank and Trace

Transpose flips a matrix over its diagonal, turning rows into columns. A 2×3 becomes a 3×2.

Rank counts the independent rows — how much genuine information the matrix holds. A 3×3 matrix with rank 2 has one row that is a combination of the others, which means its determinant is 0.

Trace is the sum of the diagonal entries of a square matrix, and it equals the sum of the eigenvalues.

Gaussian Elimination and Row Echelon Form

Gaussian elimination uses three row operations — swapping rows, multiplying a row by a non-zero number, and adding a multiple of one row to another — to simplify a matrix without changing the solutions it represents.

Row echelon form (REF) has zeros below each leading entry, forming a staircase. Reduced row echelon form (RREF) goes further: every leading entry is 1 and is the only non-zero value in its column. RREF is unique for a given matrix, which makes it the standard way to solve systems and read off the rank. Gauss-Jordan elimination is the name for carrying elimination all the way to RREF.

Select RREF above and the calculator lists every row operation it performs, in order.

Eigenvalues and Eigenvectors

An eigenvector of a matrix is a direction that the matrix does not rotate — it only stretches or shrinks it. The amount of that stretch is the eigenvalue. Formally, Av = λv.

solve det(A − λI) = 0 for λ
2×2 shortcut: λ² − (trace)λ + (determinant) = 0

For [[4,1],[2,3]] the trace is 7 and the determinant is 10, so λ² − 7λ + 10 = 0, giving eigenvalues 5 and 2. This calculator computes exact eigenvalues for 2×2 matrices and reports when they are complex. Larger matrices need iterative numerical methods that are beyond a browser tool.

Eigenvalues matter because they reveal a matrix's behaviour: they drive principal component analysis in statistics, vibration modes in engineering, and stability analysis in control systems.

Special Matrices

TypeDefinitionExample
SquareSame number of rows and columns2×2, 3×3
Identity (I)1s on the diagonal, 0s elsewhere[[1,0],[0,1]]
ZeroEvery entry is 0[[0,0],[0,0]]
DiagonalNon-zero only on the diagonal[[3,0],[0,5]]
TriangularZeros above or below the diagonal[[1,2],[0,4]]
SymmetricEqual to its own transpose[[1,2],[2,3]]
SingularDeterminant is 0, so no inverse[[1,2],[2,4]]
Non-singularDeterminant is not 0, inverse exists[[1,2],[3,4]]

The identity matrix behaves like the number 1: multiplying by it changes nothing.

Automatic Matrix Type Detection

After every calculation the tool inspects the matrix and labels what it is. A matrix can carry more than one label at once — [[1,2],[2,4]] is both symmetric and singular, and the identity matrix is simultaneously diagonal, symmetric and orthogonal, though it is named simply as the identity.

BadgeWhat it meansExample
Identity matrix1s on the diagonal, 0s elsewhere[[1,0],[0,1]]
Zero matrixEvery entry is 0[[0,0],[0,0]]
Diagonal matrixNon-zero only on the diagonal[[3,0],[0,5]]
Scalar matrixDiagonal with every entry the same[[4,0],[0,4]]
Upper triangularAll zeros below the diagonal[[1,2],[0,4]]
Lower triangularAll zeros above the diagonal[[1,0],[3,4]]
SymmetricEqual to its own transpose[[1,2],[2,3]]
Skew-symmetricEqual to the negative of its transpose[[0,2],[−2,0]]
OrthogonalA × Aᵀ gives the identity; preserves lengths[[0,−1],[1,0]]
SingularDeterminant 0, so no inverse[[1,2],[2,4]]
InvertibleDeterminant is not 0[[1,2],[3,4]]

Reading the Colour Highlights

Results are colour-coded so the structure is visible rather than something you have to work out:

Matrix Decompositions

LU decomposition splits a matrix into a lower and an upper triangular matrix, which makes solving systems and finding determinants much faster. This calculator uses LU internally for its determinant.

QR decomposition splits a matrix into an orthogonal matrix Q and an upper triangular R. It underpins least-squares fitting and eigenvalue algorithms.

Common Mistakes

Watch out for these:
  • Assuming AB = BA. Matrix multiplication is not commutative. Order changes the answer.
  • Mismatched dimensions. For A × B, the columns of A must equal the rows of B.
  • Multiplying entry by entry. That is not matrix multiplication — you must combine rows with columns.
  • Trying to invert a non-square matrix. Only square matrices can have an inverse.
  • Forgetting to check the determinant. If it is 0 the matrix is singular and no inverse exists.
  • Dividing matrices. There is no division — multiply by the inverse instead.
  • Mixing up rows and columns. A 2×3 has 2 rows and 3 columns, in that order.
  • Trusting tiny non-zero values. Results like 0.0000000001 are floating-point noise; this calculator cleans them to 0.

Real-World Applications

AI and machine learning. A neural network layer is a matrix multiplication — inputs times weights. Training a large model is billions of these operations, which is exactly what GPUs are built to do in parallel.

Computer graphics. Every rotation, scale, translation and camera perspective is a 4×4 transformation matrix. Moving a 3D model means multiplying its vertices by matrices.

Engineering. Structural analysis solves large systems of equations as matrices, and finite element analysis is matrix algebra at scale.

Physics. Quantum mechanics represents states as vectors and observables as matrices, where eigenvalues are the measurable quantities.

Data science. Principal component analysis finds eigenvectors of a covariance matrix to reduce dimensions while keeping the most variation.

Cryptography and coding. Some ciphers and error-correcting codes are built on matrix operations in modular arithmetic.

Economics. Input-output models describe how industries feed into each other using large matrices.

Practice Questions

Beginner (with answers)

  1. Add [[1,2],[3,4]] and [[5,6],[7,8]].
  2. What is the determinant of [[3,1],[2,4]]?
  3. Transpose [[1,2,3],[4,5,6]].
  4. What is the trace of [[2,7],[1,5]]?
  5. What is the 3×3 identity matrix?
Show answers

1) [[6,8],[10,12]]   2) 10   3) [[1,4],[2,5],[3,6]]   4) 7   5) [[1,0,0],[0,1,0],[0,0,1]]

Advanced (with answers)

  1. Multiply [[1,2],[3,4]] by [[0,1],[1,0]].
  2. Find the inverse of [[4,7],[2,6]].
  3. What is the rank of [[1,2],[2,4]]?
  4. Find the eigenvalues of [[4,1],[2,3]].
  5. Why does [[1,2],[2,4]] have no inverse?
Show answers

1) [[2,1],[4,3]]   2) [[0.6,−0.7],[−0.2,0.4]]   3) 1   4) 5 and 2   5) Its determinant is 0, so it is singular

Did you know? The word "matrix" was coined in 1850 by James Joseph Sylvester, but the ideas are far older — Chinese mathematicians were solving systems of linear equations with array methods in the Nine Chapters on the Mathematical Art, around two thousand years ago.
Pro tip. Check the determinant before attempting an inverse. If it is 0 you can stop — the matrix is singular and no inverse exists.
Pro tip. Verify an inverse by multiplying: A × A⁻¹ should give the identity matrix exactly. If you see 0.9999999 or −0, the tool is not cleaning its floating-point results.

🔑 Key Takeaways

  • A matrix is a grid of numbers described as rows × columns
  • For A × B, the columns of A must equal the rows of B
  • Matrix multiplication is not commutative: AB ≠ BA
  • A determinant of 0 means singular — no inverse exists
  • RREF is unique and reveals the rank immediately

Frequently Asked Questions

What is a matrix?

A matrix is a rectangular array of numbers arranged in rows and columns. Its size is described as rows by columns, so a 2 by 3 matrix has two rows and three columns.

How do you multiply matrices?

Take each row of the first matrix against each column of the second, multiply the matching entries and add the results. The columns of the first matrix must equal the rows of the second.

How do you add matrices?

Add the entries in matching positions. Both matrices must have exactly the same number of rows and columns, otherwise addition is not defined.

How do you find the determinant?

For a 2 by 2 matrix the determinant is ad minus bc. For larger matrices you can expand by cofactors or, more efficiently, reduce the matrix to triangular form and multiply the diagonal entries.

How do you find the inverse of a matrix?

Attach an identity matrix alongside the original and apply row operations until the original becomes the identity. Whatever the attached half becomes is the inverse. A matrix only has an inverse if it is square and its determinant is not zero.

What is a singular matrix?

A singular matrix has a determinant of zero, which means it has no inverse. Geometrically it collapses space onto a lower dimension, so the transformation cannot be undone.

When is a matrix invertible?

A matrix is invertible when it is square and its determinant is not zero. Equivalently, its rank equals its size and its rows are linearly independent.

What is matrix transpose?

The transpose flips a matrix over its main diagonal, so rows become columns and columns become rows. A 2 by 3 matrix becomes a 3 by 2 matrix.

What is matrix rank?

Rank is the number of linearly independent rows, which is the amount of genuine information a matrix carries. You can find it by reducing the matrix to row echelon form and counting the non-zero rows.

What is the trace of a matrix?

The trace is the sum of the entries on the main diagonal of a square matrix. It also equals the sum of the eigenvalues.

What is Gaussian elimination?

Gaussian elimination simplifies a matrix using three row operations: swapping two rows, multiplying a row by a non-zero number, and adding a multiple of one row to another. It is the standard method for solving systems of linear equations.

What is the difference between row echelon form and reduced row echelon form?

Row echelon form has zeros below each leading entry. Reduced row echelon form goes further, making every leading entry a 1 and the only non-zero value in its column. Reduced row echelon form is unique for a given matrix.

What is Gauss-Jordan elimination?

Gauss-Jordan elimination is Gaussian elimination carried all the way to reduced row echelon form. It is commonly used to find inverses and to solve systems completely.

What is an identity matrix?

An identity matrix has ones along the main diagonal and zeros everywhere else. Multiplying any matrix by a matching identity matrix leaves it unchanged, just as multiplying a number by one does.

What are eigenvalues?

An eigenvalue is the factor by which a matrix stretches or shrinks a particular direction. You find them by solving the equation determinant of A minus lambda times I equals zero.

What are eigenvectors?

An eigenvector is a direction that a matrix does not rotate, only scales. The scaling factor for that direction is its eigenvalue, and together they satisfy A times v equals lambda times v.

Can you divide matrices?

There is no matrix division. Instead of dividing by a matrix you multiply by its inverse, which is only possible when the inverse exists.

Why is AB not the same as BA?

Matrix multiplication combines rows with columns, so changing the order changes which values are paired. In many cases BA is not even defined, because the dimensions no longer line up.

How do engineers use matrices?

Engineers use matrices to solve large systems of equations in structural analysis, finite element modelling, control systems and circuit analysis, where many quantities depend on one another at once.

How do AI models use matrices?

Each layer of a neural network multiplies its inputs by a matrix of weights. Training a large model performs billions of these multiplications, which is why graphics processors, designed for parallel matrix work, are used for AI.

How do graphics engines use matrices?

Every rotation, scaling, translation and camera perspective in 3D graphics is represented as a 4 by 4 transformation matrix. Moving an object means multiplying its coordinates by these matrices.

Is this Matrix Calculator free?

Yes. It is free with no sign-up, works on any device, and runs entirely in your browser so your data stays private.

References

Last updated: July 2026
Reviewed by Mohsin Iqbal using standard linear algebra methods and trusted academic references. Determinants use LU decomposition with partial pivoting, and inverses use Gauss-Jordan elimination, both chosen for numerical stability. Results are cleaned to twelve significant figures so floating-point artefacts such as −0 and 0.0000000001 do not appear. Eigenvalues are computed exactly for 2×2 matrices only. This page is for educational purposes.