{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Homework 04 Solution

5 here is a little bit of background on the solution

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 00013*h ) = 0.5452 kg/m3. 4.5 Here is a little bit of background on the solution. The matrix that I set up is: [ [ [ What I do is guess x, and then determine y = 0.482-x. Then I determine d 3 by solving the matrix. My target is to find x that satisfies the function f (x) = 0 = d 3 - 50. My code uses a=0.01 and b=0.45 as the initial guesses for the bracket methods. The rest of the code is recycled from Homework 2, problem 2.4a. %ChE2124hw45 – Find d3 by bisection method A=[0.539 0.037 0.010 0.002; 0.391 0.481 0.102 0.018; ... 0.043 0.0 0.320 0.220; 0.027 0.0 0.568 0.76]; B=150*[0.093; 0.187; 0.260; 0.460]; iter=0; maxiter=100; tol=1e-4; a=0.01; b=0.45; A(3,2)=a; A(4,2)=1 -sum(A(1:3,2)); X=A\B; fa=50-X(3); A(3,2)=b; A(4,2)=1 -sum(A(1:3,2)); X=A\B; fb=50-X(3) if fa*fb >0 disp('Error: no solution over interval') else toli=1; while toli>tol xNS=(a+b)/2; toli=(b-a)/2; A(3,2)=xNS; A(4,2)=1 -sum(A(1:3,2)); X=A\B; fxNS=50-X(3); if fxNS==0 disp('exact solution found') break elseif fa*fxNS<0 b=xNS; fb=fxNS; else a=xNS; fa=fxNS; end iter=iter+1; if (iter>=maxiter) fprintf('did not converge in %i iterations \n',iter) break end end fprintf('solution is x = %f\n\n',xNS) end Output: solution is x = 0.405581...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online