Chapter:
1. GAUSS JORDAN METHOD lab report
TITLE:
TO SOLVE THE SYSTEM OF LINEAR EQUATIONS USING GAUSS JORDAN METHOD
OBJECTIVES:
To be able to follow the algorithm of Gauss Jordan method of solving linear equation.
To build some programming concepts by solving practical problems.
TOOLS REQUIRED:
Computer workstation
Program software (as necessary)
THEORY:
Gauss Jordan Method is a procedure for solving systems of linear equation which is in fact the modification of gauss elimination method . It is also known as Row Reduction Technique. In this method, the problem of systems of linear equation having n unknown variables is converted into a matrix having rows n and columns n+1. This matrix is also known as Augmented Matrix. After forming n x n+1 matrix, matrix is transformed to diagonal matrix by row operations. Finally result is obtained by making all diagonal element to 1 i.e. identity matrix.
ALGORITHM:
Start
Read Number of Unknowns: n
Read Augmented Matrix (A) of n by n+1 Size
Transform Augmented Matrix (A) to Diagonal Matrix by Row Operations.
Obtain Solution by Making All Diagonal Elements to 1.
Display Result.
Stop
C-PROGRAM:
#include#include #include #define SIZE 10 Void main() { float a[SIZE][SIZE], x[SIZE], ratio; int i,j,k,n; clrscr(); printf("Enter number of unknowns: "); scanf("%d", &n); /* 2. Reading Augmented Matrix */ printf("Enter coefficients of Augmented Matrix:\n"); for(i=1;i<=n;i++) { for(j=1;j<=n+1;j++) { printf("a[%d][%d] = ",i,j); scanf("%f", &a[i][j]); } } /* Applying Gauss Jordan Elimination */ for(i=1;i<=n;i++) { if(a[i][i] == 0.0) { printf("Mathematical Error!"); exit(0); } for(j=1;j<=n;j++) { if(i!=j) { ratio = a[j][i]/a[i][i]; for(k=1;k<=n+1;k++) { a[j][k] = a[j][k] - ratio*a[i][k]; } } } } /* Obtaining Solution */ for(i=1;i<=n;i++) { x[i] = a[i][n+1]/a[i][i]; } /* Displaying Solution */ printf("\nSolution:\n"); for(i=1;i<=n;i++) { printf("x[%d] = %0.3f\n",i, x[i]); } getch();}
CONCLUSION:
Thus the given linear equations were solved using Gauss Jordan Elimination Method.
Guest