simultaneous linear equations -...
TRANSCRIPT
Simultaneous Linear Equations
2012/12/23 1
Topic: Gauss-Seidel Method
Gauss-Seidel Method
Adalah metode ITERASI
Prosedur dasar:
- Menyelesaikan tiap persamaan linier secara aljabar untuk xi - Menyelesaikan tiap persamaan linier secara aljabar untuk xi
- Membuat nilai asumsi solusi
- Selesaikan untuk tiap xi dan ulangi
- Gunakan perkiraan kesalahan relatif tiap akhir iterasi untuk
mengecek apakah error sudah mencapai angka toleransi.
Gauss-Seidel Method
Kenapa?
Untuk mengatasi round-off error (kesalahan pembulatan).
Metode eliminasi seperti Gaussian Elimination and LU Decomposition(*)
rawan terhadap kesalahan pembulatan.
Gauss-Seidel Method
AlgorithmSistem persamaan linier
11313212111 ... bxaxaxaxa nn =++++
2323222121 ... bxaxaxaxa n2n =++++ 2323222121 ... bxaxaxaxa n2n =++++
nnnnnnn bxaxaxaxa =++++ ...332211
. .
. .
. . Kita mengubah sistem persamaan [A]{X}={B}untuk menyelesaikan x1 dengan persamaan pertama, menyelesaikan x2 dengan persamaan kedua, dan seterusnya.
Gauss-Seidel Method
AlgorithmGeneral Form of each equation
1
11 xacn
j
jj∑=
−1
,11
=−− ∑−
n
j
jjnn xac
11
11
1a
xjj
∑≠=
=
22
21
22
2a
xac
x
j
n
jj
j∑≠=
−
=
1,1
11
1
−−
−≠=
− =nn
njj
na
x
nn
n
njj
jnjn
na
xac
x
∑≠=
−
=1
33
23213133
22
32312122
11
31321211
a
xaxabx
a
xaxabx
a
xaxabx
−−=
−−=
−−=
Menjadi:
Untuk sistem persamaan 3x3
33a
Now we can start the solution process by choosing guesses for the x’s. A simple way to obtain initial guesses is to assume that they are zero. These zeros can be substituted into x1equation to calculate a new
x1=b1/a11.
New x1 is substituted to calculate x2 and x3. The procedure is repeated until the convergence criterion is satisfied:
Batas akhir iterasi
kandiperkenanbaru
lama
i
baru
i
ia x
xxεε p100×
−=
baru
ii x
=
=
t
a
ε
εapproximation error, sering digunakan, seringkali disebut sebagai galat absolut.
True error, kurang berarti. � digunakan Relative error, dalam
prosentase
Gauss-Seidel Method: Example 1
Diketahui sistem persamaan
=
2.279
2.177
8.106
112144
1864
1525
3
2
1
a
a
a
2.279112144 3a
Initial Guess: asumsi nilai awal,
=
5
2
1
3
2
1
a
a
a
Gauss-Seidel Method: Example 1
Tulis ulang untuk aplikasi
Gauss-Seidel
8.1061525 a
25
58.106 32
1
aaa
−−=
=
2.279
2.177
8.106
112144
1864
1525
3
2
1
a
a
a
8
642.177 31
2
aaa
−−=
1
121442.279 21
3
aaa
−−=
Gauss-Seidel Method: Example 1
Masukkan nilai perkiraan awal untuk selesaikan ai
=
2
11
a
a6720.3
25
)5()2(58.106a1 =
−−=
( ) ( )56720.3642.177 −−
=
5
2
3
2
a
a ( ) ( )8510.7
8
56720.3642.177a 2 −=
−−=
( ) ( )36.155
1
8510.7126720.31442.279a 3 −=
−−−=
Initial Guess
Gauss-Seidel Method: Example 1
Finding the absolute relative approximate error
100x
xxnew
i
old
i
new
i
ia ×−
=ε At the end of the first iteration
−=
8510.7
6720.31
a
a
%76.72100x6720.3
0000.16720.31
=−
=ε a
%47.125100x8510.7
0000.28510.72
=−
−−=ε a
%22.103100x36.155
0000.536.1553
=−
−−=ε a
The maximum absolute relative
approximate error is 125.47%
−
−=
36.155
8510.7
3
2
a
a
Gauss-Seidel Method: Example 1
Iteration #2Using
−
−=
36.155
8510.7
6720.3
2
1
a
a
a
( )056.12
25
36.1558510.758.1061 =
−−−=a
the values of ai are found:
− 36.1553a25
( )882.54
8
36.155056.12642.1772 −=
−−=a
( ) ( )34.798
1
882.5412056.121442.2793 −=
−−−=a
from iteration #1
Gauss-Seidel Method: Example 1
Hitung “the absolute relative approximate error”
%542.69100x056.12
6720.3056.121
=−
=∈a
Akhir iterasi kedua
−=
882.54
056.12
2
1
a
a
( )%695.85100x
882.54
8510.7882.542
=−
−−−=∈a
( )%54.80100x
34.798
36.15534.7983
=−
−−−=∈a
−
−=
34.798
882.54
3
2
a
a
Galat absolut terbesar 85.695%
Gauss-Seidel Method: Example 1
Tersukan iterasi, kita dapatkan nilai berikut.
Iteration a1 a2 a3
1
2
3
3.672
12.056
47.182
72.767
67.542
74.448
-7.8510
-54.882
-255.51
125.47
85.695
78.521
-155.36
-798.34
-3448.9
103.22
80.540
76.852
%1a∈ %
2a∈ %3a∈
3
4
5
6
47.182
193.33
800.53
3322.6
74.448
75.595
75.850
75.907
-255.51
-1093.4
-4577.2
-19049
78.521
76.632
76.112
75.971
-3448.9
-14440
-60072
-249580
76.852
76.116
75.962
75.931
! Lho, kok? – Error nya nggak berkurang?
Gauss-Seidel Method: Pitfall
Salahnya dimana?
Contoh tadi mengilustrasikan kemungkinan kesalahan pada Gauss-
Siedel method: tidak semua sistem persamaan akan konvergen.
Is there a fix?Is there a fix?
One class of system of equations always converges: One with a diagonally
dominant coefficient matrix.
Diagonally dominant: [A] in [A] [X] = [C] is diagonally dominant if:
∑≠=
≥n
jj
ijaa
i1
ii ∑≠=
⟩n
ijj
ijii aa1
Untuk semua ‘i’ ; DAN Untuk minimal
sebuah ‘i’
Gauss-Seidel Method: Pitfall
Diagonally dominant: Koefisien pada diagonal harus sama atau lebih besar dari jumlah semua koefisien pada baris itu, dan minimal satu baris harus
memiliki diagonal yang lebih besar dari jumlah koefisien pada baris itu.
Manakah matriks yang diagonally dominant?
[ ]
=
116123
14345
3481.52
A
=
1293496
55323
5634124
]B[
Manakah matriks yang diagonally dominant?
Gauss-Seidel Method: Example 2
Sistem persamaan linier
1 5x -3x 12x 321 =+
28 3x 5x x 321 =++
76 13x 7x 3x 321 =++
Matriks Koefisien nya adalah
[ ]
−
= 351
5312
A76 13x 7x 3x 321 =++
=
1
0
1
3
2
1
x
x
x
Dengan asumsi nilai awal
1373
Akan konvergen kah?
Gauss-Seidel Method: Example 2
[ ]
−
=
1373
351
5312
A
Cek apakah matriks nya diagonally dominant
43155 232122 =+=+≥== aaa
10731313 =+=+≥== aaa
8531212 131211 =−+=+≥== aaa
137310731313 323133 =+=+≥== aaa
Benar. Seharusnya konvergen dengan Gauss-Siedel Method
Gauss-Seidel Method: Example 2
=
−
76
28
1
1373
351
5312
3
2
1
a
a
a
Tulis ulang
531 xx +−
Asumsi nilai awal
=
1
0
1
3
2
1
x
x
x
12
531 32
1
xxx
+−=
5
328 31
2
xxx
−−=
13
7376 21
3
xxx
−−=
( ) ( )50000.0
12
150311 =
+−=x
( ) ( )9000.4
5
135.0282 =
−−=x
( ) ( )0923.3
13
9000.4750000.03763 =
−−=x
Gauss-Seidel Method: Example 2
The absolute relative approximate error
%662.6710050000.0
0000.150000.01a =×
−=∈
09000.4 −%00.100100
9000.4
09000.42a =×
−=∈
%662.671000923.3
0000.10923.33a =×
−=∈
Galat absolut terbesar di akhir iterasi pertama adalah 100%
Gauss-Seidel Method: Example 2
Setelah iterasi #1
Masukkan nilai x pada persamaan Setelah iterasi #2
=
0923.3
9000.4
5000.0
3
2
1
x
x
x
=
8118.3
7153.3
14679.0
3
2
1
x
x
x( ) ( )14679.0
12
0923.359000.4311 =
+−=x
( ) ( )7153.3
5
0923.3314679.0282 =
−−=x
( ) ( )8118.3
13
900.4714679.03763 =
−−=x
Masukkan nilai x pada persamaan Setelah iterasi #2
Gauss-Seidel Method: Example 2
Galat absolut dari Iterasi #2
%62.24010014679.0
50000.014679.01
=×−
=∈a
%887.311007153.3
9000.47153.32
=×−
=∈a %887.311007153.32
=×=∈a
%876.181008118.3
0923.38118.33
=×−
=∈a
Galat absolut maksimum 240.62%
Lebih besar dari iterasi #1. Is this a problem?
Gauss-Seidel Method: Example 2
Ulangi iterasi, didapatkanK
1aε 2aε 3aεIteration a1 a2 a3
1
2
3
0.50000
0.14679
0.74275
67.662
240.62
80.23
4.900
3.7153
3.1644
100.00
31.887
17.409
3.0923
3.8118
3.9708
67.662
18.876
4.00423
4
5
6
0.74275
0.94675
0.99177
0.99919
80.23
21.547
4.5394
0.74260
3.1644
3.0281
3.0034
3.0001
17.409
4.5012
0.82240
0.11000
3.9708
3.9971
4.0001
4.0001
4.0042
0.65798
0.07499
0.00000
=
4
3
1
3
2
1
x
x
x
=
0001.4
0001.3
99919.0
3
2
1
x
x
xHasil akhir Mendekati solusi sejati
Latihan
Sistem persamaan linier
76 13x 7x 3x 321 =++
=++ 28 3x 5x x 321 =++
1 5x - 3x 12x 32 1 =+With an initial guess of
=
1
0
1
3
2
1
x
x
x
Gauss-Seidel Method
The Gauss-Seidel Method can still be used
The coefficient matrix is not
diagonally dominant[ ]
−
=
5312
351
1373
A
But this is the same set of equations
used in example #2, which did
converge.
[ ]
−
=
1373
351
5312
A
If a system of linear equations is not diagonally dominant, check to see if
rearranging the equations can form a diagonally dominant matrix.
Gauss-Seidel Method
Not every system of equations can be rearranged to have a
diagonally dominant coefficient matrix.
Observe the set of equations
3321 =++ xxx 3321 =++ xxx
9432 321 =++ xxx
97 321 =++ xxx
Which equation(s) prevents this set of equation from having a
diagonally dominant coefficient matrix?
Gauss-Seidel Method
Summary
-Advantages of the Gauss-Seidel Method
-Algorithm for the Gauss-Seidel Method
-Pitfalls of the Gauss-Seidel Method
Gauss-Seidel Method
Questions?Questions?
Metode Penyelesaian
�Metode grafik
�Eliminasi Gauss
�Metode Gauss – Jourdan
�Metode Gauss – Seidel
�LU decomposition
LU Decomposition
A=LU
Ax=b ⇒LUx=b
Define Ux=y
Ly=b Solve y by forward substitution
Ux=y Solve x by backward substitution
LU Decomposition by Gaussian elimination
)2()2()2(
)1(
1
)1(
13
)1(
12
)1(
11
00001
00001n
aaa
aaaa
m
L
L
L
There are infinitely many different ways to decompose A.Most popular one: U=Gaussian eliminated matrix
L=Multipliers used for elimination
=
−−−−−−
)(
)(
1
)(
11
)3(
3
)3(
33
)2(
2
)2(
23
)2(
22
4,3,2,1,
3,12,11,1
2,31,3
1,2
0000
000
00
0
1
1
0
001
0001
n
nn
n
nn
n
nn
n
n
nnnn
nnn
a
aa
aa
aaa
mmmm
mmm
mm
m
AMOMMM
L
L
L
ML
MOOMM
L
L
Compact storage: The diagonal entries of L matrix are all 1’s, they don’t need to be stored. LU is stored in a single matrix.
NEXT: Solusi persamaan Non Linier
� Persamaan matematis yang sulit diselesaikan dengan “tangan” � analitis, sehingga diperlukan penyelesaian pendekatan � numerik
� Metode Numerik: Teknik menyelesaikan masalah matematika dengan pengoperasian hitungan, matematika dengan pengoperasian hitungan, umumnya mencakup sejumlah besar kalkulasi aritmetika yang sangat banyak dan menjenuhkan
� Diselesaikan dengan algoritma (serangkaian perintah untuk menyelesaikan masalah), sehingga diperlukan bantuan komputer untuk melaksanakannya
Sumber Galat / Error
� Kesalahan pemodelan
contoh: penggunaan hukum Newton
asumsi benda adalah partikel
� Kesalahan bawaan� Kesalahan bawaan
contoh: kekeliruan dlm menyalin data
salah membaca skala
� Ketidaktepatan data
� Kesalahan pemotongan / penyederhanaan persamaan(truncation error)
� Kesalahan pembulatan (round-off error)
Solusi Persamaan Non Linear
1)Metode Akolade (bracketing method)
/ Closed method
• Metode Bagi dua (Bisection Method)
• Metode Regula Falsi (False Position
Method)
• Metode Grafik
Keuntungan: selalu konvergen
Kerugian: relatif lambat konvergen
Solusi Persamaan Non Linear
2) Metode Terbuka
Contoh: • Iterasi Titik-Tetap (Fix Point Iteration)
• Metode Newton-Raphson• Metode Newton-Raphson
• Metode Secant
Keuntungan: cepat konvergen
Kerugian: tidak selalu konvergen