0% found this document useful (0 votes)
3 views2 pages

11 Gauss Seidel Iteration Method

The Gauss Seidel method is an iterative technique for solving systems of linear equations, requiring the equations to be arranged in diagonally dominant form for convergence. The algorithm involves substituting values iteratively until the changes are within a specified tolerable error. A sample program is provided to demonstrate the method, which outputs the solution for the given equations.

Uploaded by

RishiKesh Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

11 Gauss Seidel Iteration Method

The Gauss Seidel method is an iterative technique for solving systems of linear equations, requiring the equations to be arranged in diagonally dominant form for convergence. The algorithm involves substituting values iteratively until the changes are within a specified tolerable error. A sample program is provided to demonstrate the method, which outputs the solution for the given equations.

Uploaded by

RishiKesh Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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

2. Arrange given system of linear equations in diagonally dominant form

3. Read tolerable error (e)

4. Convert the first equation in terms of first variable, second equation in terms of second variable and so on.

5. Set initial guesses for x0, y0, z0 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

8. Set x0=x1, y0=y1, z0=z1 and so on and goto step 6

9. Print value of x1, y1, z1 and so on

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 */

/* In this example we are solving


3x + 20y - z = -18
2x - 3y + 20z = 25
20x + y - 2z = 17
*/

/* Arranging given system of linear equations in diagonally dominant form:


20x + y - 2z = 17
3x + 20y -z = -18
2x - 3y + 20z = 25
*/
/* Equations:
x = (17-y+2z)/20
y = (-18-3x+z)/20
z = (25-2x+3y)/20
*/
/* Defining function */
#define f1(x,y,z) (17-y+2*z)/20
#define f2(x,y,z) (-18-3*x+z)/20
#define f3(x,y,z) (25-2*x+3*y)/20

/* 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++;

/* Set value for next iteration */


x0 = x1;
y0 = y1;
z0 = z1;

}while(e1>e && e2>e && e3>e);

printf("\nSolution: x=%0.3f, y=%0.3f and z = %0.3f\n",x1,y1,z1);

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

Solution: x=1.000, y=-1.000 and z = 1.000

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy