studyhubDiscrete Structures III

Notes / Unit 2 · Module 2 · Exam 1 · §2.1–2.2

Operations with Matrices

Matrices get their own arithmetic: equality, sums and scalar multiples work entry by entry, but a product is rows times columns and only exists when the sizes fit. The exam asks you to compute these, write a system as Ax = b, and know which rules from ordinary algebra still hold and which break.

2.1Size, entries and equality

A matrix is written as an uppercase letter A, as a representative entry (aᵢⱼ), or as the full rectangular array. An m × n matrix has m rows and n columns, and aᵢⱼ is the entry in row i, column j — row first, always.

Two matrices A = (aᵢⱼ) and B = (bᵢⱼ) are equal when they have the same size m × n and aᵢⱼ = bᵢⱼ for every 1 ≤ i ≤ m and 1 ≤ j ≤ n.

A =
[ 1  2 ]
[ 3  4 ]

B =
[ 1 ]
[ 3 ]

C = [ 1  3 ]

D =
[ 1  2 ]
[ x  4 ]
Example 1 from the lecture

Worked example

Example 1: relate A, B, C and D by equality

  1. 1A and D are both 2 × 2 and agree everywhere except a₂₁ = 3 against x, so A = D exactly when x = 3.
  2. 2B is 2 × 1 and C is 1 × 2. They hold the same numbers but are different sizes, so B ≠ C.
  3. 3No 2 × 2 matrix can equal B or C, so A ≠ B, A ≠ C, D ≠ B, D ≠ C.

Equality is entry by entry, so a matrix equation with unknowns becomes one ordinary equation per position. Match the positions, then solve each.

2.2Addition, subtraction and scalar multiples

If A = (aᵢⱼ) and B = (bᵢⱼ) are both m × n, their sum is the m × n matrix A + B = (aᵢⱼ + bᵢⱼ). The sum of two matrices of different sizes is undefined.

Real numbers are called scalars here. The scalar multiple cA = (caᵢⱼ) multiplies every entry by c. −A means (−1)A, and A − B means A + (−1)B.

[ 2  1   0 ]   [  0  1 ]
[ 4  0  −1 ] + [ −1  3 ]   is undefined: 2 × 3 plus 2 × 2
Example 2(d)
A =
[  1  2   4 ]
[ −3  0  −1 ]
[  2  1   2 ]

B =
[  2   0  0 ]
[  1  −4  3 ]
[ −1   3  2 ]
Example 3

Worked example

Example 3: find 3A, −B and 3A − B

  1. 13A multiplies every entry by 3: rows (3, 6, 12), (−9, 0, −3), (6, 3, 6).
  2. 2−B flips every sign: rows (−2, 0, 0), (−1, 4, −3), (1, −3, −2).
  3. 33A − B = 3A + (−B), entry by entry: rows (1, 6, 12), (−10, 4, −6), (7, 0, 4).
3A − B =
[   1  6  12 ]
[ −10  4  −6 ]
[   7  0   4 ]

2.3Matrix multiplication

If A is m × n and B is n × p, the product AB is m × p. Its entry cᵢⱼ is row i of A times column j of B: multiply matching entries and add.

cᵢⱼ = Σₖ aᵢₖbₖⱼ = aᵢ₁b₁ⱼ + aᵢ₂b₂ⱼ + ⋯ + aᵢₙbₙⱼ

i
the row of A, and of AB
j
the column of B, and of AB

Defined only when the columns of A equal the rows of B. Write the sizes side by side: (m × n)(n × p) — the inside numbers must match, the outside ones are the answer.

  • The product of any two square matrices of the same size is always defined.
  • AB can be defined while BA is not: a 3 × 2 times a 2 × 2 works, a 2 × 2 times a 3 × 2 does not.
  • Matrix multiplication is not commutative: even when both exist, AB and BA are usually different.
A =
[ −1   3 ]
[  4  −2 ]
[  5   0 ]

B =
[ −3  2 ]
[ −4  1 ]
Example 4(i): A is 3 × 2, B is 2 × 2, so AB is 3 × 2

Worked example

Example 4(i): find AB

  1. 1c₁₁ = (−1)(−3) + (3)(−4) = 3 − 12 = −9; c₁₂ = (−1)(2) + (3)(1) = 1.
  2. 2c₂₁ = (4)(−3) + (−2)(−4) = −12 + 8 = −4; c₂₂ = (4)(2) + (−2)(1) = 6.
  3. 3c₃₁ = (5)(−3) + (0)(−4) = −15; c₃₂ = (5)(2) + (0)(1) = 10.
  4. 4BA is undefined: B has 2 columns but A has 3 rows.
AB =
[  −9   1 ]
[  −4   6 ]
[ −15  10 ]

Worked example

Exercise 1 (iv) and (v): a row times a column, then the other way

  1. 1(1 × 3)(3 × 1) is 1 × 1: [1 −2 −3] times the column (2, −1, 1) is (1)(2) + (−2)(−1) + (−3)(1) = 1, so the product is [1].
  2. 2(3 × 1)(1 × 3) is 3 × 3: every entry is one number of the column times one of the row, giving rows (2, −4, −6), (−1, 2, 3), (1, −2, −3).

2.4Ax = b and linear combinations of columns

A system of m equations in n unknowns is the single matrix equation Ax = b: A is the m × n coefficient matrix, x the n × 1 column of unknowns, b the m × 1 column of constants. Multiplying out Ax gives back the left-hand sides, row by row.

Partition A into its columns a₁, a₂, …, aₙ. Then the product is a linear combination of the columns of A with the unknowns as coefficients:

Ax = x₁a₁ + x₂a₂ + ⋯ + xₙaₙ = b

So Ax = b is consistent if and only if b is a linear combination of the columns of A, and the coefficients that build b are a solution.

Worked example

Example 5: Ax = 0 with A = [1 −2 1; 2 3 −2]

  1. 1Two equations, three unknowns, and x = 0 always works, so the system is consistent with infinitely many solutions.
  2. 2The solution set is x = (t, 4t, 7t) = t(1, 4, 7) for any real t.
  3. 3Check (1, 4, 7): 1 − 8 + 7 = 0 and 2 + 12 − 14 = 0.
  4. 4Sample solutions: (1, 4, 7), (2, 8, 14), (0, 0, 0), (−1, −4, −7) — any multiple of (1, 4, 7).

Worked example

Exercise 3: write (0, 6, 5) as a combination of (1, 1, 2), (−1, 2, 0), (−1, −1, −1)

  1. 1Set c₁(1, 1, 2) + c₂(−1, 2, 0) + c₃(−1, −1, −1) = (0, 6, 5): that is Ax = b with these three vectors as the columns of A.
  2. 2Row 1: c₁ − c₂ − c₃ = 0. Row 2: c₁ + 2c₂ − c₃ = 6. Row 3: 2c₁ − c₃ = 5.
  3. 3Row 2 − row 1 gives 3c₂ = 6, so c₂ = 2. Then c₁ − c₃ = 2 and 2c₁ − c₃ = 5 give c₁ = 3, c₃ = 1.
  4. 4(0, 6, 5) = 3(1, 1, 2) + 2(−1, 2, 0) + 1(−1, −1, −1). Check row 1: 3 − 2 − 1 = 0.

Worked example

Exercise 2: x₁ + 2x₂ + 3x₃ = 0, 4x₁ + 5x₂ + 6x₃ = 3, 7x₁ + 8x₂ + 9x₃ = 6

  1. 1A has rows (1, 2, 3), (4, 5, 6), (7, 8, 9); b = (0, 3, 6).
  2. 2x = (1, 1, −1) works: 1 + 2 − 3 = 0, 4 + 5 − 6 = 3, 7 + 8 − 9 = 6.
  3. 3So b = 1·a₁ + 1·a₂ − 1·a₃. It is not the only way: adding any multiple of (1, −2, 1), which A sends to 0, gives another.

2.5The rules that carry over

Matrix algebra shares many, but not all, of the properties of real numbers. These hold whenever the sizes make each side defined (A, B, C matrices; c, d scalars).

RuleName
A + B = B + ACommutative property of addition
A + (B + C) = (A + B) + CAssociative property of addition
(cd)A = c(dA); 1A = AAssociative property; multiplicative identity
c(A + B) = cA + cB; (c + d)A = cA + dADistributive properties
A + O = A; A + (−A) = OZero matrix O is the additive identity
cA = O ⇒ c = 0 or A = OTheorem 2.2(3), for a scalar c
A(BC) = (AB)CAssociative property of multiplication
A(B + C) = AB + AC; (A + B)C = AC + BCDistributive properties
c(AB) = (cA)B = A(cB)Scalars move freely

Worked example

Exercise 1 (2.2): solve 3X + A = B with A = [1 −2; 0 3], B = [−3 4; 2 1]

  1. 1Exactly as with numbers: subtract A from both sides, 3X = B − A = [−4 6; 2 −2].
  2. 2Multiply by 1/3: X = [−4/3 2; 2/3 −2/3].

Worked example

Exercise 2: ABC with A = [1 −2; 2 −1], B = [1 0 2; 3 −2 1], C = [−1 0; 3 1; 2 4]

  1. 1By associativity you may group either way. BC is (2 × 3)(3 × 2) = 2 × 2: BC = [3 8; −7 2].
  2. 2A(BC) = [1·3 + (−2)(−7) 1·8 + (−2)(2); 2·3 + (−1)(−7) 2·8 + (−1)(2)] = [17 4; 13 14].
  3. 3(AB)C gives the same matrix — but AB is 2 × 3 first, so it is more work.

2.6The rules that break

Three habits from ordinary algebra fail for matrices, and exam items are built on each.

AB ≠ BA
Multiplication is not commutative. One may be defined and the other not; both may be defined and differ; occasionally they agree.
No cancellation
AC = BC does not give A = B, and AB = AC does not give B = C (unless the cancelled matrix is invertible, §2.3).
Zero divisors
AB = O is possible with A ≠ O and B ≠ O. E.g. [1 1; 1 1] times [1 −1; −1 1] is the zero matrix.
AB =
[ 2   5 ]
[ 4  11 ]

BA =
[ 3   4 ]
[ 7  10 ]
Example 4(ii): A = [1 2; 3 4], B = [0 1; 1 2]

Worked example

Exercise 3: are AB and BA equal?

  1. 1(i) A = [1 3; 2 −1], B = [2 −1; 0 2]: AB = [2 5; 4 −4] but BA = [0 7; 4 −2]. Not equal.
  2. 2(ii) A = [1 2; 1 1], B = [−2 4; 2 −2]: AB = [2 0; 0 2] and BA = [2 0; 0 2]. Equal — a special pair, not the rule.
A =
[ 1  3 ]
[ 0  1 ]

B =
[ 2  4 ]
[ 2  3 ]

C =
[  1  −2 ]
[ −1   2 ]

AC = BC =
[ −2  4 ]
[ −1  2 ]
Exercise 4: AC = BC although A ≠ B

Because of this, (A + B)² = A² + AB + BA + B², which is A² + 2AB + B² only when AB = BA.

2.7The identity matrix and powers

The identity matrix Iₙ is the n × n matrix with 1s on the main diagonal and 0s elsewhere: I₁ = [1], I₂ = [1 0; 0 1], I₃ = [1 0 0; 0 1 0; 0 0 1]. It is the identity for multiplication.

A Iₙ = A Iₘ A = A

A
an m × n matrix

On the right the identity matches the columns of A; on the left it matches the rows.

For a square A, Aᵏ = AA⋯A (k factors), A¹ = A and A⁰ = I. Then AʲAᵏ = Aʲ⁺ᵏ and (Aʲ)ᵏ = Aʲᵏ.

Worked example

Exercise 4: A³ for A = [2 −1; 3 0]

  1. 1A² = AA = [2·2 + (−1)·3 2·(−1) + (−1)·0; 3·2 + 0·3 3·(−1) + 0·0] = [1 −2; 6 −3].
  2. 2A³ = A²A = [1·2 + (−2)·3 1·(−1) + (−2)·0; 6·2 + (−3)·3 6·(−1) + (−3)·0] = [−4 −1; 3 −6].

2.8The transpose

The transpose Aᵀ writes the rows of A as columns: row i of A becomes column i of Aᵀ. If A is m × n, Aᵀ is n × m, and the (i, j) entry of Aᵀ is aⱼᵢ. A square matrix is symmetric when A = Aᵀ.

PropertyName
(Aᵀ)ᵀ = ATranspose of a transpose
(A + B)ᵀ = Aᵀ + BᵀTranspose of a sum
(cA)ᵀ = c(Aᵀ)Transpose of a scalar multiple
(AB)ᵀ = BᵀAᵀTranspose of a product — the order reverses

These extend to more terms: (A + B + C)ᵀ = Aᵀ + Bᵀ + Cᵀ and (ABC)ᵀ = CᵀBᵀAᵀ.

Worked example

Exercise 6: A = [2 1 −2; −1 0 3; 0 −2 1], B = [3 1; 2 −1; 3 0]

  1. 1AB is (3 × 3)(3 × 2) = 3 × 2: AB = [2 1; 6 −1; −1 2], so (AB)ᵀ = [2 6 −1; 1 −1 2].
  2. 2BᵀAᵀ is (2 × 3)(3 × 3) = 2 × 3 and also comes to [2 6 −1; 1 −1 2]. Equal, as the theorem says.
  3. 3AᵀBᵀ would be (3 × 3)(2 × 3): undefined. The order has to reverse.
A =
[  1   3 ]
[  0  −2 ]
[ −2  −1 ]

AAᵀ =
[ 10  −6  −5 ]
[ −6   4   2 ]
[ −5   2   5 ]
Exercise 7: AAᵀ is 3 × 3 and symmetric

AAᵀ is always symmetric, because (AAᵀ)ᵀ = (Aᵀ)ᵀAᵀ = AAᵀ. It is square even when A is not.

Check yourself

Answer these out loud, without scrolling up. Any you can't, reread that section — then let the drill mark you.

  1. 1.A is 2 × 3 and B is 3 × 4. What is the size of AB, and is BA defined?
  2. 2.Write the (2, 1) entry of AB as a sum, in terms of the entries of A and B.
  3. 3.Rewrite x₁ − 2x₃ = 4, 3x₂ + x₃ = 1 as Ax = b, then write Ax as a linear combination of the columns of A.
  4. 4.Give the rule for (AB)ᵀ and explain why AᵀBᵀ can fail to be defined.
  5. 5.Name three properties of real-number multiplication that fail for matrices, with an example of one.
  6. 6.Solve 2X − A = B for X.