📐 Math & Science

Matrix Calculator

Enter matrices A and B, then pick an operation.

  • 3sizes: 2×2, 3×3, 4×4
  • 7operations
  • 1/1000fractions shown up to this denominator
  • 0sign-ups

Matrix A

Matrix B

—

How to use the Matrix Calculator

  1. 1

    Choose a size

    All matrices are square: 2 × 2, 3 × 3 or 4 × 4.

  2. 2

    Fill in A and B

    Each cell takes a number; blank or invalid cells count as 0.

  3. 3

    Pick an operation

    A + B, A − B, A × B, det(A), A⁻¹, Aᵀ or A².

  4. 4

    Read the result

    The answer grid shows simple fractions where possible, otherwise decimals to six places.

Features

Determinant

Computed by row reduction with partial pivoting, then shown as a fraction or decimal.

Inverse

Gauss–Jordan elimination; a zero determinant gives a clear “no inverse” message.

Multiplication

Row-by-column products, plus a one-click A² for powers.

Transpose

Swaps rows and columns of A.

Fraction output

Results like 0.6 appear as 3/5, matching textbook answers.

Live updates

Change any cell and the last operation reruns immediately.

Who uses it — and for what

Students

Check determinant and inverse questions in Class 12, A-level and first-year linear algebra.

Graphics programmers

Test rotation and scaling matrices.

Data and ML learners

Experiment with matrix products used in neural networks.

Engineers

Verify small stiffness or circuit matrices by hand.

Matrix operations

Matrices of the same size are added and subtracted element by element. Multiplication A × B takes the dot product of each row of A with each column of B — so A × B usually differs from B × A. The transpose Aᵀ swaps rows and columns. The determinant is a single number: for a 2×2 matrix [[a, b], [c, d]] it’s ad − bc; larger ones are computed by row reduction. A matrix has an inverse only when its determinant is non-zero, and A × A⁻¹ = I, the identity matrix.

Where matrices are used

Matrices solve systems of linear equations, rotate and scale images and 3D graphics, encode transitions in Markov chains and power the neural networks behind modern AI. The calculator uses Gaussian elimination with partial pivoting for determinants and inverses and rounds tiny floating-point errors, showing simple fractions where possible. For solving equations directly, try the System of Equations Solver.

Every result is calculated in your browser the moment you type, so you can change a number and see the effect instantly — ideal for checking homework, worksheets and exam practice. Results are shown to a sensible number of decimal places; very large or tiny values switch to scientific notation.

Step-by-step: inverting a 2×2 matrix by hand

Find the inverse of C = [[4, 7], [2, 6]].

  1. Determinant: ad − bc = 4 × 6 − 7 × 2 = 24 − 14 = 10. It is not zero, so an inverse exists.
  2. Swap the diagonal entries a and d: [[6, 7], [2, 4]].
  3. Change the signs of the off-diagonal entries: [[6, −7], [−2, 4]].
  4. Divide every entry by the determinant: [[6/10, −7/10], [−2/10, 4/10]] = [[3/5, −7/10], [−1/5, 2/5]].

The calculator shows exactly that grid. Check by multiplying: C × C⁻¹ should give the identity [[1, 0], [0, 1]] — type the inverse into B as decimals (0.6, −0.7, −0.2, 0.4) and press A × B.

Determinant of a 3×3 by cofactors

For the default 3×3 A = [[2, 1, 0], [1, 3, 1], [0, 1, 4]], expand along the first row: 2 × (3 × 4 − 1 × 1) − 1 × (1 × 4 − 1 × 0) + 0 = 2 × 11 − 4 = 18. The calculator agrees (det = 18). Remember the alternating signs + − + across the row — dropping the minus sign on the middle term is the most common error.

Mistakes students make

  • Multiplying entry by entry. Matrix multiplication is rows times columns, not cell times cell. The top-left entry of A × B is (row 1 of A) · (column 1 of B).
  • Assuming A × B = B × A. It is usually false, as the example above shows. This is also why (AB)⁻¹ = B⁻¹A⁻¹, with the order reversed.
  • Dividing by a matrix. There is no division; to “undo” A, multiply by A⁻¹ on the correct side.
  • Inverting a singular matrix. If det = 0, no inverse exists. Rows that are multiples or combinations of each other are the giveaway.
  • Expecting operations on B. det, inverse, transpose and square act on A only. To get det(B), copy B into A.

A note on decimals: the tool works in floating point and converts results to fractions with denominators up to 1,000 when they match to nine decimal places. Results with larger denominators, or irrational values, appear as decimals.

Matrices in the real world

A 2×2 matrix can rotate a point: [[0, −1], [1, 0]] turns (3, 4) into (−4, 3), a quarter-turn, and squaring it gives [[−1, 0], [0, −1]], a half-turn. Every 3D game does this with 4×4 matrices dozens of times per frame. Economists use input–output matrices, Google’s original PageRank was an eigenvector of a huge link matrix, and every layer of a neural network is a matrix multiplication. When the goal is simply to solve linear equations, the System of Equations Solver is more direct, and the Vector Calculator handles dot and cross products.

Worked examples

The default 2×2: inverse as fractions

A = [[2, 1], [1, 3]]. det(A) = 2 × 3 − 1 × 1 = 5, and A⁻¹ = [[3/5, −1/5], [−1/5, 2/5]]. (The default B in 2×2 mode is the identity matrix, so A × B returns A unchanged.)

Order matters in multiplication

X = [[3, 1], [2, 4]] and Y = [[1, 2], [0, 1]]. X × Y = [[3, 7], [2, 8]] but Y × X = [[7, 9], [2, 4]]. Put X in A and Y in B, then swap them to see it.

A singular 3×3

[[1, 2, 3], [4, 5, 6], [7, 8, 9]] has det = 0 — its third row equals twice the second minus the first — so A⁻¹ reports “A has no inverse”. Change the last entry to 10 and det becomes −3, with inverse [[−2/3, −4/3, 1], [−2/3, 11/3, −2], [1, −2, 1]].

Pro tips

  • To check an inverse, type it into B (as decimals) and multiply A × B — you should get the identity matrix.
  • det(Aᵀ) always equals det(A), a quick consistency check.
  • Swapping two rows changes the sign of the determinant; multiplying a row by k multiplies it by k.

Glossary

Identity matrix
A square matrix with 1s on the main diagonal and 0s elsewhere; multiplying by it changes nothing.
Singular matrix
A square matrix with determinant 0, which has no inverse.
Transpose
The matrix formed by turning rows into columns.
Partial pivoting
Swapping rows during elimination so the largest available number is used as the divisor, reducing rounding errors.

Frequently asked questions

Why can’t my matrix be inverted?

Its determinant is zero (it is singular).

Is A × B the same as B × A?

Generally no — matrix multiplication isn’t commutative.

What sizes are supported?

Square matrices from 2×2 to 4×4.

Can I multiply a 2×3 by a 3×2 matrix?

Not here — this calculator only handles square matrices of the same size (2×2, 3×3 or 4×4).

Why does a very small determinant show as 0?

If a pivot during elimination is smaller than 10⁻¹², the matrix is treated as singular to avoid dividing by what is almost certainly rounding noise.

Can I type fractions like 1/2 in a cell?

No, cells are number inputs. Type 0.5; results that are simple fractions are still displayed as fractions.

Found it useful? Share the Matrix Calculator:

Last updated 2026-11-28 · Built by Vinayak Agarwal · Part of Math & Science (42 tools)