How this calculator works
The entry in row i and column j of AB is the dot product of row i of A and column j of B. That means the number of columns of A must equal the number of rows of B. The product has the number of rows of A and the number of columns of B. Matrix multiplication is associative but not generally commutative, so AB and BA can differ.
Formula
(AB)ij = sum over k of Aik Bkj, for k from 1 to n, where A is m by n and B is n by p.
Worked example
Multiplying rows 1, 2; 3, 4 by rows 5, 6; 7, 8 gives row 1 as 1x5 + 2x7 = 19 and 1x6 + 2x8 = 22, and row 2 as 3x5 + 4x7 = 43 and 3x6 + 4x8 = 50. The product is 19, 22; 43, 50.
Advertisement
Frequently asked questions
Why must the inner dimensions match?
Each output entry pairs one row of A with one column of B. If those vectors have different lengths, the required dot product is undefined.
Does AB equal BA?
Not in general. Some pairs commute, such as a matrix and its inverse, but most products differ, and the shapes may not even allow both orders.
Can I multiply a row vector by a column vector?
Yes. A 1 by n matrix times an n by 1 matrix gives a 1 by 1 matrix, which is the dot product of the vector entries.