We give an introduction to finding roots using the Bisection Method.

The Intermediate Value Theorem

The Intermediate Value Theorem (IVT) simply states that if is a continuous function on the interval , then it takes on any given value between and . In other words, if is a continuous function, then any horizontal line between and intersects the graph of . Note that this theorem does not give the number or location of such intersections.

The Desmos interactive graph below gives an example of the IVT in action.

We will use the IVT to come up with numerical approximations to solutions of equations of the form .

The Bisection Method

The Bisection Method makes use of the IVT in a special situation: when and are nonzero values of opposite sign.

Suppose you are given a function and you are interested in finding at least one solution to the equation . Furthermore, suppose that , , and is continuous on the interval . Then, by the IVT, we know that our equation has at least one solution in the interval . We can narrow down our search by computing (here is the midpoint of the interval). If , then we found a solution! If , then by the IVT, there is a solution in the interval . Otherwise, if , then by the IVT, there is a solution in the inteval . We can repeat this procedure until we get an approximation that is “close enough” to a solution. At each step, we trim down the length of the inteval containing a solution in half, bounding the size of our possible error to half the size of the remaining interval.

It is possible that we may never find the exact value of a solution or that we may miss some solutions. Try, for example, to use the procedure above to find solutions to on the interval .

We can summarize the Binomial Method using the following flowchart. Here we assume that , is continuous on and .

PIC

Converting this flowchart to code gives the following:

==============================
 
def bisection(a,b,f,error):  
        c = (b+a)/2  
        while c-a > error:  
                if f(c) == 0:  
                        return c  
                elif f(a)*f(c) > 0:  
                        a = c  
                else:  
                        b = c  
                c = (b+a)/2  
        return c  
==============================

Note that we use the fact that implies that both and have the same sign.

The Binomial Method has several advantages and one major disadvantage. It is an algorithm that is relatively easy to code, requires very few assumptions on the function being used, and always converges to some solution (as long as . A big disadvantage of this method is that the convergence to a solution may be very slow compared to other methods (to be seen in the next section).

Note that we can also use the Bisection Method to solve equations of the form by solving with .

Problems

All answers in this section have been rounded to the nearest thousandth.

Use the Bisection Method to estimate the solution to where with an error of at most 0.01.
Use the Bisection Method to give an approximation of with an error of at most 0.01.
Find a simple function such that that is easy to work with.
Do not use , as this would require an approximation of the number you wish to approximate.
Use the Bisection Method to give an approximation of the solution to the equation with an error of at most 0.01.
Remember to use import math in order to use the logarithm.
Use the Bisection Method to give an approximation of all five of the solutions to on the interval . Enter your solutions in increasing order.
Use a graphical tool (like Matplotlib) to get a sense for the locations of the solutions.

Workspace