Solved.tools — Free Online Calculators & Tools

We use cookies for analytics and advertising. Learn more about our cookie policy

Matrix Multiplication Calculator

Last updated: 21 August 2026

Reviewed by Gavin · Research and drafting assisted by AI

Matrix Multiplication Calculator

Multiply any two matrices A (m×n) and B (n×p) to get C = A × B (m×p), with the row × column dot-product shown step by step for every cell.

rows×cols
dim(A) = 2 × 3
rows×cols
dim(B) = 3 × 2
C = A × B  ·  dim(C) = 2 × 2
5864
139154
dim(A)
2 × 3
dim(B)
3 × 2
inner match
yes
dim(C)
2 × 2

Step-by-step: each cell of C

C[1,1] = row 1(A) · column 1(B)
= (1)·(7) + (2)·(9) + (3)·(11)
= 1·7 + 2·9 + 3·11
= 58
C[1,2] = row 1(A) · column 2(B)
= (1)·(8) + (2)·(10) + (3)·(12)
= 1·8 + 2·10 + 3·12
= 64
C[2,1] = row 2(A) · column 1(B)
= (4)·(7) + (5)·(9) + (6)·(11)
= 4·7 + 5·9 + 6·11
= 139
C[2,2] = row 2(A) · column 2(B)
= (4)·(8) + (5)·(10) + (6)·(12)
= 4·8 + 5·10 + 6·12
= 154

Presets

Reference

Definition: C = A × B is defined only when cols(A) = rows(B). If A is m×n and B is n×p then C is m×p.
Entry formula: C[i][j] = Σk A[i][k] · B[k][j] (row i of A dotted with column j of B).
Identity: In is the n×n matrix with 1s on the diagonal and 0s elsewhere; A · I = I · A = A.
Not commutative: in general A × B ≠ B × A. Even when both are defined the products usually differ.
Source: standard linear algebra (Strang, Introduction to Linear Algebra, MIT Press; Axler, Linear Algebra Done Right).
Was this helpful?


Matrix Multiplication Calculator

The matrix product C = A × B is one of the most important operations in linear algebra, and it shows up in everything from solving systems of equations to rendering 3D scenes, training neural networks and simulating rigid-body physics. This calculator multiplies any two matrices A and B whose inner dimensions match (cols of A = rows of B), displays the result matrix C, and expands every entry C[i][j] as the dot product of row i of A with column j of B.

If A is m × n and B is n × p, then C = A × B is m × p and each entry is C[i][j] = Σ A[i][k] · B[k][j]. When the inner dimensions do not match the calculator shows a clear "dimension mismatch" error rather than silently producing garbage, that single rule (cols of A must equal rows of B) is the gate every matrix multiplication must pass.

How to Use

  1. Set the dimensions of A, use the rows and cols inputs (1 to 10 each) above the first matrix. The cells appear or disappear to match.
  2. Set the dimensions of B, same idea; the second matrix's cells update automatically.
  3. Type the values into every cell of A and B. Any real number works, including negatives and decimals.
  4. Read the result, the blue result block shows C with dim(C) = m × p. Below it, the "Step-by-step" section expands each cell as "row i(A) · column j(B) = … = result".
  5. Use the presets for one-click loads: identity, textbook 2×2, non-square 2×3 × 3×2, row × column dot product, column × row outer product, tall × wide, and negative values.

The Formula

Matrix multiplication is defined by one entrywise formula. For A (m × n) and B (n × p):

C[i][j] = Σ_{k=0..n-1}  A[i][k] · B[k][j]

In words: take row i of A, take column j of B, multiply the corresponding entries together, and sum those products. That sum is the single number C[i][j]. Doing this for every (i, j) pair produces the m × p matrix C.

                �       ┐
C[i][j]  =  A[i]│  ·  │  B[:, j]
                └       ┘
   (dot product of two vectors of length n)

The product is only defined when the inner dimensions match (cols of A = rows of B). When they do not match, the multiplication is undefined and any tool that returns a value is wrong.

Worked Examples

Example 1, Textbook 2 × 2. 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] = 3·5 + 4·7 = 43. C[2,2] = 3·6 + 4·8 = 50. Result: [[19, 22], [43, 50]].

Example 2, Non-square 2 × 3 × 3 × 2. A = [[1, 2, 3], [4, 5, 6]], B = [[7, 8], [9, 10], [11, 12]]. C[1,1] = 1·7 + 2·9 + 3·11 = 58. C[1,2] = 1·8 + 2·10 + 3·12 = 64. C[2,1] = 4·7 + 5·9 + 6·11 = 139. C[2,2] = 4·8 + 5·10 + 6·12 = 154. Result: [[58, 64], [139, 154]], note dim(C) = 2 × 2.

Example 3, Row × column dot product. A = [[1, 2, 3]] (a 1 × 3 row vector), B = [[4], [5], [6]] (a 3 × 1 column vector). The only product that fits is 1 × 1, and C[1,1] = 1·4 + 2·5 + 3·6 = 32. That single number is the dot product of the two vectors.

Example 4, Column × row outer product. A = [[1], [2], [3]] (3 × 1), B = [[10, 20, 30, 40]] (1 × 4). The product is 3 × 4 and every entry is A[i,1] · B[1,j]: C = [[10, 20, 30, 40], [20, 40, 60, 80], [30, 60, 90, 120]]. This is the outer product, every element of A scales every column of B.

Example 5, Identity matrix. I₃ × A = A for any 3 × n matrix A. The identity matrix Iₙ has 1s on the main diagonal and 0s elsewhere; multiplying by it leaves the other matrix unchanged. This is the matrix equivalent of multiplying by 1.

Where It Shows Up

  • Linear algebra, solving Ax = b, change of basis, eigendecompositions, rank and null-space computations all reduce to repeated matrix multiplication.
  • AI / machine learning, a fully-connected neural-network layer is exactly a matrix product: outputs = weights × inputs + bias. Transformers (the architecture behind modern LLMs) are dominated by matrix multiplications called "matmul" or "GEMM".
  • Computer graphics, every 3D rotation, scaling, shear and projection is a 4 × 4 matrix product. Vertex transformations in OpenGL and DirectX apply the model, view and projection matrices in sequence.
  • Physics simulations, rigid-body dynamics, finite-element analysis and quantum-mechanics state evolution all evolve in time by repeatedly applying a matrix to a state vector.
  • Signal processing and statistics, covariance matrices, principal-component analysis and the discrete Fourier transform all lean on matrix products.
  • Economics and finance, input-output models (Leontief), portfolio variance (wᵀΣw), and Markov-chain transitions are matrix products.

Common Mistakes

  • Transposing one matrix by accident. Matrix multiplication is not commutative: A × B is generally not equal to B × A. If the dimensions of one product are valid and the other is not, they cannot even be compared.
  • Ignoring the inner-dimension rule. If cols(A) ≠ rows(B), the product is undefined. The calculator will block the calculation and tell you which dimension to change, never try to "just multiply anyway".
  • Mixing up rows and columns. C[i][j] uses row i of A and column j of B. If you swap the meaning you get the wrong answer (in fact you get the (j, i) entry of Cᵀ if A and B happen to be the right shape).
  • Treating element-wise multiplication as matrix multiplication. The Hadamard product (A ⊙ B) is a different operation that requires A and B to be the same shape and multiplies entry by entry. Matrix multiplication is the row-times-column sum.
  • Forgetting that the identity matrix is square. I exists in only one size per dimension; you cannot multiply a 2 × 3 matrix by a 2 × 2 identity and get the same matrix back.

Frequently Asked Questions

What does it mean to multiply two matrices? Multiplying A and B means taking the dot product of every row of A with every column of B. The dot product of two vectors of length n is just the sum of the entry-by-entry products a₁b₁ + a₂b₂ + … + aₙbₙ, so each entry of C is one such sum. Geometrically, it composes two linear transformations: if A rotates and B scales, then A × B does both in one go.

Can any two matrices be multiplied? No. The product A × B is only defined when the number of columns of A equals the number of rows of B. When that is true and A is m × n and B is n × p, the result is m × p. If the inner dimensions do not match, the operation is mathematically undefined, this is the rule the calculator enforces.

Is matrix multiplication the same as element-wise multiplication? No. Element-wise (Hadamard) multiplication, written A ⊙ B, multiplies entry by entry and requires the two matrices to have the same shape. Matrix multiplication, written A × B or simply AB, multiplies rows by columns and produces a different-shaped result. They are completely different operations and have different formulas, different identities and different uses.

What is the identity matrix? The identity matrix Iₙ is the n × n matrix with 1s on the main diagonal and 0s everywhere else. It is the multiplicative identity: A × I = I × A = A whenever the dimensions match. Think of it as the matrix equivalent of the number 1. Any matrix multiplied by I (on either side, in the appropriate size) is unchanged.

What does the inverse of a matrix do? The inverse A⁻¹ of a square matrix A is the unique matrix that satisfies A × A⁻¹ = A⁻¹ × A = I. Multiplying by A⁻¹ "undoes" the conversion applied by A, useful for solving Ax = b because x = A⁻¹b. Not every square matrix has an inverse; a matrix is invertible if and only if its determinant is non-zero, in which case it is called non-singular.

Why is matrix multiplication so important in AI? A single layer of a neural network is just a matrix product followed by a non-linear activation function: output = σ(weights × inputs + bias). Modern transformer models stack hundreds of these layers, and the bulk of the training compute is spent on "matmul" kernels, highly optimised matrix-multiplication routines running on GPUs. The "tensor" in TensorFlow and PyTorch is just a multi-dimensional array, and the most common operation on it is batched matrix multiplication.

Q: Can the Matrix Multiplication Calculator, A × B Step by Step be used for professional or commercial purposes? A: Yes, the Matrix Multiplication Calculator, A × B Step by Step provides mathematically correct results that are suitable for professional, commercial, and educational use. For the Matrix Multiplication Calculator, A × B Step by Step, For the Matrix Multiplication Calculator, A × B Step by Step, For high-stakes applications (medical, legal, financial), verify results with a domain expert. For the Matrix Multiplication Calculator, A × B Step by Step, the Matrix Multiplication Calculator, A × B Step by Step formulas used are well-established and validated against reference standards.

Q: How often are the Matrix Multiplication Calculator, A × B Step by Step formulas updated? A: the Matrix Multiplication Calculator, A × B Step by Step formulas are based on established scientific, mathematical, or industry-standard references and rarely require updates. when standards change, the Matrix Multiplication Calculator, A × B Step by Step is updated to reflect the current authoritative source.

References

  • Strang, G. (2016). Introduction to Linear Algebra, 5th ed., Wellesley-Cambridge Press. Standard textbook definition of matrix multiplication.
  • Axler, S. (2015). Linear Algebra Done Right, 3rd ed., Springer. Proof-oriented treatment of linear maps and matrix representations.
  • Golub, G. H., & Van Loan, C. F. (2013). Matrix Computations, 4th ed., Johns Hopkins University Press. Algorithms for matrix multiplication and numerical considerations.
  • NIST Handbook of Mathematical Functions (DLMF), Chapter on Linear Algebra. Public reference for standard matrix identities.