What Is Matrix Multiplication?
Matrix multiplication is not entry-wise multiplication (that is the Hadamard product). The product C = AB is defined when the number of columns of A equals the number of rows of B. If A is m×n and B is n×p, then C is m×p, and each entry is:
This operation models composition of linear transformations: if T₁ has matrix A and T₂ has matrix B, then T₂∘T₁ (apply T₁ first, then T₂) has matrix AB. This composition interpretation explains why the definition looks the way it does.
Critical properties:
- Not commutative: AB ≠ BA in general (even when both products are defined)
- Associative: A(BC) = (AB)C
- Distributive: A(B + C) = AB + AC
- Identity: AI = IA = A
- Transpose reversal: (AB)ᵀ = BᵀAᵀ
- Inverse reversal: (AB)⁻¹ = B⁻¹A⁻¹
The determinant calculator verifies the multiplicativity property det(AB) = det(A)·det(B), useful for checking whether a product is invertible. The matrix inverse calculator demonstrates the reversal rule (AB)⁻¹ = B⁻¹A⁻¹ on concrete examples. Each entry C[i][j] is the dot product of row i of A with column j of B.
How to Use This Calculator
Set the dimensions of matrix A (rows × cols) using the dropdowns in the A panel. The number of rows in B is locked to match A's column count — this is the compatibility requirement. Set B's column count separately. Enter entries using Tab and arrow keys, then press Multiply A × B.
The result panel shows C = AB with all dimensions labeled. Expand "Show dot product calculations" to see each entry of C computed as the explicit sum of products.
Worked Example 1: 2×3 times 3×2
Let A = [[1, 2, 3], [4, 5, 6]] (2×3) and B = [[7, 8], [9, 10], [11, 12]] (3×2). C = AB is 2×2:
C[1,1] = 1·7 + 2·9 + 3·11 = 7 + 18 + 33 = 58
C[1,2] = 1·8 + 2·10 + 3·12 = 8 + 20 + 36 = 64
C[2,1] = 4·7 + 5·9 + 6·11 = 28 + 45 + 66 = 139
C[2,2] = 4·8 + 5·10 + 6·12 = 32 + 50 + 72 = 154
C = [[58, 64], [139, 154]]
Worked Example 2: Why AB ≠ BA
Let A = [[1, 2], [3, 4]] and B = [[0, 1], [1, 0]].
AB = [[1·0+2·1, 1·1+2·0], [3·0+4·1, 3·1+4·0]] = [[2, 1], [4, 3]]
BA = [[0·1+1·3, 0·2+1·4], [1·1+0·3, 1·2+0·4]] = [[3, 4], [1, 2]]
AB ≠ BA. B here is the permutation matrix that swaps rows; AB swaps the rows of A, while BA swaps the columns of A — two different operations.
Worked Example 3: Fractions in Matrix Multiplication
Let A = [[1/2, 1/3], [2/3, 1/4]] and B = [[6, 3], [4, 8]]:
C[1,1] = (1/2)(6) + (1/3)(4) = 3 + 4/3 = 13/3
C[1,2] = (1/2)(3) + (1/3)(8) = 3/2 + 8/3 = 9/6 + 16/6 = 25/6
C[2,1] = (2/3)(6) + (1/4)(4) = 4 + 1 = 5
C[2,2] = (2/3)(3) + (1/4)(8) = 2 + 2 = 4
C = [[13/3, 25/6], [5, 4]]
This calculator maintains exact fractions throughout — no rounding at any intermediate step.
When Can You Multiply Two Matrices?
A (m×n) · B (n×p) → C (m×p). The inner dimensions must match: n = n. If A is 3×4, B must have exactly 4 rows. This is the only constraint — the outer dimensions m and p can be anything.
Note that even when both AB and BA are defined (this requires m = p as well as n = n, i.e., A and B are square of the same size), they are generally not equal. Matrices that happen to satisfy AB = BA are called commuting matrices — the identity matrix commutes with everything, and diagonal matrices of the same size commute with each other.
Applications of Matrix Multiplication
Linear transformations. Composing transformations corresponds to multiplying their matrices. Rotating by θ then rotating by φ corresponds to multiplying the two rotation matrices.
Solving systems. Writing Ax = b as a matrix-vector product is the bridge between the algebraic and geometric views of linear systems.
Graph theory. If A is the adjacency matrix of a graph, Aⁿ[i][j] counts the number of paths of length n from vertex i to vertex j.
Markov chains. A transition matrix T raised to the power n gives the n-step probabilities. Computing Tⁿ by repeated matrix multiplication is the standard approach.
Neural networks. Each layer of a dense neural network computes y = Wx + b, a matrix-vector product. Training a deep network involves thousands of these products per forward pass.
Powers of Matrices and Matrix Exponentiation
The n-th power Aⁿ is A multiplied by itself n times. Powers appear in Markov chains (Tⁿ gives n-step transition probabilities), graph theory (Aⁿ[i][j] counts paths of length n between vertices i and j), and differential equations (the matrix exponential eᴬᵗ = Σ (At)ⁿ/n! solves linear ODEs).
Computing Aⁿ naively takes n−1 multiplications. Exponentiation by squaring reduces this to O(log n): compute A², A⁴, A⁸, … and multiply together the powers corresponding to set bits of n in binary. For n = 100, that is 8 multiplications instead of 99.
A = [[1,1],[1,0]] (Fibonacci matrix: Aⁿ[0][1] = Fibonacci(n))
A² = [[2,1],[1,1]], A⁴ = [[5,3],[3,2]], A⁸ = [[34,21],[21,13]]
A^10 = A⁸·A² = [[89,55],[55,34]] → Fib(10) = 55 ✓
Block Matrix Multiplication
Large matrices can be partitioned into blocks and multiplied block by block, following the same rule as scalar entries. For conformably partitioned matrices:
[[A₁₁, A₁₂], [A₂₁, A₂₂]] · [[B₁₁, B₁₂], [B₂₁, B₂₂]]
= [[A₁₁B₁₁+A₁₂B₂₁, A₁₁B₁₂+A₁₂B₂₂],
[A₂₁B₁₁+A₂₂B₂₁, A₂₁B₁₂+A₂₂B₂₂]]
Block multiplication enables parallel computation (each block product is independent), cache-efficient algorithms (BLAS routines tile matrices into blocks that fit in CPU cache), and elegant proofs (the Schur complement D − CA⁻¹B arises naturally from block multiplication and appears in the conditional covariance of Gaussian distributions and in LDU decompositions).
Matrix Multiplication and Linear Transformations
Every m×n matrix A defines a linear transformation T: ℝⁿ → ℝᵐ by T(x) = Ax. Composing two transformations T₁ (matrix A, applied first) and T₂ (matrix B) gives T₂∘T₁ with matrix BA — the order reversal explains why AB ≠ BA in general.
This interpretation makes matrix properties immediate: the identity matrix I is the identity transformation; an invertible A is a bijection; a singular A collapses at least one dimension (its null space is non-trivial). The rank of AB satisfies rank(AB) ≤ min(rank(A), rank(B)) — multiplying can only lose information, never create it. Use the RREF calculator to find the rank of any matrix, and our linear algebra basics guide to connect rank to the geometry of linear transformations.
Computational Complexity: Strassen's Algorithm
The naïve n×n matrix multiplication algorithm takes O(n³) operations. Strassen's algorithm (1969) reduced this to O(n^2.807) by computing a 2×2 product with 7 multiplications instead of 8, applied recursively. For n = 1000, this is roughly a 4–5× speedup.
Modern research has pushed the theoretical exponent lower — the current best is approximately O(n^2.37) (LeGall and Urrutia, 2024). Whether O(n²) is achievable remains one of the great open problems in theoretical computer science. Practically, all high-performance libraries (NumPy, MATLAB, cuBLAS) use Strassen variants for large n, and fall back to naïve multiplication for small blocks where the overhead of Strassen isn't worth it.
This matrix multiplication calculator computes exact results for small matrices using the straightforward dot-product formula. For large-scale computation, use optimized numerical libraries.
Frequently Asked Questions
Does matrix multiplication commute?
No, in general AB ≠ BA. Even if both products are defined and the same size, they can differ.
What dimensions does the result have?
If A is m×n and B is n×p, then AB is m×p. The inner dimensions (n) must match; the outer dimensions (m, p) determine the result size.
Can I multiply a non-square matrix by itself?
You can only square a matrix A if A is square (same number of rows and columns). For a non-square m×n matrix with m ≠ n, A·A is not defined.
Is there an entry-wise matrix multiplication?
Yes, it is called the Hadamard product or element-wise product, written A ⊙ B. It requires A and B to have exactly the same dimensions.
What is a zero matrix?
A matrix of all zeros. Multiplying any matrix by the zero matrix gives the zero matrix — analogous to multiplying by 0, but note that AB = 0 does not necessarily mean A = 0 or B = 0.
How is matrix multiplication related to RREF?
Gaussian and Gauss-Jordan elimination can be expressed as left-multiplication by elementary matrices. The product of these elementary matrices equals the overall transformation applied to A.
Can I use fractions in the input?
Yes. Enter entries like "3/4" or "-2/5" and the calculator handles them exactly.
Is this free?
Yes, completely free with no account required.