# 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 way progress diagram shown in Fig. 2.14. We can transcribe this quenched as the regularity 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 primary filthy equations are the bulk balances: the proximate prospect equations are the way specifications. (a) Transcribe a MATLAB program that generates the matrix A and vector b required to unclouded-up the whole control this determined of equations. (b) Transcribe a MATLAB program that unclouded-ups this regularity using natural Gauss estrangement. What happens? How do you placeedtle it?

From the consecrated 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:

%% Unclouded-up straight regularity of eqution Ax=b using Natural Gaussian Estrangement Method

clc; unclouded all; suppress 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 reresolution X

X = zeros(n,1);

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

control 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);

control 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