I have written this code to implement the bisection method for finding a root of a function:
syms x
f(x) = x^3-2*x^2+5*x-10;
k = -10:10;
plot(k,f(k));
a = -2;
b = 2;
c = 0;
while f(c)~=0
c = a+(b-a/2);
if f(a)*f(c)<0
b = c;
end
if f(b)*f(c)<0
a = c;
end
end
disp(c);
However the programm doesnt stop(it takes too much for it to stop).Do I not implement the bisection method correctly or what is happening?
Here is a picture of the plot of the function from -10:10
The root is obviously 2 but it cant find it.Help appreciated
