← CS Lab Math & Theory / Matrix Multiplication Open standalone ↗

Matrix multiplication chains two linear maps into one. The tool shows the arithmetic — each output cell is a row times a column. The deeper story: a matrix is a linear transformation, and multiplying matrices is doing one transformation after another.

Where you meet it

What it does

It composes maps. If B sends an input vector somewhere and A then moves that result, the single matrix A·B does both steps at once: (A·B)x = A(Bx). The product is the composition — that is why order runs right to left.

A matrix is a transformation, and multiplying them is doing one after another — which is why A·B ≠ B·A.

How it works

Each entry is the dot product of row i of A with column j of B:

(AB)ᵢⱼ = Σₖ Aᵢₖ · Bₖⱼ      sum over the shared index k

The dimension rule: an m×n times an n×p gives an m×p. The inner dimensions must match — they are the k you sum over; the outer ones become the result shape.

A = [[1, 2, 3],          B = [[7,  8],
     [4, 5, 6]]               [9, 10],
   (2×3)                      [11,12]]   (3×2)

(AB)₀₀ = 1·7 + 2·9 + 3·11 = 58       → A·B is 2×2

The transformation view: column j of A·B is just A applied to column j of B. To build the product, run A on each column of B in turn.

Watch out

  • Not commutative. A·B ≠ B·A in general — composing maps in the other order lands somewhere else, and may not even be legal.
  • Inner dimensions must match. (m×n)·(n×p) works; mismatch is an error, not a silent broadcast.
  • Not the elementwise product. A·B (matmul, NumPy @) is the dot-product rule; A*B (Hadamard, NumPy *) multiplies cell by cell and needs equal shapes.
  • It is associative: (AB)C = A(BC) — so long chains of transforms collapse into one matrix.

Go deeper

Matrixmultiplikation verkettet zwei lineare Abbildungen zu einer. Das Tool zeigt die Arithmetik — jede Ergebniszelle ist Zeile mal Spalte. Die tiefere Geschichte: Eine Matrix ist eine lineare Abbildung, und Matrizen multiplizieren heißt, eine Abbildung nach der anderen auszuführen.

Wo es vorkommt

Was es tut

Es komponiert Abbildungen. Schickt B einen Eingabevektor irgendwohin und verschiebt A dann das Ergebnis, so macht die eine Matrix A·B beide Schritte auf einmal: (A·B)x = A(Bx). Das Produkt ist die Hintereinanderausführung — darum läuft die Reihenfolge von rechts nach links.

Eine Matrix ist eine Abbildung, und sie zu multiplizieren heißt, eine nach der anderen auszuführen — darum gilt A·B ≠ B·A.

Wie es funktioniert

Jeder Eintrag ist das Skalarprodukt von Zeile i aus A mit Spalte j aus B:

(AB)ᵢⱼ = Σₖ Aᵢₖ · Bₖⱼ      Summe über den geteilten Index k

Die Dimensionsregel: m×n mal n×p ergibt m×p. Die inneren Dimensionen müssen passen — sie sind das k, über das summiert wird; die äußeren ergeben die Form des Resultats.

A = [[1, 2, 3],          B = [[7,  8],
     [4, 5, 6]]               [9, 10],
   (2×3)                      [11,12]]   (3×2)

(AB)₀₀ = 1·7 + 2·9 + 3·11 = 58       → A·B ist 2×2

Die Abbildungs-Sicht: Spalte j von A·B ist einfach A angewandt auf Spalte j von B. Um das Produkt zu bauen, wendet man A nacheinander auf jede Spalte von B an.

Worauf achten

  • Nicht kommutativ. A·B ≠ B·A im Allgemeinen — die Abbildungen in der anderen Reihenfolge zu verketten landet woanders und ist oft gar nicht erlaubt.
  • Innere Dimensionen müssen passen. (m×n)·(n×p) geht; ein Mismatch ist ein Fehler, kein stilles Broadcasting.
  • Nicht das elementweise Produkt. A·B (matmul, NumPy @) ist die Skalarprodukt-Regel; A*B (Hadamard, NumPy *) multipliziert Zelle für Zelle und braucht gleiche Formen.
  • Es ist assoziativ: (AB)C = A(BC) — lange Ketten von Abbildungen fallen so zu einer Matrix zusammen.

Mehr dazu

Next up
Math & TheoryNormal Distribution Math & TheoryBayes' Theorem All concepts →