There seems to be a logic problem in the fixedpoint function.
I don’t usually suggest altering others’ code, but it might be worthwhile to experiment by inserting between these lines:
P0 = p0;
% STEP 1
the line:
success = false;
so that it reads:
P0 = p0;
success = false;
% STEP 1
I cannot guarantee that it will find the real root of your function, since I haven’t run the fixedpoint function or your code with it.
When I used the core MATLAB function roots on your polynomial:
r = roots([1 2 0 -5])
it had one real negative root and two complex roots:
r =
-1.6209e+000 + 1.1826e+000i
-1.6209e+000 - 1.1826e+000i
1.2419e+000 + i