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);endwhile(abs(x2-x1)>acc) x3=x1+x2/2; y3=fun(x3); if(y1*y3<0) x2=x3; y2=y3; else x1=x3; y1=y3; endendfprintf('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