Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
4.6 Matrices 1 Matrices are rectangular arrangements of data that are used to represent information in tabular form. 1 0 4 A 3 - 6 8 a23 Dimensions: number of rows and columns A is a 2 x 3 matrix Elements of a matrix A are denoted by aij. a23 = 8 2 Data about many kinds of problems can often be represented by matrix. e.g Average temperatures in 3 different cities for each month: 23 26 38 47 58 71 78 77 69 55 39 33 A 14 21 33 38 44 57 61 59 49 38 25 21 3 cities 35 46 54 67 78 86 91 94 89 75 62 51 12 months Jan - Dec Average temp. in the 3rd city in July, a37, is 91. 3 Matrix of coefficients Solutions to many problems can be obtained by solving systems of linear equations. For example, the constraints of a problem are represented by the system of linear equations x + y = 70 24x + 14y = 1180 1 1 The matrix A 24 14 is the matrix of coefficient for this system of linear equations. 4 In a matrix, the arrangement of the entries is significant. Therefore, for two matrices to be equal they must have the same dimensions and the same entries in each location. Example: Let x 4 X 1 y z 0 3 4 Y 1 6 2 w If X = Y, then x = 3, y = 6, z = 2, and w = 0. 5 Square Matrix is a matrix in which the number of rows equals the number of columns. •Main Diagonal: in a n x n square matrix, the elements a11, a22, a33, …, ann form the main diagonal of the matrix. •Symmetric matrix:If the corresponding elements match when we think of folding the matrix along the main diagonal, then the matrix is symmetric about the main diagonal. In a symmetric matrix, aij = aji. 6 Example: The square matrix 1 5 7 A 5 0 2 7 2 6 Main Diagonal is symmetric. Note that a21 = a12 = 5 a31 = a13 = 7 a32 = a23 = 2 7 Matrix Operations 1. Scalar multiplication: Multiply each entry of a matrix by a fixed single number called scalar. ex: The result of multiplying matrix 1 4 5 A 6 3 2 by the scalar r = 3 is 3 12 15 A 18 - 9 6 8 2. Addition: Adding the corresponding elements of 2 matrices that have the same dimensions. ex: For 1 3 6 A 2 0 4 4 5 1 0 - 2 8 B 1 5 2 2 3 3 the matrix A+B is 1 1 14 A B 3 5 6 2 8 4 9 3. Subtraction: defined by A – B = A + (-1)B. In a zero matrix, all entries are 0. An n m zero matrix is denoted by 0. If A and B are n x m matrices and r and s are scalars, the following matrix equations are true: 0+A=A A+ B =B +A (A + B) + C = A + (B + C) r(A + B) = rA + rB (r + s)A = rA + sA r(sA) = (rs)A 10 4. Multiplication of matrices: A: B: n m matrix m p matrix The result C is an n p matrix. A B = C, where cij m aik bkj k 1 An entry in row i, column j of A B is obtained by multiplying elements in row i of A by the corresponding elements in column j of B and adding the results. To compute A times B, the number of columns in A must equal the number of rows in B. 11 Example: Let 2 4 3 A 4 1 2 2 3 matrix 5 3 2 4 3 36 4 1 2 2 2 __ 6 5 __ __ 5 3 2 4 3 36 4 1 2 2 2 __ 6 5 29 __ 5 3 2 4 3 36 29 4 1 2 2 2 30 20 6 5 5 3 B 2 2 6 5 3 2 matrix 2(5) + 4(2) + 3(6) = 10 + 8 + 18 = 36 Note that A is a 2 3 matrix and B is a 3 2 matrix. The product A • B is a 2 2 matrix. 12 Example: Compute A B and B A for 3 6 1 4 B A 3 4 6 2 1(6) 4(4) 15 22 1(3) 4(3) A B 6 ( 3 ) ( 2 )( 3 ) 6 ( 6 ) ( 2 )( 4 ) 12 28 3(1) 6(6) 3(4) 6(2) 39 0 B A 3(1) 4(6) 3(4) 4(2) 27 4 Note: A B B A . 13 Where A, B and C are matrices of appropriate dimensions and r and s are scalars, the following matrix equations are true: (The notation A(B C) is shorthand for A (B C) ) A(B C) = (A B)C A(B + C) = A B + A C (A + B)C = A C + B C rA sB = (rs)(A B) 14 Identity matrix The n n matrix with 1s along the main diagonal and 0s elsewhere is called the identity matrix, denoted by I. If we multiply I times any n n matrix A, we get A as the result. The equation I•A=A•I=A holds. Let 1 0 I 0 1 a11 A a 21 a12 a 22 1(a11 ) 0(a21 ) 1(a12 ) 0(a22 ) a11 a12 IA A 0(a11 ) 1(a21 ) 0(a12 ) 1(a22 ) a21 a22 Similarly, A • I=A. 15 An n n matrix A is invertible if there exists an n n matrix B such that A• B = B •A= I In this case B is called the inverse of A, denoted by A-1. Let 1 2 3 A 2 1 0 4 2 5 5 4 3 B 10 7 6 8 6 5 Then, following the rules of matrix multiplication, it can be shown that A • B = B • A = I, so B = A-1. 16 Boolean Matrices Matrices with only 0s and 1s as entries are called Boolean matrices. Boolean multiplication: x y = min(x,y) Boolean addition: x y = max(x,y) Boolean matrix multiplication A B is defined by m Cij = (aik bkj) k=1 A B: corresponding elements are combined using Boolean multiplication. A B: corresponding elements are combined using Boolean addition. 17 Let A and B be Boolean matrices, 1 1 0 A 0 1 0 0 0 1 Then 1 0 0 B 1 1 1 0 0 1 1 1 0 A B 1 1 1 0 0 1 1 0 0 A B 0 1 0 0 0 1 And the Boolean product A B is 1 1 1 A B 1 1 1 0 0 1 18