Lesson 4 of 8 · 15 min

Order matters: the rules of matrix algebra

See why AB and BA are usually different, use the identity matrix and the distributive laws, and avoid the algebra habits that fail for matrices.

What you will be able to do

  • Recognise that matrix multiplication is not commutative in general: usually AB≠BA\bm{AB} \neq \bm{BA}.
  • Use AI=A=IA\bm{AI} = \bm{A} = \bm{IA} and the left and right distributive laws.
  • Expand expressions such as (A+B)2(\bm{A} + \bm{B})^2 correctly, keeping every product in order.

With numbers, 3×5=5×33 \times 5 = 5 \times 3, so you never have to think about order. Try the same thing with two matrices:

A=[1201]B=[1031]\bm{A} = \begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix} \qquad \bm{B} = \begin{bmatrix} 1 & 0 \\ 3 & 1 \end{bmatrix} AB=[7231]BA=[1237]\bm{AB} = \begin{bmatrix} 7 & 2 \\ 3 & 1 \end{bmatrix} \qquad \bm{BA} = \begin{bmatrix} 1 & 2 \\ 3 & 7 \end{bmatrix}

Same two matrices, opposite order, different answers.

Interactive

Compare AB with BA

This shows AB\bm{AB}. Enter the two matrices the other way round to get BA\bm{BA}. Then look for a second matrix that gives the same product in both orders.

Key idea

Matrix multiplication is not commutative

In general, AB≠BA\bm{AB} \neq \bm{BA}. When AB=BA\bm{AB} = \bm{BA} does happen, we say A\bm{A} and B\bm{B} commute.

Order can matter even more than that. AB\bm{AB} can exist when BA\bm{BA} doesn't (a 2×22 \times 2 matrix times a 2×12 \times 1 matrix), and the two products can have different orders (a 2×12 \times 1 times a 1×21 \times 2 is 2×22 \times 2, but the reverse is 1×11 \times 1).

Because order matters, say which side you multiply on. Multiplying B\bm{B} by A\bm{A} on the left gives AB\bm{AB}: you pre-multiply B\bm{B} by A\bm{A}. Multiplying on the right gives BA\bm{BA}: you post-multiply. You will need this language to solve matrix equations.

Which statement is true for all 2×22 \times 2 matrices A\bm{A} and B\bm{B}?

Choose one answer

Key idea

The identity matrix commutes with everything

For any 2×22 \times 2 matrix A\bm{A},

AI=A=IA\bm{AI} = \bm{A} = \bm{IA}

so I\bm{I} is the multiplicative identity: it does for matrices what 1 does for numbers. Check one entry: the top-left entry of AI\bm{AI} is a×1+b×0=aa \times 1 + b \times 0 = a.

Other matrices that commute with A\bm{A} include any kIk\bm{I}, the powers A2\bm{A}^2 and A3\bm{A}^3, and, as you will see, the inverse A−1\bm{A}^{-1}.

The laws of matrix algebra
LawStatementSame as for numbers?
Commutative law for additionA+B=B+A\bm{A} + \bm{B} = \bm{B} + \bm{A}Yes
Additive identityA+0=A\bm{A} + \bm{0} = \bm{A}Yes
Additive inverseA+(−A)=0\bm{A} + (-\bm{A}) = \bm{0}Yes
Multiplicative identityAI=A=IA\bm{AI} = \bm{A} = \bm{IA}Yes
Multiplicative inverseAA−1=I=A−1A\bm{AA}^{-1} = \bm{I} = \bm{A}^{-1}\bm{A}Only when A−1\bm{A}^{-1} exists
Associative law for multiplication(AB)C=A(BC)(\bm{AB})\bm{C} = \bm{A}(\bm{BC})Yes
Left distributive lawA(B+C)=AB+AC\bm{A}(\bm{B} + \bm{C}) = \bm{AB} + \bm{AC}Yes, keeping A\bm{A} on the left
Right distributive law(B+C)A=BA+CA(\bm{B} + \bm{C})\bm{A} = \bm{BA} + \bm{CA}Yes, keeping A\bm{A} on the right
Commutative law for multiplicationAB=BA\bm{AB} = \bm{BA}No, it fails in general

Worked example

Why (A+B)2≠A2+2AB+B2(\bm{A} + \bm{B})^2 \neq \bm{A}^2 + 2\bm{AB} + \bm{B}^2

  • Complex familiar
  • Technology free

(a) Show that (A+B)2=A2+AB+BA+B2(\bm{A} + \bm{B})^2 = \bm{A}^2 + \bm{AB} + \bm{BA} + \bm{B}^2 for any 2×22 \times 2 matrices A\bm{A} and B\bm{B}.

(b) For A=[1201]\bm{A} = \begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix} and B=[1031]\bm{B} = \begin{bmatrix} 1 & 0 \\ 3 & 1 \end{bmatrix}, show that (A+B)2≠A2+2AB+B2(\bm{A} + \bm{B})^2 \neq \bm{A}^2 + 2\bm{AB} + \bm{B}^2.

4 steps

Try it yourself first, then check the working one step at a time.

Method

  1. Expand brackets with the distributive laws, keeping every product in order.

  2. Combine AB\bm{AB} and BA\bm{BA} only if you know the matrices commute.

  3. A single counterexample is enough to show that a general statement is false.

Watch out for

  • Writing 2AB2\bm{AB} for AB+BA\bm{AB} + \bm{BA}.

Expand and simplify (A+I)2(\bm{A} + \bm{I})^2, where A\bm{A} is a 2×22 \times 2 matrix.

Choose one answer

Common mistake

No zero-product rule and no cancelling

Two habits from ordinary algebra fail for matrices.

  • A zero product doesn't need a zero factor. [1111][1−1−11]=[0000]\begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}\begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix} = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix}, but neither matrix is 0\bm{0}.
  • You can't cancel. AB=AC\bm{AB} = \bm{AC} does not mean B=C\bm{B} = \bm{C}, unless A\bm{A} has an inverse you can multiply by.

And never write (A+B)2=A2+2AB+B2(\bm{A} + \bm{B})^2 = \bm{A}^2 + 2\bm{AB} + \bm{B}^2 unless you know A\bm{A} and B\bm{B} commute.

Why the distributive laws hold

Take any entry of A(B+C)\bm{A}(\bm{B} + \bm{C}), say the one in row ii and column jj. It is row ii of A\bm{A} times column jj of B+C\bm{B} + \bm{C}:

ai1(b1j+c1j)+ai2(b2j+c2j)=(ai1b1j+ai2b2j)+(ai1c1j+ai2c2j)a_{i1}(b_{1j} + c_{1j}) + a_{i2}(b_{2j} + c_{2j}) = (a_{i1}b_{1j} + a_{i2}b_{2j}) + (a_{i1}c_{1j} + a_{i2}c_{2j})

by the distributive law for numbers. The right-hand side is the (i,j)(i, j) entry of AB\bm{AB} plus the (i,j)(i, j) entry of AC\bm{AC}. Every entry agrees, so A(B+C)=AB+AC\bm{A}(\bm{B} + \bm{C}) = \bm{AB} + \bm{AC}. The right distributive law is proved the same way, with A\bm{A} on the right.

Find kk so that A=[1203]\bm{A} = \begin{bmatrix} 1 & 2 \\ 0 & 3 \end{bmatrix} and B=[2k04]\bm{B} = \begin{bmatrix} 2 & k \\ 0 & 4 \end{bmatrix} commute.

Summary

  • Matrix multiplication is not commutative: in general AB≠BA\bm{AB} \neq \bm{BA}. Pre-multiplying and post-multiplying are different operations.

  • AI=A=IA\bm{AI} = \bm{A} = \bm{IA}: the identity matrix acts like the number 1.

  • The distributive laws hold if every matrix keeps its side: A(B+C)=AB+AC\bm{A}(\bm{B} + \bm{C}) = \bm{AB} + \bm{AC} and (B+C)A=BA+CA(\bm{B} + \bm{C})\bm{A} = \bm{BA} + \bm{CA}.

  • (A+B)2=A2+AB+BA+B2(\bm{A} + \bm{B})^2 = \bm{A}^2 + \bm{AB} + \bm{BA} + \bm{B}^2. A zero product does not force a zero factor, and you cannot cancel.

Finished the lesson?

Try the 3 quick checks above and the lesson completes itself, or mark it complete now.

Lesson 4 of 80% read

Save your progress with a free account