SOLUTIONS TO HW3 rev - SOLUTIONS TO HW3 Part 1 1 n1 nc2H4 = 75 n2 n0 = 25 for mixing point 2n1 2n3 2n4 = 150 2n2 n3 2n4 n5=50 4n1 4n3 2n5=300 n 1 =

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
SOLUTIONS TO HW3 Part 1 1. n1 + nc2H4 = 75 n2 + n0 = 25 * for mixing point 2n1+ 2n3+2n4 = 150 2n2+n3+2n4+n5=50 4n1+4n3+2n5=300 n 1 = 75(0.8) = 60 n 3 – 4.5n4 = 0 2.A = [1 0 0 0 0 1 0;0 1 0 0 0 0 1;2 0 2 2 0 0 0;0 2 1 2 1 0 0 ;4 0 4 0 2 0 0 ;1 0 0 0 0 0 0;0 0 1 -4.5 0 0 0] b=[75;25;150;50;300;60;0]; x =[n1,n2,n3,n4,n5,n6,n7] 3) Matlab code for Gaussian Elimination function x = mygehw3_nita3(a,b) n = length(b); x = zeros(size(b)); % Forward elimination step of Gauss elimination for k = 1:n-1 if (abs(a(k,k)) < 1e-12) [val, index] = max(abs(a(k+1:n,k))); tmpA = a(k,:); tmpB = b(k); a(k,:) = a(index+k,:); b(k) = b(index+k); a(index+k,:) = tmpA; b(index+k) = tmpB; end % Eliminate our variable in each row for i = k+1:n % Find pivot fctr = a(i,k)/a(k,k); % For each column in the row being eliminated, subtract the initial % value times the pivot for j = k+1:n a(i,j) = a(i,j) - fctr*a(k,j); end % Don't forget to do that for the b vector as well b(i) = b(i) - fctr*b(k); end end % Backward substitution step
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/01/2011 for the course CHBE 2120 taught by Professor Gallivan during the Spring '07 term at Georgia Institute of Technology.

Page1 / 5

SOLUTIONS TO HW3 rev - SOLUTIONS TO HW3 Part 1 1 n1 nc2H4 = 75 n2 n0 = 25 for mixing point 2n1 2n3 2n4 = 150 2n2 n3 2n4 n5=50 4n1 4n3 2n5=300 n 1 =

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online