What Are the Rules for Matrix Multiplication?

A(m×n) × B(n×p) = C(m×p). The inner dimensions must match: columns of A must equal rows of B. Element C[i][j] = sum of A[i][k] × B[k][j] for all k from 1 to n.

The Dimension Rule

For multiplication to be defined, the number of columns in A must equal the number of rows in B:

A: m x [n]  *  B: [n] x p  =  C: m x p
         ^          ^
    must match

The result matrix C has the outer dimensions: rows of A and columns of B.

The Element Formula

Each element of the result is a dot product of a row from A and a column from B:

C[i][j] = A[i][1]*B[1][j] + A[i][2]*B[2][j] + ... + A[i][n]*B[n][j]

Worked Example

A = | 1  2  3 |    B = | 7   8  |
    | 4  5  6 |        | 9  10  |
                       | 11  12 |

A is 2x3, B is 3x2, so C = A*B is 2x2.

Computing each element:

C = |  58   64 |
    | 139  154 |

Key Properties

Property Holds?
Associative: (AB)C = A(BC) Yes
Distributive: A(B+C) = AB + AC Yes
Commutative: AB = BA No (in general)
Identity: AI = IA = A Yes

Use the ML3X matrix calculator to multiply matrices up to 5×5 with full dot-product step-by-step breakdown for every element.

Related Questions