Learn
Lesson · Systems and Matrices · Matrices

Matrix Products

Addition and scaling are a short entrywise warm-up. The product is the new operation: the entry in row i and column j of AB is built from the whole of row i and the whole of column j, and the order of the factors changes the answer.

A + B same size, entry by entry kA every entry multiplied by k A (m × n) times B (n × p) = AB (m × p) inner sizes must agree AB in row i, column j = row i of A against column j of B
Three operations, and the shape rule

Core ideas

What this lesson establishes

Two of the three operations behave exactly as the notation suggests. The third does not, and most of this lesson is about the third.

1

Addition is entrywise and needs matching sizes

A + B exists only when A and B have the same number of rows and the same number of columns, and then it is what it looks like. Every rule of addition from Foundations of Algebra carries over, one position at a time.

2

The product runs rows against columns

Multiply each entry of row i of A by the matching entry of column j of B and add the results. The row length of A must equal the column height of B, and that requirement is the whole of the shape rule.

3

AB and BA are different questions

They can have different sizes; one can exist while the other does not; and even when both are n × n they are usually different matrices. Every rearrangement that quietly used commutativity has to be re-earned here.

The material

Matrix products, after an entrywise warm-up

Addition and scaling in brief, then the shape rule, row-column products and the order of the factors.

Definition · Size and equality

An m × n matrix has m rows and n columns. Two matrices are equal when they have the same size and agree in every position. There is no notion of two matrices of different sizes being equal.

Definition · Sum and scalar multiple

For matrices of the same size, A + B is the matrix whose entry in each position is the sum of the entries of A and B in that position. For a number k, the matrix kA has every entry of A multiplied by k.

A number acting on a matrix this way is called a scalar, to distinguish it from a 1 × 1 matrix, which is a different object.

A = 2 −1 0 B = 1 6 −2 4 3 5 0 −3 1 A + B = 3 5 −2 3A = 6 −3 0 4 0 6 12 9 15

Addition inherits everything from the numbers, position by position: A + B = B + A, (A + B) + C = A + (B + C), the zero matrix of the right size adds nothing, and A + (−A) is that zero matrix. Nothing here requires attention.

The product

Definition · Matrix product

Let A be m × n and B be n × p. The product AB is the m × p matrix whose entry in row i, column j is a₁b₁ + a₂b₂ + … + aₙbₙ, where a₁, …, aₙ is row i of A and b₁, …, bₙ is column j of B.

If the row length of A is not the column height of B, the product does not exist. It is not zero and it is not approximately anything: there is no such matrix.

The shape rule is easier to use than to state. Write the two sizes side by side, (m × n)(n × p). If the inner pair match, they cancel and the outer pair give the size of the answer. If they do not match, stop.

C = 1 2 0 D = 2 1 3 −1 4 0 −3 5 2 C is 2 × 3, D is 3 × 2 → CD is 2 × 2 row 1, col 1 : 1(2) + 2(0) + 0(5) = 2 row 1, col 2 : 1(1) + 2(−3) + 0(2) = −5 row 2, col 1 : 3(2) + (−1)(0) + 4(5) = 26 row 2, col 2 : 3(1) + (−1)(−3) + 4(2) = 14 CD = 2 −5 DC exists too, and is 3 × 3 26 14

The definition looks arbitrary until a system is written with it. Take the coefficient matrix of the system in “Systems in Three Variables”, a column of the three unknowns, and a column of the three constants. The product of the first two is a column whose entries are the left-hand sides of the three equations, so the whole system is the single statement Ax = b.

1 1 1 x 6 2 −1 3 y = 9 −1 2 4 z 15 at (1, 2, 3): 1(1) + 1(2) + 1(3) = 6 ✓ 2(1) − 1(2) + 3(3) = 9 ✓ −1(1) + 2(2) + 4(3) = 15 ✓

Even when both products exist, order must be preserved: AB and BA can have different sizes or different entries. The arithmetic lesson here is deliberately narrow — decide existence, state the output size, and build each entry from the named row and column. “Inverse Matrices” introduces the identity and inverse when a system needs a matrix operation to be undone.

Interactive

Matrix arithmetic

Sum, difference, scalar multiple and product, with every entry derived

Matrix
every entry derivedAB against BA

Method

Computing a product

Four moves. The first one is written down, not done in your head.

1

Check the sizes and write down the size of the answer

(m × n)(n × p) gives m × p. If the inner numbers differ there is nothing to compute, and "the product does not exist" is the complete answer.

2

Take one row and one column at a time

For the entry in row i, column j, run along row i of the left matrix and down column j of the right one, multiplying in pairs. Say the position out loud before starting it.

3

Add the products and place the entry

The number of products equals the shared inner dimension, so an inner dimension of 3 means three products every time. Counting them is a free check on whether a term was skipped.

4

Never assume AB equals BA

If the question asks for BA, compute BA. Swapping the factors is not a simplification; it is a different calculation with a different answer.

Matrix arithmetic

Score 0 / 0

AB and BA for two 2 by 2 matrices

Both matrices are 2 × 2, so both products exist and both are 2 × 2. They are still not the same matrix.

A = 1 2 B = 0 1 3 4 1 0 AB row 1 : 1(0) + 2(1) = 2 1(1) + 2(0) = 1 AB row 2 : 3(0) + 4(1) = 4 3(1) + 4(0) = 3 AB = 2 1 4 3 BA row 1 : 0(1) + 1(3) = 3 0(2) + 1(4) = 4 BA row 2 : 1(1) + 0(3) = 1 1(2) + 0(4) = 2 BA = 3 4 1 2

B here is a swapper. Multiplying A on the right by it exchanged the columns of A; multiplying on the left exchanged the rows. That is a fair picture of the general situation — which side you multiply on decides whether rows or columns are acted on — and it is why the order is part of the expression rather than a detail of how it was written down.

Neither product is the entrywise one, which would have been 0, 2, 3, 0. That matrix is not AB, is not BA, and answers no question asked in this course.

Faded rehearsal: let C be 2 × 3 with rows (1, 0, −2) and (3, 1, 4), and let D be 3 × 1 with column (2, −1, 5). The shape decision is supplied: CD exists and is 2 × 1. Compute its two entries by naming each row of C against the column of D, then explain from the dimensions why DC does not exist.

Common mistakes

1
Multiplying entry by entryThe matrix of products of matching entries is a real operation with real uses, and it is not AB. For the two matrices in the worked example it would give 0, 2, 3, 0, which is neither product.
2
Putting a correct number in the wrong positionAn entry is named before it is computed: row i of the left matrix against column j of the right. Using the right row with the wrong column can produce impeccable arithmetic in a matrix that answers a different product.
3
Assuming AB exists because BA doesA 3 × 2 times a 2 × 5 is fine; the same two matrices in the other order pair 5 against 3 and there is no product at all. Write the two sizes down before reaching for the arithmetic.

Check your understanding

✓
Finish when the size of the answer is the first thing you write.

Before computing a single entry, write m × p down. It catches an impossible product before any arithmetic happens, it tells you how many entries you owe, and it is the habit that makes Ax = b in “Inverse Matrices” read as one equation rather than as three.

Note: Writing a system as Ax = b invites the obvious move: divide by A. There is no division of matrices, but there is sometimes a matrix that undoes multiplication by A. “Determinants and Cramer's Rule” produces the single number that decides whether such a matrix exists, and “Inverse Matrices” defines it as A⁻¹, constructs it by row reduction, and turns the system into x = A⁻¹b — which is the reason this course did “Gaussian Elimination” first.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.