Matrices and Vectors James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University November 11, 2013
Outline 1 Matrices and Vectors 2 Vector Details 3 Matrix Details 4 Operations On Matrices
Abstract This lecture is going discuss vectors and matrices.
Matrices and Vectors A matrix A is a rectangular collection of real numbers A = 2 4 5 12 14 15 20 4 1 A is a 3 3 matrix as it has 3 rows and 3 columns. The number of rows and columns can be any positive integer. Column vectors have only 1 column. So V 7 V = 9 2 is a 3 1 matrix or a column vector. Row vectors have only 1 row. So W W = [ 7 9 2 ] is a 1 3 matrix or a row vector.
Matrices and Vectors The transpose of a matrix swaps the rows and columns. We denote this by a superscript T. 3 3 transpose is still 3 3. 2 4 5 12 14 15 20 4 1 T = 2 12 20 4 14 4. 5 15 1 3 1 transpose is 1 3. 7 9 2 T = [ 7 9 2 ] 1 3 transpose is 3 1. [ 7 9 2 ] T = 7 9 2
Matrices and Vectors Basic Operations Add and subtract matrices and vectors of same size component wise. scalar multiply or divide a matrix or vector means you multiply or divide each component. Examples: just do vectors as matrices similar. 7 8 2( 7) 4(8) = 46 2 9 4 3 = 2( 9) 4(3) = 30 2 6 2(2) 4( 6) = 28 There are also zero vectors and zero matrices of various sizes.
Vector Details Let s look at two dimensional column vectors. Let [ ] a V = c We graph this vector using its components as coordinates in the standard x y plane. We draw a line from the origin (0, 0) to (a, c) just like we would do for the complex number a + c i. This line has a length (a) 2 + (c) 2 and we denote the length of V by V. This is called the norm of V. Hence, the vector V has a representation with a = r cos(θ), c = r sin(θ) which is called the polar coordinate representation. See the next picture.
Vector Details V a c r y θ x A vector V can be identified with an order pair (a, c). The components (a, c) are graphed in the usual Cartesian manner as an ordered pair in plane. The magnitude of V is (a) 2 + (c) 2 which is shown on the graph as r. The angle associated with V is drawn as an arc of angle θ
Vector Details Example For the vector V = [ ] 5 3 find its magnitude, its associated angle and graph it carefully, Solution The magnitude is V = ( 5) 2 + (3) 2. This vector is in Quadrant 2 and so the associated angle is π tan 1 ( 3 5 ) = π.54 = 2.60 radians. The graph is for you to do.
Vector Details Example For the vector V = [ ] 8 2 find its magnitude, its associated angle and graph it carefully, Solution The magnitude is V = ( 8) 2 + ( 2) 2. This vector is in Quadrant 3 and so the associated angle is π + tan 1 ( 2 8 ) = π +.24 = 3.38 radians. The graph is for you to do.
Vector Details Homework 31 For each vector, find its magnitude, its associated angle, and graph it carefully. 31.1 [ ] 6 V = 7 31.2 31.3 31.4 V = V = V = [ ] 3 7 [ ] 2 5 [ ] 3 5
Matrix Details A matrix is a rectangular collection of real numbers organized like this: 2 4 5 1 12 14 15 6 20 4 1 2 8 14 5 11
Matrix Details A matrix is a rectangular collection of real numbers organized like this: 2 4 5 1 12 14 15 6 20 4 1 2 8 14 5 11 In this matrix, we have a collection of numbers which are organized into 4 rows and 4 columns. We call this a square matrix because the number of rows and columns are the same. This particular matrix has only positive or negative integers in it, but of course the number 0 could be used as well as real numbers like 1.2356, π and e. It is just easier to type integers!
Matrix Details A matrix can also have a different number of rows and columns.
Matrix Details A matrix can also have a different number of rows and columns. Consider the matrices shown below. which are a 5 4 matrix and a 4 3 matrix. We call the 5 4 and the 4 3 the sizes of these matrices. In general, if a matrix has m rows and n columns, we say its size is m n 2 4 5 1 12 14 15 6 20 4 1 2 8 14 5 11 2 23 7 3 4 5 1 14 15 6 4 1 2 14 5 11 23 7 3
Matrix Details We usually denote a matrix by a capital letter such as A.
Matrix Details We usually denote a matrix by a capital letter such as A. Each entry in a matrix can be labeled by the row and column it occurs in. Thus, the entry in row 2 and column 3 of a matrix A is labeled as A 23.
Matrix Details We usually denote a matrix by a capital letter such as A. Each entry in a matrix can be labeled by the row and column it occurs in. Thus, the entry in row 2 and column 3 of a matrix A is labeled as A 23. For example A 11 A 12 A 13 A 14 B = A 21 A 22 A 23 A 24 A 31 A 32 A 33 A 34 A 41 A 42 A 43 A 44 = A 51 A 52 A 53 A 54 2 4 5 1 12 14 15 6 20 4 1 2 8 14 5 11. 2 23 7 3
Matrix Details There are some special matrices. A matrix that only has 0 as its entries is called a zero matrix.
Matrix Details There are some special matrices. A matrix that only has 0 as its entries is called a zero matrix. Now, since there are matrices of all different sizes, we can not pick just one to call the zero matrix. So when we are working on a problem, we just use the size of the zero matrix that is appropriate for the problem s context. For example, a 4 3 zero matrix would be 0 0 0 0 = 0 0 0 0 0 0 0 0 0
Matrix Details There are some special matrices. A matrix that only has 0 as its entries is called a zero matrix. Now, since there are matrices of all different sizes, we can not pick just one to call the zero matrix. So when we are working on a problem, we just use the size of the zero matrix that is appropriate for the problem s context. For example, a 4 3 zero matrix would be 0 0 0 0 = 0 0 0 0 0 0 0 0 0 A 2 2 zero matrix would be 0 = [ ] 0 0 0 0
Matrix Details Square matrices often occur in our work, i.e. matrices that have the same number of rows and columns. Consider A 11 A 12 A 13 A 14 2 4 5 1 A = A 21 A 22 A 23 A 24 A 31 A 32 A 33 A 34 = 12 14 15 6 20 4 1 2 A 41 A 42 A 43 A 44 8 14 5 11
Matrix Details A square matrix has three important parts which you are subsets of the original matrix. The Lower Triangular Part of A is L given by A 11 0 0 0 L = A 21 A 22 0 0 A 31 A 32 A 33 0 A 41 A 42 A 43 A 44
Matrix Details A square matrix has three important parts which you are subsets of the original matrix. The Lower Triangular Part of A is L given by A 11 0 0 0 L = A 21 A 22 0 0 A 31 A 32 A 33 0 A 41 A 42 A 43 A 44 The Upper Triangular Part of A is U given by A 11 A 12 A 13 A 14 U = 0 A 22 A 23 A 24 0 0 A 33 A 34 0 0 0 A 44
Matrix Details The Diagonal Part of A is D given by A 11 0 0 0 D = 0 A 22 0 0 0 0 A 33 0 = 0 0 0 A 44 2 0 0 0 0 14 0 0 0 0 1 0 0 0 0 11
Matrix Details The Diagonal Part of A is D given by A 11 0 0 0 D = 0 A 22 0 0 0 0 A 33 0 = 0 0 0 A 44 2 0 0 0 0 14 0 0 0 0 1 0 0 0 0 11 We can also define what is called the identity matrix. An identity matrix is a square matrix whose only nonzero entries are one s on the diagonal. For example, 1 0 0 I = 0 1 0 0 0 1 is a 3 3 identity matrix,
Matrix Details Consider the 5 4 matrix A defined by A = 2 4 5 1 12 14 15 6 20 4 1 2 8 14 5 11 2 23 7 3 The transpose of A is the matrix formed by switching the rows and columns of A.
Matrix Details Consider the 5 4 matrix A defined by A = 2 4 5 1 12 14 15 6 20 4 1 2 8 14 5 11 2 23 7 3 The transpose of A is the matrix formed by switching the rows and columns of A. We denote this new matrix by A T or sometimes A. Hence, 2 12 20 8 2 A T = 4 14 4 14 23 5 15 1 5 7 1 6 2 11 3
Matrix Details If a matrix A equals its own transpose, then first, we know A must be a square matrix of size n n for some positive integer n.
Matrix Details If a matrix A equals its own transpose, then first, we know A must be a square matrix of size n n for some positive integer n. Thus, ( A T) ij = A ij = A ji In this case, we say A is symmetric
Matrix Details If a matrix A equals its own transpose, then first, we know A must be a square matrix of size n n for some positive integer n. Thus, ( A T) ij = A ij = A ji In this case, we say A is symmetric Thus, the matrix A below is symmetric. A = 2 12 20 8 12 14 4 14 20 4 1 5 8 14 5 11
Matrix Details Homework 32 32.1 Find the transpose of [ 2 3 ] 4 1 4 90 32.2 Find the transpose of 2 3 4 11 4 9 6 3 8 32.3 Is this matrix symmetric? 2 3 4 3 4 3 4 3 8
Operations On Matrices We can also perform many operations on matrices. It is easiest to show these operations with examples. We can add matrices of the same size by adding their components 1 2 3 20 3 11 4 1 8 + 16 9 5 = 7 6 12 16 2 8 1 20 2 + 3 3 11 4 + 16 1 + 9 8 + 5 = 7 + 16 6 + 2 12 8 19 1 8 20 10 3 9 8 4
Operations On Matrices We can subtract matrices of the same size by subtracting their components 1 2 3 20 3 11 4 1 8 16 9 5 = 7 6 12 16 2 8 1 20 2 3 3 11 21 5 14 4 16 1 9 8 5 = 12 8 13 7 16 6 2 12 8 23 4 20
Operations On Matrices We can scale a matrix by multiplying each component of the matrix by the same number 1 2 3 3 6 9 3 4 1 8 = 12 3 24 7 6 12 21 18 36
Operations On Matrices We can multiply two matrices A and B if their sizes are just right. The number of columns of A must match the number of rows of B.
Operations On Matrices We can multiply two matrices A and B if their sizes are just right. The number of columns of A must match the number of rows of B. In the example below, the number of columns of the first matrix is 3 which matches the number of rows in the second matrix. So the matrix multiplication is defined. Since the size of A is 4 3 and the size of B is 3 2, the size of the product will be 4 2. In this example, each row of the first matrix has 3 entries and each column of the second matrix has 3 rows. Look at row 1 of the first matrix and column 1 of the second matrix.
Operations On Matrices We multiply row 1 and column 1 like this: [ ] 20 1 2 3 16 = (1)( 20) + ( 2)(16) + (3)(16). 16
Operations On Matrices We multiply row 1 and column 1 like this: [ ] 20 1 2 3 16 = (1)( 20) + ( 2)(16) + (3)(16). 16 In general, we would have for the i th row of A and the j th column of B [ ] B 1j Ai1 A i2 A i3 B 2j = B 3j 3 (A i1 )(B 1j ) + (A i2 )(B 2j ) + (A i3 )(B 3j ) = A ik B kj. k=1 where the individual components of A are denoted by A ij and those of B by B ij for appropriate indices i and j.
Operations On Matrices Hence, the full matrix multiplication of these two matrices is given by 1 2 3 4 1 8 7 6 12 20 3 16 9 16 2 12 2 3 (1)( 20) + ( 2)(16) + (3)(16) (1)(3) + ( 2)(9) + (3)(2) = (4)( 20) + (1)(16) + ( 8)(16) (4)(3) + (1)(9) + ( 8)(2) ( 7)( 20) + (6)(16) + (12)(16) ( 7)(3) + (6)(9) + (12)(2) (12)( 20) + ( 2)(16) + (3)(16) (12)(3) + ( 2)(9) + (3)(2) 20 + 32 + 48 3 + 18 + 6 4 9 = 80 + 16 + 128 12 + 9 + 16 140 + 96 + 192 21 + 54 + 24 = 192 5 428 57 240 + 32 + 48 36 + 18 + 6 224 24
Operations On Matrices If A is a square matrix of size n n, then if I denotes the identity matrix of size n n, both multiplications I A and A I are possible and give the answer A. This is why I is called the identity matrix!
Operations On Matrices If A is a square matrix of size n n, then if I denotes the identity matrix of size n n, both multiplications I A and A I are possible and give the answer A. This is why I is called the identity matrix! If A is a matrix of any size and 0 is the appropriate zero matrix of the same size, then both 0 + A and A + 0 are nicely defined operations and the result is just A.
Operations On Matrices If A is a square matrix of size n n, then if I denotes the identity matrix of size n n, both multiplications I A and A I are possible and give the answer A. This is why I is called the identity matrix! If A is a matrix of any size and 0 is the appropriate zero matrix of the same size, then both 0 + A and A + 0 are nicely defined operations and the result is just A. Matrix multiplication is not commutative: i.e. for square matrices A and B, the matrix product A B is not necessarily the same as the product B A.
Operations On Matrices Homework 33 33.1 Compute 1.0 2.5 6.0 8.0 1.0 2.5 3.0 4.2 12.0 2 5 7 33.2 Compute 1.0 2.5 6.0 5 8.0 1.0 2.5 8.2 3.0 4.2 12.0 6.1 2 5 7 10 0.3 8 1 1 2 6 16.5 2
Operations On Matrices Homework 33 Continued Consider 1.0 2.5 6.0 5 2 5 7 9 C = 8.0 1.0 2.5 8.2 3.0 4.2 12.0 6.1 and D = 10 0.3 8 10 1 1 2 5 2 3 7.2 9.4 6 16.5 2 14 33.3 Compute C + D 33.4 Compute C D 33.5 Compute 2C + 3D 33.6 Compute 4C + 5D 33.7 Compute C D D C