Matrix Multiplication Calculator: A × B With Steps
Enter two matrices to get their product, with every row-times-column sum written out. If the sizes don't fit, it tells you why and whether B × A works instead.
- Up to 8 × 8
- Exact fractions
- AB vs BA
- A (2 × 3), row 1−1 2 3
- B (3 × 2), column 15 −4 2
- Multiply and add−5 − 8 + 6
- Size of AB2 × 2
To multiply matrix A by matrix B, the number of columns of A must equal the number of rows of B. The product of an m × r matrix and an r × n matrix is m × n. Each entry is a row of A times a column of B: multiply matching entries and add. For A with rows −1 2 3 and 4 0 5, and B with rows 5 −1, −4 0 and 2 3, the top-left entry is (−1)(5) + 2(−4) + 3(2) = −7, and AB has the rows −7 10 and 30 11.
This matrix multiplication calculator handles matrices up to 8 × 8, including fractions and decimals, and writes out the sum behind every entry of the product, all 64 for an 8 × 8 result.
How to Multiply Two Matrices, Step by Step
- Check the sizes. Write A as m × r and B as r × n. The inner numbers have to match; the outer numbers give the size of AB, m × n (OpenStax Algebra and Trigonometry 2e, 11.5).
- Pick a row of A and a column of B. Row i and column j give the entry in row i, column j of AB.
- Multiply matching entries and add. First entry times first entry, second times second, and so on, then add the products.
- Repeat for every row and column. A 2 × 3 matrix times a 3 × 2 matrix gives 2 × 2 = 4 entries, each a sum of 3 products.
For OpenStax's example, the four entries of AB are:
- Row 1 · column 1: (−1)(5) + 2(−4) + 3(2) = −5 − 8 + 6 = −7
- Row 1 · column 2: (−1)(−1) + 2(0) + 3(3) = 1 + 0 + 9 = 10
- Row 2 · column 1: 4(5) + 0(−4) + 5(2) = 20 + 0 + 10 = 30
- Row 2 · column 2: 4(−1) + 0(0) + 5(3) = −4 + 0 + 15 = 11
Two square matrices work the same way. With OpenStax's 2 × 2 matrices from Example 8 (11.5), each entry is a sum of 2 products; for instance, the top-left entry is 1(5) + 2(7) = 19:
| 1 | 2 |
| 3 | 4 |
×
| 5 | 6 |
| 7 | 8 |
=
| 19 | 22 |
| 43 | 50 |
When Can You Multiply Two Matrices?
"Finding the product of two matrices is only possible when the inner dimensions are the same" (OpenStax 11.5). Some common sizes:
| A | B | Inner numbers | AB |
|---|---|---|---|
| 2 × 2 | 2 × 2 | 2 = 2 | 2 × 2 |
| 3 × 3 | 3 × 3 | 3 = 3 | 3 × 3 |
| 2 × 3 | 3 × 2 | 3 = 3 | 2 × 2 |
| 3 × 2 | 2 × 3 | 2 = 2 | 3 × 3 |
| 3 × 3 | 3 × 1 | 3 = 3 | 3 × 1 (a column) |
| 1 × 3 | 3 × 2 | 3 = 3 | 1 × 2 (a row) |
| 2 × 3 | 2 × 3 | 3 ≠ 2 | Not defined |
A 3 × 3 matrix times a 3 × 1 column is how a system of equations is written as AX = C, with X the column of unknowns (OpenStax 11.7). A row times a matrix is common too. OpenStax 11.5, Example 10, multiplies a row of three prices by a 3 × 2 matrix of quantities to get the total equipment cost for each of two teams (11.5):
| 300 | 10 | 30 |
×
| 6 | 10 |
| 30 | 24 |
| 14 | 20 |
=
| 2520 | 3840 |
Why AB Isn't the Same as BA
"Matrix multiplication is not commutative" (OpenStax 11.5). In the example above, AB is 2 × 2 but BA is 3 × 3:
BA =
| −9 | 10 | 10 |
| 4 | −8 | −12 |
| 10 | 4 | 21 |
Even for two square matrices of the same size, AB and BA usually have different entries. The calculator compares them for you whenever both products are defined.
Properties of Matrix Multiplication
- Associative: (AB)C = A(BC), so a chain of products can be grouped either way (OpenStax 11.5).
- Distributive: A(B + C) = AB + AC and (B + C)A = BA + CA (OpenStax 11.5).
- Identity: for a square matrix A, AI = IA = A, where I is the identity matrix of the same size, with 1s down the diagonal and 0s elsewhere (OpenStax 11.7).
- Determinants multiply: for square matrices A and B of the same size, det(AB) = det A × det B, even though the determinant of a sum isn't, in general, the sum of the determinants (MIT 18.06SC, Properties of determinants).
Multiplying by a number is different from multiplying by a matrix. For kA you multiply every entry by k, and any size of matrix works. Choose "kA" above to do that.
Frequently Asked Questions
Can you multiply a 2 × 3 matrix by a 2 × 3 matrix?
No. A has 3 columns but B has 2 rows. You can multiply a 2 × 3 matrix by the transpose of the other, which is 3 × 2, and get a 2 × 2 matrix. To get the transpose, use the transpose option in the matrix calculator.
How do you multiply a 3 × 3 matrix?
When you multiply two 3 × 3 matrices, each of the 9 entries of the product is a row of the first matrix times a column of the second: 3 products added together. The calculator writes out all 9.
Can you multiply matrices of different sizes?
Yes, as long as the columns of the first match the rows of the second. A 3 × 2 matrix times a 2 × 4 matrix is a 3 × 4 matrix.
How do you square a matrix?
A² = A × A, which is defined only when A is square. It is not the same as squaring each entry. Choose "Aⁿ" above to find powers up to 20. For powers of a single number, use the exponent calculator.
Can I multiply matrices with fractions or decimals?
Yes. Type entries like 3/4, −2/3 or 0.25. The answer stays in exact fractions, with a decimal version next to it. To turn a decimal into a fraction yourself, use the decimal to fraction calculator.
More tools: the matrix calculator for determinants, inverses and transposes, the quadratic formula calculator and all the math calculators.
Sources
- OpenStax, Algebra and Trigonometry 2e: 11.5 Matrices and Matrix Operations and 11.7 Solving Systems with Inverses
- MIT OpenCourseWare 18.06SC Linear Algebra (Strang), lecture summary: Properties of determinants
- Formulas and test cases: how we calculate