Hello, I am trying to do this exercise of finding a root by using the bisection method and the false position method. But, when compiling, it keeps saying this error. Can someone help me?
the code:
clear all clc
f =@(x)(1.67*cos(40.0))-(2.5*cos(x))+(1.83-cos((40.0-x)));
a0=input('Entre com a primeira aproximação a0:');
b0=input('Entre com a segunda aproximação b0:');
tol=input('Entre com o valor da tolerancia:');
while (abs(b0-a0)>tol)
xm =(a0+b0)/2;
if((f(a0)*f(xm)<0))
b0=xm
else
a0=xm
end
end
fprintf("A Raiz da equação pelo método da bissecção é= %f\n", xm);
f1 = f(a0)
f2= f(b0)
while (abs(b0-a0)>tol)
fr = (((a0)*f1)-((b0)*f2))/(f2-f1);
y=f(fr);
if((f1*y>0))
a0=fr;
f1=y;
else
b0=fr;
f2=y;
end
end
fprintf("%f",fr);