Matrix Calculator

Add, subtract, multiply, swap, transpose, invert, raise to a power, or scalar-multiply matrices up to 6×6 in an editable grid (10×10 via text), with rank, trace and determinant shown alongside every result.

How to use this calculator

  1. 1Choose an operation. Some read one matrix (transpose, determinant, inverse, a power, or a scalar multiple); others combine both.
  2. 2Set the size and fill the grid, or switch to text entry and paste rows separated by commas or spaces — useful past 6×6, up to 10×10.
  3. 3Every result shows the grid, a copyable text block, and its rank, trace and determinant where they apply.

How the calculation works

Determinant: Laplace/cofactor expansion (computed here via Gaussian elimination for speed). Inverse: A⁻¹ via Gauss-Jordan elimination on [A | I]. Power: Aⁿ = A × A × … (n times); A⁻ⁿ = (A⁻¹)ⁿ
A, B
Matrices, entered in the grid or pasted as rows of numbers
Aᵀ
Transpose — A with rows and columns swapped
A⁻¹
Inverse — the matrix such that A × A⁻¹ = the identity matrix
k
A scalar — an ordinary number multiplying every element

A matrix is a rectangular grid of numbers, and the operations here are the standard rules of linear algebra applied to that grid. They show up anywhere a system tracks several related quantities at once: transforming coordinates in computer graphics, solving simultaneous equations, encoding a graph's connections, or running the regressions behind a lot of statistics and machine learning.

The determinant is conceptually defined by cofactor expansion, but that method takes factorially longer as size grows — this calculator uses Gaussian elimination instead (reducing to an upper-triangular form and multiplying the diagonal), which gives the identical result far faster and more stably for larger matrices.

A matrix has an inverse only if it is square and its determinant is non-zero. Rank is computed the same way, by row-reducing and counting the non-zero pivot rows that survive.

Trace (the sum of the diagonal) and rank are shown alongside every square result as a quick sanity check, even for operations that are not primarily about either.

Worked example

A + B where A = [[1,2],[3,4]] and B = [[5,6],[7,8]]

  1. 1.Addition works element by element: each entry of the result is the sum of the matching entries in A and B.
  2. 2.[1+5, 2+6; 3+7, 4+8] = [6, 8; 10, 12].

Result: [[6, 8], [10, 12]]

A − B where A = [[1,2],[3,4]] and B = [[5,6],[7,8]]

  1. 1.Subtraction also works element by element, in A-minus-B order.
  2. 2.[1−5, 2−6; 3−7, 4−8] = [−4, −4; −4, −4].

Result: [[−4, −4], [−4, −4]]

A × B where A = [[1,2],[3,4]] and B = [[5,6],[7,8]]

  1. 1.Each entry of A × B is a row of A combined with a column of B: entry (i, j) is the dot product of row i of A and column j of B.
  2. 2.Top-left: (1×5 + 2×7) = 19. Top-right: (1×6 + 2×8) = 22. Bottom-left: (3×5 + 4×7) = 43. Bottom-right: (3×6 + 4×8) = 50.

Result: [[19, 22], [43, 50]]

B × A — the same two matrices, multiplied in the other order

  1. 1.Same rule, but now rows of B combine with columns of A: (5×1 + 6×3) = 23, (5×2 + 6×4) = 34, (7×1 + 8×3) = 31, (7×2 + 8×4) = 46.
  2. 2.B × A = [[23, 34], [31, 46]] — compare this to A × B = [[19, 22], [43, 50]] above. Same two matrices, different order, different answer.

Result: [[23, 34], [31, 46]]

3 × A where A = [[1,2],[3,4]]

  1. 1.Every entry is multiplied by the scalar: 3×1, 3×2, 3×3, 3×4.

Result: [[3, 6], [9, 12]]

A³ where A = [[1,2],[3,4]]

  1. 1.A² = A × A = [[7, 10], [15, 22]].
  2. 2.A³ = A² × A = [[37, 54], [81, 118]].

Result: [[37, 54], [81, 118]]

Aᵀ where A = [[1,2,3],[4,5,6]] (2×3)

  1. 1.Transposing swaps rows and columns: element (i, j) of A becomes element (j, i) of Aᵀ, so a 2×3 matrix becomes 3×2.
  2. 2.Row 1 of A, [1, 2, 3], becomes column 1 of Aᵀ. Row 2, [4, 5, 6], becomes column 2.

Result: [[1, 4], [2, 5], [3, 6]]

Determinant of [[1,2],[3,4]]

  1. 1.For a 2×2 matrix [[a,b],[c,d]], the determinant is simply a×d − b×c.
  2. 2.1×4 − 2×3 = 4 − 6 = −2.

Result: −2

Determinant of [[1,2,3],[4,5,6],[7,8,10]]

  1. 1.Expanding along the first row: 1×(5×10 − 6×8) − 2×(4×10 − 6×7) + 3×(4×8 − 5×7).
  2. 2.= 1×(50−48) − 2×(40−42) + 3×(32−35) = 1×2 − 2×(−2) + 3×(−3) = 2 + 4 − 9 = −3.

Result: −3

A⁻¹ where A = [[1,2],[3,4]]

  1. 1.First, the determinant: 1×4 − 2×3 = −2. Non-zero, so A is invertible.
  2. 2.For a 2×2 [[a,b],[c,d]], A⁻¹ = (1/det) × [[d,−b],[−c,a]] = (1/−2) × [[4,−2],[−3,1]] = [[−2, 1], [1.5, −0.5]].
  3. 3.Check: A × A⁻¹ = [[1×−2+2×1.5, 1×1+2×−0.5], [3×−2+4×1.5, 3×1+4×−0.5]] = [[1, 0], [0, 1]] — the identity matrix, as expected.

Result: [[−2, 1], [1.5, −0.5]]

What a matrix is, beyond a grid of numbers

A matrix is a rectangular array of numbers, but what makes it useful is what it can represent: a system of equations, a set of coordinates, a transformation like a rotation or a scaling, or a table of relationships between many things at once — trade flows between countries, connections between people in a network, pixel colours in an image. Once information like that is written as a matrix, the row-and-column operations this calculator performs — addition, multiplication, inversion and the rest — become ways of manipulating the underlying system directly, rather than working through it equation by equation.

Multiplication that doesn't commute

The single habit hardest to unlearn when moving from ordinary arithmetic to matrix arithmetic is that order matters: A × B is generally not the same as B × A, and often is not even the same size. This is not a quirk of notation — it reflects that matrix multiplication represents applying one transformation after another, and rotating a shape and then stretching it can leave it in a genuinely different place than stretching it first and then rotating it. Keeping A and B in the order a problem gives them is essential, which is why this calculator offers both A × B and B × A as separate operations rather than assuming they are interchangeable.

Where matrices do real work

Matrices are the standard language for systems with many interacting parts, which is why they show up across such different fields.

  • Computer graphicsevery rotation, scaling, reflection and 3D-to-2D projection applied to a game character or an animated scene is carried out by multiplying its coordinates by a transformation matrix.
  • Economicsinput-output models represent how much output from one industry feeds into another as a matrix, so that solving a linear system predicts how a change in one sector ripples through an entire economy.
  • Engineeringstructural analysis represents the forces and deflections across a bridge or a building frame as a large system of linear equations, solved using matrix methods, alongside circuit analysis and control systems.
  • Data and machine learninga dataset is naturally a matrix — rows of observations, columns of features — and the weights inside a neural network are literally matrices multiplied against the data at every layer.
  • Graph theorythe connections in a network, from road maps to social networks, can be encoded as an adjacency matrix, turning questions about paths and connectivity into matrix arithmetic.

Common mistakes with matrix operations

The most frequent error is trying to add or multiply matrices whose dimensions do not line up: addition requires identical dimensions on both matrices, while multiplying A by B requires the number of columns in A to match the number of rows in B — there is no such thing as close enough. A close second is assuming every matrix has an inverse the way every non-zero number does; only square matrices with a non-zero determinant qualify, and a zero determinant means the matrix collapses space into a lower dimension in a way that cannot be undone.

A relatively young branch of mathematics

Compared to arithmetic or geometry, matrix theory is a recent development. Individual systems of linear equations had been solved for centuries, but matrices were formalised as objects in their own right — with their own rules for addition, multiplication and inversion — largely through the work of mathematician Arthur Cayley in the mid-1800s. That relatively late arrival is part of why matrix notation can feel like a different kind of mathematics from the arithmetic learned earlier: it was built specifically to handle many numbers behaving as one coherent unit, which is precisely the problem grids of interconnected data still present today.

What this assumes, and where it stops

Assumptions

  • Every row of a matrix has the same number of columns, as a matrix requires.

Limitations

  • The grid supports up to 6×6; text entry goes to 10×10 before input and display stop being manageable — larger matrices need dedicated linear algebra software.

Common questions

Why does A × B not equal B × A?

Matrix multiplication combines rows of A with columns of B in a specific order, so swapping the order generally changes which numbers get combined — and often even changes the resulting matrix's dimensions. This is one of the most common trip-ups moving from ordinary number arithmetic to matrix arithmetic. Use "B × A" directly to compare the two without re-entering anything.

What does a zero determinant mean?

It means the matrix is singular — it squashes space into a lower dimension (for example, a 2D transformation that flattens everything onto a line), which is not reversible. A singular matrix has no inverse, and its rows (or columns) are linearly dependent on each other. Its rank will also be less than its size.

What does raising a matrix to a power mean?

Repeated multiplication by itself: A³ is A × A × A, computed left to right. A negative power inverts the matrix first, so A⁻² is (A⁻¹) × (A⁻¹) — which only exists when A is square and invertible. Any square matrix to the power 0 gives the identity matrix, the matrix equivalent of the number 1.

Formula and content last reviewed on .

Results are estimates for information only, not professional advice.

Report an error

Tools people commonly use alongside the matrix calculator.

See all math calculators →