APPENDIX A Matrix Algebra for Structural Analysis A.1 Basic Definitions and Types of Matrices With the accessibility of desk top computers, application of matrix algebra for the analysis of structures has become widespread. Matrix algebra provides an appropriate tool for this analysis, since it is relatively easy to formulate the solution in a concise form and then perform the actual matrix manipulations using a computer. For this reason it is important that the structural engineer be familiar with the fundamental operations of this type of mathematics. Matrix. A matrix is a rectangular arrangement of numbers having m rows and n columns.The numbers, which are called elements, are assembled within brackets. For example, the A matrix is written as: A = D a11 a21 am1 a12 a22 Á Á a1n a2n am2 o Á amn T Such a matrix is said to have an order of m * n (m by n). Notice that the first subscript for an element denotes its row position and the second subscript denotes its column position. In general, then, aij is the element located in the ith row and jth column. Row Matrix. If the matrix consists only of elements in a single row, it is called a row matrix. For example, a 1 * n row matrix is written as A = [a1 a2 Á an] Here only a single subscript is used to denote an element, since the row subscript is always understood to be equal to 1, that is, a1 = a11, a2 = a12, and so on. 612 A.1 BASIC DEFINITIONS AND TYPES OF MATRICES 613 Column Matrix. A matrix with elements stacked in a single column is called a column matrix. The m * 1 column matrix is a1 a2 A = D T o am Here the subscript notation symbolizes a1 = a11, a2 = a21, and so on. Square Matrix. When the number of rows in a matrix equals the number of columns, the matrix is referred to as a square matrix. An n * n square matrix would be A = D a11 a21 an1 a12 a22 Á Á a1n a2n an2 o Á ann T Diagonal Matrix. When all the elements of a square matrix are zero except along the main diagonal, running down from left to right, the matrix is called a diagonal matrix. For example, a11 A = C0 0 0 a22 0 0 0 S a33 Unit or Identity Matrix. The unit or identity matrix is a diagonal matrix with all the diagonal elements equal to unity. For example, 1 I = C0 0 0 1 0 0 0S 1 Symmetric Matrix. A square matrix is symmetric provided aij = aji. For example, 3 A = C5 2 5 -1 4 2 4S 8 A 614 APPENDIX A M AT R I X A L G E B R A FOR S T R U C T U R A L A N A LY S I S A.2 Matrix Operations Equality of Matrices. Matrices A and B are said to be equal if they are of the same order and each of their corresponding elements are equal, that is, aij = bij. For example, if A = c 6 d -3 2 4 B = c 6 d -3 2 4 then A = B. Addition and Subtraction of Matrices. Two matrices can be added together or subtracted from one another if they are of the same order. The result is obtained by adding or subtracting the corresponding elements. For example, if A = c 6 2 7 d -1 1 3 15 d 3 B = c -5 1 8 d 4 then A + B = c A A - B = c 11 1 -1 d -5 Multiplication by a Scalar. When a matrix is multiplied by a scalar, each element of the matrix is multiplied by the scalar. For example, if A = c 4 6 1 d -2 k = -6 then kA = c -24 -36 -6 d 12 Matrix Multiplication. Two matrices A and B can be multiplied together only if they are conformable. This condition is satisfied if the number of columns in A equals the number of rows in B. For example, if A = c a11 a21 a12 d a22 B = c b11 b21 b12 b22 b13 d b23 (A–1) then AB can be determined since A has two columns and B has two rows. Notice, however, that BA is not possible. Why? A.2 MATRIX OPERATIONS 615 If matrix A having an order of 1m * n2 is multiplied by matrix B having an order of 1n * q2 it will yield a matrix C having an order of 1m * q2, that is, A = B 1m * n21n * q2 C 1m * q2 The elements of matrix C are found using the elements aij of A and bij of B as follows: n cij = a aikbkj (A–2) k=1 The methodology of this formula can be explained by a few simple examples. Consider 2 A = c -1 4 6 3 d 1 2 B = C6S 7 By inspection, the product C = AB is possible since the matrices are conformable, that is, A has three columns and B has three rows. By Eq. A–2, the multiplication will yield matrix C having two rows and one column. The results are obtained as follows: c11: Multiply the elements in the first row of A by corresponding elements in the column of B and add the results; that is, c11 = c1 = 2122 + 4162 + 3172 = 49 c21: Multiply the elements in the second row of A by corresponding elements in the column of B and add the results; that is, c21 = c2 = - 1122 + 6162 + 1172 = 41 Thus C = c 49 d 41 A 616 APPENDIX A M AT R I X A L G E B R A FOR S T R U C T U R A L A N A LY S I S As a second example, consider 5 A = C 4 -2 3 1S 8 B = c 2 -3 7 d 4 Here again the product C = AB can be found since A has two columns and B has two rows. The resulting matrix C will have three rows and two columns. The elements are obtained as follows: 1first row of A times first column of B2 c11 = 5122 + 31-32 = 1 1first row of A times second column of B2 c12 = 5172 + 3142 = 47 1second row of A times first column of B2 c21 = 4122 + 11-32 = 5 1second row of A times second column of B2 c22 = 4172 + 1142 = 32 1third row of A times first column of B2 c31 = - 2122 + 81- 32 = - 28 1third row of A times second column of B2 c32 = - 2172 + 8142 = 18 The scheme for multiplication follows application of Eq. A–2. Thus, 1 C = C 5 -28 A 47 32 S 18 Notice also that BA does not exist, since written in this manner the matrices are nonconformable. The following rules apply to matrix multiplication. 1. In general the product of two matrices is not commutative: AB Z BA (A–3) 2. The distributive law is valid: A1B + C2 = AB + AC (A–4) 3. The associative law is valid: A1BC2 = 1AB2C (A–5) Transposed Matrix. A matrix may be transposed by interchanging its rows and columns. For example, if a11 A = C a21 a31 a12 a22 a32 a13 a23 S a33 B = [b1 b2 b3] A.2 MATRIX OPERATIONS 617 Then a11 A = C a12 a13 a21 a22 a23 T a31 a32 S a33 b1 B = C b2 S b3 T Notice that AB is nonconformable and so the product does not exist. (A has three columns and B has one row.) Alternatively, multiplication ABT is possible since here the matrices are conformable (A has three columns and BT has three rows). The following properties for transposed matrices hold: 1A + B2T = AT + BT (A–6) 1kA2T = kAT (A–7) 1AB2T = BTAT (A–8) This last identity will be illustrated by example. If A = c 2 d -3 6 1 B = c 4 2 3 d 5 A Then, by Eq. A–8, ac 6 1 3 T 4 db = c 5 3 2 4 dc -3 2 ac 28 -2 c 2 6 dc 5 2 28 28 T db = c 28 -12 -2 d -12 -2 28 d = c -12 28 -2 d -12 28 28 1 d -3 Matrix Partitioning. A matrix can be subdivided into submatrices by partitioning. For example, a11 A = C a21 a31 a12 a22 a32 a13 a23 a33 a14 A11 a24 S = c A21 a34 A12 d A22 Here the submatrices are A11 = [a11] A21 = c a21 d a31 A12 = [a12 a13 a14] A22 = c a23 a33 a24 d a34 a22 a32 618 APPENDIX A M AT R I X A L G E B R A FOR S T R U C T U R A L A N A LY S I S The rules of matrix algebra apply to partitioned matrices provided the partitioning is conformable. For example, corresponding submatrices of A and B can be added or subtracted provided they have an equal number of rows and columns. Likewise, matrix multiplication is possible provided the respective number of columns and rows of both A and B and their submatrices are equal. For instance, if 4 A = C -2 6 -1 -5 S 8 1 0 3 2 B = C0 7 -1 8S 4 then the product AB exists, since the number of columns of A equals the number of rows of B (three). Likewise, the partitioned matrices are conformable for multiplication since A is partitioned into two columns and B is partitioned into two rows, that is, AB = c A12 B11 A B + A12B21 dc d = c 11 11 d A22 B21 A21B11 + A22B21 A11 A21 Multiplication of the submatrices yields 4 1 2 -1 8 4 dc d = c d -2 0 0 8 -4 2 -1 -7 -4 = c d[7 4] = c c d -5 -35 -20 2 -1 = [6 3] c d = [12 18] 0 8 = [8][7 4] = [56 32] A11B11 = c A A12B21 A21B11 A22B21 c AB = D 8 -4 [12 4 -7 d + c 2 -35 18] + [56 -4 d - 20 32] 1 T = C - 39 68 0 -18 S 50 A.3 Determinants In the next section we will discuss how to invert a matrix. Since this operation requires an evaluation of the determinant of the matrix, we will now discuss some of the basic properties of determinants. A determinant is a square array of numbers enclosed within vertical bars. For example, an nth-order determinant, having n rows and n columns, is ƒAƒ = 4 a11 a21 an1 a12 a22 Á Á an2 o Á a1n a2n 4 ann (A–9) A.3 DETERMINANTS 619 Evaluation of this determinant leads to a single numerical value which can be determined using Laplace’s expansion. This method makes use of the determinant’s minors and cofactors. Specifically, each element aij of a determinant of nth order has a minor Mij which is a determinant of order n - 1. This determinant (minor) remains when the ith row and jth column in which the aij element is contained is canceled out. If the minor is multiplied by 1-12i + j it is called the cofactor of aij and is denoted as Cij = 1-12i + jMij (A–10) For example, consider the third-order determinant a11 3 a21 a31 a12 a22 a32 a13 a23 3 a33 The cofactors for the elements in the first row are C11 = 1-121 + 1 ` C12 C13 a22 a32 a = 1-121 + 2 ` 21 a31 a = 1-121 + 3 ` 21 a31 a23 a ` = ` 22 a33 a32 a23 a ` = - ` 21 a33 a31 a22 a ` = ` 21 a32 a31 a23 ` a33 a23 ` a33 a22 ` a32 A Laplace’s expansion for a determinant of order n, Eq. A–9, states that the numerical value represented by the determinant is equal to the sum of the products of the elements of any row or column and their respective cofactors, i.e., D = ai1Ci1 + ai2Ci2 + Á + ainCin 1i = 1, 2, Á , or n2 or D = a1jC1j + a2jC2j + Á + anjCnj 1j = 1, 2, Á , or n2 (A–11) For application, it is seen that due to the cofactors the number D is defined in terms of n determinants (cofactors) of order n - 1 each. These determinants can each be reevaluated using the same formula, whereby one must then evaluate 1n - 12 determinants of order 1n - 22, and so on. The process of evaluation continues until the remaining determinants to be evaluated reduce to the second order, whereby the cofactors of the elements are single elements of D. Consider, for example, the following second-order determinant D = ` 3 -1 5 ` 2 We can evaluate D along the top row of elements, which yields D = 31 -121 + 1122 + 51-121 + 21- 12 = 11 Or, for example, using the second column of elements, we have D = 51-121 + 21-12 + 21-122 + 2132 = 11 620 APPENDIX A M AT R I X A L G E B R A FOR S T R U C T U R A L A N A LY S I S Rather than using Eqs. A–11, it is perhaps easier to realize that the evaluation of a second-order determinant can be performed by multiplying the elements of the diagonal, from top left down to right, and subtract from this the product of the elements from top right down to left, i.e., follow the arrow, 3 -1 N D = ` 5 ` = 3122 - 51-12 = 11 2 Consider next the third-order determinant 1 3 ƒDƒ = 4 -1 3 2 0 -1 63 2 Using Eq. A–11, we can evaluate ƒ D ƒ using the elements either along the top row or the first column, that is D = 1121- 121 + 1 ` 2 0 6 4 ` + 1321- 121 + 2 ` 2 -1 6 4 ` + 1- 121- 121 + 3 ` 2 -1 2 ` 0 = 114 - 02 - 318 + 62 - 110 + 22 = - 40 A D = 11-121 + 1 ` 2 0 6 3 ` + 41- 122 + 1 ` 2 0 -1 3 ` + 1- 121- 123 + 1 ` 2 2 -1 ` 6 = 114 - 02 - 416 - 02 - 1118 + 22 = - 40 As an exercise try to evaluate ƒ D ƒ using the elements along the second row. A.4 Inverse of a Matrix Consider the following set of three linear equations: a11 x1 + a12 x2 + a13 x3 = c1 a21 x1 + a22 x2 + a23 x3 = c2 a31 x1 + a32 x2 + a33 x3 = c3 which can be written in matrix form as a11 C a21 a31 a12 a22 a32 a13 x1 c1 a23 S C x2 S = C c2 S a33 x3 c3 Ax = C (A–12) (A–13) A.4 INVERSE OF A MATRIX 621 One would think that a solution for x could be determined by dividing C by A; however, division is not possible in matrix algebra. Instead, one multiplies by the inverse of the matrix. The inverse of the matrix A is another matrix of the same order and symbolically written as A-1. It has the following property, AA-1 = A-1A = I where I is an identity matrix. Multiplying both sides of Eq. A–13 by A-1, we obtain A-1Ax = A-1C Since A-1Ax = Ix = x, we have x = A-1C (A–14) -1 Provided A can be obtained, a solution for x is possible. For hand calculation the method used to formulate A-1 can be developed using Cramer’s rule. The development will not be given here; instead, only the results are given.* In this regard, the elements in the matrices of Eq. A–14 can be written as x = A-1C x1 C11 1 C C12 C x2 S = ƒAƒ x3 C13 C21 C22 C23 C31 c1 C32 S C c2 S C33 c3 (A–15) Here ƒ A ƒ is an evaluation of the determinant of the coefficient matrix A, which is determined using the Laplace expansion discussed in Sec. A.3. The square matrix containing the cofactors Cij is called the adjoint matrix. By comparison it can be seen that the inverse matrix A-1 is obtained from A by first replacing each element aij by its cofactor Cij, then transposing the resulting matrix, yielding the adjoint matrix, and finally multiplying the adjoint matrix by 1> ƒ A ƒ . To illustrate how to obtain A-1 numerically, we will consider the solution of the following set of linear equations: x1 - x2 + x3 = - 1 -x1 + x2 + x3 = - 1 x1 + 2x2 - 2x3 = (A–16) 5 Here 1 A = C -1 1 -1 1 2 1 1S -2 *See Kreyszig, E., Advanced Engineering Mathematics, John Wiley & Sons, Inc., New York. A 622 APPENDIX A M AT R I X A L G E B R A FOR S T R U C T U R A L A N A LY S I S The cofactor matrix for A is ` 1 2 -1 C = F- ` 2 -1 ` 1 1 -1 ` - ` -2 1 1 1 ` ` -2 1 1 1 ` - ` 1 -1 1 -1 ` ` -2 1 1 1 ` - ` -2 1 1 1 ` ` 1 -1 1 ` 2 -1 `V 2 -1 ` 1 Evaluating the determinants and taking the transpose, the adjoint matrix is -4 CT = C - 1 -3 0 -3 -3 -2 -2 S 0 Since A 1 A = † -1 1 -1 1 2 1 1 † = -6 -2 The inverse of A is, therefore, A-1 = - -4 1 C -1 6 -3 0 -3 -3 -2 -2 S 0 Solution of Eqs. A–16 yields x1 -4 1 C x2 S = - C - 1 6 x3 -3 0 -3 -3 -2 -1 - 2 S C -1 S 0 5 x1 = - 16[1-421 -12 + 01- 12 + 1-22152] = 1 x2 = - 16[1-121 -12 + 1- 321 -12 + 1- 22152] = 1 x3 = - 16[1-321 -12 + 1- 321 -12 + 102152] = - 1 Obviously, the numerical calculations are quite expanded for larger sets of equations. For this reason, computers are used in structural analysis to determine the inverse of matrices. A.5 THE GAUSS METHOD FOR SOLVING SIMULTANEOUS EQUATIONS 623 A.5 The Gauss Method for Solving Simultaneous Equations When many simultaneous linear equations have to be solved, the Gauss elimination method may be used because of its numerical efficiency. Application of this method requires solving one of a set of n equations for an unknown, say x1, in terms of all the other unknowns, x2, x3, Á , xn. Substituting this so-called pivotal equation into the remaining equations leaves a set of n - 1 equations with n - 1 unknowns. Repeating the process by solving one of these equations for x2 in terms of the n - 2 remaining unknowns x3, x4, Á , xn forms the second pivotal equation. This equation is then substituted into the other equations, leaving a set of n - 3 equations with n - 3 unknowns. The process is repeated until one is left with a pivotal equation having one unknown, which is then solved. The other unknowns are then determined by successive back substitution into the other pivotal equations. To improve the accuracy of solution, when developing each pivotal equation one should always select the equation of the set having the largest numerical coefficient for the unknown one is trying to eliminate. The process will now be illustrated by an example. Solve the following set of equations using Gauss elimination: -2x1 + 8x2 + 2x3 = 2 (A–17) 2x1 - x2 + x3 = 2 (A–18) 4x1 - 5x2 + 3x3 = 4 (A–19) We will begin by eliminating x1. The largest coefficient of x1 is in Eq. A–19; hence, we will take it to be the pivotal equation. Solving for x1, we have x1 = 1 + 1.25x2 - 0.75x3 (A–20) Substituting into Eqs. A–17 and A–18 and simplifying yields 2.75x2 + 1.75x3 = 2 (A–21) 1.5x2 - 0.5x3 = 0 (A–22) Next we eliminate x2. Choosing Eq. A–21 for the pivotal equation since the coefficient of x2 is largest here, we have x2 = 0.727 - 0.636x3 (A–23) Substituting this equation into Eq. A–22 and simplifying yields the final pivotal equation, which can be solved for x3. This yields x3 = 0.75. Substituting this value into the pivotal Eq. A–23 gives x2 = 0.25. Finally, from pivotal Eq. A–20 we get x1 = 0.75. A