ALGEBRALinear AlgebraMathematics Calculator
📐

Matrix Multiplication

Matrix multiplication combines two matrices A and B to produce C = AB. Each element C[i][j] is the dot product of row i of A and column j of B. The inner dimensions must match: A (m×n) × B (n×p) yields C (m×p).

Concept Fundamentals
A_{m×n} × B_{n×p} = C_{m×p}
Dimensions
C_{ij} = Σ A_{ik}B_{kj}
Element
O(mnp)
Complexity
AB ≠ BA
Non-commutative

Did our AI summary help? Let us know.

Neural layers apply Wx + b — matrix-vector multiplication. Strassen algorithm: O(n^2.81) vs naive O(n³). Identity matrix I satisfies AI = IA = A.

Key quantities
A_{m×n} × B_{n×p} = C_{m×p}
Dimensions
Key relation
C_{ij} = Σ A_{ik}B_{kj}
Element
Key relation
O(mnp)
Complexity
Key relation
AB ≠ BA
Non-commutative
Key relation

Ready to run the numbers?

Why: Matrix multiplication underpins neural networks, graphics transforms, and Markov chains. Understanding row-by-column dot products is essential for linear algebra.

How: Compute each C[i][j] by taking row i of A, column j of B, multiplying element-wise and summing. Use dimension compatibility to validate before computing.

Neural layers apply Wx + b — matrix-vector multiplication.Strassen algorithm: O(n^2.81) vs naive O(n³).

Run the calculator when you are ready.

Multiply MatricesEnter matrices A and B; cols of A must equal rows of B

Quick Examples — Click to Load

Matrix A

Matrix B

Matrix A (2×2)

Matrix B (2×2)

For educational and informational purposes only. Verify with a qualified professional.

🧮 Fascinating Math Facts

AB is associative: (AB)C = A(BC)

📊

Row × column = scalar; column × row = outer product

Key Takeaways

  • • Matrix multiplication is non-commutative: AB ≠ BA in general.
  • Dimension compatibility: A (m×n) × B (n×p) → C (m×p). A's columns must equal B's rows.
  • • Matrix multiplication is associative: (AB)C = A(BC).
  • • Each element C[i][j] is the dot product of row i of A and column j of B.
  • • The identity matrix I satisfies AI = IA = A for compatible square matrices.

Did You Know?

The Strassen algorithm (1969) multiplies n×n matrices in O(n^2.81) time, faster than the naive O(n³).Source: Algorithm Theory
🧠Neural networks are essentially chains of matrix multiplications: each layer applies Wx + b.Source: Deep Learning
📊Markov chains use transition matrices; multiplying by the state vector gives the next state.Source: Probability
🎮3D graphics use 4×4 matrices for transformations; composing rotations and translations is matrix multiplication.Source: Computer Graphics
⏱️Naive matrix multiplication is O(mnp) for m×n × n×p. For square n×n, that's O(n³).Source: Complexity
⚛️Quantum computing uses matrix multiplication on state vectors; gates are unitary matrices.Source: Quantum Computing

How Matrix Multiplication Works

Matrix multiplication uses row-by-column dot products. For C = A × B:

Formula

C[i][j] = Σ A[i][k] · B[k][j]

Take row i of A and column j of B. Multiply corresponding elements and sum.

Example: C[1,1]

For a 2×2 case: C[1,1] = A[1,1]·B[1,1] + A[1,2]·B[2,1]. The "inner" dimension (columns of A, rows of B) must match.

Expert Tips

Check Dimensions First

Before multiplying, verify cols(A) = rows(B). Otherwise the operation is undefined.

Order Matters

AB ≠ BA in general. Think of matrices as linear maps: applying B then A is different from A then B.

Row × Column = Dot Product

Each result element is a dot product. A 1×n row times an n×1 column gives a scalar.

Use Identity for Checks

Multiply by I to verify: AI = A and IA = A. Great for debugging.

This Calculator vs MATLAB vs Manual

FeatureThis CalculatorMATLABManual
Step-by-step dot products⚠️
Dimension validation⚠️
Bar chart visualization
Educational content
No installation

Frequently Asked Questions

Why isn't matrix multiplication commutative?

Matrix multiplication represents composition of linear transformations. Applying transformation B then A generally gives a different result than A then B. So AB ≠ BA in general.

When can two matrices be multiplied?

A (m×n) and B (p×q) can be multiplied as AB only if n = p. The result is m×q.

What is the dot product in matrix multiplication?

Each element C[i][j] is the dot product of row i of A and column j of B: C[i][j] = Σ A[i][k]·B[k][j].

What is the identity matrix?

The n×n identity I has 1s on the diagonal and 0s elsewhere. For any compatible A, AI = IA = A.

What is the computational complexity?

Naive multiplication of m×n by n×p is O(mnp). For square n×n matrices, that's O(n³).

Can I multiply a row vector by a column vector?

Yes! A 1×n row times an n×1 column gives a 1×1 matrix (a scalar) — that's the dot product.

What about column times row?

An n×1 column times a 1×m row gives an n×m matrix — the outer product.

Is (AB)C = A(BC)?

Yes. Matrix multiplication is associative, so you can compute AB first then multiply by C, or BC first then multiply by A.

Matrix Multiplication at a Glance

m×n × n×p
Dimensions
O(n³)
Naive Complexity
AB ≠ BA
Non-commutative
(AB)C=A(BC)
Associative

Sources

Disclaimer: This calculator is for educational purposes. Results use JavaScript floating-point arithmetic. For production or research, use specialized libraries (NumPy, MATLAB) for numerical stability. Always verify critical calculations independently.

👈 START HERE
⬅️Jump in and explore the concept!
AI

Related Calculators