11 Gauss Seidel Iteration Method
11 Gauss Seidel Iteration Method
Gauss Seidel method is iterative approach for solving system of linear equations. In this method, first given system of
linear equations are arranged in diagonally dominant form. For guaranteed convergence, system must be in
Diagonally Dominant Form. In this article, we are going to develop algorithm for Gauss Seidel method.
Algorithm:
1. Start
4. Convert the first equation in terms of first variable, second equation in terms of second variable and so on.
6. Substitute value of y0, z0 ... from step 5 in first equation obtained from step 4 to calculate new value of x1. Use
x1, z0, u0 .... in second equation obtained from step 4 to caluclate new value of y1. Similarly, use x1, y1, u0... to find
new z1 and so on.
7. If| x0 - x1| > e and | y0 - y1| > e and | z0 - z1| > e and so on then goto step 9
10. Stop
Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>
/* Arrange systems of linear equations to be solved in diagonally dominant form and form equation for each
unknown and define here */
/* Main function */
int main()
{
float x0=0, y0=0, z0=0, x1, y1, z1, e1, e2, e3, e;
int count=1;
clrscr();
printf("Enter tolerable error:\n");
scanf("%f", &e);
printf("\nCount\tx\ty\tz\n");
do
{
/* Calculation */
x1 = f1(x0,y0,z0);
y1 = f2(x1,y0,z0);
z1 = f3(x1,y1,z0);
printf("%d\t%0.4f\t%0.4f\t%0.4f\n",count, x1,y1,z1);
/* Error */
e1 = fabs(x0-x1);
e2 = fabs(y0-y1);
e3 = fabs(z0-z1);
count++;
getch();
return 0;
}
Output:
Enter tolerable error:
0.0001
Count x y z
1 0.8500 -1.0275 1.0109
2 1.0025 -0.9998 0.9998
3 1.0000 -1.0000 1.0000
4 1.0000 -1.0000 1.0000