Matrix Multiplication Calculator
Free matrix multiplication calculator. Multiply two matrices in either order, with the conformability check and a worked 2×3 by 3×2 example.
Matrix Multiplication Calculator
Background.
The Quanta matrix multiplication calculator computes the product of two matrices in either order — A × B or B × A — and reports the shape of the answer, the inner dimension it summed over, how many individual multiplications the schoolbook algorithm performed, and a checksum you can use to verify a hand calculation. Type each matrix one row per line, with entries separated by spaces or commas, up to 10 × 10. If the two matrices are not conformable the calculator says exactly which count has to match which, and prints both shapes so you can see at a glance which one you mistyped.
Matrix multiplication is the operation people most often get wrong, and almost always for the same two reasons. The first is that it is not entry-wise. Adding matrices pairs up entries in matching positions; multiplying them does not. The entry in row i, column j of the product is built from the whole of row i of the left matrix and the whole of column j of the right matrix, multiplied term by term and summed. That is why the two matrices do not need to be the same size — they need only agree on the shared, inner dimension: an m × n matrix times an n × p matrix gives an m × p matrix, and the n vanishes. The second is that order matters. AB and BA are different matrices in general, and they frequently have different shapes; one can be defined while the other is not. The default inputs on this page are a 2 × 3 and a 3 × 2, and switching the order flips a 2 × 2 answer into a 3 × 3 one from exactly the same numbers.
There is also a naming trap worth flagging before you trust any result. "Matrix multiplication" is used in the literature for at least three different operations. This page computes the Cayley product, the row-by-column one described above and the one meant in essentially every linear-algebra course. The Hadamard product multiplies entries in matching positions, like addition does. The Kronecker product builds a much larger block matrix. Encyclopedia of Mathematics lists all three under the single heading "Matrix multiplication", so if you arrived expecting entry-wise multiplication, this is not the page you want — and the entry-wise operations, along with addition, subtraction and scalar multiplication, live on the separate matrix calculator linked below.
Why is the definition so strange-looking? Because it is not arbitrary. A matrix encodes a linear map, and multiplying matrices corresponds exactly to composing those maps: apply B, then apply A, and the matrix of the composite is AB. Every apparently odd feature of the rule falls out of that. The inner dimensions must agree because the output space of the first map has to be the input space of the second. The order matters because composing functions is order-dependent — putting on socks then shoes is not the same as shoes then socks. The shape of the result is m × p because the composite map goes from a p-dimensional space to an m-dimensional one. Cayley's 1858 memoir introduced this product for precisely this reason, and it is the reason the same arithmetic turns up as rotation composition in computer graphics, as one step of a Markov chain, as a layer of a neural network, and as the transition step in every state-space model in control theory.
The calculator does its arithmetic in arbitrary-precision decimal and accumulates each dot product exactly, with no intermediate rounding at all — it rounds once, to ten decimal places, only when it formats the answer. So a product that should be a whole number comes back as a whole number, not as 5.999999999999999.
What is matrix multiplication calculator?
Matrix multiplication is the operation that takes an m × n matrix A and an n × p matrix B and produces an m × p matrix AB, whose entry in row i and column j is the sum of the products of the entries of row i of A with the corresponding entries of column j of B. In symbols, (AB)ᵢⱼ = Σₖ aᵢₖ·bₖⱼ, summed for k from 1 to n. Encyclopedia of Mathematics gives it as: for A in M(m,k) and B in M(k,n), the product AB = (c_{μν}) where each entry equals the sum over j of a_{μj}·b_{jν}. The condition for the product to exist is called conformability: the number of columns of the left factor must equal the number of rows of the right factor. That shared count is the inner dimension; it is summed over and does not appear in the answer. Matrix multiplication is associative, so (AB)C = A(BC), and it distributes over addition, so A(B + C) = AB + AC. It has an identity: the square matrix with 1 on the main diagonal and 0 elsewhere leaves any conformable matrix unchanged. But it is not commutative — AB and BA are usually different, may have different shapes, and one may exist while the other does not — and it has zero divisors, meaning a product of two non-zero matrices can be the zero matrix. The reason the definition takes this form is that matrices represent linear maps and the product represents composition of those maps: if B sends a p-dimensional space to an n-dimensional one and A sends that n-dimensional space to an m-dimensional one, then AB is the matrix of the map that does B first and then A. Two important special cases are worth recognising because they look nothing alike: a 1 × n row times an n × 1 column collapses to a single number, which is the dot product; an n × 1 column times a 1 × n row expands to an n × n matrix, which is the outer product.
How to use this calculator.
- Choose the order. "A × B" puts A on the left and is what people usually mean by "multiply A and B". "B × A" puts B on the left. These give different matrices, so pick deliberately rather than by habit.
- Type Matrix A, one row per line, entries separated by spaces or commas. "1 2 3" then "4 5 6" on the next line is a 2 × 3 matrix. Semicolons also work as row separators if you prefer a single line: "1,2,3;4,5,6".
- Type Matrix B the same way. For A × B, the number of rows in B must equal the number of columns in A. If it does not, the calculator prints both shapes and tells you which count has to match which.
- Read the product in the hero panel. Semicolons separate rows: [58 64; 139 154] means the first row is 58 64 and the second is 139 154.
- Check the shape against the inner dimension. The product's rows come from the left factor, its columns from the right factor, and the inner dimension is the count that got summed away. An m × n times an n × p is always an m × p.
- Flip the order and look again. If the two matrices are square and the same size, both products exist and comparing them is the fastest way to see that matrix multiplication is not commutative. If they are not square, the shape of the answer will usually change too.
- Use the sum of entries as a checksum on a hand calculation, and the scalar-multiplications count when you are reasoning about cost — that figure is rows × inner dimension × columns, which is why multiplying two n × n matrices is an n³ operation.
The formula.
To find the entry of the product in row i and column j, take row i of the left matrix and column j of the right matrix, multiply them together term by term, and add up the results. Written out: (AB)ᵢⱼ = aᵢ₁b₁ⱼ + aᵢ₂b₂ⱼ + … + aᵢₙbₙⱼ. Both the row and the column have exactly n entries, which is the whole content of the conformability rule — the left factor's column count must equal the right factor's row count, or the terms cannot be paired up. That shared count is the inner dimension. It is summed away and does not appear in the result, so an m × n times an n × p produces an m × p. Work through the worked example on this page to see it concretely. A is 2 × 3 and B is 3 × 2, so the inner dimension is 3 and the product is 2 × 2. The top-left entry pairs row 1 of A, which is (1, 2, 3), with column 1 of B, which is (7, 9, 11), giving 1·7 + 2·9 + 3·11 = 7 + 18 + 33 = 58. The other three entries are built the same way. Counting the arithmetic: each of the 2 × 2 = 4 entries needs 3 multiplications and 2 additions, so the whole product takes 12 multiplications — which is the scalar-multiplications output, and in general is rows × inner dimension × columns. For two n × n matrices that is n³, the reason matrix multiplication dominates the cost of so much numerical work. Three properties follow from the definition and are worth checking on the calculator itself. Associativity: (AB)C = A(BC), so a chain of products can be bracketed however you like — which is not a cosmetic fact, since the bracketing changes how many multiplications you perform. Distributivity: A(B + C) = AB + AC. And the identity: the square matrix with ones on the main diagonal and zeros elsewhere leaves any conformable matrix unchanged, so multiplying [1 2; 3 4] by [1 0; 0 1] returns [1 2; 3 4] exactly. What does not hold is commutativity. AB and BA are different in general, and with the default inputs on this page — a 2 × 3 and a 3 × 2 — they are not even the same size. Rounding happens once, at the end. Each entry is accumulated as an exact decimal sum of exact decimal products with no intermediate rounding, and only the finished entry is rounded to ten decimal places for display.
A worked example.
A is the 2 × 3 matrix [1 2 3; 4 5 6] and B is the 3 × 2 matrix [7 8; 9 10; 11 12]. A has 3 columns and B has 3 rows, so the product A × B exists, the innerDimension output is 3, and the answer is 2 × 2 — the rows output is 2 and the columns output is 2. Building it entry by entry: the top-left pairs row 1 of A, (1, 2, 3), with column 1 of B, (7, 9, 11), giving 1·7 + 2·9 + 3·11 = 7 + 18 + 33 = 58. The top-right pairs (1, 2, 3) with column 2 of B, (8, 10, 12), giving 8 + 20 + 36 = 64. The bottom-left pairs row 2 of A, (4, 5, 6), with (7, 9, 11), giving 28 + 45 + 66 = 139. The bottom-right pairs (4, 5, 6) with (8, 10, 12), giving 32 + 50 + 72 = 154. So the product output is [58 64; 139 154]. The sumOfEntries output is 58 + 64 + 139 + 154 = 415, and the scalarMultiplications output is 2 × 3 × 2 = 12, because each of the four entries needed three multiplications. Now switch the order selector to "B × A" without touching either matrix. B is 3 × 2 and A is 2 × 3, so that product also exists, but the inner dimension is now 2 and the answer is 3 × 3: the product output becomes [39 54 69; 49 68 87; 59 82 105], with rows 3, columns 3, scalarMultiplications 18 and sumOfEntries 612. Two different matrices, of two different shapes, from exactly the same pair of inputs — which is what "matrix multiplication is not commutative" means in practice.
Frequently asked questions.
How do you multiply two matrices by hand?
When can two matrices be multiplied?
Is AB the same as BA?
Why is matrix multiplication defined that way instead of entry-by-entry?
What is the difference between the Cayley, Hadamard and Kronecker products?
What is the identity matrix and what does it do?
Can the product of two non-zero matrices be zero?
How many multiplications does the calculator perform?
Does the order I bracket a chain of products in matter?
What is the dot product and the outer product in terms of this calculator?
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.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 977 calculators remain free
- No billing is enabled