Chapter 6 – Intro to Matrices Operations/properties Now multiplication
Matrix Multiplication The product of matrices A (m x n) and B (n x p) is the m x p matrix C whose entry cij is given by: Check to see if 2 matrices can be multiplied - check for compatibility! Product of matrices A and B can be calculated if : # of columns of A equals # of rows in B
Matrix Multiplication Example – Sizes of Matrices and Their Product A = 3 × 5 matrix ( # columns = 5 ) B = 5 × 3 matrix (# rows = 5) so #columns_A = #rows_B COMPATIBLE! Product AB is then a 3 × 3 matrix (#rows_A × #columns_B) And(!) BA = 5 × 5 matrix product of 5 × 3 and 3 × 5 5 × 5
Matrix Multiplication Example – Sizes of Matrices and Their Product Assume: C = 3 × 5 matrix (how many columns?) 5 D = 7 × 3 matrix (how many rows?) 7 Are they compatible? Nope! What about product DC ? (different order of multiplication)?
Matrix Multiplication Example – Sizes of Matrices and Their Product Now: D = 7 × 3 matrix (how many columns?) 3 C = 3 × 5 matrix ( how many rows?) 3 So, product CD is undefined, but DC ~is~ defined. Size/dimension of product DC? product of 7 × 3 and 3 × 5 7 × 5
Matrix Multiplication Example – Sizes of Matrices and Their Product In general a m × n matrix is compatible with a n × p matrix and product is matrix of size m × p [m × n ] [n × p ] = [m × p]
Matrix Multiplication Example – Sizes of Matrices and Their Product Try: Compatible or undefined? Size of product? 3 × 6 times 6 × 5 ? 6 × 5 times 3 × 6 ? 2 × 3 times 2 × 3 ? 1 × 4 times 4 × 1 ? 4 × 1 times 1 × 4 ? bird × cat times cat × dog ? So, product CD is undefined, but DC ~is~ defined. Size/dimension of product DC? DC is a 7 × 5 matrix. In general a m × n is compatible with a n × p and product is a matrix of size m × p
Matrix Multiplication Example – Sizes of Matrices and Their Product Try: Compatible or undefined? Size of product? 3 × 6 times 6 × 5 ? Yes, compatible: 3 × 5 6 × 5 times 3 × 6 ? Undefined 2 × 3 times 2 × 3 ? Undefined 1 × 4 times 4 × 1 ? Yes, compatible: 1 × 1 4 × 1 times 1 × 4 ? Yes, compatible: 4 × 4 bird × cat times cat × dog? Yes, compatible: bird × dog
Example – Matrix Products 2 5 1 4 0 2 1 × 3 times 3 × 1 1 × 1 want first row & first column First row of matrix on left? 2 5 1 First column of matrix on right? 4 0 2 Multiply/add/combine: C11 = 2(4) + 5(0) + 1(2) = 8 + 0 + 2 = 10 Product: 𝟏𝟎
Example – Matrix Products 1 4 6 2 0 3 1 −1 3 2 × 3 times 3 × 1 2 × 1 𝑪𝟏𝟏 𝐶21 want first row & first column First row of matrix on left? 1 4 6 First column of matrix on right? 1 -1 3 Multiply/add/combine: C11 = 1(1) + 4(-1) + 6(3) = 1 + (-4) + 18 = 15 Product: 𝟏𝟓 b. c. d.
Example – Matrix Products 1 4 6 2 0 3 1 −1 3 2 × 3 times 3 × 1 2 × 1 𝟏𝟓 𝐶21 want second row & first column Second row of matrix on left? 2 0 3 First column of matrix on right? 1 -1 3 Multiply/add/combine: C21 = 2(1) + 0(-1) + 3(3) = 2 + 0 + 9 = 11 Product: 𝟏𝟓 𝟏𝟏 b. c. d.
Example – Matrix Products 1 2 0 −2 0 5 1 2 3 4 5 6 2 × 3 times 3 × 2 2 × 2 𝑪𝟏𝟏 𝐶12 𝐶21 𝐶22 (need four entries) C11? First row (left matrix), first column (right): 1 2 0 & 1 3 5 : C11 = 1(1) + 2(3) + 0(5) = 1 + 6 + 0 = 7 C12? First row (left matrix), second column(right): 1 2 0 & 2 4 6 : C12 = 1(2) + 2(4) + 0(6) = 2 + 8 + 0 = 10
Example – Matrix Products 1 2 0 −2 0 5 1 2 3 4 5 6 2 × 3 times 3 × 2 2 × 2 𝟕 𝟏𝟎 𝑪𝟐𝟏 𝑪𝟐𝟐 C21? Second row (left matrix), first column (right): -2 0 5 & 1 3 5 : C21 = -2(1) + 0(3) + 5(5) = -2 + 0 + 25 = 23 C22? Second row (left matrix), second column(right): -2 0 5 & 2 4 6 : C22 = -2(2) + 0(4) + 5(6) = -4 + 0 + 30 = 26
Example – Matrix Products – Try it …! 2 5 −1 1 4 0 0 3 7 1 2 3 4 5 6 3 × 3 times 3 × 2 3 × 2 𝑪𝟏𝟏 𝑪𝟏𝟐 𝑪𝟐𝟏 𝑪𝟐𝟐 𝑪𝟑𝟏 𝑪𝟑𝟐 (need six entries) C11? First row (left matrix), first column (right): C11 = ? C12? First row (left matrix), second column(right): C12 =
Example – Matrix Products – Try it …! 2 5 −1 1 4 0 0 3 7 1 2 3 4 5 6 3 × 3 times 3 × 2 3 × 2 𝑪𝟏𝟏 𝑪𝟏𝟐 𝑪𝟐𝟏 𝑪𝟐𝟐 𝑪𝟑𝟏 𝑪𝟑𝟐 (need six entries) C11? First row (left matrix), first column (right): C11 = 2(1) + 5(3) + (-1)(5) = 2 + 15 - 5 = 12 C12? First row (left matrix), second column(right): C12 = 2(2) + 5(4) + (-1)(6) = 4 + 20 – 6 = 18 𝟏𝟐 𝟏𝟖 ? ? ? ?
Example – Matrix Products – Try it …! 2 5 −1 1 4 0 0 3 7 1 2 3 4 5 6 3 × 3 times 3 × 2 3 × 2 𝟏𝟐 𝟏𝟖 𝑪𝟐𝟏 𝑪𝟐𝟐 𝑪𝟑𝟏 𝑪𝟑𝟐 C21? Second row (left matrix), first column (right): C21 = ? C22? Second row (left matrix), second column(right): C22 =
Example – Matrix Products – Try it …! 2 5 −1 1 4 0 0 3 7 1 2 3 4 5 6 3 × 3 times 3 × 2 3 × 2 𝑪𝟏𝟏 𝑪𝟏𝟐 𝑪𝟐𝟏 𝑪𝟐𝟐 𝑪𝟑𝟏 𝑪𝟑𝟐 C21? Second row (left matrix), first column (right): C21 = 1(1) + 4(3) + (0)(5) = 1 + 12 + 0 = 13 C22? Second row (left matrix), second column(right): C22 = 1(2) + 4(4) + (0)(6) = 2 + 16 +0 = 18 𝟏𝟐 𝟏𝟖 𝟏𝟑 𝟏𝟖 ? ?
Example – Matrix Products – Try it …! 2 5 −1 1 4 0 0 3 7 1 2 3 4 5 6 3 × 3 times 3 × 2 3 × 2 𝟏𝟐 𝟏𝟖 𝟏𝟑 𝟏𝟖 𝑪𝟑𝟏 𝑪𝟑𝟐 C31? Third row (left matrix), first column (right): C31 = 0(1) + 3(3) + (7)(5) = 0 + 9 + 35 = 44 C32? Third row (left matrix), second column(right): C32 = 0(2) + 3(4) + (7)(6) = 0 + 12 + 42 = 54 𝟏𝟐 𝟏𝟖 𝟏𝟑 𝟏𝟖 𝟒𝟒 𝟓𝟒
Example – Matrix Products b. c.
If Note that A(BC) = (AB)C. Example – Associative Property compute ABC in two ways. Solution 1: 𝑨 𝑩𝑪 = 1 −2 −3 −4 3 0 −1 1 1 2 1 0 0 2 1 1 = 1 −2 −3 −4 2 −1 3 4 = −𝟒 −𝟗 −𝟏𝟖 −𝟏𝟑 Solution 2: 𝐀𝐁 𝐂= 1 −2 −3 −4 3 0 −1 1 1 2 1 0 0 2 1 1 = 1 −2 −5 −13 −4 −5 1 0 0 2 1 1 = −𝟒 −𝟗 −𝟏𝟖 −𝟏𝟑 Note that A(BC) = (AB)C.
Two Special Matrices (Identities) Identity for addition: zero matrix O Aij = 0 for all i, j Identity matrix for multiplication I Aij = 1 for all i = j Aij = 0 for all i ≠ j (all matrix elements on diagonal are 1, all others 0) E.g: A+O = 𝟏 𝟐 𝟑 𝟒 + 𝟎 𝟎 𝟎 𝟎 = 𝟎 𝟎 𝟎 𝟎 + 𝟏 𝟐 𝟑 𝟒 = O+A = 𝟏 𝟐 𝟑 𝟒 = A AI = 𝟏 𝟐 𝟑 𝟒 𝟏 𝟎 𝟎 𝟏 = 𝟏 𝟎 𝟎 𝟏 𝟏 𝟐 𝟑 𝟒 = 𝟏 𝟐 𝟑 𝟒 = A
Solution: Example – Matrix Operations Involving I and O If compute each of the following. Solution:
Given the price and the quantities, calculate the total cost. Example – Cost Vector Given the price and the quantities, calculate the total cost. Solution: The cost vector is
in matrix form by using matrix multiplication. Example – Matrix Form of a System Using Matrix Multiplication Write the system in matrix form by using matrix multiplication. Solution: If then the single matrix equation is