Having trouble determining what I am doing wrong. I don't feel like I am initiallizing x incorrectly, because that is what I am trying to solve for. Not sure if I am making use of ea and es error approximations as well.
code is as follows:
cleara=input('Enter Number'); %User input number
x=sqrt(a);ea=100; %approximate relative error 100 percent
es=0.01; %stopping point for error must be less than
count=1; %iteration beginning
countmax=1000; %max number of iterations allowed
if 0<a %must be positive number
while (count<countmax) && (es<ea) %How is es/ea even a factor???
x=(x+(a/x))/2; %equation to solve for square root
disp(x); %show answer
x_old=x; ea=((x-x_old)/x)*100; count=count+1; endelse msgbox("Enter Positive Number") %number entered not positive
end
Best Answer