Skip to content

Matrix Multiplication

The ordered contraction of compatible matrices, producing cᵢⱼ=Σₖaᵢₖbₖⱼ and representing composition of linear transformations.

Version
v2 · 2026-11-14 · History
Domain-specific #
10614
Domain group
Formal Sciences
Origin domain
Mathematics
Subdomains
Linear Algebra, Matrix Operations → Mathematics
Aliases
Matrix product

Core Idea

For A of shape m×n and B of shape n×p, AB has shape m×p. Each entry sums products between one row of A and one column of B across n intermediate coordinates.

The formula expresses linear-map composition: B acts first and A second. This explains associativity and typical noncommutativity, while implementations can vary without changing the operation.

How would you explain it like I'm…

Two Machines in a Row

Think of two machines in a row. The first one changes your toy a bit, then the second changes it some more. Matrix multiplication is a way to make one grid of numbers that does both machines' jobs at once. Putting the machines in a different order usually gives a different result.

Row-Times-Column Rule

A matrix is a grid of numbers. To multiply two matrices, you take a row from the first and a column from the second, multiply matching numbers, and add them up; that gives one spot in the answer. The first matrix needs as many columns as the second has rows. Each matrix can stand for a rule that changes points, and multiplying them makes one rule that does the second matrix's change first and then the first matrix's. That is why switching the order usually changes the answer.

Composition of Linear Maps

If A is m × n and B is n × p, their product AB is an m × p matrix. Each entry of AB is found by taking one row of A and one column of B, multiplying matching entries across the n positions, and adding the results. The inner sizes must match, which is why the shapes need to line up. The reason for this odd-seeming rule is that matrices represent linear maps, and AB represents doing B first and then A. Because composing maps in sequence is associative, (AB)C = A(BC), but swapping order usually gives a different map, so AB generally does not equal BA. Computers may use different tricks to compute products faster, but the result is the same operation.

 

For A of shape m by n and B of shape n by p, the product AB has shape m by p, with (AB)_ij equal to the sum over k from 1 to n of A_ik B_kj: each entry pairs row i of A with column j of B across the n shared intermediate coordinates. The inner dimensions must agree because the intermediate coordinates are the output of B and the input of A. The formula is exactly the coordinate expression of composing linear maps, with B applied first and A second. Composition of functions is associative, so matrix multiplication is associative, (AB)C = A(BC). Composition is generally order-dependent, so matrix multiplication is typically noncommutative: AB need not equal BA, and one of the products may not even be defined. Implementations, from the naive triple loop to blocked or asymptotically faster algorithms, can differ widely in cost without changing the operation they compute.

Structural Signature

Sig role-phrases:

  • Left matrix — Supplies output rows and shared columns. It is required factor. Counterfactual: Reversing factors changes meaning or definedness.
  • Right matrix — Supplies shared rows and input columns. It is required factor. Counterfactual: Under column convention it acts first.
  • Shared dimension — Pairs columns of A with rows of B. It is conformability condition. Counterfactual: If dimensions differ the product is undefined.
  • Scalar multiplication — Combines paired entries. It is local combination. Counterfactual: Changing it changes the algebra.
  • Summation — Aggregates intermediate-coordinate contributions. It is contraction rule. Counterfactual: No sum gives an elementwise-like result.
  • Ordered composition — Preserves direction and noncommutativity. It is structural meaning. Counterfactual: Interchanging AB and BA destroys the semantics.

What It Is Not

  • It is not Hadamard multiplication.
  • It is not generally commutative.
  • Outer dimensions do not determine compatibility.
  • A faster algorithm does not define a different product.
  • Closest near-miss. The Hadamard product multiplies same-position entries and needs equal shapes; matrix product contracts one shared dimension.

Scope of Application

  • Linear algebra. Composes transformations.
  • Numerical computing. Implements dense and sparse kernels.
  • Machine learning. Expresses linear layers and models.
  • Graph algebra. Aggregates paths under chosen semirings.

Clarity

State shapes, scalar domain, vector convention, and factor order. For boolean, tropical, block, or sparse products, specify addition and multiplication.

Manages Complexity

The shared-index rule compresses dependency paths into one operation and lets evaluation be optimized independently of meaning.

Abstract Reasoning

  1. Assign domain and codomain dimensions.
  2. Match the inner dimension.
  3. Pair row and column entries.
  4. Aggregate over the shared index.
  5. Interpret order and verify shape.

Knowledge Transfer

The contraction transfers to tensors and semirings when axes and algebra are restated. Elementwise array operations remain distinct.

Examples

Canonical

A 2×3 matrix times a 3×4 matrix yields 2×4; each output aggregates three paths through the intermediate coordinate.

Mapped back: left → 2×3; right → 3×4; shared → 3; output → 2×4.

Applied / In Practice

If B maps inputs to an intermediate space and A maps that space to outputs, AB represents A after B.

Mapped back: first → B; second → A; composition → AB.

Structural Tensions

T1 — Coordinate Formula versus Map Composition. The row-column calculation represents a basis-independent operation.

Diagnostic: Is the argument about entries or transformations?

T2 — Mathematical Product versus Algorithm. Blocking and fast algorithms change evaluation but not semantics.

Diagnostic: Does the implementation preserve the declared algebra?

Structural–Framed Character

Matrix Multiplication is strongly structural.

Structural Core vs. Domain Accent

The skeleton is ordered contraction over a shared interface. Linear algebra supplies bases, maps, dimensions, and scalars.

This entry is a kind of Composition.

  • Approved root. No current parent entails this contraction rule.

  • Related — linear transformation, tensor contraction, dot product, and composition. They provide meaning and generalization.

Relationships to Other Abstractions

Local relationship map for Matrix MultiplicationParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Matrix MultiplicationDOMAINPrime abstraction: Composition — is a kind ofCompositionPRIME

Current abstraction Matrix Multiplication Domain-specific

Parents (1) — outgoing typed relations

  • Matrix Multiplication is a kind of Composition Prime

    Matrix Multiplication is Composition of compatible linear transformations expressed by index contraction.

Hierarchy path (1) — routes to 1 parentless root

Neighborhood in Abstraction Space

Matrix Multiplication sits in a crowded region of the domain-specific corpus (21st percentile for distinctiveness): several abstractions share nearly its structure, so a description that fits it tends to fit its neighbors too.

Family — Matrices, Measures & Numeric Structures (30 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-11-14

Not to Be Confused With

  • Hadamard product. Tell: Multiplies corresponding entries.
  • Outer product. Tell: Forms pairwise products without summing.
  • Dot product. Tell: Produces one scalar.
  • Matrix addition. Tell: Combines equal shapes entrywise.

References

  • Frozen Wikipedia discovery revision: https://en.wikipedia.org/wiki/Matrix_multiplication (revision 1370857627).