Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Matrix Multiplication


Symbolic visualization of A × B = C, step by step.

General A × B·A × B·2×3 · 3×2|Row · Column

Scenario

Order

Dimensions

A2×3
B3⇌×2
A2×3
a1,1
a1,2
a1,3
a2,1
a2,2
a2,3
×
B3×2
b1,1
b1,2
b2,1
b2,2
b3,1
b3,2
=
C2×2
c1,1
c1,2
c2,1
c2,2
Step 0 / 21

Step explanations

Matrix multiplication: A × B = C
Each ci,j = (row i of A) · (column j of B). 4 cells to compute.
The definition made literal: each ci,j is one row of A dotted with one column of B. Learn more about the row · column view · all four strategies
Any m × n times n × p. The inner sizes must agree; the outer sizes are the shape of C. Learn more about the general case · all three scenarios













Key Terms

Matrix multiplication — the product C=ABC = AB of an m×nm \times n matrix AA and an n×pn \times p matrix BB: an m×pm \times p matrix with entries ci,j=∑k=1nai,k bk,jc_{i,j} = \sum_{k=1}^{n} a_{i,k}\, b_{k,j}.

Inner dimensions — the number of columns of the left factor and the number of rows of the right factor. They must be equal, or the product is undefined.

Outer dimensions — the number of rows of the left factor and the number of columns of the right factor. They are the shape of the product.

Dot product — the sum of paired products of a row and a column of the same length. Every entry of CC is one dot product.

Linear combination — a weighted sum of vectors. Each column of CC is a linear combination of the columns of AA, and each row of CC is a linear combination of the rows of BB.

Outer product — a column times a row: an m×pm \times p matrix of rank at most one. The product ABAB is the sum of nn of them.

Non-commutative — AB≠BAAB \neq BA in general. The two products can differ in value, differ in shape, or one of them may not exist at all.

Getting Started with the Visualizer

Pick a case, pick a way of thinking about the product, and watch C=A×BC = A \times B build itself one highlighted step at a time.

• The Scenario tab holds three pills for the three scenarios, an Order toggle between A×BA \times B and B×AB \times A, and three steppers for the sizes of AA and BB. The rows of BB are shown with a link icon because they are tied to the columns of AA; a scenario can lock one stepper to 11, which shows a padlock
• The Strategy tab holds four cards for the four strategies, each a different reading of the same product
• The summary strip at the right of the tab bar always shows the scenario, the order, the shapes, and the strategy in play
• Below the panel, the scene player animates the product. Play, step back and forward, reset, and choose a speed. The Step explanations log on the right keeps every step you have passed and opens with an unnumbered lead block describing the whole run

Every strategy produces the same CC. They differ only in what is highlighted and in how many steps the product takes.

The Three Scenarios

The Scenario pills choose which shapes the product takes. They do not change the rule, only which part of the rule is on display.

• General A × B — any m×nm \times n times n×pn \times p, sizes 11 to 55 on every free stepper. This is the full picture
• Matrix × vector — BB is locked to a single column, so CC is a single column. The product is a matrix acting on a vector
• Vector × matrix — AA is locked to a single row, so CC is a single row. The product is a row vector acting on a matrix

The Order toggle sits beside the pills and swaps the factors. For the default shapes both orders exist, but with other sizes one of them may not, and the tool replaces the animation with a banner. That case has its own section: order and the undefined product.

General A × B: Any Compatible Pair of Shapes

The first scenario places no restriction beyond the one the definition already imposes. AA is m×nm \times n, BB is n×pn \times p, and every stepper from 11 to 55 is free except the rows of BB, which follow the columns of AA.

The tool opens here at its defaults, AA 2×32 \times 3 and BB 3×23 \times 2. The frozen picture below is that opening scene, before any cell has been computed.
A2×3a1,1a1,2a1,3a2,1a2,2a2,3×B3×2b1,1b1,2b2,1b2,2b3,1b3,2=C2×2c1,1c1,2c2,1c2,2
General A × B, the opening scene

A is 2×3 and B is 3×2. The inner 3s match, so the product exists, and the outer 2 and 2 fix C at 2×2. Every cell of C still shows the dashed placeholder: nothing has been computed yet.

Two numbers are decided before a single product is formed. The inner pair, 33 and 33, must agree or nothing can be paired. The outer pair, 22 and 22, becomes the shape of CC. Change the columns of AA and the rows of BB follow; change the rows of AA or the columns of BB and CC changes shape with them. The compatibility rule section states this precisely.

Every cell of CC is a dot product of a row of AA with a column of BB, so there are m×pm \times p dot products to form, each with nn terms. At the defaults that is four cells with three terms each, twelve multiplications in all. The step count in the player grows with all three sizes, which is the first hint that matrix multiplication is expensive: doubling every dimension multiplies the work by eight.

The other two scenarios are this one with a stepper pinned to 11. Matrix × vector pins the columns of BB and vector × matrix pins the rows of AA. Nothing about the rule changes; only the shapes do.

Matrix × Vector: A Column on the Right

The second scenario locks the columns of BB to 11. BB is now a column vector of length nn, and CC is a column vector of length mm: the matrix AA has acted on a vector.

At the frozen step below, AA is 2×32 \times 3 and BB is a 3×13 \times 1 column. The first cell of CC is being formed, and the second of its three terms is highlighted.
A2×3a1,1a1,2a1,3a2,1a2,2a2,3×B3×1b1,1b2,1b3,1=C2×1c1,1c2,1
Matrix × vector, c1,1 at term 2 of 3

B has collapsed to a single column, so C is a single column too. Row 1 of A is highlighted against the whole of B, with the second pair, a1,2 and b2,1, raised.

This is the shape that systems of linear equations take. The system Ax=bAx = b is exactly a matrix times a column vector, with xx the unknown column and bb the known one. Each row of AA dotted with xx is one equation, which is why CC has one entry per row of AA.

There is a second reading worth holding onto. With BB a single column, the column by column strategy has only one column to build, and that column is b1,1b_{1,1} times column 11 of AA plus b2,1b_{2,1} times column 22 of AA and so on. A matrix times a vector is a linear combination of the columns of the matrix, with the entries of the vector as the weights. That sentence is the foundation of the column space and of everything built on it.

Switch to vector × matrix for the mirror image, where the single row is on the left and the rows of BB are combined instead.

Vector × Matrix: A Row on the Left

The third scenario locks the rows of AA to 11. AA is now a row vector of length nn, and CC is a row vector of length pp: a row acting on the matrix BB.

In the frozen step, AA is a 1×31 \times 3 row and BB is 3×23 \times 2. The first cell of CC is under construction with its second term active, and the whole of AA is the highlighted row because there is no other.
A1×3a1,1a1,2a1,3×B3×2b1,1b1,2b2,1b2,2b3,1b3,2=C1×2c1,1c1,2
Vector × matrix, c1,1 at term 2 of 3

A is one row, so C is one row. That row is read against column 1 of B, and the second pair, a1,2 and b2,1, is raised. The remaining cell of C waits with a dashed outline.

The result has one entry per column of BB, each a dot product of the row with that column. Under the row by row strategy there is a single row of CC to build, and it equals a1,1a_{1,1} times row 11 of BB plus a1,2a_{1,2} times row 22 of BB and so on. A row vector times a matrix is a linear combination of the rows of the matrix, with the entries of the row vector as weights. This is the row space counterpart of the column picture in matrix × vector.

The two scenarios are tied together by the transpose. Transposing a product reverses the order, (AB)T=BTAT(AB)^T = B^T A^T, so a row times a matrix is the transpose of the corresponding matrix times a column. Anything true of one picture has a twin in the other.

Row vectors on the left appear whenever a linear functional is applied to a matrix, in the left eigenvector equation xA=λxxA = \lambda x, and in Markov chains, where the state is a row of probabilities and each step is a multiplication by the transition matrix on the right.

Order and the Undefined Product

The Order toggle swaps the factors. A×BA \times B pairs the columns of AA with the rows of BB; B×AB \times A pairs the columns of BB with the rows of AA. Those are different requirements, and one can hold while the other fails.

When it fails, the scene player is replaced by a red banner stating the two shapes and the mismatched inner pair, and the toggle itself turns red as a warning before you press it. The still below is such a case: BB is 3×33 \times 3, AA is 2×32 \times 3, and B×AB \times A asks three columns to pair with two rows.
B3×3b1,1b1,2b1,3b2,1b2,2b2,3b3,1b3,2b3,3×A2×3a1,1a1,2a1,3a2,1a2,2a2,3=?
B × A with B 3×3 and A 2×3

The three columns of B are shaded grey and the two rows of A blue. A dot product would have to pair one of each, and 3 cannot be paired with 2, so nothing can be written where C would stand.

At the defaults, AA 2×32 \times 3 and BB 3×23 \times 2, both orders exist, but they are not the same product. A×BA \times B is 2×22 \times 2 while B×AB \times A is 3×33 \times 3. That is the most direct demonstration that matrix multiplication is not commutative: the two results cannot even be compared entry by entry because they have different shapes.

For square factors of the same size both orders exist and have the same shape, and they still differ in general. Play the row · column strategy in both orders on a 2×22 \times 2 pair and watch which cells are paired: c1,2c_{1,2} in one order draws on row 11 of AA and column 22 of BB, in the other on row 11 of BB and column 22 of AA. Different pairs, different sums.

Whether a given order exists is decided by the compatibility rule alone. The banner links there. Pick sizes so that the columns of BB equal the rows of AA and the toggle turns blue again.

The Four Strategies

The Strategy tab offers four ways to build the same product. Each is a valid definition on its own, and each brings a different structure to the front.

• Row · column — one cell of CC at a time, each a dot product. The textbook definition, and the slowest: m×pm \times p cells with nn terms each
• Column by column — one column of CC at a time, each a weighted sum of the columns of AA. pp columns, nn terms each
• Row by row — one row of CC at a time, each a weighted sum of the rows of BB. mm rows, nn terms each
• Sum of outer products — all of CC at once, accumulated from nn rank-one matrices. Marked advanced because it is the least familiar

The step counter changes with the strategy. At the defaults the row · column strategy takes 2222 scenes, column by column and row by row take 1212, and the sum of outer products takes 1111. The result is identical every time.

Row · Column: One Cell at a Time

The first strategy is the definition made literal. To fill ci,jc_{i,j}, take row ii of AA and column jj of BB, multiply them entry by entry, and add the nn products. Then move to the next cell.

The frozen scene below is the second cell, c1,2c_{1,2}, at its second of three terms. Row 11 of AA is shaded blue and column 22 of BB grey, with the active pair a1,2a_{1,2} and b2,2b_{2,2} raised.
A2×3a1,1a1,2a1,3a2,1a2,2a2,3×B3×2b1,1b1,2b2,1b2,2b3,1b3,2=C2×2c1,1c1,2c2,1c2,2
Row · column, c1,2 at term 2 of 3

Row 1 of A in blue meets column 2 of B in grey. The active pair, a1,2 and b2,2, is raised, and the cell being written, c1,2, is solid green while the other cells of C keep their dashed outline.

The formula line under the player spells out the dot product with the current term emphasised, c1,2=a1,1b1,2+a1,2b2,2+a1,3b3,2c_{1,2} = a_{1,1} b_{1,2} + a_{1,2} b_{2,2} + a_{1,3} b_{3,2}, and the cell of CC being written is solid green while the untouched cells keep a dashed outline. Cells sweep in reading order: across the first row of CC, then the second.

This is the strategy to run first, because the other three are shortcuts that assume you already believe this one. It is also the one that exposes the cost. Every cell needs nn multiplications, and there are m×pm \times p cells, so the product costs m×n×pm \times n \times p multiplications in all: twelve at the defaults, and one hundred and twenty five for a pair of 5×55 \times 5 matrices.

The same dot products are grouped differently by column by column and row by row, and dissolved entirely by the sum of outer products.

The rule is correct, and it hides what the product does. Drawn in the plane rather than tabulated, the product moves whole columns or whole rows, never single entries.

Column by Column: Combining the Columns of A

The second strategy builds CC one column at a time. Column jj of CC is AA times column jj of BB, and that in turn is a weighted sum of the columns of AA: b1,jb_{1,j} times column 11, plus b2,jb_{2,j} times column 22, and so on down column jj of BB.

The still below is column 22 of CC at its second of three terms. Column 11 of CC is already complete and solid green. Column 22 of AA is highlighted whole, the single entry b2,2b_{2,2} is the weight, and column 22 of CC is the column being filled.
A2×3a1,1a1,2a1,3a2,1a2,2a2,3×B3×2b1,1b1,2b2,1b2,2b3,1b3,2=C2×2c1,1c1,2c2,1c2,2
Column by column, column 2 of C at term 2 of 3

Column 1 of C is already solid green. Column 2 of A is highlighted whole, the single grey entry b2,2 is its weight, and column 2 of C is the column being filled.

The formula line reads col2(C)=b1,2 col1(A)+b2,2 col2(A)+b3,2 col3(A)\mathrm{col}_2(C) = b_{1,2}\,\mathrm{col}_1(A) + b_{2,2}\,\mathrm{col}_2(A) + b_{3,2}\,\mathrm{col}_3(A), and this is the most consequential of the four readings. Every column of CC lies in the span of the columns of AA, whatever BB is. That single observation is why the column space of ABAB sits inside the column space of AA, why the rank of a product cannot exceed the rank of either factor, and why solving Ax=bAx = b means asking whether bb is a combination of the columns of AA.

The number of steps is pp, one per column of CC, each with nn terms: at the defaults, two columns of three terms. Compare that with the m×pm \times p cells of the row · column view. The multiplications are the same twelve; they are simply grouped by column instead of by cell.

The matrix × vector scenario is this strategy with a single column to build.

Row by Row: Combining the Rows of B

The third strategy is the mirror of the second. Row ii of CC is row ii of AA times BB, which is a weighted sum of the rows of BB: ai,1a_{i,1} times row 11, plus ai,2a_{i,2} times row 22, and so on across row ii of AA.

The frozen scene is row 22 of CC at its second term. Row 11 of CC is done. The single entry a2,2a_{2,2} is the weight, row 22 of BB is highlighted whole, and row 22 of CC is the row being filled.
A2×3a1,1a1,2a1,3a2,1a2,2a2,3×B3×2b1,1b1,2b2,1b2,2b3,1b3,2=C2×2c1,1c1,2c2,1c2,2
Row by row, row 2 of C at term 2 of 3

Row 1 of C is complete. The single blue entry a2,2 is the weight, row 2 of B is highlighted whole in grey, and row 2 of C is the row being filled.

The formula line reads row2(C)=a2,1 row1(B)+a2,2 row2(B)+a2,3 row3(B)\mathrm{row}_2(C) = a_{2,1}\,\mathrm{row}_1(B) + a_{2,2}\,\mathrm{row}_2(B) + a_{2,3}\,\mathrm{row}_3(B). Every row of CC lies in the span of the rows of BB, whatever AA is, so the row space of ABAB sits inside the row space of BB. Together with the column reading this bounds the rank of a product from both sides.

This is also the view behind row operations. Multiplying BB on the left by an elementary matrix replaces the rows of BB by combinations of themselves, which is exactly what the row by row strategy shows: each new row is built from the old rows with the entries of the left factor as weights. Gaussian elimination is a sequence of such left multiplications.

There are mm steps, one per row of CC, each with nn terms: at the defaults, two rows of three terms. Column by column grouped the same work by columns; the vector × matrix scenario is this strategy with a single row to build.

Sum of Outer Products: All of C at Once

The fourth strategy gives up on cells, rows, and columns and builds all of CC in nn additions. For each kk from 11 to nn, column kk of AA times row kk of BB is a full m×pm \times p matrix of rank at most one. Adding those nn matrices gives CC.

In the frozen scene, contribution 22 of 33 is being added. Column 22 of AA and row 22 of BB are highlighted together, and every cell of CC is green because every cell receives a term from this pair.
A2×3a1,1a1,2a1,3a2,1a2,2a2,3×B3×2b1,1b1,2b2,1b2,2b3,1b3,2=C2×2c1,1c1,2c2,1c2,2
Sum of outer products, contribution 2 of 3

Column 2 of A and row 2 of B are highlighted together. Their outer product is a full 2×2 matrix, added into every cell of C at once, which is why all of C is green rather than a single cell.

The formula line reads C=col1(A) row1(B)+col2(A) row2(B)+col3(A) row3(B)C = \mathrm{col}_1(A)\,\mathrm{row}_1(B) + \mathrm{col}_2(A)\,\mathrm{row}_2(B) + \mathrm{col}_3(A)\,\mathrm{row}_3(B). Expand any one cell of that sum and the row · column dot product reappears, because the (i,j)(i,j) entry of colk(A) rowk(B)\mathrm{col}_k(A)\,\mathrm{row}_k(B) is ai,kbk,ja_{i,k} b_{k,j}. The four strategies are one formula with the summation performed in different orders.

The outer product view is the one that generalises. It is the shape of the singular value decomposition, A=∑kσkukvkTA = \sum_k \sigma_k u_k v_k^T, of every low-rank approximation, and of the update rules in numerical linear algebra that add one rank-one matrix at a time. Recognising a product as a sum of rank-one pieces is often the first step in seeing why an algorithm is cheap.

At the defaults there are three contributions, one per inner index. The step count no longer depends on mm or pp at all, only on nn.

Reading the Scene Player

Each scene combines highlights on AA, BB and CC with arrows and a title, and the same colours mean the same things in every strategy.

• Blue on AA marks the row, column, or cell currently being read. A raised, darker blue cell is the active entry of a pair
• Grey on BB marks its counterpart on the other side, with the same raised treatment for the active entry
• Solid green on CC marks cells that are being written or are complete; a dashed green outline marks a cell that has not been touched yet
• Arrows run from the highlighted entries of AA and BB to the cell of CC that receives their product
• The title names the cell, column, row, or contribution in play, and the formula beneath it in the log shows the full expression with the active term emphasised

The Step explanations log keeps every scene you have passed. Its lead block, above step 11, describes the run as a whole and carries a short note on the active strategy and scenario; click any entry to jump the player to that scene.

What Matrix Multiplication Is

The product of an m×nm \times n matrix AA and an n×pn \times p matrix BB is the m×pm \times p matrix CC whose entries are

ci,j=∑k=1nai,k bk,jc_{i,j} = \sum_{k=1}^{n} a_{i,k}\, b_{k,j}


Each entry is a dot product of row ii of AA with column jj of BB, which is why the row must be as long as the column: the columns of AA must equal the rows of BB.

The definition looks arbitrary until it is read as composition. A matrix is a linear map, sending a column xx to AxAx. Applying BB first and then AA sends xx to A(Bx)A(Bx), and the matrix that does this in one step is exactly ABAB. The rule for ci,jc_{i,j} is what it has to be for (AB)x=A(Bx)(AB)x = A(Bx) to hold for every xx.

Every other property follows from that one fact. Associativity is the associativity of composition. The failure of commutativity is the observation that doing two things in different orders usually gives different results. The compatibility rule is the requirement that the output of the first map can be fed into the second.

The Compatibility Rule

A×BA \times B is defined exactly when the number of columns of AA equals the number of rows of BB. Writing AA as m×nm \times n and BB as n×pn \times p, the inner nns must agree and the product is m×pm \times p.

Some pairs and their outcomes:

• 2×32 \times 3 times 3×23 \times 2: defined, result 2×22 \times 2
• 3×23 \times 2 times 2×32 \times 3: defined, result 3×33 \times 3
• 3×23 \times 2 times 3×43 \times 4: undefined, since 2≠32 \neq 3
• 4×44 \times 4 times 4×14 \times 1: defined, result 4×14 \times 1
• 1×41 \times 4 times 4×44 \times 4: defined, result 1×41 \times 4

The rule is not symmetric. A×BA \times B and B×AB \times A impose different conditions, and the tool's order toggle lets you see one hold while the other fails. In the tool the rows of BB are linked to the columns of AA, so A×BA \times B always exists; only B×AB \times A can be undefined.

A useful way to keep the rule straight: write the shapes side by side, (m×n)(n×p)(m \times n)(n \times p), and check that the two middle numbers match. The two outer numbers are the answer.

Key Properties

Matrix multiplication keeps some of the familiar rules of arithmetic and drops others.

• Associative: (AB)C=A(BC)(AB)C = A(BC), so a chain of products can be bracketed freely
• Distributive: A(B+C)=AB+ACA(B + C) = AB + AC and (A+B)C=AC+BC(A + B)C = AC + BC
• Scalars pass through: (kA)B=A(kB)=k(AB)(kA)B = A(kB) = k(AB)
• Identity: ImA=AIn=AI_m A = A I_n = A for an m×nm \times n matrix AA
• Transpose reverses the order: (AB)T=BTAT(AB)^T = B^T A^T
• Not commutative: AB≠BAAB \neq BA in general, and one of the two may not exist

Two consequences catch people out. Because there is no commutativity, (A+B)2=A2+AB+BA+B2(A + B)^2 = A^2 + AB + BA + B^2, and the middle terms do not merge. And because there are zero divisors, AB=0AB = 0 does not force A=0A = 0 or B=0B = 0: a nonzero matrix can kill another nonzero matrix. Cancellation, AB=ACAB = AC implying B=CB = C, holds only when AA is invertible.

The transpose rule mirrors the compatibility rule. If AA is m×nm \times n and BB is n×pn \times p, then BTB^T is p×np \times n and ATA^T is n×mn \times m, so BTATB^T A^T is the only order in which the transposes can be multiplied at all.

Worked Example

Take AA as 2×32 \times 3 and BB as 3×23 \times 2, the tool's default shapes:

A=(123456),B=(789101112)A = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix}, \qquad B = \begin{pmatrix} 7 & 8 \\ 9 & 10 \\ 11 & 12 \end{pmatrix}


The inner sizes agree, so C=ABC = AB is 2×22 \times 2. Cell by cell:

c1,1=1⋅7+2⋅9+3⋅11=58,c1,2=1⋅8+2⋅10+3⋅12=64c_{1,1} = 1 \cdot 7 + 2 \cdot 9 + 3 \cdot 11 = 58, \qquad c_{1,2} = 1 \cdot 8 + 2 \cdot 10 + 3 \cdot 12 = 64


c2,1=4⋅7+5⋅9+6⋅11=139,c2,2=4⋅8+5⋅10+6⋅12=154c_{2,1} = 4 \cdot 7 + 5 \cdot 9 + 6 \cdot 11 = 139, \qquad c_{2,2} = 4 \cdot 8 + 5 \cdot 10 + 6 \cdot 12 = 154


AB=(5864139154)AB = \begin{pmatrix} 58 & 64 \\ 139 & 154 \end{pmatrix}


The same numbers come out of every strategy. Column 11 of CC is 77 times column 11 of AA plus 99 times column 22 plus 1111 times column 33: (7+18+33, 28+45+66)=(58,139)(7 + 18 + 33,\ 28 + 45 + 66) = (58, 139). Row 11 of CC is 11 times row 11 of BB plus 22 times row 22 plus 33 times row 33: (7+18+33, 8+20+36)=(58,64)(7 + 18 + 33,\ 8 + 20 + 36) = (58, 64). And the three outer products are

(782832)+(18204550)+(33366672)=(5864139154)\begin{pmatrix} 7 & 8 \\ 28 & 32 \end{pmatrix} + \begin{pmatrix} 18 & 20 \\ 45 & 50 \end{pmatrix} + \begin{pmatrix} 33 & 36 \\ 66 & 72 \end{pmatrix} = \begin{pmatrix} 58 & 64 \\ 139 & 154 \end{pmatrix}


For the reverse order, BABA is 3×33 \times 3: it exists, but it is a different matrix of a different shape. Set the tool to 2×32 \times 3 and 3×23 \times 2 and run each strategy to see these four groupings animated.

Common Mistakes

A few errors recur whenever matrix multiplication is new.

• Multiplying entry by entry — ci,jc_{i,j} is not ai,jbi,ja_{i,j} b_{i,j}. That operation exists, the Hadamard product, but it is a different thing and needs equal shapes
• Checking the wrong pair of sizes — the inner dimensions must match, columns of the left factor against rows of the right. Matching rows to rows is the most common slip
• Assuming commutativity — ABAB and BABA are different products, and expanding (A+B)2(A+B)^2 as A2+2AB+B2A^2 + 2AB + B^2 is wrong
• Reversing the transpose rule — (AB)T=BTAT(AB)^T = B^T A^T, not ATBTA^T B^T; the shapes only work in the reversed order
• Cancelling a factor — AB=ACAB = AC does not give B=CB = C unless AA is invertible
• Reading the result shape from the wrong ends — the product of m×nm \times n and n×pn \times p is m×pm \times p, the outer numbers, never n×nn \times n

The tool guards against the first two by construction: the rows of BB are linked to the columns of AA, and the undefined B×AB \times A case is shown as a banner rather than a wrong answer.

Applications

Matrix multiplication is the operation by which linear maps are composed, so it appears wherever several linear steps are chained.

Computer graphics: rotations, scalings, and translations are matrices, and applying them in sequence is a single product. Every frame of a 3D scene multiplies vertex coordinates by transformation matrices.

Systems of equations: Ax=bAx = b is a matrix times a column vector, the matrix × vector scenario, and solving it is the central problem of numerical linear algebra.

Machine learning: a layer of a neural network multiplies its input by a weight matrix. Training and inference are dominated by these products, which is why hardware is built around them.

Markov chains: the state is a row of probabilities and each time step is a multiplication by the transition matrix on the right, the vector × matrix scenario. Powers of the transition matrix give multi-step behaviour.

Graph theory: if MM is the adjacency matrix of a graph, the entry (i,j)(i,j) of MkM^k counts walks of length kk from vertex ii to vertex jj.

Data analysis: covariance matrices, projections, and the singular value decomposition are all products, and the sum of outer products is the form in which low-rank approximations are written.