Matrix Calculator

Perform matrix operations including addition, subtraction, multiplication, transpose, determinant, inverse, and adjoint. Supports 2x2 to 5x5 matrices with step-by-step solutions. All calculations happen locally — nothing leaves your browser.

Matrix Calculator
Ready
2×2 · 2 matrices
Matrix Size
Operation
Matrix A
+
Matrix B

What is a matrix? A matrix is a rectangular array of numbers arranged in rows and columns, written m × n for m rows and n columns. It encodes a linear transformation, so matrix multiplication composes two transformations rather than multiplying elements pairwise: each entry of the product is the dot product of a row of A with a column of B. The determinant of a square matrix says how that transformation scales area or volume, and a determinant of zero means it cannot be undone.

How to Use the Matrix Calculator

  1. Set the matrix size — Pick 2×2 up to 5×5. The calculator works with square matrices, which is what determinant, inverse and adjoint require; changing the size rebuilds the input grids and clears them.
  2. Choose the operation — Add, subtract, multiply, scalar multiply, transpose, determinant, inverse or adjoint. Single-matrix operations hide the Matrix B grid, and scalar multiply reveals a box for the multiplier.
  3. Fill in the values — Type a number into each cell of Matrix A, and Matrix B as well for the two-matrix operations. Use the I button to fill A with the identity matrix and Swap to exchange A and B — useful because A × B and B × A are usually different.
  4. Press Calculate — The result grid appears below, with the determinant shown separately in its own panel when you ask for one. An error message explains any operation that is undefined for the values you entered.
  5. Read the step-by-step working — The steps panel shows the intermediate arithmetic — the dot products behind each entry of a product, or the cofactor expansion behind a determinant — so you can check a hand calculation line by line.
  6. Copy or clearCopy Result puts the answer on your clipboard in plain rows and columns; Clear All resets both matrices to zero for the next problem.

How Matrix Operations Work

A matrix is a rectangular array of numbers written m × n, meaning m rows by n columns, with aij naming the entry in row i and column j. What makes matrices more than a grid of numbers is that each one represents a linear transformation: multiply a vector by the matrix and it gets rotated, scaled, sheared or projected. Almost every rule below follows from that reading.

Addition and subtraction act element by element, so both matrices must have identical dimensions. Scalar multiplication multiplies every entry by one number, stretching the whole transformation uniformly. Transposition reflects the matrix across its main diagonal, sending aij to aji.

Multiplication is the operation that surprises people, because it is not element-by-element. Each entry of the product is a dot product — row i of A against column j of B:

(AB)ij = Σk aik × bkj

That is why the columns of A must match the rows of B, and why matrix multiplication is not commutative: AB and BA describe applying two transformations in opposite orders, which generally lands somewhere different. It is, however, associative, so (AB)C and A(BC) always agree.

The determinant is a single number that measures how much the transformation scales area in two dimensions or volume in three, with a negative sign meaning orientation is flipped. For a 2×2 matrix it is a direct cross-multiplication:

det = a11a22 − a12a21

Larger matrices are handled by cofactor expansion: pick a row, and for each entry multiply it by the determinant of the smaller matrix left after deleting that entry's row and column, alternating signs as you go. That is exactly what this calculator does, recursing down to the 2×2 case, and it is the working shown in the steps panel.

The inverse A−1 is the matrix that undoes A, satisfying A × A−1 = I. It is computed from the adjoint — the transpose of the cofactor matrix — divided by the determinant:

A−1 = adj(A) ÷ det(A)

The division makes the failure case obvious. When the determinant is zero the transformation has collapsed space onto a line or a plane, information has been destroyed, and no inverse exists. Such a matrix is called singular.

Operation Requirements and Results

OperationRequirementResult
Add / SubtractBoth matrices the same sizeSame size as the inputs
MultiplyColumns of A = rows of BRows of A × columns of B
Scalar multiplyAny matrix and one numberSame size as the input
TransposeAny matrixn × m from an m × n input
DeterminantSquare matrixA single number
AdjointSquare matrixSame size as the input
InverseSquare, determinant not zeroSame size as the input

Notation You Will See

  • Dimensions — always rows first: a 3×2 matrix has 3 rows and 2 columns.
  • Square matrix — rows equal columns. Determinant, inverse, adjoint and eigenvalues are only defined for square matrices.
  • Identity matrix I — ones on the main diagonal, zeros elsewhere. It is the do-nothing transformation, so A × I = A for any compatible A.
  • Singular matrix — determinant zero, therefore no inverse.
  • Eigenvalues — the scalars λ for which A v = λ v holds for some non-zero vector v. They identify the directions the transformation only stretches, without rotating.

Examples

2×2 Matrix Addition

A = | 1 2 | B = | 5 6 |
     | 3 4 |       | 7 8 |

A + B = | 1+5 2+6 | = | 6 8 |
         | 3+7 4+8 |   | 10 12 |

2×2 Matrix Multiplication

A × B = | (1×5 + 2×7) (1×6 + 2×8) | = | 19 22 |
          | (3×5 + 4×7) (3×6 + 4×8) |   | 43 50 |

2×2 Determinant

det(| 1 2 |) = (1 × 4) − (2 × 3) = 4 − 6 = −2
     | 3 4 |

Since the determinant is non-zero (−2), this matrix has an inverse.

Frequently Asked Questions

For matrix multiplication A × B, the number of columns in A must equal the number of rows in B. For square matrices of the same size, multiplication is always defined but is generally not commutative (A × B ≠ B × A).

A matrix is not invertible (singular) when its determinant is zero. This means the matrix maps space to a lower dimension and cannot be reversed.

Eigenvalues are scalars λ such that Av = λv for some non-zero vector v (the eigenvector). They reveal important properties about the matrix's behavior, such as scaling factors along principal axes. This calculator reports them for 2×2 and 3×3 matrices, where the characteristic polynomial is small enough to solve directly.

Because each matrix is a transformation and order of application matters. Rotating then stretching does not land in the same place as stretching then rotating. Concretely, take A = [[1,1],[0,1]] and B = [[1,0],[1,1]]: AB gives [[2,1],[1,1]] while BA gives [[1,1],[1,2]]. Matrix multiplication is associative and distributive, but never assume it is commutative — use the Swap button to see both products.

The arithmetic uses standard double-precision floating point, so results carry roughly 15 significant digits and a value that should be a clean integer can display as 2.9999999999999996. Inverses of nearly singular matrices are the worst case: a determinant close to zero amplifies rounding error, so treat an inverse as unreliable when the determinant is very small relative to the size of the entries.

No. Every operation runs in JavaScript in your browser, so the numbers you type stay on your device and nothing is logged or transmitted. The page continues to work offline once it has loaded.

The most common causes are asking for an inverse of a singular matrix (determinant zero, or close enough to zero that it is treated as singular) and leaving cells empty so they read as blanks. Check the determinant first: if it is zero, the inverse and the adjoint-based operations genuinely do not exist and no tool can produce one.

Yes, for a square system. Write the system as Ax = b, invert the coefficient matrix A here, and multiply the inverse by the column of constants to get x. It is a clean method for small systems, though for larger or ill-conditioned ones, Gaussian elimination is numerically safer than forming the inverse explicitly.

Use Cases

Checking Linear Algebra Homework

A student who has multiplied two 3×3 matrices by hand compares each entry against the dot products listed in the steps panel to find where the arithmetic slipped.

Testing Whether a System Has a Solution

Before solving Ax = b, an engineer takes the determinant of the coefficient matrix: zero means the equations are dependent and no unique solution exists.

Solving a Small Circuit or Mixture Problem

Three unknowns and three equations become a 3×3 matrix; inverting it and multiplying by the constants gives the currents or concentrations in one step.

Verifying an Inverse Really Works

Compute A−1, then multiply it back by A: anything other than the identity matrix means the original entries were mistyped or the matrix is near-singular.

Composing 2D Graphics Transforms

A developer multiplies a rotation matrix by a scale matrix to get the single combined transform a canvas or shader needs, and checks the determinant for an accidental flip.