You are on page 1of 6

% soal no 1a

% metode eliminasi gauss


A=[-0.005 1 1;1 2 1;-3 -1 6]
A =
-0.0050
1.0000
-3.0000

1.0000
2.0000
-1.0000

1.0000
1.0000
6.0000

b=[2;4;2]
b =
2
4
2
gauss (A,b)
ans =
0.9840
1.0111
0.9938
% metode LU Decomposition
ludec (A,b)
ans =
0.9840
1.0111
0.9938
% soal no 1b
% metode eliminasi gauss
A=[1 -1 2;2 -2 1;3 -2 7]
A =
1
2
3

-1
-2
-2

2
1
7

b=[5;1;20]
b =
5
1
20
% metode LU Decomposition
ludec (A,b)
ans =
NaN
NaN

NaN
% soal no 1c
% metode eliminasi gauss
A=[1.34 7.2 1.04;3.18 4.01 0.98;2.84 -24.0 -2.24]
A =
1.3400
7.2000
3.1800
4.0100
2.8400 -24.0000

1.0400
0.9800
-2.2400

b=[9.60;8.17;-23.4]
b =
9.6000
8.1700
-23.4000
gauss (A,b)
ans =
0.2913
0.5171
5.2756
% metode LU Decomposition
ludec (A,b)
ans =
0.2913
0.5171
5.2756
% soal no 2
x0=[0;0;0;0]
x0 =
0
0
0
0
A=[5 7 6 5;7 10 8 7;6 8 10 9;5 7 9 10]
A =
5
7
6
5

7
10
8
7

b=[1;-1;-1;1]
b =

6
8
10
9

5
7
9
10

1
-1
-1
1
tol=10e-6
tol =
1.0000e-005
maks=10
maks =
10
maks=50
maks =
50
x=jacobian(A,b,x0,maks)
x =
1.0e+017 *
-1.8536
-1.2899
-1.3075
-1.2143
x=gauss_seidel(A,b,x0,tol,maks)
f x1 x2 x3...
x =
18.9527
-11.6501
-5.2813
3.5319
% soal no 3
x0=[0;0;0;0]
x0 =
0
0
0
0
w=1.75
w =
1.7500

A=[1 2 5 3;2 1 3 -5;-2 -1 5 1;3 3 -1 2]


A =
1
2
-2
3

2
1
-1
3

5
3
5
-1

3
-5
1
2

b=[-3;3;-2;3]
b =
-3
3
-2
3
uiopen('C:\Users\ATIKA\Desktop\120210102106_modul5\SOR.m',1)
uiopen('C:\Users\ATIKA\Desktop\120210102106_modul5\SOR.m',1)
SOR (A,b,x0,w,10e-6,50)
ans =
1.0e+070 *
0.7115
-4.9732
-0.9807
9.0250
SOR (A,b,x0,1.9387,10e-6,75)
ans =
1.0e+106 *
-0.2191
1.5315
0.3020
-2.7793
SOR
{???
Too
}
SOR

(A,b,x0,1,9387,10e-6,150)
Error using ==> SOR
many input arguments.
(A,b,x0,1.9387,10e-6,150)

ans =
1.0e+212 *
0.6399
-4.4725
-0.8820
8.1165
% Kesimpulan : ketika nilai maksimal berbeda akan menghasilkan SOR yang berbeda.
Pada w=1.9387 angtar nilai maks 75 dan 150 hasil matriks yang positif menjadi n
egatif dan yang negatif menjadi positif

uiopen('C:\Users\ATIKA\Desktop\120210102106_modul5\jacobian.m',1)
uiopen('C:\Users\ATIKA\Desktop\120210102106_modul5\gauss_seidel.m',1)
% soal no 4
A=[20 -5 -15;-5 20.1 -10;-15 -20 40.1]
A =
20.0000 -5.0000 -15.0000
-5.0000 20.1000 -10.0000
-15.0000 -20.0000 40.1000
b=[220;0;0]
b =
220
0
0
x0=[0;0;0]
x0 =
0
0
0
uiopen('C:\Users\ATIKA\Desktop\120210102106_modul5\jacobian.m',1)
jacobian (A,b,x0,50)
ans =
30.6626
17.7300
20.3103
uiopen('C:\Users\ATIKA\Desktop\120210102106_modul5\gauss_seidel.m',1)
gauss_seidel (A,b,x0,10e-6,50)
f x1 x2 x3...
metode iterasi gauss seidel telah konvergen
ans =
30.6826
17.7460
20.3282
uiopen('C:\Users\ATIKA\Desktop\120210102106_modul5\SOR.m',1)
uiopen('C:\Users\ATIKA\Desktop\120210102106_modul5\SOR.m',1)
uiopen('C:\Users\ATIKA\Desktop\120210102106_modul5\SOR.m',1)
uiopen('C:\Users\ATIKA\Desktop\120210102106_modul5\SOR.m',1)
uiopen('C:\Users\ATIKA\Desktop\120210102106_modul5\SOR.m',1)
SOR (A,b,x0,1.75,10e-6,50)
metode SOR telah konvergen
ans =
30.6826
17.7460

20.3282
diary off

You might also like