Solution of Liner Algebric Equtions using the Guss-Jordn Method Populr pproch for solving liner equtions The Guss Jordn method depends on two properties of liner equtions: Scling one or more of ny of the liner equtions by non-zero vlue hs no effect on the solution of these equtions eplcing ny eqution in the set by the ddition or subtrction of tht eqution with ny other eqution in the set hs no effect on the finl solution
To understnd the Guss-Jordn method nd to develop n lgorithm we will work with numericl emple We will follow the steps of the Guss-Jordn method to develop n lgorithm for solving liner equtions Consider the following system of equtions: 6
Guss Jordn: Emple Step : Form the ugmented mtri contining only the constnts nd right hnd side of the equtions 6 6
The Guss-Jordn method uses the two properties mentioned erlier to reduce the ugmented mtri 6 Solution:
The Guss Jordn method requires number of generl steps clled psses The number of psses is equl to the number of equtions ( pss is the current row) Within ech pss two steps re performed:. A normliztion step to reduce digonl element to one. An elimintion step to reduce off digonl elements in the sme column s the normlized digonl element to zeros in the other rows
Pss : () Normliztion Normlize row In generl: j jj is the pivot element j jj 6 6 6
Guss Jordn: Emple Pss : (b) Elimintion Eliminte first column of row nd 8
8 Guss Jordn: Emple Pss : (b) Elimintion Summry of Elimintion: ij j i i j i N i,
Pss : () Normliztion Normlize row
Guss Jordn: Emple Pss : (b) Elimintion Eliminte second column of row nd 8 8
Pss : (b) Elimintion Eliminte second column of row nd
Pss : () Normliztion Normlize row
Pss : (b) Elimintion Eliminte third column of row nd 6 8
Pss : (b) Elimintion Eliminte third column of row nd
Solution:. 6.8.6
Guss-Jordn: Code (p.) void GussJordn(double **, int N, int M) { int i, j, k; } for(j=;j<n;j++) { // Normliztion for(i=j+;i<m;i++) [j][i]/=[j][j]; [j][j]=.; // Elimintion for(k=;k<n;k++) { if(k==j) continue; // Skip this itertion for(i=j+;i<m;i++) [k][i]-=[j][i]*[k][j]; [k][j]=.; } } 6
Guss-Jordn: Code (p.) #include <iostrem> using nmespce std; #define OWS #define COLS #define contents {{,,6,}, {,,,}, {,,,} } // prototype of function void GussJordn(double **, int N, int M); int min() { int i, j; double **m; double temp[ows][cols]=contents; // Allocte memory for mtri m = new double * [OWS]; for(i=;i<ows;i++) m[i]=new double [COLS];
Guss-Jordn: Code (p.) // Lod vlues into mtri from sttic rry for(i=;i<ows;i++) for(j=;j<cols;j++) m[i][j]=temp[i][j]; GussJordn(m,OWS,COLS); // Solve the mtri // Print out mtri for(i=;i<ows;i++) { for(j=;j<cols;j++) cout << m[i][j] << " "; cout << endl; } // Un-llocte memory for mtri for(i=;i<ows;i++) delete m[i]; delete m; } // Done return ; 8
Guss-Jordn Two questions tht my come to mind regrding the Guss-Jordn method re:. Wht hppens if digonl element we re using s pivot is zero?. Wht hppens if there is no unique solution to the lgebric set?
Guss-Jordon Mimum Pivoting Before Normliztion, re-order the ugmented mtri. Strting t the current pss row, nd continuing through ll the subsequent rows, look for the lrgest bsolute pivot element (remember which row where you found it). If this vlue is very smll (<e-), stop round off errors will occur. The row where it is found should then be switched with the pss row (e.g.: If lrgest vlue in row is t column, switch row with row )