## Gauss Jordan Method Best Explained with MATLAB & C Program Examples

In the last article about solving the roots of given linear equations, we have discussed Gauss Elimination method. In that method we just go on eliminating one variable and keep on decreasing number of equations. Finally we get only one equation, with only one variable. We put this value in former equations to get values of other roots.

Similarly there is another method for finding the roots of given set of linear equations, this method is known as Gauss Jordan method. This method is same that of Gauss Elimination method with some modifications. In Gauss Jordan method we keep number of equations same as given, only we remove one variable from each equation each time. Thus finally we get same number of equations with only one variable in each equation. Thus we can find out roots of given set of linear equation.

## Gauss Jordan Method with MATLAB & C Program Examples

Let us consider set of three equations as follows:

```a1x+b1y+c1z=d1…………………1)

a2x+b2y+c2z=d2…………………2)

a3x+b3y+c3z=d3…………………3)```

Solution:

Step 1):

Eliminate ‘x’ from 2nd and 3rd equation using 1st equation as follows:

```eq.(2) – (a2/a1)*eq.(1) ;
eq.(3) – (a3/a1)*eq.(1) ;```

When we solve above two equations, we get two new equations in ‘y’ and ‘z’

Write first and these two equations as follows:

```a1x+b1y+c1z=d1       …………4)

b1’y+c1’z=d1’        …………5)

b2’y+c2’z=d2’        …………6)```

Step 2):

Eliminate ‘y’ from 4th and 6th equation using 5th equation as follows:

```eq.(4) – (b1/b1’)*eq.(5)  ;
eq.(6) – (b2’/b1’)*eq.(5) ;```

When we solve above two equations, we get two new equations, write these equations in the following form. (Note that we are writing 5th equation as it is and defining it as 8th equation)

```a1”x+c1”=d1”       ……………7)

b1’y+c1’z=d1’      ……………8)

c2”z=d2”           ……………9)```

Don’t get over exited, here we don’t use value of z from 9th equation directly because it is not an elimination method.

Step 3):

Eliminate ‘z’ from 7th and 8th equation using 9th equation as follows:

```eq.(7) – (c1”/c2”)*eq.(9) ;
eq.(c1’/c2”)*eq.(9);```

After solving above two equation, we directly get two new equations contains only one variable each.

Let us discuss Gauss Jordan method by solving one simple set of linear equation.

### Example:

Find roots of following set of linear equations:

```x+y+z=9       …………1)

2x-3y+4z=13   …………2)

3x+4y+5z=40   …………3)```

Solution:

Step 1):

Eliminate ‘x’ from 2nd and 3rd equation using 1st equation as follows:

```eq.(2) – 2*eq.(1);
eq.(3) – 3*eq.(1);

x+y+z=9      ……………4)

-5y+2z=-5     ……………5)

y+2z=13      ……………6)```

Step 2):

Eliminate ‘y’ from 4th and 6th equation using 5th equation as follows:

```eq.(4)+(1/5)*eq.(5)  ;
eq.(6)+(1/5)*eq.(5)  ;

x+(7/5)z=8     ……………7)

-5y+2z=-5      ……………8)

(12/5)z=12     …………9)```

Step 3):

Eliminate ‘z’ from 7th and 8th equation using 9th equation as follows:

```eq.(7)-(7/12)*eq.(9) ;
eq.(8) – (5/6)*eq.(9)

x=1; -5y=-15
i.e. y=3; Z=5```

### Gauss Jordan Method C Program

```/* Gauss Jordan Method C Program */

#include<stdio.h>
int main()
{
int i,j,k,n;
float A[20][20],c,x[10];
printf("\nPlease enter the size of matrix: ");
scanf("%d",&n);
printf("\nPlease enter the elements of augmented matrix row-wise:\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]);
}
}
/* Below for loop is used to find the elements of diagonal matrix */
for(j=1; j<=n; j++)
{
for(i=1; i<=n; i++)
{
if(i!=j)
{
c=A[i][j]/A[j][j];
for(k=1; k<=n+1; k++)
{
A[i][k]=A[i][k]-c*A[j][k];
}
}
}
}
printf("\nThe solution is:\n");
for(i=1; i<=n; i++)
{
x[i]=A[i][n+1]/A[i][i];
printf("\n x%d=%f\n",i,x[i]);
}
return(0);
}```

You may also like:

I hope you liked this article on Gauss Jordan Method with MATLAB Code and C Program. If you have any queries, please use below comments section for the same. Please like our Facebook page and subscribe to our newsletter for future updates. Have a nice day! tada…

## Gauss elimination method :

### Introduction:

Many times we are required to find out solution of linear equations. We also know that, we can find out roots of linear equations if we have sufficient number of equations. For example if we have to calculate three unknown variables, then we must have three equations. Many times we have solved such problems by eliminating one of the root and keep on decreasing number of variables. But in some cases it is not possible or it will take more time to solve.

Gauss elimination method is one of the simple and famous methods used for finding roots of linear equations. Let us discuss this method assuming we have three linear equations in x, y and z. That is we have to find out roots of that equations (values of x, y and z).

Steps to find out roots of linear equations using Gauss elimination method:

In this method we just eliminate ‘x’ from first equation using second and third equation. After that we get only two equations with two unknowns. Similarly, we then eliminate ‘y’ from first (among two equations that we get from last step) equation using second equation. Finally we get single equation in z having constant in its right side. Now we can find ‘z’, using ‘z’ we can find ‘y’, similarly ‘x’.

Don’t get confused, I will explain each step clearly.

Let us consider three linear equations as follows:

a1x+b1y+c1z=d1…………………1)

a2x+b2y+c2z=d2…………………2)

a3x+b3y+c3z=d3…………………3)

From above three equations we are asked for finding values of x, y and z (values of a1, b1, c1,……..,d3 are given).

Step 1: Eliminate ‘x’ from first equation using second and third equation. For doing this we have to subtract 1st eq. from 2nd eq. by making coefficient of ‘x’ (of 1st equation) equals to coefficient of ‘x’ (of 2nd equation). Similarly we have to do same thing for third equation.

In short we have to solve following equations:

eq.(2) – (a2/a1)*eq.(1) and eq.(3) – (a3/a1)*eq.(1)

We get two new equations in y and z as follows:

b2’y+c2’z=d2’……..4)

b3’y+c3’z=d3’……..5)

Step 2: similarly, we have to eliminate ‘y’ from 4th equation using 5th equation.

We have to solve following equation.

eq.(5) – (b3’/b2’)*eq.(4)

we get c3”z=d3”……………6)

solving above equation we get, z=d3”/c3”

Step 3: Finally we have to put above value of ‘z’ in equation 4) (or (5)), then we get ‘y’. now we have two roots (y and z). put ‘y’ and ‘z’ in eq.(1) (or (2) or eq.(3)), we will get ‘x’.

## Example 1:

Find the roots of following equations using Gauss Elimination method.

X + 4y – z = -5 ………….1)

X + y – 6z = -12…………2)

3x – y – z = 4      ………3)

### Solution:

Step 1: Perform eq.(2) – (a2/a1)*eq.(1) and eq.(3) – (a3/a1)*eq.(1)

We get,                                              3y +5z =7……………4)

And

-13y +2z = 19…………..5)

Step 2: Now perform eq.(5) – (b3’/b2’)*eq.(4)

We get, -13y + 2z – (-13/3)*(3y + 5z) = 19 + (13/3)*7

71z = 148

i.e. z=148/71.

Step 3: From eq.(5) – 13y = 19 – 2*(148/71)

= 19 – 296/71

Y= -81/71

From eq.(1) x+4(-81/71)-148/71=-5

Therefore, x=117/71.

Thus roots of given linear equations using Gauss elimination method is

X=117/71; y=-81/71; z=148/71.

## Example 2:

Find roots of following linear equations using Gauss Elimination method:

2x+y+z=10………1)

3x+2y+3z=18……..2)

X+4y+9z=16………..3)

### Solution :

Step 1: Perform eq.(2)-(3/2)*eq(1)   and   eq(3)-(1/2)*eq(1)

We get,                                                  y+3z=6…………4)

And                                                   7y+17z=22……….5)

Step 2: Perform eq(5) – 7*eq(4)

We get, -4z=-20

i.e. z=5;

Step 3: From equation (5) y=-63/7 i.e. y=-9

From equation (1) 2x=14   i.e. x=7

Thus the roots of given linear equations is

X=7; y=-9; z=5.

## Iterative methods for solving linear equations:

The preceding methods of solving simultaneous linear equations are known as direct methods as they yield an exact solution. On the other hand, an iterative method is that in which we start from an approximation to the true solution and obtain better and better approximation from a computation cycle repeated as often as may be necessary for achieving the desired accuracy. Simple iteration methods can be devised for systems in which the coefficient of leading diagonal is large compared to others.

There are two iterative methods as follows:

1)      Jacobi’s iteration method.

2)     Gauss-Seidel iteration method.

Today we are just concentrating on the first method that is Jacobi’s iteration method. We will see second method (Gauss-Seidel iteration method) for solving simultaneous equations in next post. After that, I will show you how to write a MATLAB program for solving roots of simultaneous equations using Jacobi’s Iterative method.

## Jacobi’s Iteration Method:

Let us consider set of simultaneous equations as follows:

a1x+b1y+c1z=d1…………………1)

a2x+b2y+c2z=d2…………………1)

a3x+b3y+c3z=d3…………………1)

If a1, b2, c3 are large as compare to other coefficient then solving these for x,y, and z respectively. Then the system can be written in the form:

x = (k1) – (l1)y – (m1)z…………..2)

y = (k2) – (l2)x – (m2)z…………….2)

z = (k3) – (l3)x – (m3)y…………….2)

Let us starts with the initial approximations x0=k1, y0=k2 and z0=k3.(by putting x=y=z=0 in right hand side above equation)

Then the second approximation is given by,

x1 = (k1) – (l1)y0 – (m1)z0…………..3)

y1= (k2) – (l2)x0 – (m2)z0…………….3)

z1 = (k3) – (l3)x0 – (m3)y0…………….3)

Third approximation is given by,

x2 = (k1) – (l1)y1 – (m1)z1…………..4)

y2= (k2) – (l2)x1 – (m2)z1…………….4)

z2 = (k3) – (l3)x1 – (m3)y1…………….4)

This process is repeated till difference between two consecutive approximations is negligible.

Let us understand this method in detail by solving one simple example.

## Example

Solve following set of simultaneous equations using Jacobi’s iterative method.

20x+y-2z=17

3x+20y-z=-18

2x-3y+20z=25

## Solution

We write the given equations in the following form:

x = (1/20)(17-y+2z)……………..1)

y = (1/20)(-18-3x+z)…………….1)

z = (1/20)(25-2x+3y)……………1)

Substitute x0=y0=z0=0 in above equation we get,

x1 = (1/20)(17);  y1 = (1/20)(-18);  z1=(1/20)(25).

Or x1=0.85;  y1=-0.90;  z1=1.25

Put x1, y1 and z1 in equation (1)

x2 = 1.02;  y2 = -0.965;  z2 = 1.03.

Put x2, y2 and z2 in equation (1)

x3 = 1.001;  y3 = -1.001;  z3 = 1.003.

Put x3, y3 and z3 in equation (1)

x4 = 1.0004;  y4 = -1;  z4=0.99975

Put x4, y4 and z4 in equation (1)

x5 = 1;  y5 = -1;  z5=1

Now it is sufficient. If you observe above two sets of roots, they are almost same.

Hence the roots of given simultaneous equations using Jacobi’s iterative method are:

x=1;  y = -1;  z=1

## Lagrange Interpolation With MATLAB Program Example

Lagrange’s Interpolation Formula is used to determine the value of any function f(x), which is known at discrete points. That is if we have any function with its value at different points such as, at x=0, 1, 2… So using Lagrange’s Interpolation Formula, we can determine the value of that function at any point.

## Derivation

We can derive the Lagrange’s Interpolation formula by using Newton’s divided difference formula. If f(x) is approximated with a Nth degree polynomial then the Nth divided difference of f(x) constant and (N+1)th divided difference is zero. That is

as we know Lagrange’s interpolation is a Nth degree polynomial approximation to f(x) and the Nth degree polynomial passing through (N+1) points is unique hence the Lagrange’s and Newton’s divided difference approximations are one and the same. However, Lagrange’s interpolation formula is very useful for the computer programming while Newton’s difference formula is convenient for the hand calculations.

Question: Given set of values of x and y (5,12),(6,13),(9,14),(11,16)
Find the value of x corresponding to y=15 using lagrange interpolation

## Solution

Tabular the given data:

y:  12  13  14  16

x:   5    6    9    11

Applying lagrange interpolation formula,

x(y)=(y-13)(y-14)(y-16)*5/(12-13)(12-14)(12-16)+

(y-12)(y-14)(y-16)*6/(13-12)(13-14)(13-16)+

(y-12)(y-13)(y-16)*9/(14-12)(14-13)(14-16)+

(y-12)(y-13)(y-14)*11/(16-12)(16-13)(16-14).

By putting y=15 we get x(15)=11.5

## MATLAB Code for Lagrange Interpolation Formula

```%Created by myclassbook.org
%Created on 26 May 2013
%lagrange interpolation formula

% Question: Given set of values of x and y (5,12),(6,13),(9,14),(11,16)
% Find the value of x corresponding to y=15 using lagrange interpolation

clc;
clear all;
close all;
y=[12 13 14 16]; %Change here for different function
x=[5 6 9 11];
a=15;

%Applying Lagrange's Interpolation:
ans1=((a-y(2))*(a-y(3))*(a-y(4)))*x(1)/((y(1)-y(2))*(y(1)-y(3))*(y(1)-y(4)));
ans2=((a-y(1))*(a-y(3))*(a-y(4)))*x(2)/((y(2)-y(1))*(y(2)-y(3))*(y(2)-y(4)));
ans3=((a-y(1))*(a-y(2))*(a-y(4)))*x(3)/((y(3)-y(1))*(y(3)-y(2))*(y(3)-y(4)));
ans4=((a-y(1))*(a-y(2))*(a-y(3)))*x(4)/((y(4)-y(1))*(y(4)-y(2))*(y(4)-y(3)));

m=ans1+ans2+ans3+ans4;

y
x
fprintf('the value of x corresponding to y=15 is %f',m);```

## Question

Evaluate the integral x^4 within limits -3 to 3 using Simpson’s 3/8th Rule.

## Solution

Let y(x)=x^4

here a=-3 and b=3

therefore (b-a)=6

let ‘n’ be the number of intervals. assume n=6 in this case.

also h=(b-a)/n = 6/6 =1

x: -3  -2  -1  0  1  2  3

y: 81  16  1  0  1  16  81

According to Simpson’s 3/8th Rule:

## MATLAB Code for Simpson’s 3/8th Rule

```%Created by myclassbook.org (Mayuresh)
%Created on 24 May 2013
%Question: Evaluate the integral x^4 within limits -3 to 3

clc;
clear all;
close all;

[email protected](x)x^4; %Change here for different function
a=-3;b=3; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;

for i=a:b
p=p+1;
x(p)=i;
y(p)=i^4; %Change here for different function
end

l=length(x);
x
y

## Second Example

Evaluate the integral 1/(1+x) within limits 0 to 6 using Simpson’s 3/8th rule.

## Solution

Let y(x)=1/(1+x)

here a=0 and b=6

therefore (b-a)=6

let ‘n’ be the number of intervals. assume n=6 in this case.

also h=(b-a)/n = 6/6 =1

x: 0                  1                    2              3                  4               5               6

y: 1.0000   0.5000   0.3333   0.2500   0.2000   0.1667   0.1429

According to Simpson’s 3/8th rule:

## MATLAB Code for Simpson’s 3/8th Rule

```%Created by myclassbook.org (Mayuresh)
%Created on 24 May 2013
%Question: Evaluate the integral 1/(1+x) within limits 0 to 6

clc;
clear all;
close all;

[email protected](x)1/(1+x); %Change here for different function
a=0;b=6; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;

for i=a:b
p=p+1;
x(p)=i;
y(p)=1/(1+i); %Change here for different function
end

l=length(x);
x
y

## Question

Evaluate the integral x^4 within limits -3 to 3 using Simpson’s 1/3 rd rule.

## Solution

Let y(x)=x^4

here a=-3 and b=3

therefore (b-a)=6

let ‘n’ be the number of intervals. assume n=6 in this case.

also h=(b-a)/n = 6/6 =1

x: -3  -2  -1  0  1  2  3

y: 81  16  1  0  1  16  81

According to Simpson’s 1/3rd  rule:

## MATLAB Program For Simpson’s 1/3rd Rule

```%Created by myclassbook.org (Mayuresh)
%Created on 24 May 2013
%Question: Evaluate the integral X^4 within limits 3 to -3

clc;
clear all;
close all;

[email protected](x)x^4; %Change here for different function
a=-3;b=3; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;

for i=a:b
p=p+1;
x(p)=i;
y(p)=i^4; %Change here for different function
end

l=length(x);
x
y

## Second Example

Evaluate the integral 1/(1+x) within limits 0 to 6 using Simpson’s 1/3 rd rule.

## Solution

Let y(x)=1/(1+x)

here a=0 and b=6

therefore (b-a)=6

let ‘n’ be the number of intervals. assume n=6 in this case.

also h=(b-a)/n = 6/6 =1

x: 0                  1                    2              3                  4               5               6

y: 1.0000   0.5000   0.3333   0.2500   0.2000   0.1667   0.1429

According to Simpson’s 1/3 rd rule.

## MATLAB Code for Simpson’s 1/3rd Rule

```%Created by myclassbook.org (Mayuresh)
%Created on 24 May 2013
%Question: Evaluate the integral 1/(1+x) within limits 0 to 6

clc;
clear all;
close all;

[email protected](x)1/(1+x); %Change here for different function
a=0;b=6; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;

for i=a:b
p=p+1;
x(p)=i;
y(p)=1/(1+i); %Change here for different function
end

l=length(x);
x
y

## Trapezoidal Rule Derivation

The derivation for obtaining formula for Trapezoidal rule is given by,

## Example

Evaluate the integral x^4 within limits -3 to 3 using Trapezoidal rule.

## Solution

Let y(x)=x^4

here a=-3 and b=3

therefore (b-a)=6

let ‘n’ be the number of intervals. assume n=6 in this case.

also h=(b-a)/n = 6/6 =1

x: -3  -2  -1  0  1  2  3

y: 81  16  1  0  1  16  81

According to trapezoidal rule:

## MATLAB Program for Trapezoidal Rule

```%Created by myclassbook.org (Mayuresh)
%Created on 24 May 2013
%Question: Evaluate the integral X^4 within limits 3 to -3

clc;
clear all;
close all;

[email protected](x)x^4; %Change here for different function
a=-3;b=3; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;

for i=a:b
p=p+1;
x(p)=i;
y(p)=i^4; %Change here for different function
end

l=length(x);
x
y

## Example

Evaluate the integral 1/(1+x) within limits 0 to 6 using Trapezoidal rule.

## Solution

Let y(x)=1/(1+x)

here a=0 and b=6

therefore (b-a)=6

let ‘n’ be the number of intervals. assume n=6 in this case.

also h=(b-a)/n = 6/6 =1

x: 0                  1                    2              3                  4               5               6

y: 1.0000   0.5000   0.3333   0.2500   0.2000   0.1667   0.1429

According to trapazoidal rule:

### MATLAB code for the Trapazoidal rule:

```%Created by myclassbook.org (Mayuresh)
%Created on 24 May 2013
%Question: Evaluate the integral 1/(1+x) within limits 0 to 6

clc;
clear all;
close all;

[email protected](x)1/(1+x); %Change here for different function
a=0;b=6; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;

for i=a:b
p=p+1;
x(p)=i;
y(p)=1/(1+i); %Change here for different function
end

l=length(x);
x
y

## Newton’s Forward Interpolation Formula with MATLAB Program

In everyday life, sometimes we may require finding some unknown value with the given set of observations. For example, the data available for the premium, payable for a policy of Rs.1000 at age x, is for every fifth year. Suppose, the data given is for the ages 30, 35, 40, 45, 50 and we are required to find the value of the premium at the age of 42 years, which is not directly given in the table. Here we use the method of estimating an unknown value within the range with the help of given set of observation which is known as interpolation.

## Definition of Interpolation

Given the set of tabular values (x0, y0), (x1, y1),…,(xn, yn) satisfying the relation y=f(x) where the explicit nature of f(x) is not known, it is required to find a simpler function say ?(x), such that f(x) and ?(x) agree at the set of tabulated points. Such a process is called as interpolation.

If we know ‘n’ values of a function, we can get a polynomial of degree (n-1) whose graph passes through the corresponding points. Such a polynomial is used to estimate the values of the function at the values of x.

We will study two different interpolation formula based on finite differences when the values of x are equally spaced. The first formula is:

Newton’s forward difference interpolation formula:

The formula is stated as:

Where ‘a+ph’ is the value for which the value of the function f(x) is to be estimated. Here ‘a’ is the initial value of x and ‘h’ is the interval of differencing.

## Question

The table gives the distance between nautical miles of the visible horizon for the given height in feet above the earth surface.  Find the value of y when x= 218 feet.

## Newton Raphson Method & It’s MATLAB Program

Introduction to Iterative methods: There are number of iterative methods like  Jacobi method, Gauss–Seidel method that has been tried and used successfully in various problem situations. All these methods typically generate a sequence of estimates of the solution which is expected to converge to the true solution. Newton-Raphson method is also one of the iterative methods which are used to find the roots of given expression.

### Newton-Raphson Method with MATLAB code:

If point x0 is close to the root a, then a tangent line to the graph of f(x) at x0 is a good approximation the f(x) near a. So the root of the tangent line, where the line cuts the X-axis; x1 is the better approximation to a than x0 is.

Slope of the tangent =

Therefore

Repeating process, we obtain a better approximation,

Continue in this way. If xn is the current estimate, then the next estimate xn+1 is given by

if x0 is sufficiently close to a, xn?a as n?8.

## Limitations of Newton-Raphson Method

1. If initial guess is too far away from the required root, the process may converge to some other root.
2. Division by zero may occur if f’(xi) is zero or very close to zero.
3. A particular value in the iteration sequence may repeat, resulting in an infinite loop.

## Newton-Raphson MATLAB program:

```% Newton Raphson Method
clear all
close all
clc
% Change here for different functions
[email protected](x) cos(x)-3*x+1
%this is the derivative of the above function
[email protected](x) -sin(x)-3
% Change lower limit 'a' and upper limit 'b'
a=0; b=1;
x=a;
for i=1:1:100
x1=x-(f(x)/df(x));
x=x1;
end
sol=x;
fprintf('Approximate Root is %.15f',sol)
a=0;b=1;
x=a;
er(5)=0;
for i=1:1:5
x1=x-(f(x)/df(x));
x=x1;
er(i)=x1-sol;
end
plot(er)
xlabel('Number of iterations')
ylabel('Error')
title('Error Vs. Number of iterations')```

f =
@(x)cos(x)-3*x+1
df =
@(x)-sin(x)-3
Approximate Root is 0.6071016481031231

Newton-Raphson Method MATLAB program

## Gauss Seidel Method MATLAB Program & Algorithm

We have studied in the last article that, the preceding methods of solving simultaneous linear equations are known as direct methods as they yield the exact solution. On the other hand, an iterative method is that in which we start from an approximation to the true solution and obtain better and better approximation from a computation cycle repeated as often as may be necessary for achieving the desired accuracy. Simple iteration methods can be devised for systems in which the coefficient of leading diagonal is large compared to others.

In the last article about solving roots of given simultaneous equations, we have studied Jacobi’s iterative method. Similarly, there is another method for solving roots of simultaneous equations which is called as Gauss-Seidel Iterative Method. After that, we will see MATLAB program on how to find roots of simultaneous equations using Gauss-Seidel Method.

Let us consider set of simultaneous equations as follows:

• a1x+b1y+c1z=d1…………………1)
• a2x+b2y+c2z=d2…………………1)
• a3x+b3y+c3z=d3…………………1)

We then solve above equation for x, y and z respectively. Then the system can be written in the form:

• x = (k1) – (l1)y – (m1)z…………..2)
• y = (k2) – (l2)x – (m2)z…………….2)
• z = (k3) – (l3)x – (m3)y…………….2)

Gauss-Seidel Method is a modification of Jacobi’s iteration method as before we starts with initial approximations, i.e. x0=y0=z0=0 for x, y and z respectively.

Substituting y=y0, z=z0 in the equation x1=k1, then putting x=x1, z=z0 in the second of equation (2) i.e.

• (y1) = (k2) – (l2)x1 – (m2)z0

Substituting x=x1, y=y1 in the third of equation (2) i.e.

• (z1) = (k3) – (l3)x1 – (m3)y1  and so on.

As soon as a new approximation for an unknown is found it is immediately used in the next step. This process is then repeated till the desired degree of accuracy is obtained.

Let us discuss Gauss-Seidel method by solving one simple example.

## Example

Find the roots of following simultaneous equations using the Gauss-Seidel method.

20x+y-2z=17…………..1)

3x+20y-z=-18…………..1)

2x-3y+20z=25…………..1)

## Solution

Let us write the given equation in the form as:

x = (1/20)(17-y+2z)……………..2)

y = (1/20)(-18-3x+z)…………….2)

z = (1/20)(25-2x+3y)……………2)

we start approximation by x0=y0=z0=0.

Substituting y=y0 and z=z0 in right hand side of first of equation (2)

X1 = 17/20=0.85

In second of equation second put x=x1 and z=z0

Y1 = (1/20)(-18-3*0.85) = -1.0275

Put x=x1, y=y1 in third of equation (2)

Z1 = (1/20)(25-2*0.85+3*-1.0275) = 1.011

Similarly we get,

x2=1.002; y2 =-0.9998; z2 =0.9998

x3 =1.0000; y3 =-1.0000; z3 =1.0000

x4 =1.0000; y4 =-1.0000; z4 =1.0000

Now it is sufficient. If you observe above two sets of roots, they are almost same.

Hence the roots of given simultaneous equations using Gauss-Seidel Method are:

x=1;  y = -1;  z=1