Audited 29 Jul 2026·Last updated 31 Jul 2026·6 citations·Tier 1·0 uses

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

Which product?
One row per line. Separate entries with spaces or commas. Max 10 × 10.
For A × B the number of rows here must equal the number of columns in A.
Product matrix
[58 64; 139 154]
The Cayley product — rows of the left factor combined with columns of the right, with semicolons between rows. This is not the entry-wise (Hadamard) product; for that, and for adding or scaling matrices, use the matrix calculator.
Rows
2
Columns
2
Inner dimension
3
Scalar multiplications
12
Sum of entries
415

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.

  1. 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.
  2. 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".
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.

(AB)ᵢⱼ = Σₖ aᵢₖ · bₖⱼ

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.

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.

matrix B7 8 9 10 11 12
matrix A1 2 3 4 5 6
orderAB

Frequently asked questions.

How do you multiply two matrices by hand?
For each position in the answer, take the matching row of the left matrix and the matching column of the right matrix, multiply them term by term, and add. The entry in row 2, column 1 of the product comes from row 2 of the left factor and column 1 of the right factor. If row 2 is (4, 5, 6) and column 1 is (7, 9, 11), that entry is 4·7 + 5·9 + 6·11 = 28 + 45 + 66 = 139. Repeat for every position. The row and column must have the same number of entries, which is the conformability rule.
When can two matrices be multiplied?
When the inner dimensions agree: the number of columns of the left factor must equal the number of rows of the right factor. An m × n matrix can be multiplied by an n × p matrix, and the result is m × p. The outer dimensions m and p can be anything. This is a much weaker requirement than for addition, which needs all four dimensions to match. It also means A × B can be defined while B × A is not — a 2 × 3 times a 3 × 4 works, but the reverse does not.
Is AB the same as BA?
Almost never. Matrix multiplication is not commutative. Often the two products have different shapes, so they cannot even be compared: with a 2 × 3 and a 3 × 2, AB is 2 × 2 and BA is 3 × 3. Even when both are square and the same size, the entries usually differ — [1 2; 3 4] × [5 6; 7 8] = [19 22; 43 50], while [5 6; 7 8] × [1 2; 3 4] = [23 34; 31 46]. Matrices that do satisfy AB = BA are called commuting matrices and are a special case, not the norm.
Why is matrix multiplication defined that way instead of entry-by-entry?
Because a matrix represents a linear map, and the product represents composing two maps. If B takes vectors from a p-dimensional space into an n-dimensional one, and A takes that n-dimensional space into an m-dimensional one, then the matrix of "do B, then do A" is exactly AB as defined. Everything odd about the rule follows: inner dimensions must agree because the output of the first map has to be a legal input to the second; the order matters because composing functions is order-dependent; and the result is m × p because that is where the composite map goes. The entry-by-entry product exists too — it is called the Hadamard product — but it does not correspond to composing maps, which is why it is not the default meaning.
What is the difference between the Cayley, Hadamard and Kronecker products?
All three are called "matrix multiplication" somewhere in the literature. The Cayley product is the row-by-column one this calculator computes, requires the inner dimensions to agree, and gives an m × p result. The Hadamard product multiplies entries in matching positions, requires both matrices to be the same size, and gives a result of that same size — it behaves like addition does. The Kronecker product multiplies every entry of A by the whole of B and assembles the results into a block matrix, so an m × n times a p × q gives an mp × nq. Encyclopedia of Mathematics lists all three in a single article, which is why this page states which one it computes.
What is the identity matrix and what does it do?
The identity matrix of size n, usually written I or Iₙ, is the square matrix with 1 in every position on the main diagonal and 0 everywhere else. It is the multiplicative identity: AI = A and IA = A for any conformable A. Multiplying [1 2; 3 4] by [1 0; 0 1] returns [1 2; 3 4] unchanged. It plays the same role for matrices that the number 1 plays for ordinary multiplication, and it is what the definition of the matrix inverse is written against — A⁻¹ is the matrix with AA⁻¹ = A⁻¹A = I.
Can the product of two non-zero matrices be zero?
Yes, and that is one of the more surprising differences from ordinary arithmetic. [1 0; 0 0] × [0 0; 0 1] = [0 0; 0 0], even though neither factor is the zero matrix. Matrices therefore have what algebraists call zero divisors, which is why you cannot cancel: AB = AC does not let you conclude B = C unless A is invertible. Geometrically it means the first map sends everything the second map produced into the zero vector — the composition annihilates the whole space.
How many multiplications does the calculator perform?
Rows × inner dimension × columns, which the calculator reports as the scalar-multiplications output. Each entry of the answer is a sum of as many products as the inner dimension, and there are rows × columns entries. For the worked example, a 2 × 3 times a 3 × 2, that is 2 × 3 × 2 = 12 multiplications and 2 × 2 × 2 = 8 additions. For two n × n matrices it is n³ multiplications, which is why matrix multiplication dominates the cost of most numerical linear algebra and why Level 3 BLAS routines — the matrix-matrix operations — are the ones libraries tune hardest.
Does the order I bracket a chain of products in matter?
Not for the answer, but very much for the work. Matrix multiplication is associative, so (AB)C and A(BC) give exactly the same matrix. The number of multiplications, however, can differ enormously. Take a 100 × 1 column u, a 1 × 100 row v and a 100 × 1 column w. Bracketing (uv)w builds the 100 × 100 outer product first — 100 × 1 × 100 = 10,000 multiplications — then multiplies it by w for another 100 × 100 × 1 = 10,000, so 20,000 in all. Bracketing u(vw) collapses vw to a 1 × 1 first — 1 × 100 × 1 = 100 multiplications — then costs another 100, so 200 in all: the same answer for a hundredth of the work. Choosing the cheapest bracketing is the classic matrix-chain-ordering problem.
What is the dot product and the outer product in terms of this calculator?
They are both matrix products, just with degenerate shapes. Enter a single row, say "1 2 3", as Matrix A and a single column, "4" then "5" then "6", as Matrix B: the product is 1 × 1, namely [32], because 1·4 + 2·5 + 3·6 = 32. That is the dot product of the two vectors. Swap them — column first, row second — and the product is 3 × 3, namely [4 8 12; 5 10 15; 6 12 18]. That is the outer product. Same two vectors, two completely different answers, purely from the order.

References& sources.

  1. [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. [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. [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. [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. [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. [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
Coming soon