Solution (source code)

= Solution
{c}

At the left endpoint $f(-1)=36>0$. If $b=2$, the endpoint is exactly a root and the function above immediately returns $2$. For $2<b\leq4$, $f(b)<0$, so the first midpoint is $m=(b-1)/2$.

If $2<b<3$, then $1/2<m<1$ and $f(m)<0$. The first retained bracket is $[-1,m]$, containing only the root zero, so the iterates converge to zero. If $b=3$, the first midpoint is exactly the root one and is returned. If $3<b\leq4$, then $1<m\leq3/2$ and $f(m)>0$. The retained bracket is $[m,b]$, containing only the root two, so the iterates converge to two. Hence
$$
\boxed{\text{returned root}=\begin{cases}
2,&b=2,\\0,&2<b<3,\\1,&b=3,\\2,&3<b\leq4.
\end{cases}}
$$
This illustrates <root selection by bisection with multiple roots in the initial bracket>: bisection guarantees a root, but which root it chooses depends discontinuously on the starting endpoint.