DM559 Linear and Integer Programming Lecture 2 Matrices and Vectors Marco Chiarandini Department of Mathematics & Computer Science University of Southern Denmark
Matrices and Vectors Outline 1. Matrices and Vectors 2
Matrices and Vectors Outline 1. Matrices and Vectors 3
Matrices and Vectors Matrices and Vectors Definition (Matrix) A matrix is a rectangular array of numbers or symbols. It can be written as a 11 a 12 · · · a 1 n a 21 a 22 · · · a 2 n . . . ... . . . . . . a m 1 a m 2 · · · a mn • We denote this array by a single letter A or by ( a ij ) and • we say that A has m rows and n columns, or that it is an m × n matrix. • The size of A is m × n . • The number a ij is called the ( i , j ) entry or scalar. 4
Matrices and Vectors • A square matrix is an n × n matrix. • The diagonal of a square matrix is the list of entries a 11 , a 22 , . . . , a nn • The diagonal matrix is a matrix n × n with a ij = 0 if i � = j (ie, a square matrix with all the entries which are not on the diagonal equal to 0): a 11 0 · · · 0 0 a 22 · · · 0 . . . ... . . . . . . 0 0 · · · a mn Definition (Equality) Two matrices are equal if they have the same size and if corresponding entries are equal. That is, if A = ( a ij ) and B = ( b ij ) are both m × n matrices, then: A = B ⇐ ⇒ a ij = b ij 1 ≤ i ≤ m , 1 ≤ j ≤ n 5
Matrices and Vectors Matrix Addition and Multiplication Definition (Addition) If A = ( a ij ) and B = ( b ij ) are both m × n matrices, then A + B = ( a ij + b ij ) 1 ≤ i ≤ m , 1 ≤ j ≤ n Definition (Scalar Multiplication) If A = ( a ij ) is an m × n matrix and λ ∈ R , then λ A = ( λ a ij ) 1 ≤ i ≤ m , 1 ≤ j ≤ n Eg: � 3 1 � � − 1 � 2 1 4 A + B = + =? 0 5 − 2 2 − 3 1 − 2 A =? 6
Matrices and Vectors Matrix Multiplication Two matrices can be multiplied together, depending on the size of the matrices Definition (Matrix Multiplication) If A is an m × n matrix and B is an n × p matrix, then the product is the matrix AB = C = ( c ij ) with c ij = a i 1 b 1 j + a i 2 b 2 j + · · · + a in b nj . b 1 j b 2 j . What is the size of C? . a i 1 a i 2 · · · a in . b nj 7
Matrices and Vectors 1 1 1 3 4 3 0 2 0 1 5 3 = 1 1 AB = 1 2 4 1 14 − 1 3 2 2 − 1 9 − 1 ( 2 )( 3 ) + ( 0 )( 1 ) + ( 1 )( − 1 ) = 5 The motivation behind this definition will become clear later. It is exactly what is needed in our study of linear algebra 8
Matrices and Vectors • AB � = BA in general, ie, not commutative try with the example of previous slide... 3 1 � 2 1 3 � 1 0 A = B = 1 2 1 1 1 � � � � 1 2 1 1 A = B = 3 4 0 1 9
Matrices and Vectors Matrix Algebra Matrices are useful because they provide compact notation and we can perform algebra with them Bear in mind to use only operations that are defined. In the following rules, the sizes are dictated by the operations being defined. • commutative A + B = B + A . Proof? • associative: • ( A + B ) + C = A + ( B + C ) Size? • λ ( AB ) = ( λ A ) B = A ( λ B ) • ( AB ) C = A ( BC ) • distributive: • A ( B + C ) = AB + AC Why both first two rules? • ( B + C ) A = BA + CA • λ ( A + B ) = λ A + λ B 10
Matrices and Vectors Definition (Zero Matrix) A zero matrix, denoted 0, is an m × n matrix with all entries zero: 0 0 · · · 0 0 0 · · · 0 . . . ... . . . . . . 0 0 · · · 0 • additive identity: A − A = 0 • A + 0 = A • A − A = 0 • 0 A = 0 , A 0 = 0 11
Matrices and Vectors Definition (Identity Matrix) The n × n identity matrix, denoted I n or I is the diagonal matrix with a ii = 1: zero: 1 0 · · · 0 0 1 · · · 0 I = . . . . ... . . . . . 0 0 · · · 1 • multiplicative identity (like 1 does for scalars) A of size m × n . • AI = A and IA = A What size is I ? Exercise: 3 A + 2 B = 2 ( B − A + C ) 12
Matrices and Vectors Matrix Inverse • If AB = AC can we conclude that B = C ? � 8 � 0 0 � � 1 − 1 � � 0 A = , B = , C = 1 1 3 5 − 4 4 � 0 0 � AB = AC = 4 4 • A + 5 B = A + 5 C = ⇒ B = C addition and scalar multiplication have inverses ( − A and 1 / c ) • Is there a multiplicative inverse? 13
Matrices and Vectors Definition (Inverse Matrix) The n × n matrix A is invertible if there is a matrix B such that AB = BA = I where I is the n × n identity matrix. The matrix B is called the inverse of A and is denoted by A − 1 . � 1 2 � � − 2 � 1 A = , B = 3 4 3 / 2 − 1 / 2 Theorem If A is an n × n invertible matrix, then the matrix A − 1 is unique. Proof: Assume A has two inverses B , C so AB = BA = I and AC = CA = I . Consider the product CAB : CAB = C ( AB ) = CI = C associativity + AB = I CAB = ( CA ) B = IB = B associativity + CA = I 14
Matrices and Vectors • If a matrix has an inverse we say that it is invertible or non-singular If a matrix has no inverse we say that it is non-invertible or singular Eg: � � � � � � 0 0 a b 1 0 = 1 1 c d 0 1 • If � a b � A = , ad − bc � = 0 c d then A has the inverse � � 1 d − b A − 1 = ad − bc � = 0 − c a ad − bc • The scalar ad − bc is called determinant of A and denoted | A | . 15
Matrices and Vectors Matrix Inverse Back to the question: • If AB = AC can we conclude that B = C ? If A is invertible then the answer is yes: A − 1 AB = A − 1 AC = ⇒ IB = IC = ⇒ B = C • But AB = CA then we cannot conclude that B = C . 16
Matrices and Vectors Properties of the Inverse ⇒ A − 1 exists Let A be invertible = • ( A − 1 ) − 1 = A • ( λ A ) − 1 = 1 λ A − 1 the inverse of the matrix ( λ A ) is a matrix C that satisfies ( λ A ) C = C ( λ A ) = I . Using matrix algebra: � 1 � 1 � � = λ 1 ( λ A ) = 1 λ AA − 1 = I and λ A − 1 λ A − 1 λλ A − 1 A = I ( λ A ) • ( AB ) − 1 = B − 1 A − 1 17
Matrices and Vectors Powers of a matrix For A an n × n matrix and r ∈ N A r = AA . . . A � �� � r times For the associativity of matrix multiplication: • ( A r ) − 1 = ( A − 1 ) r • A r A s = A r + s • ( A r ) s = A rs 18
Matrices and Vectors Transpose Matrix Definition (Transpose) The transpose of an m × n matrix A is the n × m matrix B defined by b ij = a ji for j = 1 , . . . , n and i = 1 , . . . , m It is denoted A T a 11 a 12 · · · a 1 n a 11 a 21 · · · a m 1 a 21 a 22 · · · a 2 n a 12 a 22 · · · a m 2 A T = ( a ji ) = A = ( a ij ) = . . . . . . ... ... . . . . . . . . . . . . a m 1 a m 2 · · · a mn a 1 n a 2 n · · · a nm � � � � 1 0 1 3 3 1 0 1 Note that if D is a diagonal matrix: D T = D 19
Matrices and Vectors Properties of the transpose • ( A T ) T = A • ( λ A ) T = λ A T • ( A + B ) T = A T + B T • ( AB ) T = B T A T (consider first which matrix sizes make sense in the multiplication, then rewrite the terms) • if A is invertible, ( A T ) − 1 = ( A − 1 ) T A T ( A − 1 ) T = ( A − 1 A ) T = I T = I ( A − 1 ) T A T = ( AA − 1 ) T = I T = I 20
Matrices and Vectors Symmetric Matrix Definition (Symmetric Matrix) A matrix A is symmetric if it is equal to its transpose, A = A T . (only square matrices can be symmetric) 21
Matrices and Vectors Vectors • An n × 1 matrix is a column vector, or simply a vector: v 1 v 2 v = . . . v n The numbers v 1 , v 2 , . . . are known as the components (or entries) of v . • A row vector is a 1 × n matrix • We write vectors in lower boldcase type (writing by hand we can either underline them or add an arrow over v ). • Addition and scalar multiplication are defined for vectors as for n × 1 matrices: v 1 + w 1 λ v v 2 + w 2 λ v v + w = λ v = . . . . . . v n + w n λ v 22
Matrices and Vectors • For a fixed n , the set of vectors together with the operations of addition and multiplication form the set R n , usually called Euclidean space • For vectors v 1 , v 2 , . . . , v k in R n and scalars α 1 , α 2 , . . . , α k in R , the vector v = α 1 v 1 + α 2 v 2 + · · · + α k v k is known as linear combination of the vectors v 1 , v 2 , . . . , v k • A zero vector is denoted by 0 ; 0 + v = v + 0 = v ; 0 v = 0 • The matrix product of v and w cannot be calculated • The matrix product of v T w gives an 1 × 1 matrix • The matrix product of vw T gives an n × n matrix 23
Recommend
More recommend