SlideServe
Menu
Préférences
© SlideServe · v2026

GAUSS ELIMINATION & BACK SUBSTITUTION

chase-williamson avatar
13 diapositives · 458 Views · Dec 01, 2014

GAUSS ELIMINATION & BACK SUBSTITUTION. Dayun Yu Seungmuk Ji. Gauss Elimination. n n matrix : A , n-vector : x and b , Ax = b  The solution vector x can be obtained without difficulty in case A is upper-triangular with all diagonal. Ax = b .

GAUSS ELIMINATION & BACK SUBSTITUTION - slide 1
01 / 13GAUSS ELIMINATION & BACK SUBSTITUTION
1 / 17

Télécharger la présentation

GAUSS ELIMINATION & BACK SUBSTITUTION
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. GAUSS ELIMINATION & BACK SUBSTITUTION Dayun Yu Seungmuk Ji

  2. Gauss Elimination nn matrix : A , n-vector : x and b, Ax = b  The solution vector x can be obtained without difficulty in case A is upper-triangular with all diagonal. Ax = b 

  3. Back Substitution ann  0, We must have We now know xn, the second last equation Similarly, In general

  4. Define matrix W Define matrix W in the system Ax = b

  5. Pivoting Partial-pivoting is interchanging row. ☞ If first column(a11=0) of first row is zero, we have to interchange other row . Full-pivoting is interchanging row and columns. ☞ If is satisfy, we must find . So we execute interchanging row ( row i  row p).

  6. Example Ex)

  7. Algorithm 1 (Upper-triangular) Initialize the n-vector p to have pi = i, i = 1,,n. For k = 1,∙∙∙,n-1, do; For i = k+1, ∙∙∙,n , do; set m and , m equal to . For j = k+1,∙∙∙, n+1, do; set .

  8. Algorithm 2 (Back substitution) For k = n, n-1,∙∙∙,1 , do; calculate .

  9. Programming with C #include <stdio.h> #include <math.h> #include <conio.h> main() { int i, j, k, t; int n, N; float m, s; float w[3][4]={{2,3,-1, 5},{4,4,-3, 3},{-2,3,-1, 1}}; float p[3]={0.0}; clrscr(); n = 3; N = 4; printf("\n\n***** Matrix W ****\n\n"); for(i = 0; i < n; i++) { for(j = 0; j < N; j++) printf("%10.3f", w[i][j]); printf("\n"); p[i] = i; } for(k = 0; k < n-1; k ++) { for(j = k; j < N; j++) { if(j == n) { printf(" W is not invertible ! "); break; } else if(w[p[j]][k] == 0) continue; else { for(t = k; t < N; t++) { s = w[p[j]][t]; w[p[j]][t] = w[p[k]][t]; w[p[k]][t] = s; } } break; } for(i = k+1; i < n; i++) { q = w[p[i]][k] / w[p[k]][k]; for(j = k; j < N; j++) w[p[i]][j] = w[p[i]][j] - q*w[p[k]][j]; } }

  10. Programming with C printf("\n\n"); for(i = 0; i < n; i++) { for(j =0; j < N; j++) printf("%10.3f", w[p[i]][j]); printf("\n"); } } getch(); return(0); }

  11. Result ***** Matrix W **** 2.000 3.000 -1.000 5.000 4.000 4.000 -3.000 3.000 -2.000 3.000 -1.000 1.000 2.000 3.000 -1.000 5.000 0.000 -2.000 -1.000 -7.000 0.000 0.000 -5.000 -15.000

  12. General program with C #include <stdio.h> #include <conio.h> #include <math.h> #include <stdlib.h> #define MAXROW 20 typedef struct { int Row,Column; double Element[MAXROW][MAXROW+1]; } Matrix; Matrix M; void gainp(int a, int b); void gapiv(int row, int i); void gacal(int row, int col); int main() { int a,b; clrscr(); printf(“Row is :”); scanf(“%2d”,&a); printf(“Column is :”); scanf(“%2d”,&b); gainp(a,b); gacal(a,b); getch(); return 0; } void gainp(int a, int b) { int i,j; double tmp; printf(“\n”); printf("Enter the matrix (%2d,%2d) \n",a,b); for(i=0;i<a;i++) { for(j=0;j<b;j++){ printf("Enter for element (%2d,%2d) :", i+1,j+1); scanf(" %lf",&tmp); M.Element[i][j]=tmp; } printf("\n"); } }

  13. General program with C void gapiv(int row, int i) { int j,ii; double tmp; for(ii=i+1;ii<row;ii++){ if(M.Element[ii][i]!=0.0){ for(j=i;j<row+1;j++){ tmp=M.Element[i][j]; M.Element[i][j]=M.Element[ii][j]; M.Element[ii][j]=tmp; } break; } } } void gacal(int row, int col) { int i,j,k, N; double div, sum, X[MAXROW]; for(i=0;i<row;i++){ if(M.Element[i][i]==0.0) gapiv(row,i); for(j=i+1;j<row;j++){ div=M.Element[j][i]/M.Element[i][i]; for(k=0;k<col;k++) M.Element[j][k]-=M.Element[i][k]*div; } } N=row; X[N-1]=M.Element[N-1][N]/M.Element[N-1][N-1]; for(i=N-2;i>=0;i--){ sum=0.0; for(j=i+1;j<N;j++) sum += M.Element[i][j]*X[j]; X[i]=(M.Element[i][N]-sum)/M.Element[i][i]; } printf("Solution is :\n"); for(i=0;i<N;i++) printf(" X%-d = %f\n",i+1,X[i]); }