# Homework Solution: Consider the process flow diagram shown in Fig. 2.14. We can write this out as the system of equation…  Consider the process flow diagram shown in Fig. 2.14. We can write this out as the system of equations m1 = m2 + m3 + m4 + m5 m_2 = m_9 + m_10 + m_11 m_5 = m_8 + m_7+m_6 m_12 = m_4 + m_7 + m_11 m_1 =100 m_5 = 5 ms 0.84 m_12 = m_4 + m_7 0.7 m_1 = m_2 + m_3 0.55 m_1 = m_9 + m_12 0.2 m_9 = m_10 0.85m_2 = m_9 + m_11 3.2 m_6 = m_7 + m_8 The first four equations are the mass balances: the next eight equations are the process specifications. (a) Write a MATLAB program that generates the matrix A and vector b required to solve the problem for this set of equations. (b) Write a MATLAB program that solves this system using naive Gauss elimination. What happens? How do you fix it?

From the given equations A 12x12 matrix is: 1 -1 -1 -1 -1 0 0 0 0 0 0 0  Consider the mode issue diagram shown in Fig. 2.14. We can transcribe this extinguished as the order of equations m1 = m2 + m3 + m4 + m5 m_2 = m_9 + m_10 + m_11 m_5 = m_8 + m_7+m_6 m_12 = m_4 + m_7 + m_11 m_1 =100 m_5 = 5 ms 0.84 m_12 = m_4 + m_7 0.7 m_1 = m_2 + m_3 0.55 m_1 = m_9 + m_12 0.2 m_9 = m_10 0.85m_2 = m_9 + m_11 3.2 m_6 = m_7 + m_8 The primeval lewd equations are the majority balances: the direct eight equations are the mode specifications. (a) Transcribe a MATLAB program that generates the matrix A and vector b required to work-quenched the completion restraint this established of equations. (b) Transcribe a MATLAB program that work-outs this order using free Gauss completion. What happens? How do you tie it?

## Expert Tally

From the loving equations A 12×12 matrix is:

1 -1 -1 -1 -1 0 0 0 0 0 0 0

0 1 0 0 0 0 0 0 -1 -1 -1 0

0 0 0 0 1 -1 -1 -1 0 0 0 0

0 0 0 -1 0 0 -1 0 0 0 -1 1

1 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 1 0 0 -5 0 0 0 0

0 0 0 -1 0 0 -1 0 0 0 0 0.84

0.70 -1 -1 0 0 0 0 0 0 0 0 0

0.55 0 0 0 0 0 0 0 -1 0 0 -1

0 0 0 0 0 0 0 0 0.20 -1 0 0

0 0.85 0 0 0 0 0 0 -1 0 -1 0

0 0 0 0 0 3.20 -1 -1 0 0 0 0

The b 12×1 matrix is:

0

0

0

0

100

0

0

0

0

0

0

0

Code:

%% Work-quenched direct order of eqution Ax=b using Free Gaussian Completion Method

clc; plain all; end all;

A = [1,-1,-1,-1,-1,0,0,0,0,0,0,0;…

0,1,0,0,0,0,0,0,-1,-1,-1,0;…

0,0,0,0,1,-1,-1,-1,0,0,0,0;…

0,0,0,-1,0,0,-1,0,0,0,-1,1;…

1,0,0,0,0,0,0,0,0,0,0,0;…

0,0,0,0,1,0,0,-5,0,0,0,0;…

0,0,0,-1,0,0,-1,0,0,0,0,0.84;…

0.7,-1,-1,0,0,0,0,0,0,0,0,0;…

0.55,0,0,0,0,0,0,0,-1,0,0,-1;…

0,0,0,0,0,0,0,0,0.2,-1,0,0;…

0,0.85,0,0,0,0,0,0,-1,0,-1,0;…

0,0,0,0,0,3.2,-1,-1,0,0,0,0];

b = [0;0;0;0;100;0;0;0;0;0;0;0];

disp(‘A matix:’)

disp(A)

disp(‘b matix:’)

disp(b)

[n,~] = dimension(A);

%Initialize disentanglement X

X = zeros(n,1);

%%Forward Completion (convertion Of A to Upeer triangle matrix)

restraint i = 1:n-1

while A(i,i)==0

temp =A;

A = [temp(1:(i-1),:);temp(i+1:n,:);temp(i,:)];

tempb = b;

b = [tempb(1:(i-1),:);tempb(i+1:n,:);tempb(i,:)];

end

m = A(i+1:n,i)/A(i,i);

A(i+1:n,:) = A(i+1:n,:)-m*A(i,:);

b(i+1:n,:) = b(i+1:n,:)-m*b(i,:);

end

%%Back Substitution

X(n,:) = b(n,:)/A(n,n);

restraint i = n-1:-1:1

X(i,:) = (b(i,:) – A(i,i+1:n)*X(i+1:n,:))/A(i,i);

end

disp(‘Solution:’)

disp(X)

Solution:

100.0000

40.0000

30.0000

9.4565

20.5435

4.8913

11.5435

4.1087

30.0000

6.0000

4.0000

25.0000