Matrix Multiplication Calculator
Multiply two matrices up to 10 × 10 in either order, AB or BA, and see the product's shape, the inner dimension and the number of multiplications used.
Matrix Multiplication Calculator
Background.
Ask someone new to linear algebra to multiply [1 2; 3 4] by [5 6; 7 8] and the usual first answer is [5 12; 21 32]: one times five, two times six, and so on, position by position. That operation exists — it is called the Hadamard product — but it is not what matrix multiplication means in algebra, physics, statistics or computing. The standard product is [19 22; 43 50]. Each entry pairs a whole row of the left matrix with a whole column of the right one: the top-left is 1·5 + 2·7 = 19, the bottom-right 3·6 + 4·8 = 50.
That row-by-column rule has consequences people trip over. The two matrices do not have to be the same size; they only have to agree on one number, the columns of the left factor against the rows of the right. A 2 × 3 matrix times a 3 × 2 matrix is fine and gives a 2 × 2 answer. Order matters as well. Swap the two 2 × 2 matrices above and the product becomes [23 34; 31 46], and for non-square matrices one order can exist while the other does not.
The rule is not arbitrary, and it was already set out in Arthur Cayley's 1858 memoir on matrices. A matrix describes a linear transformation — a rotation, a reflection, a stretch, a change of coordinates — and multiplying two matrices gives the single matrix that performs one transformation after the other. Rotate the plane an anticlockwise quarter-turn and then reflect it in the x-axis, and you get [0 −1; −1 0], a reflection in the line y = −x. Reflect first and then rotate, and you get [0 1; 1 0], a reflection in y = x. Different orders, different results, exactly as with the matrices.
Enter each matrix with one row per line and entries separated by spaces or commas, choose A × B or B × A, and the result shows the product with semicolons between its rows, along with its dimensions, the inner dimension that was summed over, how many number-by-number multiplications it took, and the sum of all entries as a check figure. Each matrix can have up to ten rows and ten columns. For entry-wise products, addition and scalar multiplication, use the general matrix calculator.
What is matrix multiplication calculator?
Matrix multiplication, sometimes called the Cayley product to distinguish it from entry-wise and Kronecker products, combines an m × n matrix A with an n × p matrix B into an m × p matrix AB. The entry in row i and column j is the sum, over k from 1 to n, of aᵢₖ times bₖⱼ. The product exists only when the left factor's column count equals the right factor's row count; that shared count, the inner dimension, disappears from the result. The operation is associative, (AB)C = A(BC), and distributes over addition, A(B + C) = AB + AC. The identity matrix, with ones on the main diagonal and zeros elsewhere, leaves any compatible matrix unchanged. Two properties of ordinary numbers do not carry over: AB and BA are generally different, and two non-zero matrices can multiply to the zero matrix.
How to use this calculator.
- Type Matrix A one row per line, separating entries with spaces or commas; "1 2 3" above "4 5 6" is a 2 × 3 matrix. You can also put a whole matrix on one line with semicolons between rows, as in 1,2,3;4,5,6.
- Type Matrix B the same way. Every row must have the same number of entries, and no matrix may exceed ten rows or ten columns.
- Choose the order. A × B puts A on the left and needs A's column count to equal B's row count; B × A needs the reverse. If the sizes do not fit, the message names both shapes and the counts that must match.
- Read the product: [58 64; 139 154] means a first row of 58 and 64 and a second row of 139 and 154. Its rows always come from the left factor and its columns from the right.
- If you are checking a hand calculation, compare your sum of entries with the one shown before hunting for the wrong entry.
The formula.
The definition is (AB)ᵢⱼ = Σₖ aᵢₖ · bₖⱼ, with k running from 1 to n: walk along row i of A and down column j of B together, multiply the pairs and add. Row i of A has n entries and column j of B has n entries, which is the whole reason the inner dimensions must match.
The same arithmetic can be read in several ways, and Gilbert Strang's MIT linear algebra course teaches them side by side. Entry by entry, each element of AB is a dot product of a row with a column. Column by column, each column of AB is A multiplied by the matching column of B, so it is a combination of A's columns. Row by row, each row of AB is the matching row of A multiplied by B, a combination of B's rows. And as a sum of pieces, AB is the total of n outer products, column k of A times row k of B. In the default example these three pieces are [7 8; 28 32], [18 20; 45 50] and [33 36; 66 72], which add to [58 64; 139 154].
The work counts follow directly. There are m × p entries and each takes n multiplications, so the product costs m × n × p multiplications: 12 for a 2 × 3 by 3 × 2, and n³ for two n × n matrices, 1,000 for a pair of 10 × 10s. That cubic growth is why matrix-matrix routines, the Level 3 BLAS, are among the most heavily optimised code in numerical computing.
Two identities are worth knowing because they let you check or reorganise a calculation. Transposing a product reverses the order, (AB)ᵀ = BᵀAᵀ; multiplying the transposes of the default matrices gives [58 139; 64 154], the transpose of the original answer. And a product with a matrix of all-zero rows or columns inherits them: a zero row in A gives a zero row in AB, a zero column in B gives a zero column in AB.
A worked example.
Take the default matrices: A = [1 2 3; 4 5 6], which is 2 × 3, and B = [7 8; 9 10; 11 12], which is 3 × 2. A has three columns and B has three rows, so A × B exists with an inner dimension of 3, and the answer has A's 2 rows and B's 2 columns. Row 1 of A is (1, 2, 3). Against column 1 of B, (7, 9, 11), it gives 1·7 + 2·9 + 3·11 = 7 + 18 + 33 = 58; against column 2, (8, 10, 12), it gives 8 + 20 + 36 = 64. Row 2 of A is (4, 5, 6): against column 1 it gives 28 + 45 + 66 = 139, and against column 2 it gives 32 + 50 + 72 = 154. The product is [58 64; 139 154]. Four entries at three multiplications each makes 2 × 3 × 2 = 12 multiplications. The entries add up to 58 + 64 + 139 + 154 = 415, and that total can be predicted without doing the product at all. Add up each column of A to get (5, 7, 9) and each row of B to get (15, 19, 23); their dot product is 75 + 133 + 207 = 415. When the two totals agree, your arithmetic is very likely right.
Frequently asked questions.
Why won't my 2 × 3 and 2 × 2 matrices multiply?
Which matrices give the same answer in either order?
How are the Hadamard and Kronecker products different from this one?
Can I use this to get a dot product or an outer product of two vectors?
Can two non-zero matrices multiply to give zero?
Does the order of brackets in a chain of products matter?
Is m × n × p multiplications the least work possible?
How does the sum of entries help me check my work?
Can I enter fractions, decimals or negative numbers?
Where does matrix multiplication turn up outside a maths course?
References& sources.
- [1]Encyclopedia of Mathematics (EMS Press / Springer), article "Matrix" — gives the product definition used here: for A ∈ M(m,k) and B ∈ M(k,n), AB = (c_{μν}) with c_{μν} = Σ_j a_{μj} b_{jν}. Retrieved 2026-07-29; open access.
- [2]Encyclopedia of Mathematics (EMS Press / Springer), article "Matrix multiplication" — names the row-by-column product "Cayley multiplication" and distinguishes it from Hadamard (entry-wise) and Kronecker multiplication, and relates it to composition of linear transformations. Retrieved 2026-07-29; open access.
- [3]NIST Digital Library of Mathematical Functions, §1.3(iv) "Matrices as Linear Operators" — matrices acting as linear operators, the framing that explains why the product is composition. Retrieved 2026-07-29; open access.
- [4]MIT OpenCourseWare 18.06 Linear Algebra, Spring 2010, Prof. Gilbert Strang — lectures on matrix multiplication, the four ways to view it, and its relationship to linear maps. CC BY-NC-SA 4.0; retrieved 2026-07-29; open access.
- [5]Netlib BLAS (Basic Linear Algebra Subprograms) reference site — "the Level 3 BLAS perform matrix-matrix operations"; the GEMM routines are the standard reference implementation of the product computed on this page. Retrieved 2026-07-29; open access.
- [6]Cayley, A. (1858). "A Memoir on the Theory of Matrices." Philosophical Transactions of the Royal Society of London 148, 17–37 — the paper that introduced the row-by-column product. DOI resolves; the publisher returned HTTP 403 to an unauthenticated request, so this is a bibliographic, gated citation rather than a page read in full.
How this page was produced
- Published by
- Quanta Calculator
- Overseen by
- Daniel, Quanta Calculator Researcher
- Primary sources
- 6 cited below
- Method
- (AB)ᵢⱼ = Σₖ aᵢₖ · bₖⱼ
- Published
- Last verified
Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 1560 calculators remain free
- No billing is enabled