How multiplying matrices works
Every cell of the answer is built the same way: take a row of A, take a column of B, lay them side by side, multiply the pairs, and add the products up. That one move, row times column, is the whole operation. It also explains the famous entry requirement: a row of A holds as many numbers as A has columns, a column of B holds as many numbers as B has rows, and the pairing only works when those two counts agree. So an m×n matrix times an n×p matrix works exactly when the inner numbers match, and the outer numbers, m and p, are the shape of the answer. A 2×3 times a 3×2 gives a 2×2. The inner numbers do the work and then vanish.
This page does one operation as deeply as we know how: every cell of the product is written out with your own numbers, and whenever the reverse order B × A is also legal, you get both products side by side. Addition, subtraction, determinants and inverses live on the matrix calculator; multiplication earned its own page.
The formula
Here aik is the entry in row i, column k of A, and bkj is the entry in row k, column j of B. The sum over k is the row-dot-column move described above: k walks along row i of A and down column j of B at the same time, and the products pile up into one number, which becomes row i, column j of the answer.
Worked example
Multiply a 2×3 by a 3×2. Let A = [[1, 2, 3],[4, 5, 6]] and B = [[7, 8],[9, 10],[11, 12]]. The inner numbers are 3 and 3, so the product exists, and the outer numbers say the answer is 2×2. Top left: 1×7 + 2×9 + 3×11 = 7 + 18 + 33 = 58. Top right: 1×8 + 2×10 + 3×12 = 64. Bottom left: 4×7 + 5×9 + 6×11 = 139. Bottom right: 4×8 + 5×10 + 6×12 = 154. So A × B = [[58, 64],[139, 154]].
Now feed the same two matrices in the other order. B × A is a 3×2 times a 2×3, which is also legal, and it comes out 3×3: nine entries instead of four. Same ingredients, different order, and not even the same shape of answer. Run it above and watch.
Why the rule is row times column at all
The rule looks arbitrary until you see what it is for. A row-times-column sum is a weighted combination: one list of weights meeting one list of values, each value scaled by its weight, all of it added into a single number. That is the most useful move in applied math. An invoice total is a row of quantities times a column of prices. A course grade is a row of category weights times a column of your scores. Matrix multiplication is nothing more than doing that weighted combination for every row of A against every column of B at once, and organizing the answers into a grid. When the result is a single number, one row against one column, it has its own name, the dot product, and its own page: the dot product calculator.
The reason your graphics card is an AI chip
A neural network layer is a matrix multiplication. Not something like one: it is one. The layer's learned weights sit in a matrix, the inputs arrive as a column, and each output neuron is one row-times-column sum, a weighted combination of every input. Here is the whole idea at house scale. Put three houses in a 3×3 matrix, one row per house, with columns for size in hundreds of square feet, bedrooms, and age in decades: [[14, 3, 2],[20, 4, 1],[11, 2, 3]]. Now score them with a 3×1 column of weights, 5 points per hundred square feet, 10 per bedroom, minus 4 per decade of age: [[5],[10],[-4]]. The product is a 3×1 column of scores of 92, 136 and 63, one weighted judgment per house, all three computed in a single multiplication. Feed those numbers through the calculator above and you can watch each score get built term by term.
A real model does exactly this with matrices thousands of rows wide, chained layer after layer, billions of multiply-and-add steps per answer. Graphics cards happen to be machines built to do enormous numbers of these products every second, because moving and lighting 3D scenes is matrix multiplication too. That is the entire story of why the chip that ran your games became the chip that runs AI: same operation, new customer.
AB and BA: order is part of the question
With numbers, 3 × 5 and 5 × 3 are the same thing, so it is natural to assume matrices work the same way. They do not, and this page would rather show you than tell you: whenever both orders are legal, it computes both and puts them side by side. Three things can happen, and all three are instructive. The two products can differ cell by cell, which is the normal case. They can come out different shapes entirely, a 2×2 in one order and a 3×3 in the other. Or one order can be flatly impossible while the other works fine, and the shapes alone settle it before any arithmetic starts. Once you have watched a pair of matrices give two different answers, non-commutativity stops being a rule to memorize and becomes something you saw happen. The rare pairs that do commute, two diagonal matrices, anything with the identity, a matrix with its own powers, get noticed and congratulated when they turn up.
The identity, and the rule that survives
Matrix multiplication does keep a version of the number 1: the identity matrix I, with ones down the diagonal and zeros everywhere else. Multiply any matrix by I, on either side, and it comes back untouched. Enter one above and watch it happen; the page will point it out.
And one law does survive the loss of commutativity: associativity. (AB)C = A(BC), always. You may not reorder the factors, but you may group them however you like, and that freedom is quietly load-bearing. It is why a chain of neural network layers makes sense at all: the network can be read as one long matrix product, and associativity guarantees that applying the layers one at a time gives the same answer as collapsing any stretch of them into a single matrix first. Order of factors is sacred; order of grouping is free.