7 Lecture Notes 15-16 Jacobi Gauss Siedel Method
7 Lecture Notes 15-16 Jacobi Gauss Siedel Method
Lecture Notes-15-16
by
Prof. Santwana Mukhopadhyay
1 Preliminaries
2 Iteration Methods
Jacobi iteration method:
Gauss-Seidel iteration method:
1 Swap the rows so that all rows with all zero entries are on the bottom.
2 Swap the rows so that the row with the largest, leftmost nonzero
entry is on top.
3 Multiply the top row by a scalar so that top row’s leading entry
becomes 1.
4 Add/subtract multiples of the top row to the other rows so that all
other entries in the column containing the top row’s leading entry are
all zero.
5 Repeat steps 2-4 for the next leftmost nonzero entry until all the
leading entries are 1.
6 Swap the rows so that the leading entry of each nonzero row is to the
right of the leading entry of the row above it.
Prof. S. Mukhopadhyay (Department of Mathematical
Numerical
SciencesTechniques
IIT(BHU),(MA-201)
Varanasi) 4 / 29
Gauss-Jordan elimination method contd...
Example 1:
Find the inverse of the matrix
2 1 1
A= 3 2 1
2 1 2
by Gauss-Jordan method.
Solution:
Solution contd...
R1 →R1 −R3 1 0 0 3 −1 −1
R2 →R2 +R3
−−−−−−−→ 0 1 0 −4 2 1
0 0 1 −1 0 1
3 −1 −1
So, A−1 = −4 2 1 .
−1 0 1
Verify that you get the same result with partial pivoting in the present
case.
Example 2:
Find the inverse of the matrix
1 2 1
A = 2 3 −1
2 −1 3
by Gauss-Jordan method
with partial
pivoting.
−8 7 5
Answer: A−1 = 161
8 −1 −3 .
8 −5 1
Iteration methods:
1. Jacobi method
2. Gauss-Seidel method
Iteration methods:
Whenever the algebraic equations contain large number of equations
at that time Direct Method become lengthy and time consuming
headache.
In this case the Iteration Methods play a vital role by being the
substitute of the method.
In iterative methods, we start from an initial approximation to actual
solution and obtain the better approximation after repeating the
iteration. This method can give solution with desired accuracy.
Stop when the max absolute error in solution reaches the desired accuracy.
A can be written as
a11 0 ... 0 0 ... 0 0
0 a22 ... 0 a21 ... 0 0
A = +
: : : : :
0 0 ... ann an1 ... an(n−1) 0
0 ... a12 a1n
0 ... 0 :
+
: a(n−1)n
0 0 ... 0
=D + L + U
where D is diagnal matrix, L is lower triangular matrix, and U is upper triangular matrix.
Prof. S. Mukhopadhyay (Department of Mathematical
Numerical
SciencesTechniques
IIT(BHU),(MA-201)
Varanasi) 16 / 29
contd...
Ax = b is transformed to
(D + L + U) x = b ⇒ Dx = − (L + U) x + b
x = −D −1 (L + U) x + D −1 b
1
x1 = (b1 − a12 x2 − a13 x3 − ....a1n xn )
a11
1
x2 = (b2 − a21 x1 − a23 x3 − ....a2n xn ) (2.5)
a22
..............................................................
1
xn = bn − an1 x1 − an2 x2 − ....an(n−1) xn−1
ann
which is same as obtained earlier.
Prof. S. Mukhopadhyay (Department of Mathematical
Numerical
SciencesTechniques
IIT(BHU),(MA-201)
Varanasi) 18 / 29
Examples on Jacobi iteration method contd...
Example 1:
Apply the Jacobi method to solve
Solution:
1/5 0 0 0 −2 3 x1 1/5 0 0 −1
=− 0 1/9 0 −3 0 1 x2 + 0 1/9 0 2
0 0 −1/7 2 −1 0 x3 0 0 −1/7 3
# (k−1)
0 −2/5 3/5 x1 −1/5
" " #
(k−1)
=− −3/9 0 1/9 x2 + 2/9
−2/7 1/7 0 (k−1)
x3 −3/7
# (k−1)
0 −0.4 0.6 x1 −0.2
" " #
(k−1)
=− −0.333 0 0.111 x2 + 0.222
−0.286 0.143 0 (k−1)
x3 −0.429
Solution contd...
n 0 1 2 3 4 5 6 7
x1 0.000 −0.200 0.146 0.192 0.181 0.185 0.186 0.186
x2 0.000 0.222 0.203 0.328 0.332 0.329 0.331 0.331
x3 0.000 −0.429 −0.517 −0.416 −0.421 −0.423 −0.423 -0.423
We stop in 7th iterations when the last two columns in above Table are
identical, and we can conclude that the solution correct to three significant
digits is
x1 = 0.186, x2 = 0.331, x3 = −0.423
i.e.,
i−1 n
(k) 1 X (k)
X
(k−1)
xi = − aij xj − aij xj + bi , i = 1, 2, ...
aii j=1 j=i+1
(k+1)
With the Gauss-Seidel method, we use the new values xi as soon
as they are known.
(k+1)
For example, once we have computed x1 from the first equation,
(k+1)
its value is then used in the second equation to obtain the new x2
and so on.
(k)
Note: With the Jacobi method, the values of xi obtained in the
k-th iteration remain unchanged until the entire (k + 1)th iteration
has been calculated.
Example:
Use the Gauss-Seidel iteration method to approximate the solution to the
system of equations given in Example 1,i.e.,
Solution contd...
n 0 1 2 3 4 5
x1 0.000 −0.200 0.167 0.191 0.186 0.186
x2 0.000 0.156 0.334 0.333 0.331 0.331
x3 0.000 −0.508 −0.429 −0.422 −0.423 −0.423
Note that after only five iterations of the Gauss-Seidel method, you
achieved the same accuracy as was obtained with seven iterations of the
Jacobi method in Example 1.
Task:
Solve the following system of equations by performing 3 iterations of (i)
Jacobi method (ii) Gauss-Siedel method:
4x1 + x2 + x3 =2
x1 + 5x2 + 2x3 = − 6
x1 + 2x2 + 3x3 = − 4
****************