Skip to content
ihateDesmos

Matrix multiplication calculator

Type two matrices and get their product in exact fractions, with an entry worked out so you can see the pattern. If the sizes don’t fit, it tells you why.

A × B (2 × 2)
1922
4350
Steps
  1. Each entry is a row of A times a column of B. The sizes 2 × 2 and 2 × 2 fit because A’s columns match B’s rows.
  2. For example, the top-left entry is 1·5 + 2·7 = 19

How to use it

  1. 1
    Type the matrix with one row per line and spaces between entries. Fractions like 1/2 and decimals both work.
  2. 2
    Leave the operation on “A × B”, and type the second matrix in its box.
  3. 3
    The answer stays in exact fractions, so nothing is rounded, and the row operations are listed underneath.

How matrix multiplication works

Each entry of the product is one row of A times one column of B: multiply matching numbers, then add. The entry in row i, column j uses row i of A and column j of B.

For A with rows (1, 2) and (3, 4), and B with rows (5, 6) and (7, 8), the top-left entry is 1·5 + 2·7 = 19 and the top-right is 1·6 + 2·8 = 22. The bottom row is 3·5 + 4·7 = 43 and 3·6 + 4·8 = 50.

Which sizes can be multiplied?

A × B works only when A has as many columns as B has rows. An m × n matrix times an n × p matrix gives an m × p matrix: the inner numbers must match, and the outer numbers give the size of the result. A 2 × 3 times a 3 × 4 gives a 2 × 4, but a 2 × 3 times a 2 × 3 is impossible.

Order matters

Unlike ordinary numbers, AB and BA are usually different, and one may not exist even when the other does. Matrix multiplication represents doing one transformation after another: rotating and then reflecting isn’t the same as reflecting and then rotating. It is associative, though: (AB)C = A(BC).

Frequently asked questions

How do you multiply a 2×2 matrix by a 2×2 matrix?
Each entry is a row of the first times a column of the second. The result is also 2×2, with four entries to work out.
Can you multiply matrices of different sizes?
Yes, if the first has as many columns as the second has rows. A 2 × 3 can multiply a 3 × 5, giving a 2 × 5.
Is matrix multiplication commutative?
No. In general AB ≠ BA.
What is the identity matrix?
The square matrix with 1s on the diagonal and 0s elsewhere. Multiplying by it changes nothing, like multiplying a number by 1.

Related tools and guides

Try the matrix multiplication calculator

It opens instantly, with no account and nothing to install.

Open the calculator