# fwefdzwrqw412

Description
Categories
Published

View again

All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Transcript
LBYEC34 (NUMMETH Lab) Experiment No. 5: Gauss Elimination  Page 1 of 5   Experiment 5 Gauss Elimination Objectives: 1.   To be able to implement naïve Gauss and Gauss-Jordan elimination in a program. 2.   To be able to understand the difference between naïve Gauss and Gauss-Jordan elimination. Introductory Information:  A linear system of equations is of the general form, nnnnnn nnnn b xa xa xa b xa xa xa b xa xa xa    ......... 2211 22222121 11212111   where the a ’s are constant coefficients, the b ’s are constant solutions, the  x ’s are the unknown variables, and n  is the number of equations. It can also be represented in matrix form as the matrix equation  Ax = b , where  A  is the matrix of coefficients,  x  is the column vector of the unknown variables, and b  is the column vector of constant solutions. Each equation in the system is dependent on the other equations, e.g. they have an influence on each other; therefore all equations must be solved simultaneously in order to obtain the values of the unknowns. Gauss Elimination Method Gauss elimination (naïve Gauss) method reduces a set of linear equations with n  equations in n  unknowns into an equivalent upper triangular matrix set, which can be easily solved by using  back substitution. Given the set of equations 11212111  ...  b xa xa xa nn    (1a) 22222121  ...  b xa xa xa nn    (1b) 33232131  ...  b xa xa xa nn    (1c) nnnnnn  b xa xa xa    ... 2211   Procedure: 1.   Equation (1a) is divided by the coefficient of  x 1  in that equation to obtain  LBYEC34 (NUMMETH Lab) Experiment No. 5: Gauss Elimination  Page 2 of 5   11111131113211121  ... ab xaa xaa xaa x nn   (2) This is called the pivot  equation, which will eliminate one specific unknown variable in all of the equations that follow it. In the pivot equation, the coefficient of the variable that is to be eliminated from subsequent equations is known as the pivot coefficient. In the case of the  pivot Equation (2), the variable to be eliminated is  x 1  and the pivot coefficient is a 11 . 2.    Next, Equation (2) is multiplied by the coefficient of  x 1  in Equation (1b), and the resulting equation is subtracted from Equation (1b), thus eliminating the  x 1  term from it. Equation (2) is then multiplied by the coefficient of  x 1  in Equation (1c), and the resulting equation is subtracted from (1c). In a similar manner, the  x 1  terms are eliminated from all equations of the set except the first, so that the set assumes the form 11313212111  ...  b xa xa xa xa nn    (3a) 22313222  ''...''  b xa xa xa nn    (3b) 33333232  ''...''  b xa xa xa nn    (3c) nnnnnn  b xa xa xa  ''...'' 3322     3.   Following the steps above, Equation (3b) becomes the pivot equation and steps 1 and 2 are repeated to eliminate the  x 2  terms from all the equations following this pivot equation. This reduction yields 11313212111  ...  b xa xa xa xa nn    (4a) 22313222  ''...''  b xa xa xa nn    (4b) 33333  ''''...''  b xa xa nn    (4c) 44443  ''''...''  b xa xa nn     nnnnn  b xa xa  ''''...'' 33     4.   Equation (4c) is next used as the pivot equation, and the steps described above are used to eliminate the  x 3  terms from all equations following (4c). This procedure of using pivot equations is used until the srcinal set of equations has been reduced. 5.   After the upper triangular matrix set of equations has been obtained, the last equation in this equivalent set yields the value of  x n  directly. The value is then substituted to the equation directly above it to obtain the value for  x n-1 , which is, in turn used along with the value of  x n  in the equation directly above to obtain the value of  x n-2 , and so on until the value of  x 1  is solved for.  LBYEC34 (NUMMETH Lab) Experiment No. 5: Gauss Elimination  Page 3 of 5   Gauss-Jordan Elimination Method This differs from the Gauss Elimination method in that instead of an upper triangular set, the set of equations is reduced into an equivalent identity matrix set in order to directly obtain the values of each variable. To better illustrate to process involve in this method, let us solve the following set of equations: 13522 321    x x x  (1a) 20432 321    x x x  (1b) 1033 321    x x x  (1c) Procedure: 1.   Begin by normalizing Equation (1a); divide it by the  x 1  coefficient, 2, to obtain 5.65.2 321    x x x  (2a) 20432 321    x x x  (2b) 1033 321    x x x  (2c) 2.   Eliminate the  x 1  term from Equation (2b) by multiplying (2a) with the  x 1  coefficient of (2b) and subtracting the resulting equation from (2b). Do the same for Equation (2c) by multiplying (2a) with the  x 1  coefficient of (2c) and subtracting the resulting equation from (2c). 5.65.2 321    x x x  (3a) 75 32    x x  (3b) 5.95.42 32    x x  (3c) 3.    Next, normalize Equation (3b) by dividing it with the  x 2  coefficient, 5, to obtain 5.65.2 321    x x x  (4a) 4.12.0 32    x x  (4b) 5.95.42 32    x x  (4c) 4.   Reduce the  x 2  terms from Equations (4a) and (4c) by similar means from step 2: multiply (4b)  by the  x 2  coefficient in (4a) and subtract the product from (4a), and do the same for Equation (4c). 9.73.2 31    x x  (5a) 4.12.0 32    x x  (5b) 3.121.4 3    x  (5c) 5.   Equation (5c) is normalized by dividing it with the coefficient of  x 3 , -4.1, to obtain  LBYEC34 (NUMMETH Lab) Experiment No. 5: Gauss Elimination  Page 4 of 5   9.73.2 31    x x  (6a) 4.12.0 32    x x  (6b) 3 3    x  (6c) 6.   Finally, the  x 3  terms from Equations (6a) and (6b) are eliminated using Equation (6c) to obtain the exact values for the unknown variables. 1 1    x   2 2    x   3 3    x  Although the procedure was preset to fit our example that has 3 equations in 3 unknowns, it is quite easy to modify the procedure steps to fit a system of n  equations in n  unknowns. Note:   For both Gauss and Gauss-Jordan Elimination, whenever the pivot coefficient is equal to  zero, we must perform an interchange between the pivot equation and the row succeeding it in order to avoid division by zero during the normalization process. Exercise ****************************************************************************** Create a program the can accept a set of n  linear equations with n  unknown variables each. The user will select to use either Gauss or Gauss-Jordan elimination and input individually each value of the coefficients of each unknown and the solution in all equations. After that the program will display the srcinal matrix entered, the final matrix before getting the values of the unknowns (upper triangular matrix in Gauss and identity matrix in Gauss-Jordan) and the solution for each unknown. ****************************************************************************** Hint on getting the set of linear equations: eq=input( Enter the number of equations );  b=[]; for i1=1:eq for i2=1:eq  printf( Please input the coefficient for x^%i term of Equation %i ,eq-i2,i1); c=input( );  b=[b c]; end  printf( Please input the solution for Equation %i ,i1); c=input( );  b=[b c];

Jul 23, 2017

#### Ecce Ch. 18 Culture Worksheet Legendary Heroes of Rome Pp. 7-9

Jul 23, 2017
Search
Similar documents
Tags