c Math 166, Fall 2015, Robert Williams Ch 5- Matrices Matrix Basics If A is a matrix with m rows and n columns, then the order of A is denoted by m × n. A is sometimes written as (ai,j )m×n or (ai,j ). The element in the ith row and j th column is denoted ai,j . Some matrices have special names that describe their order or special properties. A few that we will talk about are: 1. A row vector or row matrix is a matrix that consists of a single row. If the order of the matrix is 1 × n, then it is a row matrix of dimension n 2. A column vector or column matrix is a matrix that consists of a single column. If the order of the matrix is m × 1, then it is a column matrix of dimension m 3. A square matrix is a matrix where the number of rows is equal to the number of columns (i.e. it has order n × n) Example 1 Consider the following matrices: 10 h i −12 3 1 0 C = 3 −1 −5 −12 B= A= 2 2 −1 4 7 What is the order of A, B, and C? What are a2,3 , b3,1 , and c1,4 ? 1 c Math 166, Fall 2015, Robert Williams Two matrices are considered to be equal if they have the same order AND all corresponding entries are equal. Non-Example: No two of 1 2 3 4 the below matrices are equal h i 1 3 1 1 2 3 4 2 4 3 2 4 0 0 Example 2 Find the values of x and y such that 1 x 3 1 7 3 = 0 2 5 y 2 5 Matrix Operations A number c is often referred to as a scalar to make it clear that we mean a number and not a 1 × 1 matrix. Scalar Multiplication: If c is a number and A is a matrix, then cA is the matrix obtained by multiplying every entry in A by c 1 2 3 6 = 3 3 4 9 12 Transpose of a Matrix: If A = (ai,j ) is a m × n matrix, then the transpose of A is the n × m matrix AT = (aj,i ) 1 3 5 T 2 1 4 = 2 6 2 3 5 4 6 c Math 166, Fall 2015, Robert Williams Matrix Addition/Subtraction: If A and B are both m×n matrices, then A+ B (or A−B) is the matrix obtained by adding (or subtracting) the corresponding entries of A and B. Addition and subtraction between matrices of different sizes is not defined. 1 3 2 2 + 4 3 3 = −2 6 0 2 2 Example 3 Consider the following matrices: 1 A= 4 3 1 2 −3 B= 0 −2 −3 Find each of the following: 1. 2A 2. A + B 3. A − 2B T 3 4 6 3 c Math 166, Fall 2015, Robert Williams Example 4 A local movie store recieves shipments from two local warehouses. The current stock of the warehouses is given in the tables below. Warehouse A Comedy Horror Drama Action DVD 103 213 172 154 Blu-ray 85 97 83 72 Warehouse B Comedy Horror Drama Action DVD 178 97 104 126 Blu-ray 95 84 76 83 Make a matrix representing the available stock that the store can request from these warehouses. We let 0m×n , sometimes written simply as 0, denote the zero matrix- i.e. the m × n matrix with all entries equal to zero. If A, B, and C are all m × n matrices, then we have the following rules: • A+0=0+A=A • A−A=0 • A+B =B+A • A + (B + C) = (A + B) + C 4 c Math 166, Fall 2015, Robert Williams h i Row Vector × Column Vector: Let R = r1 r2 . . . rn be a row vector c1 c2 and C = .. be a column vector such that R and C have an equal number of . cn entries. Then we define multiplication of R and C as c1 i h i c2 h = r c + r c + ··· + r c RC = r1 r2 . . . rn 1 1 2 2 n n .. . cn h Example 5 3 4 −1 i 1 2 = 0 Example 6 A company has four employees: Bob, Sarah, Jane, and Chris. Bob is paid $10.50 an hour and worked 32 hours last week. Sarah is paid $15 an hour and worked 38 hours last week. Jane is paid $11.25 an hour and worked 28 hours last week. Chris is paid $13.75 an hour and worked 35 hours last week. Use matrices to determine how much money the company paid its employees. 5 c Math 166, Fall 2015, Robert Williams Matrix Multiplication: Let A be a m × p matrix and B be a p × n matrix. Then AB is the m × n matrix where entry in the ith row and j th column of AB is the product of the ith row of A with the j th column of B. Note that AB is only defined when the number of columns in A is equal to the number of rows in B. 1 Example 7 3 5 2 3 4 2 6 1 0 0 1 We let In = .. .. . . 5 = 1 0 . . . 0 . be the n × n matrix with ones on the diagonal and .. . .. 0 0 ... 1 zero everywhere else. This matrix is called the n × n identity matrix. Matrix ... multiplication obeys the following rules: • In A = AIm = A where A is a n × m matrix • A(BC) = (AB)C where A is n × m, B is m × p, and C is p × q • A(B + C) = AB + AC where A is n × m and both B and C are m × p 6 c Math 166, Fall 2015, Robert Williams Example 8 Let A, B, and C be the matrices shown below: 1 3 −1 0 1 A= B= C= 4 3 3 7 2 Find the following: • AC • CA • AB • BA 7 c Math 166, Fall 2015, Robert Williams Example 9 John wants to surprise Elaine with a homemade cake, but he only has time to visit one store to gather the ingredients. He knows how to make two different cakes. The first cake requires two sets of batter ingredients and one set of icing ingredients, while the second cake only requires one set of batter ingredients but two sets of icing ingredients. The first store he can go to sells a set of the batter ingredients for $2.75 and a set of the icing ingredients for $1.82. The second store that he can go to sells a set of the batter ingredients for $3.15 and a set of the icing ingredients for $1.45. If John wants to minimize the amount of money he spends, which cake should he make and from which store should he buy the ingredients? Inverse Matrix: The n × n matrix B is said to be the inverse of the n × n matrix A if AB = BA = In . In this case, we write B = A−1 . Only square matrices may have an inverse, but not all do. A matrix that does not have an inverse is called a singular matrix. If A is an n × n matrix, we find A−1 as follows: • Form the augmented matrix [A|In ] • If possible, use row operations to reduce [A|In ] to [In |B]. If it is not possible, then A is not invertible. • A−1 = B 8 c Math 166, Fall 2015, Robert Williams −1 Example 10 Let A = 2 −1 −1 is A ? Is B = B ? 6 0 and B = −1 1 2 7 Example 11 Let A = 3 −6 11 3 13 1 0 . Is A = B −1 ? If not, what −3. What is A−1 ? 8 We can re-write systems of equations using matrices. Suppose we have the following system: a1,1 x1 + a1,2 x2 + · · · + a1,n xn = b1 a2,1 x1 + a2,2 x2 + · · · + a2,n xn = b2 .. . an,1 x1 + an,2 x2 + · · · + an,n xn = bn a1,1 a1,2 . . . a1,n x1 b1 a2,1 a2,2 . . . a2,n x2 b2 , X = , and B = , then Then if we let A = .. . . .. .. .. .. . .. . . . an,1 an,2 . . . an,n xn bn we can write the system of equations as AX = B. The system of equations has a unique solution if and only if A is invertible. In this case, we get X = A−1 B. 9 c Math 166, Fall 2015, Robert Williams Example 12 Solve the two systems of linear equations below System 1 System 2 3x + 2y − z = 20 3x + 2y − z = 32 −x + 3y + z = 10 −x + 3y + z = 32 10x − 20y + 30z = 60 10x − 20y + 30z = 140 10