Algebra equation with functions, constraints and a graph. Consider the function $f:[1,3]\to\mathbf R$, $f(x)=-x^4+8x^3+ax^2+bx+d$, where $a$, $b$, $d$ are real constants. Find the values of $d$ for which $f$ has 3 stationary points between $x=1$ and $x=3$ and $f(1)=f(3)=0$.

$f(1)=f(3)=0$, then $7+a+b+d=0$ and $135+9a+3b+d=0$. We know that $a=(d-57)/3$ and $b=12-4d/3$. Since there're three roots for the first derivative, by Rolle's theorem there are two roots for second derivative between $[1,3]$. Namely, $-12x^2+48x+2a=0$ has two roots in $[1,3]$, that is $2\pm \sqrt{4+\frac{a}{6}}\in[1,3]$. Solving the equation we know that $-24\le a< -18$, which implies $-15\le d< 3$. We may now solve for the first derivative. Then $f'(1),f'(2-\sqrt{4+\frac{a}{6}})$,$f'(2+ \sqrt{4+\frac{a}{6}}),f'(3)$ have different signs. These can be written as $-2(9+d)/3,-2\sqrt{2}/27(15+d)^{3/2},2\sqrt{2}/27(15+d)^{3/2},2(9+d)/3$. The second one is definitely negative, so the first one should be positive, which means $-15\le d< -9$
