LINEAR TRANSFORMATIONS AND MATRICES [Continued] SPH 5421 notes.014 Note that the output of the program in notes.013 is a postscript file, gsas.grf, which may be viewed and printed with ghostview on an X-terminal: ghostview gsas.grf Note that a linear transformation always transforms the origin (0, 0) back to the origin. A linear transformation is often represented by a matrix: If F(x, y) = (a*x + b*y, c*x + d*y), the matrix is: | a b | A = | | | c d | The linear transformation itself corresponds to multiplying the matrix A by the column vector : | x | | y |. This is represented as follows: | a b | | x | | a*x + b*y | | | | | = | | . | c d | | y | | c*x + d*y | Matrices can be multiplied together, with the rules for multiplication being as follows: | a b | | e f | | a*e + b*g a*f + b*h | [1] | | * | | = | | | c d | | g h | | c*e + d*g c*f + d*h |. Multiplication of matrices exactly corresponds to doing two linear transformations in succession (that is, composition of linear transformations). That is, if F is represented by the matrix | a b | A = | | | c d | and G by the matrix | e f | B = | | , | g h | then F(G) is represented by A * B as in equation [1] above. The determinant of a 2 x 2 matrix is defined as | a b | det | | = a * d - b * c. | c d | There is an interesting relationship between the determinant of the matrix of a linear transformation and the image of the unit square. It turns out that the absolute value of the determinant is the AREA of the image of the unit square. Of course, the original unit square has area = 1. So the determinant is essentially a multiplier of areas: if some region S in R^2 has area W, and F is a linear transformation whose matrix has determinant d, then f(S) has area d*W. The SAS program above illustrates this, since it prints the determinant of the matrix corresponding to the linear transformation on the graph. Determinants are defined only for square matrices. The definition of the determinant for a 3 x 3 matrix is more complicated: | a b c | If A = | d e f |, then | g h i | det(A) = a*e*i - a*f*h - b*d*i + b*f*g + c*d*h - c*e*g. For a 3 x 3 matrix, the absolute value of the determinant is the volume of the image of the unit cube by the linear transformation F: R^3 --> R^3 which corresponds to the matrix. A 1 x 1 matrix is just a single real number. If A = [a], note that the linear transformation F correponding to A is just F(x) = a * x. The determinant of a 1 x 1 matrix [a] is just a. Note that abs(a) is the length of the image of the unit interval [0, 1] under the linear transformation F: the image itself is [0, a]. ======================================================================= QUESTIONS (see later notes for answers) 1. If linear transformation F has determinant 0, what does it do to the unit square? 2. What does the linear transformation F(x, y) = (-x, -y) do to the unit square? 3. The unit circle is defined to be the circle around (0, 0) with radius 1. If F(x, y) = (2x + y, x + 2y), what does the image of the unit circle look like? 4. If F(x, y) = (x*cos(a) - y*sin(a), x*sin(a) + y*cos(a)) for some angle a, what is the determinant of f ? 5. What does the linear transformation F in question 4 do to the unit square? 6. If the matrix of a linear transformation F has a negative determinant, what does it do to the unit square? That is, in what way is it different from a transformation with a positive determinant? 7. Compute A * B and B * A for the following matrices A and B: | 1 -1 | | 3 2 | A = | | , B = | |. | 3 2 | | 1 5 | Also compute det(A * B) and det(B * A). ======================================================================= SOME DEFINITIONS The TRANSPOSE of a matrix A is essentially the reflection of A through its diagonal. That is, rows and columns are interchanged. The transpose of A is often written as A'. Thus, if | a b | | a c | A = | |, then the transpose of A is A' = | |. | c d | | b d | The dimensions of a matrix are the numbers of rows and columns. Thus the matrix A above is a 2 by 2 matrix. A matrix with one column is called a column vector: for example, | 1 | A = | 2 | is a 3 by 1 matrix. | 3 | Note that the transpose of a 3 x 1 matrix is a 1 x 3 matrix: A' = [1 2 3]. Note that if A is a 2 x 2 matrix, then A and A' both have the same determinant (prove this for yourself). ---> FACT: (A * B)' = B' * A' for any two matrices that can be multiplied together. This raises the question: which matrices can be multiplied together? The answer is, any pair of matrices which have the right combinations of rows and columns. If A is an n x m matrix, and B is an m x p matrix, then A * B is defined, and A * B is an n x p matrix. However, unless p = n, B * A is NOT defined. The rules on dimensions can be represented as follows: n x m m x p n x p A * B = C The TRACE of a square matrix is defined to be the sum of the entries along the diagonal. Thus if | a b c | A = | d e f |, then trace(A) = a + e + i. | g h i | ---> FACT: trace(A + B) = trace(A) + trace(B). ---> FACT: trace(c * A) = c * trace(A), where c is a scalar. ---> FACT: trace(A * B) = trace(B * A). ---> FACT: trace(A) = trace(A'). The trace turns out to be a useful concept in statistics, as will be explained later. A SYMMETRIC matrix is one which equals its transpose. That is, A is symmetric only if A' = A. Only square matrices can be symmetric. The definition implies that if A is a symmetric 2 x 2 matrix, then A must be of the form | a b | A = | | . | b d | The IDENTITY matrix is a square matrix which has only 1's along the diagonal and 0's everywhere else: for example, the 2 x 2 and 3 x 3 identity matrices are: | 1 0 | | 1 0 0 | I = | | and I = | 0 1 0 | . | 0 1 | | 0 0 1 | Note that det(I) = 1. Note that trace(I) = n if I is an n x n identity matrix. | x | Note that if v = | | is any 2 x 1 column vector, then I * v = v. | y | Note that if I is the m x m identity matrix, and A is any other m x p matrix, then I * A = A. Similarly, if A is any p x m matrix, A * I = A. Essentially, the identity matrix plays the same role among matrices that the number 1 does among real numbers. An INVERSE of a square matrix A is a matrix B such that A * B = I. It can be shown that if A * B = I, then B * A = I also. ---> FACT: Any square matrix which has a nonzero determinant has an inverse. Square matrices which have determinants equal to 0 are called 'singular' matrices. In general it is tedious to calculate the inverse of a matrix. Explicit formulas can be written down, but they are very complicated for anything larger than a 2 x 2 matrix. For 2 x 2 matrices, the inverse is reasonably simple: | a b | | d/D -b/D | if A = | |, then inv(A) = | |, | c d | | -c/D a/D | where D = det(A) = a*d - b*c. Of course, for a 1 x 1 matrix [a] the inverse is [1/a] (unless a is zero, in which case the inverse is not defined). ---> FACT: If A and B are square matrices of the same size, and both A and B have inverses, then inv(A * B) = inv(B) * inv(A). MORE QUESTIONS | 1 2 | 8. Suppose X = | 1 3 |. What is X'* X ? | 1 5 | 9. Referring to the previous problem, what is inv(X'*X) ? ================================================================================= ANSWERS TO QUESTIONS 1. Squashes it flat. 2. Reflects it through the origin. 3. An ellipse with major axis along the 45-degree line through the origin. 4. 1. 5. Rotates it counterclockwise through angle a. 6. The image has the vertices ordered counterclockwise rather than clockwise. The technical phrase is, it reverses the orientation. | 2 -3 | | 9 1 | 7. A * B = | | and B * A = | | , and |11 16 | |16 9 | det(A * B) = det(B * A) = 65. | 3 10 | 8. X'* X = | |. | 10 38 | | 19/7 -5/7 | 9. inv(X'* X) = | | . | -5/7 3/14 | /home/walleye/john-c/5421/notes.014 Last update: October 9, 2003.