matrix multiplication
/ MAY-triks mul-tih-plih-KAY-shun /
Multiplying two matrices is just doing many dot products at once and stowing the answers in a fresh grid. To find the number that belongs in row i, column j of the result, you take row i of the first matrix and column j of the second, line them up, multiply entry by entry, and add — that's one dot product. Fill in every (i, j) cell that way and you have the product matrix.
There is one rule you cannot break: the inner dimensions must match. An A-by-B matrix times a B-by-C matrix works (the two B's meet in the middle) and gives an A-by-C result; anything else is simply undefined. A second surprise: order matters. Unlike ordinary numbers, where 3×4 equals 4×3, matrix multiplication is generally not commutative — swapping the two matrices usually gives a different answer, or no answer at all.
This is the single most-run computation in modern AI. A neural network layer transforms its inputs by multiplying them by a matrix of weights; stacking layers means stacking matrix multiplications. Because these operations are so regular and repetitive, specialized chips like GPUs and TPUs are built to blast through them at staggering speed — which is, in large part, why deep learning became practical at all. When people talk about the cost of training a giant model, they are mostly talking about the price of a mountain of matrix multiplications.
[ [1, 2], [3, 4]] times [ [5, 6], [7, 8]]: the top-left of the answer is row [1, 2] dotted with column [5, 7] = 1×5 + 2×7 = 19. Working through all four cells gives [ [19, 22], [43, 50]]. Swap the order and you instead get [ [23, 34], [31, 46]] — a different matrix, proving order is not free.
Each output cell is one dot product of a row with a column; and A×B is not the same as B×A.
Matrix multiplication is not entry-by-entry — that different, simpler operation is called the element-wise (Hadamard) product. And because order matters, always check which matrix sits on the left; flipping them can quietly break a model.