Uni-Sine
MathematicsAlgebra

Matrix multiplication calculator with every entry worked out

To multiply two matrices, each entry of the answer is a row of the first matrix times a column of the second: multiply the matching entries and add them up. This only works when the first matrix has as many columns as the second has rows. Our matrix multiplication calculator, part of the Matrix Calculator, multiplies matrices up to 5 by 5 exactly and writes out the sum for each entry.

Try it

Matrix Calculator

Multiply, invert and find determinants and eigenvalues

Go to its page

How to multiply matrices in the calculator

  1. Open the Matrix Calculator. It starts on Eigenvalues, so choose the A × B chip at the top of the Matrices section.
  2. Set the rows and columns of A, then type its entries. Fractions and decimals work.
  3. Set the rows and columns of B. Its rows must match A's columns.
  4. Read the product at the top. The working below shows each entry as a row of A times a column of B, then puts them together.
  5. Or press Multiply in the Examples section to load a ready-made 2 by 2 product.

The working lists up to nine entries in full, which covers every entry of a 3 by 3 product. If the sizes don't fit, the calculator says so and gives both sizes. For a matrix times itself, the Power chip works out A², A³ and so on. Random problem in the Practice section asks for single entries of a product.

How to multiply matrices: row times column

The entry in row i, column j of AB comes from row i of A and column j of B. Pair up their entries, first with first, second with second, multiply each pair, and add:

(AB)_{ij} = a_{i1}b_{1j} + a_{i2}b_{2j} + \dots + a_{in}b_{nj}Row i of A times column j of B

This is the dot product of a row and a column, so the row and the column need the same number of entries. That is where the size rule comes from.

The size rule

Write the sizes side by side, rows by columns. The inside numbers must match, and the outside numbers give the size of the answer: an m by n matrix times an n by p matrix is an m by p matrix.

ABA × B
2 by 22 by 22 by 2
2 by 33 by 22 by 2
3 by 22 by 33 by 3
3 by 33 by 1 (a column vector)3 by 1
1 by 33 by 11 by 1, a single number
2 by 32 by 3Not possible: 3 ≠ 2

Worked examples you can check in the calculator

Example 1: 2 by 2 matrix multiplication

Multiply A = [1, 2; 3, 4] by B = [5, 6; 7, 8], writing each matrix row by row with a semicolon between rows. This is the calculator's Multiply example.

EntryRow of A × column of BValue
Row 1, column 11 × 5 + 2 × 719
Row 1, column 21 × 6 + 2 × 822
Row 2, column 13 × 5 + 4 × 743
Row 2, column 23 × 6 + 4 × 850
AB = \left[19,\ 22;\ 43,\ 50\right]

Now swap the order. B × A = [23, 34; 31, 46], a different answer. Matrix multiplication is not commutative: AB and BA are usually different, so always multiply in the order the question gives.

Example 2: 3 by 3 matrix times a vector

Set A to 3 by 3 and B to 3 by 1. Multiply A = [1, 0, 2; −1, 3, 1; 2, 1, 0] by the column vector (3, 1, 2):

  • Row 1: 1 × 3 + 0 × 1 + 2 × 2 = 7
  • Row 2: (−1) × 3 + 3 × 1 + 1 × 2 = 2
  • Row 3: 2 × 3 + 1 × 1 + 0 × 2 = 7

The answer is the column vector (7, 2, 7). A 3 by 3 times a 3 by 1 gives a 3 by 1. This is how a matrix transforms a point or solves a system of equations written as Ax = b.

Example 3: a row times a column, and a column times a row

A 1 by 3 row times a 3 by 1 column gives a single number: [1, 2, 3] times the column (4, 5, 6) is 1 × 4 + 2 × 5 + 3 × 6 = 32. Swap the order and the answer is a 3 by 3 matrix, because every entry of the column multiplies every entry of the row:

4812
51015
61218

The same two matrices, multiplied in the two orders, give a 1 by 1 and a 3 by 3. It is the clearest example of why order matters.

Example 4: squaring a matrix

A² means A × A, not squaring each entry. For A = [3, −2; 1, 4]:

A^2 = \left[3 \times 3 + (-2) \times 1,\ 3 \times (-2) + (-2) \times 4;\ 1 \times 3 + 4 \times 1,\ 1 \times (-2) + 4 \times 4\right] = \left[7,\ -14;\ 7,\ 14\right]

Squaring each entry would give [9, 4; 1, 16], which is wrong. Only square matrices can be squared, because the size rule needs columns to match rows.

Try one

practice
Pick an answer, then check it.
A = [2, −1; 0, 3] and B = [4, 1; 5, −2]. What is the entry in row 2, column 1 of AB?

Matrix multiplication rules

RuleIn symbolsTrue?
Order mattersAB = BAUsually not
Grouping doesn't matter(AB)C = A(BC)Always
Brackets multiply outA(B + C) = AB + ACAlways
The identity changes nothingAI = IA = AAlways
Transpose of a product(AB)ᵀ = BᵀAᵀAlways, note the order flips
Zero productAB = 0 means A = 0 or B = 0Not always

The identity matrix I has 1s down the main diagonal and 0s elsewhere. Multiplying [3, 1; 2, 5] by the 2 by 2 identity gives [3, 1; 2, 5] back. The last row of the table is a surprise: two matrices that aren't zero can multiply to give the zero matrix, so you can't cancel matrices the way you cancel numbers.

Common mistakes

  • Multiplying matching entries. That is not matrix multiplication. Each entry is a whole row times a whole column.
  • Using a column of A or a row of B. It is always rows of the first matrix and columns of the second.
  • Swapping the order. AB and BA are different, and one of them may not even exist.
  • Getting the answer's size wrong. It has the first matrix's rows and the second matrix's columns.
  • Sign slips with negatives. Put negative entries in brackets as you write the products, as the calculator does.

Common questions

Can you multiply a 2 by 3 matrix by a 3 by 2 matrix?
Yes. The inside numbers match (3 and 3), and the answer is 2 by 2, from the outside numbers. In the other order, a 3 by 2 times a 2 by 3, you also can, and the answer is 3 by 3.
Why isn't matrix multiplication commutative?
Because AB uses the rows of A and the columns of B, while BA uses the rows of B and the columns of A. These are different numbers, so the sums come out different. Thought of as transformations, rotating then reflecting is usually not the same as reflecting then rotating.
How do you multiply a matrix by a number?
Multiply every entry by that number. 3 times [1, 2; 0, 4] is [3, 6; 0, 12]. This is called scalar multiplication, and it has no size rule.
How do you multiply three matrices?
Multiply two of them, then multiply that answer by the third, keeping the order. Grouping doesn't change the answer, so you can start with either pair. In the calculator, multiply A by B, then type the answer in as the new A.
What size matrices can the calculator multiply?
Any sizes up to 5 by 5, as long as A's columns match B's rows.

Revision cards

Read the front, say your answer, then flip to check.

Where to go next

  • Solve it

    Matrix Calculator

    Multiply, invert and find determinants and eigenvalues

    Open the tool
  • Test it

    College Linear Algebra

    A new exam-style paper every day, with instant marking and a mark scheme

    Start today's paper
Read next
Maths · AlgebraMatrix calculator: multiply, inverse, determinant, RREFAdd, multiply, invert and row reduce matrices up to 5 by 5 with exact fractions, plus determinants, eigenvalues and worked examples to check.