Anda di halaman 1dari 5

# TUGAS INPUT OUTPUT

Disusun Oleh:

## PROGRAM PASCASARJANA DEPARTEMEN TEKNIK INDUSTRI

FAKULTAS TEKNIK

UNIVERSITAS INDONESIA

2018
TUGAS 7 : INPUT OUTPUT
Soal:

Industri pemerintah
1 2 3 investasi pemerintah expor
1 320 150 210 20 30 70 800
Beli dari 2 80 60 140 10 - 10 300
3 160 210 280 15 20 15 700
Σ buruh dll 400 240 280 60 980

 Tabel diatas disusun menjadi tabel koefisien per unit produk, sebagai berikut:

## Jual kepada 1 2 3 I G X Total

1 0.4 0.5 0.3 20 30 70 800
Beli dari 2 0.1 0.2 0.2 10 - 10 300
3 0.2 0.7 0.4 15 20 15 700
Σ buruh dll 0.5 0.8 0.4 60 0 0 980

## 1 0 0 0.4 0.5 0.3 0.6 -0.5 -0.3

0 1 0 - 0.1 0.2 0.2 = -0.1 0.8 -0.2
0 0 1 0.2 0.7 0.4 -0.2 -0.7 0.6

o (I-A)X ≥ D
o Al X ≤ L
o X≥0

## 0.5X1 + 0.8X2 + 0.4X3 ≥ 1300

 Persamaan diatas kemudian diselesaikan menggunakan program MATLAB dengan rincian sebagai
berikut:
 Program untuk Input Output
% Gauss-Seidel Method in MATLAB

function x = gauss_seidel(A , B)
disp ('Enter the system of linear equations in the form of AX=B')

%Inputting mstrix A

## A = input ( 'Enter matrix A : \n')

% check if the entered matrix is a square matrix

## [na, ma] = size (A);

if na ~= ma
disp('ERROR: Matrix A must be a square matrix')
return
end

%Inputting matrix B

## B = input ( 'Enter matrix B : ')

% check if B is a column matrix

## [nb, mb] = size (B);

if nb ~= na || mb~=1
disp('ERROR: Matrix B must be a column matrix')
return
end

## % Separation of matrix A into lower triangular and upper triangular

% matrices

% A = D + L + U

D = diag(diag(A));
L = tril(A)- D;
U = triu(A)- D;

## % check for convergence condition for Gauss-Seidel method

e= max (eig(-inv(D+L)*(U)));
if abs(e) >=1
disp ('Since the modulus of the largest Eigen value of iterative matrix
is not less than 1')
disp ('this process is not convergen.')
return
end

## % initial guess for X..?

% deault guess is [1 1 .... 1]

## r = input ('Any initial guess for X? (y/n): ','s');

switch r
case 'y'
X0 = input('Enter initial guess for X :\n')
% check for initial guess
[nx, mx] = size(X0);
if nx ~= na || mx ~= 1
disp('ERROR: Check input')
return
end
otherwise
X0 = ones(na,1);
end

## t = input ( 'Enter the error allowable in final answer: ')

tol = t*ones(na,1);
k= 1;

X( : , 1 ) = X0;
err= 1000000000*rand(na,1);% initial error assumption for looping
while sum(abs(err) >= tol) ~= zeros(na,1)
X ( : ,k+ 1 ) = -inv(D+L)*(U)*X( : ,k) + inv(D+L)*B;% Gauss-Seidel
formula
err = X( :,k+1) - X( :, k);% finding error
k = k + 1;

end

## fprintf ('The final answer obtained after %g iterations is \n', k)

X( : ,k)
 Hasil Input Ouput
Enter the system of linear equations in the form of AX=B
Enter matrix A : [0.6 -0.5 -0.3; -0.1 0.8 -0.2; -0.2 -0.7 0.6]

A=
0.6 -0.5 -0.3
-0.1 0.8 -0.2
-0.2 -0.7 0.6

B=
105
40
75

## Any initial guess for X? (y/n): 1

Enter the error allowable in final answer: 0.01

t = 0.01

##  Didapati hasil X1, X2, dan X3 setelah 42 iterasi dimana nilai:

X1 = 1,316.70126351987
X2 = 204.048702758478
X3 = 608.215263510847

### Dapatkan aplikasi gratis kami

Hak cipta © 2021 Scribd Inc.