CH-01 (523167), страница 4
Текст из файла (страница 4)
Forsmall systems, Cramer’s Rule can be conveniently applied which allows the unknownvector {A} to be obtained by the formula:[{A} = [c1 ] [c2 ]]T[C ](5)Equation 5 involves the calculation of three determinants, i.e., , [C1], [C2], and[C] where [C1] and [C2] are matrices derived from the matrix [C] when the firstand second columns of [C] are replaced by {Y}, respectively. If we denote theelements of a general matrix [C] of order 2 by cij for i,j = 1,2, the determinant of[C] by definition is:[C] = c11c22 − c12c21(6)The general definition of the determinant of a matrix [M] of order N and whoseelements are denoted as mij for i,j = 1,2,…,N is to add all possible product of Nelements selected one from each row but from different column.
There are N! suchproducts and each product carries a positive or negative sign depending on whethereven or odd number of exchanges are necessary for rearranging the N subscripts inincreasing order. For example, in Equation 6, c11 is selected from the first row andfirst column of [C] and only c22 can be selected and multiplied by it while the otherpossible product is to select c12 from the second row and first column of [C] andthat leaves only c21 from the second row and first column of [C] available as a factorof the second product. In order to arrange the two subscripts in non-decreasing order,one exchange is needed and hence the product c12c21 carries a minus sign.
We shallexplain this sign convention further when a matrix of order 3 is discussed. However,it should be evident here that a matrix whose order is large the task of calculatingits determinant would certainly need help from computer.
This will be the a topicdiscussed in Section 1.5.Let us demonstrate the application of Cramer’s Rule by having a numerical case.If the two given points to be passed by the straight line y = a1 + a2x are (x1,y1) =(1,2) and (x2,y2) = (3,4). Then we can have:© 2001 by CRC Press LLC[C ] = 11x1 1=x2 11= 1× 3 −1×1 = 3 −1 = 23y1x1 2=x2 41= 2 × 3 −1× 4 = 6 − 4 = 23y1 1=y2 12= 1× 4 − 2 ×1 = 4 − 2 = 24[c ] = y12and1[C ] = 12Consequently, according to Equation 5 we can find the coefficients in thestraight-line equation to be:a1 = [C1 ][C ] = 2 2 = 1and a 2 = [C2 ] [C] = 2 2 = 1Hence, the line passing through the points (1,2) and (3,4) is y = a1 + a2x = 1 + x.Application of Cramer’s Rule can be extended for solving three unknowns fromthree linear algebraic equations.
Consider the case of finding a plane which passesthree points (xi,yi) for i = 1 to 3. The equation of that plane can first be written asz = a1 + a2x + a3y. Similar to the derivation of Equation 3, here we substitute thethree given points into the z equation and obtain:(1)a1 + (x1 )a 2 + (y1 )a 3 = z1(7)(1)a1 + (x 2 )a 2 + (y2 )a 3 = z2(8)(1)a1 + (x3 )a 2 + (y3 )a 3 = z3(9)andAgain, the above three equations can be written in matrix form as:[C]{A} = {Z}(10)where the matrix [C] and the vector {A} previously defined in Equation 4 need tobe reexpanded and redefined as:1[C ] = 11© 2001 by CRC Press LLCx1x2x3y1a1 z1 y 2 , {A} = a 2 , and {Z} = z 2 z3 y3a3(11)And, the Cramer’s Rule for solving Equation 10 can be expressed as:[{A} = [C1 ][C2 ] [C3 ]]T[C ](12)where [Ci] for i = 1 to 3 for matrices formed by replacing the ith column of thematrix [C] by the vector {Z}, respectively.
Now, we need the calculation of thedeterminant of matrices of order 3. If we denote the element in a matrix [M] as mijfor i,j = 1 to 3, the determinant of [M] can be calculated as:[M] = m11m 22 m33 − m11m 23m32 + m12 m 23m31− m12 m 21m 33 + m13m 21m 32 − m13m 22 m 31(13)To give a numerical example, let us consider a plane passing the three points,(x1,y1,z1) = (1,2,3), (x2,y2,z2) = (–1,0,1), and (x3,y3,z3) = (–4,–2,0).
We can then have:1[C ] = 11z1[C1 ] = z2z31C=[ 2] 11x1x2x3y1 1y2 = 1y3 11−1−420 = −2−2x1x2x3y1 3y2 = 1y3 01−1−420 =0−2z1z2z3y1 1y2 = 1y3 131020 =2−21−1−431 = −4−2and[C ]31=11x1x2xz1 1z2 = 1z 1According to Equation 13, we find a1 = [C1]/[C] = 0/(–2) = 0, a2 = [C2]/[C] =2/(–2) = –1, and a3 = [C3]/[C] = –4/(–2) = 2. Thus, the required plane equation isz = a1 + a2x + a3y = -x + 2y.QUICKBASIC VERSIONOF THE PROGRAMCRAMERRA computer program called CramerR has been developed as a reviewing exercise in programming to solve a matrix equation of order 3 by application of Cramer© 2001 by CRC Press LLCRule and the definition of determinant of a 3 by 3 square matrix according toEquations 12 and 13, respectively. First, a subroutine called Determ3 is createdexplicitly following Equation 13 as listed below:To interactively enter the elements of the coefficient matrix [C] and also theelements of the right-hand-side vector {Z} in Equation 12 and to solve for {A}, theprogram CramerR can be arranged as:© 2001 by CRC Press LLC1.4 PROGRAM GAUSSProgram Gauss is designed for solving N unknowns from N simultaneous, linearalgebraic equations by the Gaussian Elimination method.
In matrix notation, theproblem can be described as to solve a vector {X} from the matrix equation:[C]{X} = {V}(1)where [C] is an NxN coefficient matrix and {V} is a Nx1 constant vector, and bothare prescribed. For example, let us consider the following system:9x1 + x 2 + x3 = 10(2)3x1 + 6x 2 + x3 = 14(3)2 x1 + 2 x 2 + 3x3 = 3(4)If the above three equations are expressed in matrix form as Equation 1, then:9[C] = 3216211,310 {V} = 14, 3 (5,6)and x1 X={ } x 2 = x1 x 2 x3 x3 []T(7)where T designates the transpose of a matrix.GAUSSIAN ELIMINATION METHODA systematic procedure named after Gauss can be employed for solving x1, x2,and x3 from the above equations.
It consists of first dividing Equation 28 by theleading coefficient, 9, to obtain:x1 +1110x + x =9 2 9 3 9(8)This step is called normalization of the first equation of the system (1). The nextstep is to eliminate x1 term from the other (in this case, two) equations. To do that,we multiply Equation 8 by the coefficients associated with x1 in Equations 3 and 4,respectively, to obtain:© 2001 by CRC Press LLC11103x1 + x 2 + x3 =333(9)2220x 2 + x3 =999(10)and2 x1 +If we subtract Equation 9 from Equation 3, and subtract Equation 10 from Equation 4, the x1 terms are eliminated. The resulting equations are, respectively:17232x 2 + x3 =333(11)16257x 2 + x3 =999(12)andThis completes the first elimination step. The next normalization is applied toEquation 11, and then the x2 term is to be eliminated from Equation 12.
The resultingequations are:232(13)x 2 + x3 =1717and393393(14)x =−153 3153The last normalization of Equation 14 then gives:x3 = −1(15)Equations 8, 13, and 15 can be organized in matrix form as:1{V} = 0019101 9 x1 10 9 2 17 x 2 = 32 171 x3 −1 (16)The coefficient matrix is now a so-called upper triangular matrix since allelements below the main diagonal are equal to zero.As x3 is already obtained in Equation 15, the other two unknowns, x2 and x3,can be obtained by a sequential backward-substitution process. First, Equation 13can be used to obtain:x2 =© 2001 by CRC Press LLC32 232 232 + 2=2− x3 =− ( −1) =17 1717 1717Once, both x2 and x3 have been calculated, x1 can be obtained from Equation 8 as:x1 =10 1110 1110 − 2 + 1=1− x 2 − x3 =− (2) − ( −1) =9 999 999To derive a general algorithm for the Gaussian elimination method, let us denotethe elements in [C], {X}, and {V} as ci,j, xi, and vi, respectively.
Then the normalization of the first equation can be expressed as:(c )1, j new( ) (c )= c1, jold1,1 old(17)and(v1 )new = (v1 ) old (c1,1 )old(18)Equation 17 is to be used for calculating the new coefficient associated with xjin the first, normalized equation. So, j should be ranged from 2 to N which is thenumber of unknowns (equal to 3 in the sample case). The subscripts old and neware added to indicate the values before and after normalization, respectively. Suchdesignation is particularly helpful if no separate storage in computer are assignedfor [C] for the values of its elements.
Notice that (c1,1)new = 1 is not calculated.Preserving this diagonal element enables the determinant of [C] to be computed.(See the topic on matrix inversion and determinant.)The formulas for the elimination of x1 terms from the second equation are:(c )2 , j new( ) − (c ) (c )= c2, jold2 ,1 old1, j old(19)for j = 2,3,…,N (there is no need to include j = 1) and(v2 )new = (v2 )old − (c2,1 )old (v1 )old(20)By changing the subscript 2 in Equations 19 and 20, x1 term in the third equationcan be eliminated.
In other words, the general formulas for elimination of x1 termsfrom all equation other than the first equation are, for k = 2,3,…,N(c )k , j newfor j = 2,3,…,N© 2001 by CRC Press LLC( ) − (c ) (c )= ck,joldk ,l old1, j old(21)(vk )new = (vk )old − (ck,1 )old (v1 )old(22)Instead of normalizing the first equation, we can generalize Equations 17 and18 for normalization of the ith equation, for i = 1,2,…,N to the expressions:(c )i , j new( ) (c )= ci. joldi ,i old(23)for j = i + 1,i + 2,…,N and(vi )new = (vi ) old (ci,i )old(24)Note that (ci,i)new should be equal to 1 but no need to calculate since it is notinvolved in later calculation for finding {X}.Similarly, elimination of xi term from kth equation for k = i + 1,i + 2,…,Nconsists of using the general formula:(c )k , j new( ) − (c ) (c )= ck,jk ,i oldoldi , j old(25)for j = i + 1,i + 2,…,N and(vk )new = (vk )old − (ck,i )old (vi )old(26)Backward substitution for finding xi involves the calculation of:Nx i = vi −∑cxi, j j(27)j= i +1for i = N–1,N–2,…,2,1.