You are on page 1of 2

xa=0

xb=0
fx="0"
function root=HIM(xa, xb, fx)
xa(1,1)=input("Enter the lower-value estimate?
")
xb(1,1)=input("Enter the upper-value estimate?
")
fx=input("Enter the equation(use "")
")
x=xa,fa=evstr(fx)
x=xb,fb=evstr(fx)
k=1;eps=0.000001;fxk=1;
//condition is (fa)(fb)<0
if(fa*fb)<0 then
while(abs(fxk)>eps)
xk(k,1)=(xa(k,1)+xb(k,1))*0.5;
x=xk(k,1),fxk(k,1)=evstr(fx)
if fa*fxk(k,1)<0 then
xb(k+1,1)=xk(k,1);
xa(k+1,1)=xa(k,1);0.4
else
xa(k+1,1)=xk(k,1)
xb(k+1,1)=xb(k,1)
end
k=k+1
end
end
root=[(1:k-1)',xa(1:k-1),xb(1:k-1),xk,fxk]
[(1:k-1)',xa(1:k-1),xb(1:k-1),xk,fxk]
//condition is (fa)(fb)>0

if(fa*fb)>0 then xa=input("new trial value:")


end
endfunction

You might also like