Upload
phungnguyet
View
246
Download
4
Embed Size (px)
Citation preview
Gauss-Seidel methodDr. Motilal Panigrahi
Dr. Motilal Panigrahi, Nirma University
Solving system of linear equations
We discussed Gaussian elimination with partial pivoting
Gaussian elimination was an exact method or closed
method
Now we will discuss an open method or iteration method
Dr. Motilal Panigrahi, Nirma University
Gauss–Seidel method
Gauss–Seidel method, also known as the Liebmann
method or the method of successive displacement
It is an iterative method
It is named after the German mathematicians Carl
Friedrich Gauss and Philipp Ludwig von Seidel, and is
similar to the Jacobi method.
Dr. Motilal Panigrahi, Nirma University
Gauss–Seidel method
First we discuss the method and then we will discuss when
the solution converges or diverges.
As noted in the previous slide, method of successive
displacement means first we assume with an initial
solution and then we displace the values successively.
Dr. Motilal Panigrahi, Nirma University
Gauss–Seidel method
We are given a system of equation
𝐴𝑥 = 𝑏
Say 𝑥 = 𝑥1, 𝑥2, … , 𝑥𝑛𝑇
First we make two assumptions,
(i) the diagonal of the matrix is nonzero, that is 𝑎𝑖𝑖 ≠ 0,
For 𝑖 = 1,2,… , 𝑛
(ii) The system has a solution.
Dr. Motilal Panigrahi, Nirma University
Gauss–Seidel method
We write the given system
𝐴𝑥 = 𝑏 (1)
in the following way
𝑥1 =𝑏1−𝑎12𝑥2−⋯−𝑎1𝑛𝑥𝑛
𝑎11… 2.1
𝑥2 =𝑏2−𝑎21𝑥1−𝑎23𝑥3…−𝑎2𝑛𝑥𝑛
𝑎22… 2.2
…
𝑥𝑛 =𝑏𝑛−𝑎𝑛1𝑥1−𝑎𝑛2𝑥2…−𝑎𝑛𝑛−1𝑥𝑛−1
𝑎𝑛𝑛… 2. 𝑛
Dr. Motilal Panigrahi, Nirma University
Gauss–Seidel method
We start with an initial values 𝑥1 = 0, 𝑥2 = 0,… , 𝑥𝑛 = 0
Then we use the equations (2.1) to (2.n) successively.
That in the first iteration
Eqn (2.1) will give the value of 𝑥1(1)
, we use this value of
𝑥1, and the other previous values of 𝑥𝑖′𝑠, in Eqn(2.2) to get
𝑥2(1). Then values 𝑥1
(1), 𝑥2
(1)and the other previous values
of 𝑥𝑖′𝑠, in Eqn(2.3) to get 𝑥3
(1)and so on till we get 𝑥𝑛
(1).
Dr. Motilal Panigrahi, Nirma University
After first iteration
We have got 𝑥1(1), 𝑥2(1)
,…, 𝑥𝑛(1)
.
Then we start the second iteration. And so on.
Dr. Motilal Panigrahi, Nirma University
But when should we stop?
Again as we were doing previously, calculate the
percentage relative error for each variable and find the
maximum among them which should be less than a
tolerance values.
Dr. Motilal Panigrahi, Nirma University
Does the Method always converge?
No.
It depends whether the system is diagonally
dominant or not?
If diagonally dominant then it converges.
Dr. Motilal Panigrahi, Nirma University
Diagonally Dominant
A system
𝑎11𝑥1 + 𝑎12𝑥2 +⋯+ 𝑎1𝑛𝑥𝑛 = 𝑏1𝑎21𝑥1 + 𝑎22𝑥2 +⋯+ 𝑎2𝑛𝑥𝑛 = 𝑏2
…
𝑎𝑛1𝑥1 + 𝑎𝑛2𝑥2 +⋯+ 𝑎𝑛𝑛𝑥𝑛 = 𝑏𝑛
is said to be diagonally dominant if it satisfy
𝑎𝑖𝑖 > 𝑎𝑖1 + 𝑎𝑖2 +⋯+ 𝑎𝑖,𝑖−1 + 𝑎𝑖,𝑖+1 +⋯+ 𝑎𝑖𝑛
For each 𝑖 = 1,2, … , 𝑛Dr. Motilal Panigrahi, Nirma University
That is
𝑎𝑖𝑖 > 𝑗=1,𝑗≠𝑖𝑛 𝑎𝑖𝑗
For 𝑖 = 1,2, … , 𝑛
Then we say that system is diagonally dominant.
Dr. Motilal Panigrahi, Nirma University
Example 1
Solve using Gauss-Seidel method
8𝑥 − 3𝑦 + 2𝑧 = 20
4𝑥 + 11𝑦 − 𝑧 =33
6𝑥 + 3𝑦 + 12𝑧 = 35
Dr. Motilal Panigrahi, Nirma University
Answer
The system in the given example is diagonally
dominant, as
8𝑥 − 3𝑦 + 2𝑧 = 20 8 > −3 + 2 = 5
4𝑥 + 11𝑦 − 𝑧 =33 11 > 4 + −1 = 5
6𝑥 + 3𝑦 + 12𝑧 = 35 12 > 6 + 3 = 9
Dr. Motilal Panigrahi, Nirma University
Rewriting the equations, we get
8𝑥−3𝑦+2𝑧=20⇒ 𝑥 =20+3𝑦−2𝑧
8… (1.a)
4𝑥+11𝑦−𝑧=33⇒ 𝑦 =33−4𝑥+𝑧
11… (1.b)
6𝑥+3𝑦+12𝑧=35⇒ 𝑧 =35−6𝑥−3𝑦
12… (1.c)
Dr. Motilal Panigrahi, Nirma University
Initial values assigned
𝑥(0) = 0, 𝑦(0) = 0, 𝑧(0) = 0
Now use equation (1.a), which gives
Dr. Motilal Panigrahi, Nirma University
First iteration
𝑥(1) =20+3𝑦(0)−2𝑧(0)
8=20
8= 2.5
𝑦(1) =33−4𝑥 1 +𝑧(0)
11=33−4×2.5+0
11=
2.090909
𝑧(1) =35−6𝑥 1 −3𝑦(1)
12=35−6×2.5−3×2.090909
12
= 1.1439394Dr. Motilal Panigrahi, Nirma University
Second iteration
𝑥(2) =20+3×2.090909−2×1.1439394
8=2.998106
𝑦(2) =33−4×2.998106 +1.1439394
11= 2.013774
𝑧(2) =35−6×2.998106 −3×2.013774
12= 0.91417
Dr. Motilal Panigrahi, Nirma University
i=0 i=1 i=2 i=3 i=4 i=5 i=6
𝑥(𝑖) = 0 2.5 2.998106 3.026623 3.016512 3.0166 3.016768
𝑦(𝑖) = 0 2.090909 2.013774 1.982516 1.985607 1.985964 1.985891
𝑧(𝑖) = 0 1.143939 0.91417 0.907726 0.912009 0.911875 0.91181
Dr. Motilal Panigrahi, Nirma University
Percentage error calculation
i=2 i=3 i=4 i=5 i=6
%ea(x) 16.61402 0.942195 0.335179 0.00293 0.005546
%ea(y) 3.830369 1.576674 0.155661 0.017986 0.003675
%ea(z) 25.13419 0.709894 0.469584 0.014639 0.007174
Dr. Motilal Panigrahi, Nirma University
Example 2
Solve using Gauss-Seidel method
10𝑥 − 2𝑦 + 𝑧 = 12
3𝑥 + 9𝑦 − 𝑧 =21
2𝑥 + 3𝑦 + 8𝑧 = 30
Dr. Motilal Panigrahi, Nirma University
Answer
The system in the given example is diagonally
dominant, as
10𝑥 − 2𝑦 + 𝑧 = 12 10 > −2 + 1 = 3
3𝑥 + 9𝑦 − 𝑧 =21 9 > 3 + −1 = 4
2𝑥 + 3𝑦 + 8𝑧 = 30 8 > 2 + 3 = 5
Dr. Motilal Panigrahi, Nirma University
Rewriting the equations, we get
10𝑥 − 2𝑦 + 𝑧 = 12 ⇒ 𝑥 =12+2𝑦−𝑧
10… (2.a)
3𝑥+9𝑦−𝑧=21⇒ 𝑦 =21−3𝑥+𝑧
9… (2.b)
2𝑥+3𝑦+8𝑧=30⇒ 𝑧 =30−2𝑥−3𝑦
8… (2.c)
Dr. Motilal Panigrahi, Nirma University
Initial values assigned
𝑥(0) = 0, 𝑦(0) = 0, 𝑧(0) = 0
Now use equation (2.a), (2.b), (2.c),
which gives
Dr. Motilal Panigrahi, Nirma University
i=0 i=1 i=2 i=3 i=4 i=5 i=6
𝑥(𝑖) = 0 1.2 1.314167 1.379892 1.372959 1.373259 1.373268
𝑦(𝑖) = 0 1.933333 2.198056 2.161946 2.163935 2.163945 2.163933
𝑧(𝑖) = 0 2.725 2.597188 2.594297 2.595284 2.595206 2.595208
Dr. Motilal Panigrahi, Nirma University
Percentage error calculation
i=2 i=3 i=4 i=5 i=6
%ea(x) 8.687381 4.763103 0.504966 0.021792 0.000716
%ea(y) 12.04347 1.670253 0.091956 0.000458 0.000555
%ea(z) 4.921189 0.111406 0.038032 0.003026 7.87E-05
Dr. Motilal Panigrahi, Nirma University