Question: Issue with loop

B(4) := x^4 - 4*x^3/(2 + p) - 6*(p - 1)*x^2/((3 + p)*(2 + p)) - 4*p*(p - 5)*x/((4 + p)*(3 + p)*(2 + p)) - (p - 1)*(p^2 - 15*p - 4)/((5 + p)*(4 + p)*(3 + p)*(2 + p));
for p from -1 to 5000 do
    A(p) := fsolve(B(4), x, ':-complex');
end do;
Error, (in fsolve) p is in the equation, and is not solved for
ptlist := [0];
for j from -1 to 5000 do
    ptlist := [op(ptlist), A(j)];
end do;
with(plots);
complexplot(ptlist, x = -1 .. 1.5, y = -0.5 .. 0.5, style = point);


I get an error with this code, but when I replace B(4) with its assignment in fsovle, it works. Why is this, and is there a way I can write B(4) instead of the longer expression x^4 - 4*x^3/(2 + p) - 6*(p - 1)*x^2/((3 + p)*(2 + p)) - 4*p*(p - 5)*x/((4 + p)*(3 + p)*(2 + p)) - (p - 1)*(p^2 - 15*p - 4)/((5 + p)*(4 + p)*(3 + p)*(2 + p)) in the fsolve argument?

Please Wait...