Matrix Multiplication Calculator

Multiply two matrices of compatible size and get every entry of the product matrix, computed step by step from the row-by-column dot product formula.

Quick Facts

Compatibility rule
cols(A) = rows(B)
The product AB is only defined when A's column count matches B's row count.
Result size
rows(A) × cols(B)
An m×n matrix times an n×p matrix gives an m×p product matrix.
Entry formula
C[i,j] = Σ A[i,k]·B[k,j]
Each entry is the dot product of a row of A with a column of B.
Not commutative
AB ≠ BA (generally)
Swapping the order usually changes the result, or makes the product undefined.

Your Results

Calculated
Product Matrix C = A×B
-
Rows separated by " | ", entries by commas
Dimensions of C
-
rows(A) × cols(B)
Sum of all entries
-
Sum of every value in C
Trace of C
-
Sum of the main diagonal (square matrices only)

Ready

Set your matrix dimensions, enter values, then press Calculate.

How Matrix Multiplication Works

Matrix multiplication combines two matrices, A and B, into a new matrix C = AB. Unlike adding matrices, you cannot just multiply entries in the same position — the product is only defined when the number of columns in A equals the number of rows in B. If A is an m×n matrix and B is an n×p matrix, the product C is an m×p matrix, and every entry of C is a dot product of a row from A and a column from B.

The formula and method

Each entry of the product is given by C[i,j] = A[i,1]·B[1,j] + A[i,2]·B[2,j] + ... + A[i,n]·B[n,j], written compactly as C[i,j] = Σₖ A[i,k]·B[k,j]. In words: to get the entry in row i, column j of the result, walk along row i of A and down column j of B at the same time, multiply the paired values, and add them up. For example, multiplying a 2×2 matrix A = [[1,2],[3,4]] by B = [[5,6],[7,8]] gives C[1,1] = 1×5 + 2×7 = 19, C[1,2] = 1×6 + 2×8 = 22, C[2,1] = 3×5 + 4×7 = 43, and C[2,2] = 3×6 + 4×8 = 50, so C = [[19,22],[43,50]].

Common mistakes

  • Ignoring the dimension rule: multiplication AB is undefined unless columns(A) = rows(B); a 2×3 matrix can multiply a 3×2 matrix, but not another 2×3 matrix.
  • Assuming commutativity: in general AB ≠ BA — matrix order matters, and reversing the order can change the result or make the product undefined entirely.
  • Confusing it with entrywise multiplication: matrix multiplication is not the same as multiplying corresponding entries (the Hadamard product); it uses row-by-column dot products instead.

Real-world applications

  • Computer graphics use matrix multiplication to rotate, scale, and translate 2D and 3D objects by chaining transformation matrices.
  • Systems of linear equations can be written and solved as Ax = b, where matrix multiplication maps an input vector x to an output vector b.
  • Neural networks compute each layer's output by multiplying an input vector or matrix by a weight matrix, then applying an activation function.
  • Markov chains multiply a state vector by a transition matrix repeatedly to project how probabilities evolve over time.

Frequently Asked Questions

When can two matrices be multiplied?
Matrix A can be multiplied by matrix B only when the number of columns in A equals the number of rows in B. If A is m×n and B is n×p, the product AB exists and is an m×p matrix.
How is each entry of the product matrix calculated?
Entry C[i,j] of the product is the dot product of row i of A and column j of B: multiply corresponding entries and add them up, C[i,j] = A[i,1]B[1,j] + A[i,2]B[2,j] + ... + A[i,n]B[n,j].
Is matrix multiplication commutative?
No. In general AB ≠ BA. The order of multiplication matters, and BA may not even be defined if the dimensions do not line up the other way.
What size is the resulting matrix?
The product of an m×n matrix and an n×p matrix is always an m×p matrix — it takes its row count from the first matrix and its column count from the second.