MATLAB: Dont Know , What is error. It shows busy

dont know reasonerror

The Program is
fun=@(x)cos(x)-1.3*x;
x1=input('Enter The Value of Initial Guess x1 = ');
x2=input('Enter The Value of Initial Guess x2 = ');
acc=input('Enter Accuracy Criteria = ');
y1=fun(x1);
y2=fun(x2);
while(y1*y2>0)
x1=input('Enter The Value of Initial Guess x1 = ');
x2=input('Enter The Value of Initial Guess x2 = ');
y1=fun(x1);
y2=fun(x2);
end
while(abs(x2-x1)>acc)
x3=x1+x2/2;
y3=fun(x3);
if(y1*y3<0)
x2=x3;
y2=y3;
else
x1=x3;
y1=y3;
end
end
fprintf('The Root of Equation is %f ',x3);
after running program and giving input , it shows nothing :
and fun=@(x)cos(x)-1.3*x; also tried fun=inline('(cos(x)-1.3*x)');
but no result …

Best Answer

x3=x1+x2/2;
is wrong. It does not take the value half-way between the two. It can get stuck. Consider that if x1 = 1 and x2 = 2, then 1 + (2/2) = 1+1 = 2, so your x3 would be the same as your x2 and you would get stuck in an infinite loop.