Search:

Submit Article

# GAUSS SEIDEL METHOD

Posted By: Harriet Hughes     Category: C Programming     Views: 78252

## Code for GAUSS SEIDEL METHOD in C Programming

```#include<stdio.h>
#include<conio.h>
#include<math.h>
#define ESP 0.0001
#define X1(x2,x3) ((17 - 20*(x2) + 2*(x3))/20)
#define X2(x1,x3) ((-18 - 3*(x1) + (x3))/20)
#define X3(x1,x2) ((25 - 2*(x1) + 3*(x2))/20)

void main()
{
double x1=0,x2=0,x3=0,y1,y2,y3;
int i=0;
clrscr();
printf("\n__________________________________________\n");
printf("\n   x1\t\t   x2\t\t   x3\n");
printf("\n__________________________________________\n");
printf("\n%f\t%f\t%f",x1,x2,x3);
do
{
y1=X1(x2,x3);
y2=X2(y1,x3);
y3=X3(y1,y2);
if(fabs(y1-x1)<ESP && fabs(y2-x2)<ESP && fabs(y3-x3)<ESP )
{
printf("\n__________________________________________\n");
printf("\n\nx1 = %.3lf",y1);
printf("\n\nx2 = %.3lf",y2);
printf("\n\nx3 = %.3lf",y3);
i = 1;
}
else
{
x1 = y1;
x2 = y2;
x3 = y3;
printf("\n%f\t%f\t%f",x1,x2,x3);
}
}while(i != 1);
getch();
}

/*     OUT PUT       _____________________________________________________   x1              x2              x3__________________________________________0.000000         0.000000       0.0000000.850000        -1.027500       1.0108751.978588        -1.146244       0.8802052.084265        -1.168629       0.8662792.105257        -1.172475       0.8636032.108835        -1.173145       0.8631452.109460        -1.173262       0.8630652.109568        -1.173282       0.863051__________________________________________x1 = 2.110x2 = -1.173x3 = 0.863*/```
Share:

Didn't find what you were looking for? Find more on GAUSS SEIDEL METHOD Or get search suggestion and latest updates.

 Harriet Hughes author of GAUSS SEIDEL METHOD is from London, United Kingdom. View All Articles

• Comment should be atleast 30 Characters.