hw11_p06 - f_ g_ % open file fid4 =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
clc clear format long f CA0 = 50; CB0 = 20; CC0 = 5; CD0 = 10; K1 = 4E-4; K2 = 3.7E-2; K x0 = [ 1 1 ]; x = x0; tolerance = 0.0001 n = 1; n [xnew(1), xnew(2)] = hw11_p06newton( x(1), x(2), CA0, CB0, CC0, CD0, K1, K2 ); xnew; x while ( abs( xnew(1) - x(1) ) > tolerance | abs( xnew(2) - x(2) ) > tolerance ) x = xnew; [xnew(1), xnew(2)] = hw11_p06newton( x(1), x(2), CA0, CB0, CC0, CD0, K1, K2 ); % xnew n = n + 1; end e disp(n) d f_ = K1*(CA0-2*xnew(1)-xnew(2))^2*(CB0-xnew(1)) - (CC0 +xnew(1) + xnew(2)); g_ = K2*(CA0-2*xnew(1)-xnew(2))*(CD0-xnew(2)) - (CC0 +xnew(1) + xnew(2));
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: f_ g_ % open file fid4 = fopen('hw11_p06_answer.txt','a'); % 'wt' means "write text" if (fid4 < 0) error('could not open file "hw11_p06_answer.txt"'); end; fprintf(fid4,'\n\nInitial guesses are \n'); for i = 1:length(x0) fprintf(fid4,'%15.5f\n',x0(i)); end fprintf(fid4,'Tolerance = %10.3e\n',tolerance); fprintf(fid4,'Number of iteration = %10d\n',n); fprintf(fid4,'Solutions are \n'); for i = 1:length(xnew) fprintf(fid4,'%15.5f\n',xnew(i)); end fclose(fid4); f...
View Full Document

This note was uploaded on 02/22/2010 for the course CHE 348 taught by Professor Chelikowsky during the Spring '08 term at University of Texas at Austin.

Ask a homework question - tutors are online