Gauss Seidel Jacobi
Gauss Seidel Jacobi
1
The Jacobi Method
2
Main idea of Jacobi
To begin, solve the 1st equation for 𝑥𝑥1 , the 2nd equation for 𝑥𝑥2 and so on to
obtain the rewritten equations:
1
𝑥𝑥1 = (𝑏𝑏1 − 𝑎𝑎12 𝑥𝑥2 − 𝑎𝑎13 𝑥𝑥3 − ⋯ 𝑎𝑎1𝑛𝑛 𝑥𝑥𝑛𝑛 )
𝑎𝑎11
1
𝑥𝑥2 = (𝑏𝑏2 − 𝑎𝑎21 𝑥𝑥1 − 𝑎𝑎23 𝑥𝑥3 − ⋯ 𝑎𝑎2𝑛𝑛 𝑥𝑥𝑛𝑛 )
𝑎𝑎22
⋮
1
𝑥𝑥𝑛𝑛 = (𝑏𝑏𝑛𝑛 − 𝑎𝑎𝑛𝑛1 𝑥𝑥1 − 𝑎𝑎𝑛𝑛2 𝑥𝑥2 − ⋯ 𝑎𝑎𝑛𝑛,𝑛𝑛−1 𝑥𝑥𝑛𝑛−1 )
𝑎𝑎𝑛𝑛𝑛𝑛
(0) (0) (0) (0)
Then make an initial guess of the solution 𝒙𝒙(0) = (𝑥𝑥1 , 𝑥𝑥2 , 𝑥𝑥3 , … 𝑥𝑥𝑛𝑛 ).
Substitute these values into the right hand side the of the rewritten
(1) (1) (1) (1)
equations to obtain the first approximation, �𝑥𝑥1 , 𝑥𝑥2 , 𝑥𝑥3 , … 𝑥𝑥𝑛𝑛 �.
This accomplishes one iteration.
3
(2) (2) (2) (2)
In the same way, the second approximation �𝑥𝑥1 , 𝑥𝑥2 , 𝑥𝑥3 , … 𝑥𝑥𝑛𝑛 � is
computed by substituting the first approximation’s value
(1) (1) (1) (1)
�𝑥𝑥1 , 𝑥𝑥2 , 𝑥𝑥3 , … 𝑥𝑥𝑛𝑛 � into the right hand side of the rewritten equations.
By repeated iterations, we form a sequence of approximations 𝒙𝒙(𝑘𝑘) =
(𝑘𝑘) (𝑘𝑘) (𝑘𝑘) (𝑘𝑘) 𝑡𝑡
�𝑥𝑥1 , 𝑥𝑥2 , 𝑥𝑥3 , … 𝑥𝑥𝑛𝑛 � , 𝑘𝑘 = 1,2,3, …
(𝑘𝑘)
The Jacobi Method. For each 𝑘𝑘 ≥ 1, generate the components 𝑥𝑥𝑖𝑖 of
𝒙𝒙(𝒌𝒌) from 𝒙𝒙(𝒌𝒌−𝟏𝟏) by
⎡ 𝑛𝑛 ⎤
(𝑘𝑘) 1 ⎢ (𝑘𝑘−1) ⎥,
𝑥𝑥𝑖𝑖 = �(−𝑎𝑎 𝑥𝑥 ) + 𝑏𝑏 for 𝑖𝑖 = 1,2, , … 𝑛𝑛
𝑎𝑎𝑖𝑖𝑖𝑖 ⎢⎢ 𝑖𝑖𝑖𝑖 𝑗𝑗 𝑖𝑖 ⎥
⎥
𝑗𝑗=1,
⎣ 𝑗𝑗≠𝑖𝑖 ⎦
4
Example. Apply the Jacobi method to solve
5𝑥𝑥1 − 2𝑥𝑥2 + 3𝑥𝑥3 = −1
−3𝑥𝑥1 + 9𝑥𝑥2 + 𝑥𝑥3 = 2
2𝑥𝑥1 − 𝑥𝑥2 − 7𝑥𝑥3 = 3
Continue iterations until two successive approximations are identical when
rounded to three significant digits.
Solution
𝑛𝑛 𝑘𝑘 = 0 𝑘𝑘 = 1 𝑘𝑘 = 2 𝑘𝑘 = 3 𝑘𝑘 = 4 𝑘𝑘 = 5 𝑘𝑘 = 6
(𝑘𝑘) 0.000 -0.200 0.146 0.192
𝑥𝑥1
(𝑘𝑘) 0.000 0.222 0.203 0.328
𝑥𝑥2
(𝑘𝑘) 0.000 -0.429 -0.517 -0.416
𝑥𝑥2
5
||𝒙𝒙(𝑘𝑘) −𝒙𝒙(𝑘𝑘−1) ||
When to stop: 1. < 𝜀𝜀; or ��𝒙𝒙(𝑘𝑘) − 𝒙𝒙(𝑘𝑘−1) �� < 𝜀𝜀. Here 𝜀𝜀 is
||𝒙𝒙(𝑘𝑘) ||
||𝒙𝒙(𝑘𝑘) −𝒙𝒙(𝑘𝑘−1) ||
a given small number . Another stopping criterion:
||𝒙𝒙(𝑘𝑘) ||
Definition 7.1 A vector norm on 𝑅𝑅𝑛𝑛 is a function, || ∙ ||, from 𝑅𝑅𝑛𝑛 to 𝑅𝑅
with the properties:
(i) ||𝒙𝒙|| ≥ 0 for all 𝒙𝒙 ∈ 𝑅𝑅𝑛𝑛
(ii) �|𝒙𝒙|� = 0 if and only if 𝒙𝒙 = 𝟎𝟎
(iii)�|𝛼𝛼𝒙𝒙|� = |𝛼𝛼|�|𝒙𝒙|� for all 𝛼𝛼 ∈ 𝑅𝑅 and 𝒙𝒙 ∈ 𝑅𝑅𝑛𝑛
(iv) �|𝒙𝒙 + 𝒚𝒚|� ≤ �|𝒙𝒙|� + ||𝒚𝒚|| for all 𝒙𝒙, 𝒚𝒚 ∈ 𝑅𝑅𝑛𝑛
Definition 7.2 The Euclidean norm 𝑙𝑙2 and the infinity norm 𝑙𝑙∞ for the
vector 𝒙𝒙 = [𝑥𝑥1 , 𝑥𝑥2 , … , 𝑥𝑥𝑛𝑛 ]𝑡𝑡 are defined by
1
𝑛𝑛 2
||𝒙𝒙||2 = �� 𝑥𝑥𝑖𝑖 2 �
𝑖𝑖=1
and
6
||𝒙𝒙||∞ = max |𝑥𝑥𝑖𝑖 |
1≤𝑖𝑖≤𝑛𝑛
Example. Determine the 𝑙𝑙2 and 𝑙𝑙∞ norms of the vector 𝑥𝑥 = (−1,1, −2)𝑡𝑡 .
Solution:
||𝒙𝒙||2 = �(−1)2 + (1)2 + (−2)2 = √6.
7
The Jacobi Method in Matrix Form
Consider to solve an 𝑛𝑛 × 𝑛𝑛 size system of linear equations 𝐴𝐴𝒙𝒙 = 𝒃𝒃 with
𝑎𝑎11 𝑎𝑎12 … 𝑎𝑎1𝑛𝑛 𝑏𝑏1 𝑥𝑥1
𝑎𝑎21 𝑎𝑎22 … 𝑎𝑎2𝑛𝑛 𝑏𝑏2 𝑥𝑥2
𝐴𝐴 = � and 𝒃𝒃 = � � for 𝒙𝒙 = � �.
⋮ ⋮ ⋱ ⋮ � ⋮ ⋮
𝑎𝑎𝑛𝑛1 𝑎𝑎𝑛𝑛2 … 𝑎𝑎𝑛𝑛𝑛𝑛 𝑏𝑏𝑛𝑛 𝑥𝑥𝑛𝑛
We split 𝐴𝐴 into
8
𝑎𝑎11 0 … 0 0 … 0 0
0 𝑎𝑎22 … 0 −𝑎𝑎21 … 0 0
𝐴𝐴 = � �−� �
⋮ ⋮ ⋱ ⋮ ⋮ ⋱ ⋮
0 0 … 𝑎𝑎𝑛𝑛𝑛𝑛 −𝑎𝑎𝑛𝑛1 … −𝑎𝑎𝑛𝑛,𝑛𝑛−1 0
0 −𝑎𝑎12 … −𝑎𝑎1𝑛𝑛
− �0 0 ⋮ � = 𝐷𝐷 − 𝐿𝐿 − 𝑈𝑈
⋮ ⋮ ⋱ −𝑎𝑎𝑛𝑛−1,𝑛𝑛
0 0 … 0
𝑎𝑎11 0 … 0 0 … 0 0
0 𝑎𝑎22 … 0 −𝑎𝑎21 … 0 0
Where 𝐷𝐷 = � � 𝐿𝐿 = � �,
⋮ ⋮ ⋱ ⋮ ⋮ ⋱ ⋮
0 0 … 𝑎𝑎𝑛𝑛𝑛𝑛 −𝑎𝑎𝑛𝑛1 … −𝑎𝑎𝑛𝑛,𝑛𝑛−1 0
9
0 −𝑎𝑎12 … −𝑎𝑎1𝑛𝑛
𝑈𝑈 = �0 0 ⋮ �
⋮ ⋮ ⋱ −𝑎𝑎𝑛𝑛−1,𝑛𝑛
0 0 … 0
𝐴𝐴𝒙𝒙 = 𝒃𝒃 is transformed into (𝐷𝐷 − 𝐿𝐿 − 𝑈𝑈)𝒙𝒙 = 𝒃𝒃.
𝐷𝐷𝒙𝒙 = (𝐿𝐿 + 𝑈𝑈)𝒙𝒙 + 𝒃𝒃
1
⎡𝑎𝑎11 0 … 0⎤
⎢ 1 ⎥
0 … 0⎥
Assume 𝐷𝐷 −1 exists and 𝐷𝐷−1 =⎢ 𝑎𝑎22
⎢ ⋮ ⎥
⎢ ⋮ ⋮ ⋱ 1 ⎥
⎣0 0 … 𝑎𝑎𝑛𝑛𝑛𝑛 ⎦
Then
𝒙𝒙 = 𝐷𝐷−1 (𝐿𝐿 + 𝑈𝑈)𝒙𝒙 + 𝐷𝐷 −1 𝒃𝒃
The matrix form of Jacobi iterative method is
𝒙𝒙(𝑘𝑘) = 𝐷𝐷−1 (𝐿𝐿 + 𝑈𝑈)𝒙𝒙(𝑘𝑘−1) + 𝐷𝐷−1 𝒃𝒃 𝑘𝑘 = 1,2,3, …
10
Define 𝑇𝑇𝑗𝑗 = 𝐷𝐷−1 (𝐿𝐿 + 𝑈𝑈) and 𝒄𝒄 = 𝐷𝐷−1 𝒃𝒃, Jacobi iteration method can also
be written as
𝒙𝒙(𝑘𝑘) = 𝑇𝑇𝑗𝑗 𝒙𝒙(𝑘𝑘−1) + 𝒄𝒄 𝑘𝑘 = 1,2,3, …
12
5𝑥𝑥1 − 2𝑥𝑥2 + 3𝑥𝑥3 = −1
−3𝑥𝑥1 + 9𝑥𝑥2 + 𝑥𝑥3 = 2
2𝑥𝑥1 − 𝑥𝑥2 − 7𝑥𝑥3 = 3
Choose the initial guess 𝑥𝑥1 = 0, 𝑥𝑥2 = 0, 𝑥𝑥3 = 0
𝑛𝑛 𝑘𝑘 = 0 𝑘𝑘 = 1 𝑘𝑘 = 2 𝑘𝑘 = 3 𝑘𝑘 = 4 𝑘𝑘 = 5 𝑘𝑘 = 6
(𝑘𝑘) 0.000 -0.200 0.167
𝑥𝑥 1
(𝑘𝑘) 0.000 0.156 0.334
𝑥𝑥2
(𝑘𝑘) 0.000 -0.508 -0.429
𝑥𝑥2
(𝑘𝑘)
The Gauss-Seidel Method. For each 𝑘𝑘 ≥ 1, generate the components 𝑥𝑥𝑖𝑖
of 𝒙𝒙(𝒌𝒌) from 𝒙𝒙(𝒌𝒌−𝟏𝟏) by
13
𝑖𝑖−1 𝑛𝑛
(𝑘𝑘) 1 (𝑘𝑘) (𝑘𝑘−1)
𝑥𝑥𝑖𝑖 = �− �(𝑎𝑎𝑖𝑖𝑖𝑖 𝑥𝑥𝑗𝑗 ) − � (𝑎𝑎𝑖𝑖𝑖𝑖 𝑥𝑥𝑗𝑗 ) + 𝑏𝑏𝑖𝑖 � , for 𝑖𝑖
𝑎𝑎𝑖𝑖𝑖𝑖
𝑗𝑗=1 𝑗𝑗=𝑖𝑖+1
= 1,2, , … 𝑛𝑛
Namely,
(𝑘𝑘) (𝑘𝑘−1) (𝑘𝑘−1)
𝑎𝑎11 𝑥𝑥1 = −𝑎𝑎12 𝑥𝑥2 − ⋯ − 𝑎𝑎1𝑛𝑛 𝑥𝑥𝑛𝑛 + 𝑏𝑏1
(𝑘𝑘) (𝑘𝑘) (𝑘𝑘−1) (𝑘𝑘−1)
𝑎𝑎22 𝑥𝑥2 = −𝑎𝑎21 𝑥𝑥1 − 𝑎𝑎23 𝑥𝑥3 − ⋯ − 𝑎𝑎2𝑛𝑛 𝑥𝑥𝑛𝑛 + 𝑏𝑏2
(𝑘𝑘) (𝑘𝑘) (𝑘𝑘) (𝑘𝑘−1) (𝑘𝑘−1)
𝑎𝑎33 𝑥𝑥3 = −𝑎𝑎31 𝑥𝑥1 − 𝑎𝑎32 𝑥𝑥2 − 𝑎𝑎34 𝑥𝑥4 − ⋯ − 𝑎𝑎3𝑛𝑛 𝑥𝑥𝑛𝑛 + 𝑏𝑏3
⋮
(𝑘𝑘) (𝑘𝑘) (𝑘𝑘) (𝑘𝑘)
𝑎𝑎𝑛𝑛𝑛𝑛 𝑥𝑥𝑛𝑛 = −𝑎𝑎𝑛𝑛1 𝑥𝑥1 − 𝑎𝑎𝑛𝑛2 𝑥𝑥2 − ⋯ − 𝑎𝑎𝑛𝑛,𝑛𝑛−1 𝑥𝑥𝑛𝑛−1 + 𝑏𝑏𝑛𝑛
14
(𝐷𝐷 − 𝐿𝐿)𝒙𝒙(𝒌𝒌) = 𝑈𝑈𝒙𝒙(𝑘𝑘−1) + 𝒃𝒃
𝒙𝒙(𝒌𝒌) = (𝐷𝐷 − 𝐿𝐿)−1 𝑈𝑈𝒙𝒙(𝑘𝑘−1) + (𝐷𝐷 − 𝐿𝐿)−1 𝒃𝒃
Define 𝑇𝑇𝑔𝑔 = (𝐷𝐷 − 𝐿𝐿)−1 𝑈𝑈 and 𝒄𝒄𝑔𝑔 = (𝐷𝐷 − 𝐿𝐿)−1 𝒃𝒃, Gauss-Seidel method
can be written as
𝒙𝒙(𝑘𝑘) = 𝑇𝑇𝑔𝑔 𝒙𝒙(𝑘𝑘−1) + 𝒄𝒄𝑔𝑔 𝑘𝑘 = 1,2,3, …
Lemma 7.18 If the spectral radius satisfies 𝜌𝜌(𝑇𝑇) < 1, then (𝐼𝐼 − 𝑇𝑇)−1
exists, and
∞
17
Definition 7.8 A matrix norm || ∙ || on 𝑛𝑛 × 𝑛𝑛 matrices is a real-valued
function satisfying
(i) ||𝐴𝐴|| ≥ 0
(ii) �|𝐴𝐴|� = 0 if and only if 𝐴𝐴 = 0
(iii)�|𝛼𝛼𝛼𝛼|� = |𝛼𝛼 |�|𝐴𝐴|�
(iv) �|𝐴𝐴 + 𝐵𝐵|� ≤ �|𝐴𝐴|� + ||𝐵𝐵||
(v) �|𝐴𝐴𝐴𝐴|� ≤ �|𝐴𝐴|�||𝐵𝐵||
Theorem 7.9. If || ∙ || is a vector norm, the induced (or natural) matrix
norm is given by
�|𝐴𝐴|� = max ||𝐴𝐴𝒙𝒙||
�|𝒙𝒙|�=1
18
Theorem 7.11. If 𝐴𝐴 = [𝑎𝑎𝑖𝑖𝑖𝑖 ] is an 𝑛𝑛 × 𝑛𝑛 matrix, then
𝑛𝑛
1 2 −1
Example. Determine �|𝐴𝐴|�∞ for the matrix 𝐴𝐴 = �0 3 −1�
5 −1 1
Corollary 7.20 If �|𝑇𝑇|� < 1 for any natural matrix norm and 𝒄𝒄 is a given
vector, then the sequence {𝒙𝒙(𝑘𝑘) }∞
𝑘𝑘=0 defined by
𝒙𝒙(𝑘𝑘) = 𝑇𝑇𝒙𝒙(𝑘𝑘−1) + 𝒄𝒄 converges, for any 𝒙𝒙(0) ∈ 𝑅𝑅𝑛𝑛 , to a vector 𝒙𝒙 ∈ 𝑅𝑅𝑛𝑛 ,
with 𝒙𝒙 = 𝑇𝑇𝒙𝒙 + 𝒄𝒄 , and the following error bound hold:
(𝑘𝑘) 𝑘𝑘
(i) |�𝒙𝒙 − 𝒙𝒙 �| ≤ �|𝑇𝑇|� |�𝒙𝒙(0) − 𝒙𝒙�|
19
𝑘𝑘
�|𝑇𝑇|�
(ii) |�𝒙𝒙 − 𝒙𝒙(𝑘𝑘) �| ≤ |�𝒙𝒙(1)
− 𝒙𝒙(0) �|
1−||𝑇𝑇||
Theorem 7.21 If 𝐴𝐴 is strictly diagonally dominant, then for any choice of
𝒙𝒙(0) , both the Jacobi and Gauss-Seidel methods give sequences {𝒙𝒙(𝑘𝑘) }∞
𝑘𝑘=0
that converges to the unique solution of 𝐴𝐴𝒙𝒙 = 𝒃𝒃.
Rate of Convergence
Corollary 7.20 (i) implies |�𝒙𝒙 − 𝒙𝒙(𝑘𝑘) �| ≈ 𝜌𝜌(𝑇𝑇)𝑘𝑘 |�𝒙𝒙(0) − 𝒙𝒙�|
Theorem 7.22 (Stein-Rosenberg) If 𝑎𝑎𝑖𝑖𝑖𝑖 ≤ 0, for each 𝑖𝑖 ≠ 𝑗𝑗 and 𝑎𝑎𝑖𝑖𝑖𝑖 ≥ 0,
for each 𝑖𝑖 = 1,2, … , 𝑛𝑛, then one and only one of following statements
holds:
(i) 0 ≤ 𝜌𝜌�𝑇𝑇𝑔𝑔 � < 𝜌𝜌�𝑇𝑇𝑗𝑗 � < 1;
(ii) 1 < 𝜌𝜌�𝑇𝑇𝑗𝑗 � < 𝜌𝜌�𝑇𝑇𝑔𝑔 �;
(iii)𝜌𝜌�𝑇𝑇𝑗𝑗 � = 𝜌𝜌�𝑇𝑇𝑔𝑔 � = 0;
(iv) 𝜌𝜌�𝑇𝑇𝑗𝑗 � = 𝜌𝜌�𝑇𝑇𝑔𝑔 � = 1.
20
21