Matrix Multiplication Calculator

Multiply two matrices of compatible dimensions instantly — get the product matrix with automatic dimension validation for linear algebra and engineering.

Enter Matrix A and Matrix B using semicolons for rows and commas for columns, then click Calculate to compute their product.

Matrix Multiplication Calculator
Multiply two matrices of compatible dimensions instantly — get the product matrix with automatic dimension validation for linear algebra and engineering.

Separate rows with semicolons (;) and columns with commas (,). For A × B, the number of columns in A must equal the number of rows in B.

About the matrix multiplication calculator

Matrix multiplication is one of the central operations of linear algebra. Unlike addition, which simply combines corresponding elements, multiplication is defined by a dot-product rule that links rows of the first matrix with columns of the second. The result encodes how two linear transformations compose — applying B first and then A produces the same effect as applying the single matrix AB. For the product A × B to be defined, the number of columns in A must equal the number of rows in B. If A is an m×n matrix and B is an n×p matrix, the product C = A × B is an m×p matrix. The entry C[i][j] is computed as the dot product of row i of A with column j of B: C[i][j] = Σ(k=0 to n−1) A[i][k] × B[k][j]. This means every entry in the result depends on an entire row from A and an entire column from B. Matrix multiplication is not commutative: AB ≠ BA in general, and BA may not even be defined if the dimensions of A and B do not allow it. It is, however, associative: (AB)C = A(BC), which means you can group a chain of multiplications in any order without changing the final result. Multiplying by the identity matrix leaves any matrix unchanged: AI = IA = A. This mirrors the role that 1 plays in ordinary multiplication. The identity matrix has 1 on the main diagonal and 0 everywhere else. In applications, matrix multiplication compresses a wide variety of computations into a compact notation. Computer graphics uses matrix multiplication to apply rotations, translations, and perspective projections to 3D coordinates. Robotics uses chains of rotation matrices to transform between coordinate frames. In machine learning, the forward pass of a neural network layer is essentially a matrix-vector multiplication: output = W × input + bias. Markov chains, graph adjacency calculations, and covariance propagation in statistics all rely on matrix multiplication. Understanding matrix multiplication is therefore an essential skill for anyone working in a quantitative field.

Matrix multiplication examples

Four examples showing square and non-square matrix products with step-by-step element calculations.

InputProductNotes
A = [[1,2],[3,4]], B = [[2,0],[1,2]][[4,4],[10,8]]C[0][0] = 1×2 + 2×1 = 4. C[0][1] = 1×0 + 2×2 = 4. C[1][0] = 3×2 + 4×1 = 10. C[1][1] = 3×0 + 4×2 = 8.
A = [[1,2,3]], B = [[4],[5],[6]][[32]]A is 1×3 and B is 3×1. The product is 1×1: 1×4 + 2×5 + 3×6 = 4+10+18 = 32. This is the dot product of the two vectors.
A = [[1,0],[0,1]], B = [[7,3],[2,8]][[7,3],[2,8]]Multiplying by the 2×2 identity matrix returns B unchanged. The identity is the multiplicative neutral element for matrix multiplication.
A = [[1,2],[3,4],[5,6]], B = [[7,8,9],[10,11,12]][[27,30,33],[61,68,75],[95,106,117]]A is 3×2 and B is 2×3, so the product is 3×3. C[0][0] = 1×7 + 2×10 = 27. C[2][2] = 5×9 + 6×12 = 45+72 = 117.

How to use the matrix multiplication calculator

  1. Enter Matrix A in the first field. Use commas to separate elements in a row and semicolons to separate rows. For example, 1,2;3,4 represents [[1,2],[3,4]].
  2. Enter Matrix B in the second field using the same format. For the multiplication A × B to work, the number of columns in A must equal the number of rows in B.
  3. Click Calculate. The product matrix C = A × B is displayed below, with dimensions equal to (rows of A) × (columns of B).
  4. Verify a single entry by hand if needed: pick any position [i][j] in the result and compute the dot product of row i of A with column j of B.
  5. Click Reset to clear both inputs and start a new calculation, or modify either matrix to explore how changes affect the product.

Frequently asked questions

When can two matrices be multiplied?
Two matrices A and B can be multiplied (as A × 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 exists and is an m×p matrix. If this inner dimension condition is not met, the multiplication is undefined.
Is matrix multiplication commutative?
No. In general, AB ≠ BA, even when both products are defined. For example, if A represents a rotation and B represents a shear, applying them in different orders produces different results. This non-commutativity is one of the defining characteristics of matrix algebra that distinguishes it from ordinary number arithmetic.
What is the identity matrix?
The identity matrix I is a square matrix with 1 on the main diagonal and 0 everywhere else. Multiplying any matrix A by I always returns A unchanged: AI = IA = A. The identity matrix plays the same role in matrix multiplication that the number 1 plays in scalar multiplication.
How is matrix multiplication used in machine learning?
In neural networks, the forward pass through a fully connected layer is computed as output = W × input + bias, where W is the weight matrix and input is a column vector. During backpropagation, gradients are propagated using transpose matrix multiplications. Batched computations extend this to matrix-matrix multiplication, making GPUs highly efficient for neural network training.
What is the difference between element-wise and matrix multiplication?
Element-wise multiplication (the Hadamard product) multiplies corresponding elements of two matrices of the same size: (A ⊙ B)[i][j] = A[i][j] × B[i][j]. Matrix multiplication uses dot products of rows and columns: (AB)[i][j] = Σ A[i][k] × B[k][j]. They are different operations with different requirements and different results.
Can non-square matrices be multiplied?
Yes. Non-square matrices can be multiplied as long as the inner dimensions match. For example, a 2×3 matrix times a 3×4 matrix produces a 2×4 matrix. The result matrix has the row count of the first matrix and the column count of the second. Non-square products are very common in practice — for instance, a batch of input vectors (n×d) multiplied by a weight matrix (d×k) produces the layer outputs (n×k).