Matrix Multiplication Calculator

Multiply matrices A*B for 2x2, 3x3, and non-square (mxp * pxn) cases. Shows step-by-step dot products, tests commutativity AB vs BA, demonstrates the identity matrix, and explains applications in graphics and neural networks.

C[1,1]
C[1,2]
C[2,1]
C[2,2]
C = A*B
Extended More scenarios, charts & detailed breakdown
A*B
B*A (check commutativity)
AB = BA?
Professional Full parameters & maximum detail

Products & Commutativity

A*B
B*A
Associativity note

Identity & Applications

Identity check A*I
Applications

How to Use This Calculator

  1. Enter matrices A and B (2x2) — product appears instantly.
  2. Use 3x3 tab for larger square matrices.
  3. Use Non-Square tab for mxp * pxn products.
  4. Professional shows AB vs BA and identity checks.

Formula

C[i,j] = sum_k A[i,k] * B[k,j]

Dimensions: (m×p) * (p×n) = (m×n)

Example

A=[[1,2],[3,4]], B=[[5,6],[7,8]]: C[1,1]=1*5+2*7=19, C[1,2]=1*6+2*8=22, C[2,1]=41, C[2,2]=50.

Frequently Asked Questions

  • To multiply matrix A (m×p) by matrix B (p×n), the number of columns in A must equal the number of rows in B. The result C is m×n, where each entry C[i,j] = sum of A[i,k]×B[k,j] for k = 1 to p — i.e., the dot product of row i of A with column j of B. Example: A = [[1,2],[3,4]] and B = [[5,6],[7,8]]. C[1,1] = 1×5 + 2×7 = 19; C[1,2] = 1×6 + 2×8 = 22; C[2,1] = 3×5 + 4×7 = 43; C[2,2] = 3×6 + 4×8 = 50. Common pitfall: trying to multiply a 2×3 matrix by a 2×3 matrix — the inner dimensions must match (3 = 2 fails here), so this multiplication is undefined.
  • No — matrix multiplication is generally not commutative, meaning AB ≠ BA. Even for square matrices of the same size, AB and BA produce different results. Example: A = [[1,2],[0,1]] and B = [[1,0],[1,1]]. AB = [[3,2],[1,1]] but BA = [[1,2],[2,3]] — clearly different. Additionally, if A is m×p and B is p×n with m ≠ n, then AB has dimensions m×n while BA is undefined (dimensions don't match). Commutativity only holds in special cases: diagonal matrices, scalar multiples of the identity, or when AB = BA happens to be true for a specific pair. Always check whether order matters in your computation.
  • Yes — matrix multiplication is always associative: (AB)C = A(BC) for any compatible dimensions. This means the grouping of multiplications does not change the final result, though it can dramatically affect computational cost. Example: if A is 1000×2, B is 2×1000, and C is 1000×2. Computing (AB)C requires multiplying a 1000×1000 intermediate matrix, while A(BC) first computes a 2×2 matrix and then a 1000×2 result — far cheaper. This "optimal matrix chain order" is a classic dynamic programming problem in computer science. A common misconception is thinking associativity implies commutativity — they are separate properties and AB can still differ from BA.
  • Multiplying any matrix A by the identity matrix I leaves A unchanged: AI = IA = A. The identity matrix has 1s on the main diagonal and 0s everywhere else. For 2×2: I = [[1,0],[0,1]]. Example: A = [[3,5],[2,7]]. A × I = [[3×1+5×0, 3×0+5×1],[2×1+7×0, 2×0+7×1]] = [[3,5],[2,7]] = A ✓. The identity matrix is the multiplicative neutral element in matrix algebra, analogous to 1 in scalar multiplication. A common pitfall is using the wrong size identity matrix — when multiplying A (m×n) on the right, you need Iₙ (n×n); multiplying on the left requires Iₘ (m×m).
  • Matrix multiplication is one of the most widely used operations in applied mathematics. In 3D computer graphics, transformation matrices are multiplied together to combine rotation, scaling, and translation — your GPU performs billions of these per second. In neural networks, each layer computes W×x + b, where W is the weight matrix and x is the input vector. In Markov chains, the transition matrix T raised to the power n (via repeated multiplication) gives the n-step transition probabilities. In quantum computing, applying gates corresponds to multiplying unitary matrices. A common pitfall in programming is accidentally transposing a matrix before multiplication — row-major vs. column-major storage differences in languages like C, MATLAB, and NumPy can silently produce wrong results.

Related Calculators

Sources & References (5)
  1. Introduction to Linear Algebra — Gilbert Strang — Wellesley-Cambridge Press
  2. OpenStax Precalculus — Matrix Multiplication — OpenStax
  3. MIT OCW 18.06 — Multiplication and Inverse Matrices — MIT OpenCourseWare
  4. Khan Academy — Matrix Multiplication — Khan Academy
  5. NIST DLMF Chapter 1 — Algebraic Methods — NIST