You learn matrix addition, scalar multiplication, matrix product, transpose and trace; when a product is defined; and the rules that behave differently from numbers, such as AB ≠ BA.
matrixentrysize (order)square matrixzero matrixidentity matrixscalar multiplematrix productlinear combinationtransposesymmetric matrixtracecommutematrix power
This week we turn the matrix from a table of numbers into an algebraic object: we will add, multiply and take powers. Most of the rules are familiar from numbers. Exam questions come exactly from the places that are not familiar: when a product is defined, why AB is not equal to BA, why (AB)T is BTAT.
Golden rules:
Before a product, write the sizes: (m×n)(n×p)=m×p. If the inner dimensions are not equal, the product does not exist.
(AB)ij = row i of A · column j of B. If only one entry is asked, compute only that.
AB=BA in general. Leave the habit “order doesn’t matter” from numbers behind here.
Transpose and inverse reverse the order in a product: (AB)T=BTAT.
Definitions and notation
A matrix with m rows and n columns is called an m×nmatrix. The element in row i, column j is called aij (entry). The notation A=[aij] expresses this.
Name
Definition
Example
Square matrix
m=n
2×2, 3×3
Zero matrix O
all entries are 0
A+O=A
Identity matrix In
1 on the diagonal, 0 elsewhere
AI=IA=A
Diagonal
0 off the diagonal
diag(2,−1,5)
Upper triangular
0 below the diagonal
square matrices in REF
Row / column vector
1×n / m×1
x=(x1,…,xn)T
Two matrices are equal only if they have the same size and every corresponding entry is equal. So a “matrix equation” is really as many numerical equations as there are entries (Q6).
Addition and scalar multiplication
Two matrices of the same size are added entry by entry. Multiplying by a number c multiplies every entry by c.
Both are defined but one is 2×2 and the other 3×3. Even for square matrices they are generally not equal:
C=[1011],D=[1101]:CD=[2111]=DC=[1112].
When AB=BA, A and B are said to commute. This is a special case, not the default.
Writing a system as a matrix
A system of m equations in n unknowns becomes a single matrix equation: Ax=b. And Ax has a nice interpretation: it is a linear combination of the columns of A, with the components of x as coefficients.
1302−14[2−1]=2130−12−14=07−4
This view will come back in weeks 7 and 9 (span, column space): Ax=b is consistent if and only if b is a combination of the columns of A.
Properties of the product
What is true (when the sizes fit):
Property
Formula
Associative
A(BC)=(AB)C
Left distributive
A(B+C)=AB+AC
Right distributive
(A+B)C=AC+BC
Scalar
c(AB)=(cA)B=A(cB)
Identity
ImA=A=AIn
Powers
ArAs=Ar+s, (Ar)s=Ars, A0=I
What is true for numbers but false for matrices:
For numbers
For matrices
ab=ba
AB=BA in general
ab=0⇒a=0 or b=0
[1224][2−1−42]=O
ab=ac, a=0⇒b=c
for P=[1224], PI=P[3−1−43] but I=[3−1−43]
(a+b)2=a2+2ab+b2
(A+B)2=A2+AB+BA+B2
PITFALL · cancelling on both sides. When you see AB=AC you can’t “cancel the A‘s”. This is true only if A is invertible (next week): you multiply from the left by A−1. The P above is not invertible (detP=0), which is why cancellation fails.
Transpose
The transposeAT of A is the matrix with its rows made into columns: (AT)ij=aji. The transpose of an m×n matrix is n×m.
A=[1023−14]⇒AT=12−1034
Rules: (AT)T=A, (A+B)T=AT+BT, (cA)T=cAT and
(AB)T=BTAT.
Why does the order reverse? If AB is m×p, then (AB)T is p×m. BT is p×n, AT is n×m: only BTAT gives this size. In the example above, (AB)T=[−3−4920] and BTAT gives the same.
Symmetric matrix:AT=A. It must be square and aij=aji: a mirror about the diagonal. ATA and AAT are symmetric for every matrix, because (ATA)T=AT(AT)T=ATA. Symmetric matrices are the main topic of week 14.
Trace
The trace of a square matrix is the sum of its diagonal entries: trA=a11+a22+⋯+ann.
tr(A+B)=trA+trB, tr(cA)=ctrA, tr(AT)=trA.
tr(AB)=tr(BA), even when AB and BA have different sizes. In the example above both are 17.
The trace will return in week 13 as the sum of the eigenvalues.
Powers
For square A, A2=AA, A3=AAA, and so on. When computing, look for a pattern:
A=[1021]:A2=[1041],A3=[1061],An=[102n1].
The power of a diagonal matrix is the easiest: take the power of each number on the diagonal. diag(2,−1)5=diag(32,−1). In week 13 the whole point of diagonalization will be to bring every matrix to this easy case.
TIP · a matrix inside a polynomial. If p(x)=x2−5x−2, then p(A)=A2−5A−2I. The constant term is multiplied by I; you can’t write "−2" and subtract a number from a matrix.
Common mistakes
Wrong
Right
Trying to multiply (2×3)(2×3)
The inner dimensions (3 and 2) are not equal: undefined
Multiplying entry by entry
Row · column
Assuming AB=BA
Try a concrete matrix, they usually differ
(AB)T=ATBT
(AB)T=BTAT
AB=0⇒A=0 or B=0
False, there are matrices that are zero divisors
AB=AC⇒B=C
Only if A is invertible
(A+B)2=A2+2AB+B2
A2+AB+BA+B2
Writing A2−5A−2
A2−5A−2I
Test yourself
Exam-style questions. Solve them on paper first, then reveal the answer.
Question 1easy
Let A be 3×4 and B be 4×2. What is the size of AB? Is BA defined?
Show answer
3×2; BA is not defined
(3×4)(4×2): the inner dimensions 4 and 4 are equal, and the result has the outer dimensions 3×2.BA: (4×2)(3×4), the inner dimensions 2 and 3 are different. Undefined.
Question 2easy
Let X=[13−20] and Y=[2−114]. Compute 2X−3Y.
Show answer
[−49−7−12]
Entry by entry: 2X=[26−40], 3Y=[6−3312]. Difference: (2−6,−4−3;6+3,0−12)=[−49−7−12].
Question 3easy
Let A=[210−113] and B=1402130−25. Find only the entry (AB)23.
Show answer
17
(AB)23 is the dot product of row 2 of A with column 3 of B.(1,−1,3)⋅(0,−2,5)=0+2+15=17. When only one entry is asked, do not compute the whole product.
Question 4medium
With A and B as in the previous question, compute AB.
Show answer
[2−3710517]
(2×3)(3×3) → 2×3. Row 1 (2,0,1): with the columns, 2+0+0=2, 4+0+3=7, 0+0+5=5. Row 2 (1,−1,3): 1−4+0=−3, 2−1+9=10, 0+2+15=17.
Question 5medium
With the same A and B, find (AB)T. Which product of transposes equals it?
Show answer
275−31017=BTAT
Transpose: rows become columns. Since AB is 2×3, (AB)T is 3×2. The rule is (AB)T=BTAT, the order reverses. ATBT would be (3×2)(3×3), not even defined.
Question 6medium
Find x and y such that [x32y]+2[1xy1]=[5964].
Show answer
x=3,y=2
Equate entry by entry: x+2=5, 2+2y=6, 3+2x=9, y+2=4. The first equation gives x=3, the second y=2. The other two also hold (3+6=9, 2+2=4), so it is consistent.
Question 7medium
Let A=[1324]. Compute A2−5A−2I.
Show answer
[0000]
A2=[1+63+122+86+16]=[7151022].5A=[5151020], 2I=[2002].7−5−2=0, 10−10=0, 15−15=0, 22−20−2=0. The zero matrix. Note: for a 2×2 matrix, A2−(trA)A+(detA)I=0 is always true (Cayley-Hamilton in week 13).
Question 8hard
Find all 2×2 matrices B that commute with C=[1011], i.e. CB=BC.
Show answer
B=[a0ba], a,b∈R
Take B=[acbd]. CB=[a+ccb+dd], BC=[aca+bc+d]. Equate: a+c=a⇒c=0; b+d=a+b⇒d=a; the others hold automatically. Result: c=0, d=a, with a and b free.
Question 9hard
True or false: (A+B)2=A2+2AB+B2 for all n×n matrices A,B.
Show answer
False
The correct expansion is (A+B)2=A2+AB+BA+B2. It becomes 2AB only if AB=BA. Counterexample: C=[1011], D=[1101]. (C+D)2=[5445] but C2+2CD+D2=[6444].
Question 10medium
Let A=[1023−14] and B=2−13105. Find tr(AB) and tr(BA).
Show answer
Both are 17
AB=[−39−420], trace −3+20=17.BA=2−137−2212117, trace 2−2+17=17. Even when AB and BA have different sizes, tr(AB)=tr(BA) is always true.
Question 11hard
Let A=[1021]. Find A10.
Show answer
[10201]
A2=[1041], A3=[1061]. Pattern: An=[102n1] (by induction: the upper right entry of AnA is 2n+2).n=10: upper right 20.
Question 12easy
For which x is [12x−3x+14] a symmetric matrix?
Show answer
x=4
Symmetric: AT=A, that is, a12=a21. x+1=2x−3⇒x=4. Check: the matrix is [1554].
Verification: All matrix products, transposes, powers and traces were computed exactly in node with BigInt fractions; the claims about properties (no commutativity, AB = 0, no cancellation, (AB)^T = B^T A^T) were checked with concrete matrices (verify/MAT1041/02.mjs).
Review card
Size m×n: m rows, n columns. a_ij: row i, column j.
Addition/subtraction: ONLY the same size, entry by entry. cA: every entry × c.
AB defined ⇔ (m×n)(n×p): inner dimensions equal → result m×p.
(AB)_ij = row i of A · column j of B.
Ax = x1·(column 1) + x2·(column 2) + ... (a linear combination of the columns)
AB ≠ BA in general! (A+B)² = A² + AB + BA + B²
AB = 0 is possible with A≠0, B≠0. AB = AC ⇏ B = C (no cancellation).
AI = IA = A. A⁰ = I, A^r A^s = A^(r+s).
(A^T)^T = A, (A+B)^T = A^T + B^T, (cA)^T = cA^T, (AB)^T = B^T A^T (ORDER REVERSES)
Symmetric: A^T = A (square, a_ij = a_ji). A^T A is always symmetric.
Trace: tr A = sum of the diagonal. tr(AB) = tr(BA).
If only one entry is asked, compute only that.