Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

MATH-352 Numerical Methods – 2+1 CHs

By

Prof Dr Safia Akram

(GAUSS-JACOBI METHOD)

(GAUSS-SIEDAL METHOD)

Lec # 4

1
SIMULTANEOUS LINEAR ALGEBRAIC EQUATIONS
Simultaneous linear algebraic equations are very common in various
fields of Engineering and Science. These can be solved by direct
method and indirect methods.
❖ Gauss Elimination method
❖ Gauss Jordan method
❖Triangularization method and
❖Crout’s method
are direct methods where as
❖ Gauss-Jacobic method
❖Gauss Siedal method
❖ S.O.R method
are indirect methods.

2
ITERATIVE / INDIRECT METHODS
In these methods we start from an approximation to the true solution
and if convergent, derive a sequence of closer approximation we
repeat the cycle of computations till the required accuracy is obtained.

But the method of iteration is not applicable to all system of equations.


For this, each equation of the system must contain one large
coefficient (much larger than the others in that equation) and the large
coefficient must be attached to a different unknown in that equation.
CONDITION FOR CONVERGENCE
The solution to a system of linear equations will exist by iterative
procedure if the absolute value of the largest coefficient is greater than
the sum of the absolute values of all remaining coefficients in each
equation.
3
JACOBI METHOD OF ITERATION
This method is also known as Gauss-Jacobi method.
Consider the following system of equations
𝑎1 𝑥 + 𝑏1 𝑦 + 𝑐1 𝑧 = 𝑑1
𝑎2 𝑥 + 𝑏2 𝑦 + 𝑐2 𝑧 = 𝑑2 Eq. (1)

𝑎3 𝑥 + 𝑏3 𝑦 + 𝑐3 𝑧 = 𝑑3
Let
𝑎1 > 𝑏1 + |𝑐1 |
𝑏2 > 𝑎2 + |𝑐2 |
𝑐3 > 𝑎3 + |𝑏3 |
That is, in each equation the coefficients of the diagonal terms are large.
Hence the system (1) is ready for iteration.
Solving for 𝑥, 𝑦 and 𝑧 respectively we get
4
1
𝑥= 𝑑1 − 𝑏1 𝑦 − 𝑐1 𝑧 Eq. (2)
𝑎1
1
𝑦= 𝑑 − 𝑎2 𝑥 − 𝑐2 𝑧 Eq. (3)
𝑏2 2
1
z = (𝑑3 − 𝑎3 𝑥 − 𝑏3 𝑦) Eq. (4)
𝑐3
Let 𝑥0 , 𝑦0 and 𝑧0 be the initial approximations of the unknowns 𝑥, 𝑦 and 𝑧.
Substituting these on right hand side of Eqs. (2) to (4), the 1st approximation
are given by
1
𝑥1 = 𝑑 − 𝑏1 𝑦0 − 𝑐1 𝑧0
𝑎1 1
1
𝑦1 = 𝑑2 − 𝑎2 𝑥0 − 𝑐2 𝑧0
𝑏2
1
𝑧1 = (𝑑3 − 𝑎3 𝑥0 − 𝑏3 𝑦0 )
𝑐3

Substituting the values 𝑥1 , 𝑦1 and 𝑧1 in the right-hand side of Eqs. (2) to (4),
the 2nd approximation are given by
5
1
𝑥2 = 𝑑1 − 𝑏1 𝑦1 − 𝑐1 𝑧1
𝑎1
1
𝑦2 = 𝑑 − 𝑎2 𝑥1 − 𝑐2 𝑧1
𝑏2 2
1
𝑧2 = (𝑑3 − 𝑎3 𝑥1 − 𝑏3 𝑦1 )
𝑐3
Proceeding in the same way if 𝑥𝑛 , 𝑦𝑛 and 𝑧𝑛 are the nth iterates then

1
𝑥𝑛+1 = 𝑑 − 𝑏1 𝑦𝑛 − 𝑐1 𝑧𝑛
𝑎1 1
1
𝑦𝑛+1 = 𝑑2 − 𝑎2 𝑥𝑛 − 𝑐2 𝑧𝑛 Eq. (A)
𝑏2
1
𝑧2 = (𝑑3 − 𝑎3 𝑥𝑛 − 𝑏3 𝑦𝑛 )
𝑐3
The process is continued till convergency is secured.
NOTE: In the absence of any better estimates, the initial approximations are
taken as 𝑥0 = 𝑦0 = 𝑧0 = 0.
6
EXAMPLE: Solve the following system of equations by Jacobi
iteration method.
3𝑥 + 4𝑦 + 15𝑧 = 54.8
𝑥 + 12𝑦 + 3𝑧 = 39.66 Eq. (A)
10𝑥 + 𝑦 − 2𝑧 = 7.74
SOLUTION: The coefficient matrix of the given system is not diagonally
dominant. Hence, we rearrange the equations as follows, such that the elements in the
coefficient matrix are diagonally dominant.
10𝑥 + 𝑦 − 2𝑧 = 7.74 Eq. (1)

𝑥 + 12𝑦 + 3𝑧 = 39.66 Eq. (2)

3𝑥 + 4𝑦 + 15𝑧 = 54.8 Eq. (3)


Now we write the equations in the form
1
𝑥= 7.74 − 𝑦 + 2𝑧 Eq. (4)
10
1
𝑦= 39.66 − 𝑥 − 3𝑧 Eq. (5)
12
1
z= (54.8 − 3𝑥 − 4𝑦) Eq. (6)
15 7
The Eqs. (4) to (6) can now written as
1
𝑥𝑛+1 = 7.74 − 𝑦𝑛 + 2𝑧𝑛
10
1 Eq. (B)
𝑦𝑛+1 = 39.66 − 𝑥𝑛 − 3𝑧𝑛
12
1
𝑧𝑛+1 = (54.8 − 3𝑥𝑛 − 4𝑦𝑛 )
15
We start from an initial approximation 𝑥0 = 𝑦0 = 𝑧0 = 0
Now when 𝑛 = 0

1 1
𝑥1 = 7.74 − 𝑦0 + 2𝑧0 = 7.74 − 0 + 2 0 = 0.774
10 10
1 1
𝑦1 = 39.66 − 𝑥0 − 3𝑧0 = 39.66 − 0 − 3 0 = 3.305
12 12
1 1
𝑧1 = 54.8 − 3𝑥0 − 4𝑦0 = 54.8 − 3 0 − 4 0 = 3.6533
15 15
8
2nd approximation when 𝑛 = 1

1 1
𝑥2 = 7.74 − 𝑦1 + 2𝑧1 = 7.74 − 3.305 + 2 3.6533 = 1.17416
10 10
1 1
𝑦2 = 39.66 − 𝑥1 − 3𝑧1 = 39.66 − 0.774 − 3 3.6533 = 2.327175
12 12
1 1
𝑧2 = 54.8 − 3𝑥1 − 4𝑦1 = 54.8 − 3 0.774 − 4 3.305 = 2.6172
15 15

3rd approximation when 𝑛 = 2

1 1
𝑥3 = 7.74 − 𝑦2 + 2𝑧2 = 7.74 − 2.327175 + 2 2.6172 = 1.0647225
10 10
1 1
𝑦3 = 39.66 − 𝑥2 − 3𝑧2 = 39.66 − 1.17416 − 3 2.6172 = 2.552853
12 12
1 1
𝑧3 = 54.8 − 3𝑥2 − 4𝑦2 = 54.8 − 3 1.17416 − 4(2.327175 = 2.797921
15 15
9
4th approximation when 𝑛 = 3
1
𝑥4 = 7.74 − 𝑦3 + 2𝑧3 = 1.078298967
10
1
𝑦4 = 39.66 − 𝑥3 − 3𝑧3 = 2.5167928
12
1
𝑧4 = 54.8 − 3𝑥3 − 4𝑦3 = 2.759628033
15
5th approximation when 𝑛 = 4
1
𝑥5 = 7.74 − 𝑦4 + 2𝑧4 = 1.074246327
10
1
𝑦5 = 39.66 − 𝑥4 − 3𝑧4 = 2.525234745
12
1
𝑧5 = 54.8 − 3𝑥4 − 4𝑦4 = 2.766528793
15

10
6th approximation when 𝑛 = 5
1
𝑥6 = 7.74 − 𝑦5 + 2𝑧5 = 1.074782284
10
1
𝑦6 = 39.66 − 𝑥5 − 3𝑧5 = 2.523847275
12
1
𝑧6 = 54.8 − 3𝑥5 − 4𝑦5 = 2.764778081
15

7th approximation when 𝑛 = 6

1
𝑥7 = 7.74 − 𝑦6 + 2𝑧6 = 1.074570889
10
1
𝑦7 = 39.66 − 𝑥6 − 3𝑧6 = 2.524240289
12
1
𝑧7 = 54.8 − 3𝑥6 − 4𝑦6 = 2.765350937
15
From 6th and 7th approximation
𝑥 = 1.075, 𝑦 = 2.524, 2.765
Correct to three decimal places.
11
GAUSS-SEIDEL ITERATION METHOD
This is a modification of Gauss-Jacobi method. As before the system of linear
equations
𝑎1 𝑥 + 𝑏1 𝑦 + 𝑐1 𝑧 = 𝑑1
𝑎2 𝑥 + 𝑏2 𝑦 + 𝑐2 𝑧 = 𝑑2 Eq. (A)

𝑎3 𝑥 + 𝑏3 𝑦 + 𝑐3 𝑧 = 𝑑3
is written as
1
𝑥= 𝑑1 − 𝑏1 𝑦 − 𝑐1 𝑧 Eq. (1)
𝑎1
1
𝑦= 𝑑 − 𝑎2 𝑥 − 𝑐2 𝑧 Eq. (2)
𝑏2 2
1
z = (𝑑3 − 𝑎3 𝑥 − 𝑏3 𝑦) Eq. (3)
𝑐3
We start with the initial approximations 𝑥0 , 𝑦0 and 𝑧0 , substituting 𝑦0 and 𝑧0
in Eq. (1), we get
1
𝑥1 = 𝑑1 − 𝑏1 𝑦0 − 𝑐1 𝑧0 Eq. (4)
𝑎1
12
Now substituting 𝑥 = 𝑥1 , 𝑧 = 𝑧0 in Eq. (2), we get
1
𝑦1 = 𝑑2 − 𝑎2 𝑥1 − 𝑐2 𝑧0 Eq. (5)
𝑏2
Now substituting 𝑥 = 𝑥1 , 𝑦 = 𝑦1 in Eq. (3), we get
1
𝑧1 = 𝑑3 − 𝑎3 𝑥1 − 𝑏3 𝑦1 Eq. (6)
𝑐3
This process is continued till the values of 𝑥, 𝑦 and 𝑧 are obtained to the
desired degree of accuracy. The general algorithm is as follows.
If 𝑥𝑛 , 𝑦𝑛 and 𝑧𝑛 are the nth iterates then

1
𝑥𝑛+1 = 𝑑1 − 𝑏1 𝑦𝑛 − 𝑐1 𝑧𝑛
𝑎1
1 Eq. (B)
𝑦𝑛+1 = 𝑑 − 𝑎2 𝑥𝑛+1 − 𝑐2 𝑧𝑛
𝑏2 2
1
𝑧2 = (𝑑3 − 𝑎3 𝑥𝑛+1 − 𝑏3 𝑦𝑛+1 )
𝑐3
Since the current values of the unknowns at each stage of iteration are used in
proceeding to the next stage of iteration. This method is more rapid in convergence
than Gauss-Jacobi method.
13
EXAMPLE: Solve the following system of equations by Gauss-Seidal
iteration method. Values of 𝑥, 𝑦 and z correct to 4-decimal places.
28𝑥 + 4𝑦 − 𝑧 = 32
𝑥 + 3𝑦 + 10𝑧 = 24 Eq. (A)

2𝑥 + 17𝑦 + 4z = 35
SOLUTION: The coefficient matrix of the given system is not diagonally
dominant. Hence, we rearrange the equations as follows, such that the elements in the
coefficient matrix are diagonally dominant.
28𝑥 + 4𝑦 − 𝑧 = 32 Eq. (1)

2𝑥 + 17𝑦 + 4z = 35 Eq. (2)

𝑥 + 3𝑦 + 10𝑧 = 24 Eq. (3)


Hence, we can apply the Gauss-Seidal iteration method. From above equations
1
𝑥𝑛+1 = 32 − 4𝑦𝑛 + 𝑧𝑛 Eq. (4)
28
1
𝑦𝑛+1 = 35 − 2𝑥𝑛+1 − 4𝑧𝑛 Eq. (5)
17
1
𝑧𝑛+1 = (24 − 𝑥𝑛+1 − 3𝑦𝑛+1 ) Eq. (6)
10 14
We start from an initial approximation 𝑥0 = 𝑦0 = 𝑧0 = 0
Now when 𝑛 = 0 1st approximation is
1 1
𝑥1 = 32 − 4𝑦0 + 𝑧0 = 32 − 4(0) + (0) = 1.142857
28 28

1 1
𝑦1 = 35 − 2𝑥1 − 4𝑧0 = 35 − 2(1.142857) − 4(0) = 1.924370
17 17
1 1
𝑧1 = 24 − 𝑥1 − 3𝑦1 = 24 − 1.142857 − 3(1.924370) = 1.708403
10 10
2nd approximation when 𝑛 = 1

1 1
𝑥2 = 32 − 4𝑦1 + 𝑧1 = 32 − 4(1.924370) + (1.708403) = 0.928962
28 28
1 1
𝑦2 = 35 − 2𝑥2 − 4𝑧1 = 35 − 2(0.928962) − 4(1.708403) = 1.547557
17 17

1 1
𝑧2 = 24 − 𝑥2 − 3𝑦2 = 24 − 0.928962 − 3(1.547557) = 1.842837
10 10
15
3rd approximation when 𝑛 = 2 is
1 1
𝑥3 = 32 − 4𝑦2 + 𝑧2 = 32 − 4(1.547557) + (1.842837) = 0.987593
28 28
1 1
𝑦3 = 35 − 2𝑥3 − 4𝑧2 = 35 − 2(0.987593) − 4(1.842837) = 1.509027
17 17
1 1
𝑧3 = 24 − 𝑥3 − 3𝑦3 = 24 − 0.987593 − 3(1.509027) = 1.848532
10 10
4th approximation when 𝑛 = 3

1 1
𝑥4 = 32 − 4𝑦3 + 𝑧3 = 32 − 4(1.509027) + (1.848532) = 0.993301
28 28
1 1
𝑦4 = 35 − 2𝑥4 − 4𝑧3 = 35 − 2(0.993301) − 4(1.848532) = 1.507016
17 17

1 1
𝑧4 = 24 − 𝑥4 − 3𝑦4 = 24 − 0.993301 − 3(1.507016) = 1.848565
10 10

16
5th approximation when 𝑛 = 4 is
1 1
𝑥5 = 32 − 4𝑦4 + 𝑧4 = 32 − 4(1.507016) + (1.848565) = 0.993589
28 28
1 1
𝑦5 = 35 − 2𝑥5 − 4𝑧4 = 35 − 2(0.993589) − 4(1.848565) = 1.506974
17 17
1 1
𝑧5 = 24 − 𝑥5 − 3𝑦5 = 24 − 0.993589 − 3(1.5069741) = 1.848549
10 10
6th approximation when 𝑛 = 5
1
𝑥6 = 32 − 4𝑦5 + 𝑧5 = 0.993595
28
1
𝑦6 = 35 − 2𝑥6 − 4𝑧5 = 1.506977
17
1
𝑧6 = 24 − 𝑥6 − 3𝑦6 = 1.848547
10
The values of 𝑥, 𝑦, 𝑧 in 4th and 5th iteration are same upto four decimals. We stop the
process here.
Hence 𝑥 = 0.9936, 𝑦 = 1.5069, 𝑧 = 1.8485
17
EXERCISES

18
19
20
21

You might also like