Or, you can use analytical tools.
f = -2*x^3 + x^2 + 0.5*x -8;
Before you do ANYTHING, plot the basic function.
So, when a is zero, the root real found will be near -1.5. You should understand that only when a is between roughly 7 and 8, are there three real roots. For all other values of a, there will be exactly 1 real root.
The value of a adjusts the constant term, and by doing so, it translates the entire curve up or down in y.
faroots = solve(fa,x,'maxdegree',3)
faroots =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1747106/image.png)
Ugh. That really is pretty messy looking. It is actually the second root you want, which is the real root when a==0.
vpa(subs(faroots(2),a,0))
ans = ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1747111/image.png)
Well, there is a tiny imaginary part, but that is just floating point trash. We can plot the root found, as a function of a now.
fplot(real(faroots(2)),[-5,5])