# Jacobi’s Iteration Method with MATLAB Program

## 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