i=1;
p0=[0.5 0 0 50];
N=10;
error=0.00001;
syms 'x'
%To simplify the equation,we need to make the coefficients
z1=0.949;
z2=3.439;
z3=18.72;
z4=37.51;
z5=1.169;
%equation for the 4 components
f(x)= [z1*x(1)*(1-x(1)/z2);z3*x(1)*x(4)/(z4+x(4))-1.0617*x(2); z5*x(2);-z3*x(1)*x(4)/(z4+x(4))];
df= diff(f)
while i<= N
p=p0-(f(p0)/df(p0));
if (abs(p-p0))/(abs(p))< error
fprintf('solution is %\n',double(p))
return
end
i=i+1;
p0=p;
end
fprintf('solution did not converge within %d iterationat require precision',N,error)
Best Answer