Gauss seidel method:explanation,Algorithm and flowchart

 GAUSS SEIDEL METHOD


Gauss-Seidel and Gauss Jacobi method are iterative methods used to find the solution of a system of linear simultaneous equations. Both are based on fixed point iteration method. Whether it’s a program, algorithm, or flowchart, we start with a guess solution of the given system of linear simultaneous equations, and iterate the equations till the desired degree of accuracy is reached.

In Gauss Jacobi method, we assume x1, x2 and x3 as the three initial guesses. To get better values, the approximations in previous iterations are used. In this method, we should see that the variable absolute value coefficient is greater than or equal to sum of the absolute values of the coefficient of the remaining variables.

Guass-Seidel method is very similar to Gauss Jacobi method, and here are simple algorithm and flowchart for Gauss-Seidel and Gauss Jacobi method. In Gauss Seidel method, the most recent values or fresher values are used in successive iterations.

Gauss-Seidel Method Algorithm:

  1. Start
  2. Declare the variables and read the order of the matrix n
  3. Read the stopping criteria er
  4. Read the coefficients aim as
    Do for i=1 to n
    Do for j=1 to n
    Read a[i][j]
    Repeat for j
    Repeat for i
  5. Read the coefficients b[i] for i=1 to n
  6. Initialize x0[i] = 0 for i=1 to n
  7. Set key=0
  8. For i=1 to n
    Set sum = b[i]
    For j=1 to n
    If (j not equal to i)
    Set sum = sum – a[i][j] * x0[j]
    Repeat j
    x[i] = sum/a[i][i]
    If absolute value of ((x[i] – x0[i]) / x[i]) > er, then
    Set key = 1
    Set x0[i] = x[i]
    Repeat i
  9. If key = 1, then
    Goto step 6
    Otherwise print results

FLOWCHART FOR GAUSS SEIDEL METHOD :




C PROGRAM FOR GAUSS SEIDEL METHOD

#include<stdio.h>
#include<math.h>
#define X 2
main()
{
    float x[X][X+1],a[X], ae, max,t,s,e;
    int i,j,r,mxit;
    for(i=0;i<X;i++) a[i]=0;
    puts(" Eneter the elemrnts of augmented matrix rowwise\n");
    for(i=0;i<X;i++)
    {
    for(j=0;j<X+1;j++)
    {
    scanf("%f",&x[i][j]);
    }
    }
    printf(" Eneter the allowed error and maximum number of iteration: ");
    scanf("%f%d",&ae,&mxit);
    printf("Iteration\tx[1]\tx[2]\n");
    for(r=1;r<=mxit;r++)
    {
        max=0;
        for(i=0;i<X;i++)
        {
            s=0;
            for(j=0;j<X;j++)
            if(j!=i) s+=x[i][j]*a[j];
            t=(x[i][X]-s)/x[i][i];
            e=fabs(a[i]-t);
            a[i]=t;
        }
        printf(" %5d\t",r);
        for(i=0;i<X;i++)
        printf(" %9.4f\t",a[i]);
        printf("\n");
        if(max<ae)
        {
            printf(" Converses in %3d iteration\n", r);
            for(i=0;i<X;i++)
            printf("a[%3d]=%7.4f\n", i+1,a[i]);
            return 0;
        }
 
        }
    }



FLOWCHART OF JACOBII  METHOD:





Comments

Popular posts from this blog

PICARD'S METHOD:Explanation,algorithm and flowchart

GAUSS ELIMINATION METHOD:EXPLANATION,ALGORITHM AND FLOWCHART