Matrix Multiplication

Compute \(C=AB\) and inspect each result cell's dot product.

A 2x3 x B 3x2 = C 2x2 8 multiply-add terms

Matrix A

2 rows x 3 columns

Matrix B

3 rows x 2 columns

Operation

A has 3 columns and B has 3 rows. The matrices are compatible.

Ready.

Result C

2 rows x 2 columns

Dot product preview Run multiplication to see how a result cell is formed.

Geometric composition

See the same square at every step: B acts first, then A acts on B's result.

Transformed unit square First basis vector e₁ Second basis vector e₂

Choose the 2D geometry preset to visualize two 2×2 transformations.

How to read the product

Each output cell is a dot product: one row from A paired with one column from B. Select a result cell after multiplying to inspect its arithmetic.

Output shape: —Dot products: —Terms per cell: —Scalar operations: —

📚 Mathematical Background

🔢 Matrix Multiplication - Introduction

Matrix multiplication is a fundamental operation in linear algebra that combines two matrices to produce a third matrix. Unlike scalar multiplication, matrix multiplication is not element-wise; instead, it involves a systematic combination of rows and columns.

This operation is essential for representing compositions of linear transformations, solving systems of equations, and modeling complex relationships in science, engineering, and computer graphics.

📐 Mathematical Definition

Given two matrices A (m×n) and B (n×p), their product C = AB is an (m×p) matrix where each element is:

\[C_{ij}=\sum_{k=1}^{n}A_{ik}B_{kj}\]

In other words, element C[i,j] is computed by taking the dot product of the i-th row of matrix A and the j-th column of matrix B.

Dimension Compatibility: For AB to be defined, columns in A must equal rows in B.

⚙️ Properties of Matrix Multiplication

Matrix multiplication has several important properties:

  • Associativity: (AB)C = A(BC)
  • Distributivity: A(B + C) = AB + AC
  • Non-Commutativity: AB ≠ BA in general - order matters!
  • Identity: AI = IA = A for identity matrix I
  • Transpose: (AB)T = BTAT

🌟 Geometric Interpretation

Matrix multiplication represents composition of linear transformations:

  • Each matrix represents a transformation (rotation, scaling, etc.)
  • Product AB means: apply B first, then A
  • This explains why AB ≠ BA
  • Used in 3D graphics for transformations

🔬 Applications

  • Computer Graphics: 3D transformations and rendering
  • Neural Networks: Deep learning computations
  • Quantum Mechanics: State evolution
  • Markov Chains: Probability transitions
  • Robotics: Kinematics calculations
  • Graph Theory: Path counting

💻 Computational Complexity

Standard algorithm for n×n matrices: O(n³) operations.

Optimizations:

  • Strassen's Algorithm: O(n2.807)
  • GPU acceleration for parallel processing
  • Sparse matrix methods

⚠️ Common Mistakes

  • Dimension mismatch (columns of A must equal rows of B)
  • Assuming AB = BA (it's not commutative!)
  • Confusing with element-wise multiplication

Tips: Always check dimensions first: (m×n) × (n×p) → (m×p)