Now we can consider the problem of implementing the body of the loop. As with any loop body, we must make sure that it will eventually make the loop condition become false so that the loop can terminate. The behavior of the loop body, in fact, is determined by the bisection method that we are implementing. Recall how each iteration of the bisection method works:
It looks like the body of the while loop will contain a statement to do the averaging as well as an if statement to reset neg or pos as appropriate. What does our implementation look like now?