Metode Gauss-Seidel: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
Tidak ada ringkasan suntingan |
Tidak ada ringkasan suntingan |
||
Baris 21:
LANGKAH-LANGKAH :
:1. Set penghitung iterasi ''k'' = 1
:2. WHILE ''k'' <= ''N'' DO
::(a) FOR ''i'' = 1, 2, 3, ..., ''n'', hitung :<math>
x^{(k)}_i = \frac{1}{a_{ii}} \left(b_i - \sum_{j=1}a_{ij}x_j-\sum_{j=i+1}a_{ij}x_j\right),\, i=1,2,\ldots,n.
</math>
::(b) Set X = (x<sub>1</sub> x<sub>2</sub> x<sub>3</sub> ...x<sub>''n''</sub>)<sup>''T''</sup>
::(c) IF ||X - Y|| < T THEN STOP
::(d) Tambah penghitung iterasi, ''k'' = ''k'' + 1
::(e) FOR ''i'' = 1, 2, 3, ..., ''n'', Set y<sub>i</sub> = x<sub>i</sub>
::(f) Set Y = (y<sub>1</sub> y<sub>2</sub> y<sub>3</sub> ...y<sub>''n''</sub>)<sup>''T''</sup>
:3. Tulis pesan "metode gagal setelah N iterasi"
:4. STOP.
==Implementasi dengan MATLAB==
function [X1,g,h] = seidel(A,b,X0,T,N)
H = X0';
n = length(b);
X1 = X0 ;
|