Matrix A
Current size: 3 × 3
Matrix multiplication cost tool
Calculate how many scalar multiplications and additions are required to multiply two matrices using the standard Row × Column method. Enter the matrix dimensions to see the result size, operation count, and the calculation behind it.
Current size: 3 × 3
Current size: 3 × 3
Result Matrix
3 × 3
Result Cells
9
Per Result Cell
3 multiplications
2 additions
Total Multiplications
27
Total Additions
18
Total Scalar Operations
45
Multiplications + additions
9 result cells × 3 multiplications per cell = 279 result cells × 2 additions per cell = 1827 multiplications + 18 additions = 45 total scalar operationsSee exactly how the operation count is built from the Row × Column calculations in the result matrix.
A × B cannot be multiplied because the inner dimensions do not match.
Columns of A3
Rows of B4
These numbers must be equal.
The 3×3 case is a common example. Here is the same reasoning written out specifically for 3×3 matrices.
A 3×3 result matrix contains 9 result cells. Each result cell is a dot product of one row and one column, so each cell contains 3 scalar multiplications and 2 additions.
9 cells × 3 multiplications = 27 multiplications
9 cells × 2 additions = 18 additions
Total: 45 scalar arithmetic operations
c11 = a11b11 + a12b21 + a13b31c12 = a11b12 + a12b22 + a13b32c13 = a11b13 + a12b23 + a13b33c21 = a21b11 + a22b21 + a23b31c22 = a21b12 + a22b22 + a23b32c23 = a21b13 + a22b23 + a23b33c31 = a31b11 + a32b21 + a33b31c32 = a31b12 + a32b22 + a33b32c33 = a31b13 + a32b23 + a33b339 cells × 3 multiplications = 27 multiplications
9 cells × 2 additions = 18 additions
You do not need to memorize these formulas: the calculator applies them automatically.
For an m × n matrix multiplied by an n × p matrix, the result dimensions are m × p and there are mp result cells.
mnpmp(n - 1)mp(2n - 1)N3, additions N2(N - 1), total 2N3 - N2| Matrix Product | Result Size | Multiplications | Additions | Total Operations |
|---|---|---|---|---|
| 2×2 × 2×2 | 2×2, 4 cells | 8 | 4 | 12 |
| 3×3 × 3×3 | 3×3, 9 cells | 27 | 18 | 45 |
| 4×4 × 4×4 | 4×4, 16 cells | 64 | 48 | 112 |
| 3×3 × 3×1 | 3×1, 3 cells | 9 | 6 | 15 |
| 2×3 × 3×4 | 2×4, 8 cells | 24 | 16 | 40 |
For square N × N matrices, the standard Row × Column algorithm uses N3 scalar multiplications and N2(N - 1) scalar additions, so its arithmetic complexity grows on the order of O(N3).
The calculator above gives the exact operation count for a particular matrix size. Big-O describes how that count grows as the matrix size increases.
Advanced
Reducing scalar multiplications does not automatically make a method faster for small matrices or modern hardware. Additions, memory access, implementation overhead, vectorization, cache behavior, and hardware architecture also matter.
| Size | Standard | Faster algorithm note |
|---|---|---|
| 2×2 | 8 multiplications, 4 additions | Strassen uses 7 multiplications and more additions/subtractions; a common formulation uses 18 additions/subtractions. |
| 3×3 | 27 multiplications, 18 additions | Laderman-type algorithms use 23 multiplications but require substantially more additions/subtractions. |
| 4×4 | 64 multiplications, 48 additions | Recursive Strassen uses 49 scalar multiplications with additional additions/subtractions and overhead. |
For small matrices, the standard Row × Column method is often preferred because it is simple, predictable, and easy to optimize. Fast matrix multiplication algorithms are mainly important in algorithm analysis and larger-scale computation. Standard square multiplication is O(N3); Strassen is approximately O(N2.807).
This calculator reports scalar arithmetic operations: multiplications plus additions. When the matrix entries are floating-point values, similar counts are often discussed in terms of floating-point operations (FLOPs). Hardware and FMA conventions can make practical performance accounting different from this simple arithmetic count.