A matrix is a rectangular block of numbers that represents a linear transformation or a system of relationships. Nearly everything computational — graphics, statistics, machine learning, structural engineering — is matrix arithmetic underneath. This matrix calculator performs the five operations that make up the bulk of a first linear algebra course: addition, subtraction, matrix multiplication, scalar multiplication and transposition, on matrices up to four rows by four columns, with the arithmetic behind each entry written out.
Arb Digital added this page because the working is the part that gets skipped. A calculator that returns a 3×3 product and nothing else is no use when your hand answer disagrees with it, because you cannot see which entry went wrong. This one lists the dot products that produced each entry of the result, so you can find the error rather than just being told there is one.
What This Matrix Calculator Does
It reads two matrices typed as plain rows of numbers, checks that the shapes are compatible with the operation you selected, and returns the result together with its dimensions, trace, total and largest entry. For a product it also shows the row-by-column expansion for each entry — the sum of products that most textbooks make you write out by hand. When shapes do not match, it explains which rule was broken instead of returning an empty grid.
Inversion is deliberately not here: a square matrix is inverted by row reduction rather than by any of these five operations, so that job lives on our matrix inverse calculator, which shows the Gauss-Jordan steps and reports singularity in plain English. Likewise the single number that tells you whether an inverse exists at all comes from our determinant calculator.
How to Use It
- Pick the operation first. The shape rules differ, and the calculator validates against whichever one you chose.
- Type each matrix one row per line. Spaces, commas or tabs all work as separators, and every row must have the same number of entries.
- Set the scalar if you need it. It only applies to the k × A option; the other operations ignore it.
- Read the working panel under the grid. For products it lists the sum of products for each entry, which is where hand-calculation errors nearly always hide.
- Check the dimensions of the result. An m×n times n×p product is m×p, and if that is not the shape you expected, the operands are probably the wrong way round.
The Rules and How It's Calculated
Addition and subtraction are element by element: the entry in row i, column j of A + B is simply aᵢⱼ + bᵢⱼ. Both matrices must have exactly the same shape, and there is no way to add a 2×3 to a 3×2. Scalar multiplication multiplies every entry by k. The transpose reflects the matrix across its main diagonal, so the entry at row i, column j moves to row j, column i, and an m×n matrix becomes n×m.
Multiplication is the operation with the rule people forget. The entry at row i, column j of A × B is the dot product of row i of A with column j of B: cᵢⱼ = Σₖ aᵢₖ · bₖⱼ. That only makes sense when the number of columns in A equals the number of rows in B, and the result has as many rows as A and as many columns as B.
Work through the defaults. Row 1 of A is (2, 1, 0) and column 1 of B is (1, 0, 3), so the first entry is 2×1 + 1×0 + 0×3 = 2. Row 1 against column 2 gives 2×0 + 1×1 + 0×2 = 1, and against column 3 gives 2×2 + 1×1 + 0×0 = 5. Continuing through the remaining rows gives the product 2 1 5 / 7 7 5 / 12 9 1. Its trace is 2 + 7 + 1 = 10 and its entries total 49. The MIT OpenCourseWare 18.06 Linear Algebra course works through the same product in four different ways in its opening lectures, which is worth an hour if the row-times-column view has never quite clicked.
Why AB and BA Are Different Matrices
Matrix multiplication is associative and distributive but not commutative, and this is not a technicality. Interpret each matrix as a transformation of space: one might rotate, another might stretch along an axis. Rotating and then stretching produces a different final shape from stretching and then rotating. The matrices record that ordering, so the product records it too.
With the default matrices, A × B has first row 2 1 5, while B × A has first row 2 3 8. Same numbers, different products. With non-square matrices the asymmetry is even starker: a 2×3 times a 3×2 gives a 2×2, while the reverse order gives a 3×3. The habit that prevents most errors is to write the dimensions under the operands before multiplying and check that the inner pair match.
What Multiplication Is Actually Doing
The mechanical definition hides the useful idea. If you treat a matrix as a function that takes vectors to vectors, then the product AB is the composition of the two functions: apply B first, then A. That ordering — right to left, like nested function notation — is why AB reads naturally as "A of B of x" and why the columns of B must live in the space A expects as input.
This reading explains several rules that look arbitrary otherwise. The identity matrix is the transformation that changes nothing, so multiplying by it returns the original. A matrix with a column of zeros collapses one direction of space to a point, which is exactly what makes it non-invertible: information has been destroyed, and no second transformation can restore it. The same view is developed carefully in the Matrix Algebra for Engineers lecture notes, which cover addition, multiplication, transpose and inverse in that order.
The Transpose Is More Than a Rotation
Transposing looks like a formatting operation and is treated as one by most people meeting it. Two facts make it substantive. First, it reverses the order of a product: (AB)ᵀ equals BᵀAᵀ, not AᵀBᵀ, which surprises almost everyone the first time and is a frequent source of dropped marks. Second, AᵀA is always square and symmetric whatever shape A was, which is why that particular combination appears in the normal equations behind least squares fitting.
A matrix equal to its own transpose is symmetric, and symmetry is what guarantees real eigenvalues — the connection our eigenvalue calculator relies on. Covariance and correlation matrices are symmetric by construction, which is why statistical software can use faster algorithms on them than on general matrices.
Matrices as Systems of Equations
Any linear system can be written Ax = b, with the coefficients in A, the unknowns stacked in x and the right-hand sides in b. That compression is the reason matrices exist. Three equations in three unknowns become one matrix equation, and everything you might want to know about the system — whether it has a solution, one solution, or infinitely many — becomes a question about A alone.
Multiplying a candidate solution back through A is also the fastest way to check an answer. Type A into this calculator, put your solution vector in as a single-column matrix B, multiply, and compare against the original right-hand side. If it matches, the solution is right regardless of how you found it. To solve the system in the first place rather than verify it, our system of equations calculator is the direct route.
Reading Errors Before They Reach the Answer
Three checks catch most mistakes without redoing the arithmetic. Compare dimensions first: if the result is not the shape you predicted, the operands or the operation are wrong and no amount of recomputation will fix it. Second, check one entry independently — recompute a single dot product by hand and compare. Third, use the trace: for square matrices the trace of A + B equals the trace of A plus the trace of B, so a mismatch localises the error to the addition.
Sign errors deserve special mention because they survive every one of those checks except the last. When subtracting, it is the entries of B that all change sign, not just the first one, and a single missed negative propagates through any later multiplication into every entry it touches. If you are working with vectors rather than full matrices, our vector calculator handles dot and cross products with the same working shown.
Arb Digital's analysts build attribution and forecasting models on the same linear algebra this page runs on, and explain the output in plain English.
Browse All Free Tools Talk To Our TeamCommon Mistakes to Avoid
- Multiplying element by element — that is not matrix multiplication; every entry of a product is a whole sum of products across a row and a column.
- Assuming AB equals BA — order changes the answer and sometimes the shape, so the operands are never interchangeable.
- Ignoring the inner dimension rule — the columns of A must equal the rows of B, and the product is undefined otherwise no matter how convenient it would be.
- Transposing a product term by term — (AB)ᵀ is BᵀAᵀ, with the order reversed, and this trips up more people than any other identity here.
- Typing ragged rows — every line must have the same number of entries, and a stray extra number silently changes the shape of the matrix you meant to enter.
Related Free Tools From Arb Digital
Test whether a square matrix can be inverted at all with the determinant calculator, find characteristic roots with the eigenvalue calculator, handle magnitudes and angles with the vector calculator, or run a quick side calculation with the scientific calculator. The full free online tools hub lists every mathematics tool we publish.
Frequently Asked Questions
Anything up to four rows by four columns, and the two matrices do not have to be the same shape as long as the operation you chose allows it. Rows are read one per line.
Matrix multiplication requires the number of columns in the first matrix to equal the number of rows in the second. If those inner dimensions differ, the product is undefined and swapping the order may fix it.
No. A × B and B × A are generally different matrices, and with non-square operands they can even have different shapes. Order always matters.
It reflects the matrix across its main diagonal, turning rows into columns. An m by n matrix becomes n by m, and transposing twice returns the original.
The trace is the sum of the entries on the main diagonal of a square matrix. It is a quick error check, because the trace of a sum equals the sum of the traces, and it also equals the sum of the eigenvalues.
No. Addition and subtraction work entry by entry, so both matrices must have identical dimensions. There is no meaningful way to add a 2 by 3 to a 3 by 2.
No, those are separate jobs with their own pages. This tool covers addition, subtraction, multiplication, scalar multiplication and transposition only.
This page explains a mathematical method for study and for checking your own working. It is not a substitute for showing your method, and it is not medical, legal, or financial advice.