The body of the function will consist in large part of a loop that will compute
a root of f to some tolerance. The first question that arises when
contemplating a loop implementation should be ``What condition will control the
loop?'' And to answer that question, you must answer the question ``What must
be true when the loop terminates?''
Click here for the answer
This is an important point. If we want the difference between pos and
neg to be less than or equal to 1e-5 after the loop terminates, we
must make sure that the loop continues to run as long as the difference is
greater than 1e-5. Now what do we know about the implementation of
bisection?
Click here for the answer
Note that fabs is the C function for finding the absolute value of
a floating-point number.
Joseph L. Zachary
Hamlet Project
Department of Computer Science
University of Utah