# The Bisection Method In Python

Hello there. This page is on using Python to find approximate roots with the bisection method.

Sections

What Is The Bisection Method? (Brief)

The Bisection Method In Python

References

What Is The Bisection Method? (Brief)

The Bisection Method belongs to a class of numerical methods found in applied/computational mathematics. There are cases when the exact answer to a question cannot be found. Approximate solutions (with a small acceptable margin of error) are used instead.

Source: Source: http://www.mathwarehouse.com/calculus/continuity/images/bisection-algorithm-basic-idea.png

The Bisection Method In Python

In the Python code, I define one function as an example. This function is .

In the bisection method function, I have the inputs as a, b from the interval [a, b], and the tolerance (margin of error allowed) represented by tol.

Instead of c, I use the variable midpoint.

The output from the bisection method would be the approximate solution to the function. This approximate solution would be off from the exact solution by less than the tolerance.

Here is a function call of the bisection method with with the interval and a tolerance of 0.0001. The round function is used to limit the number of decimals.

References

• Tim Sauer – Numerical Analysis Second Edition
• https://stackoverflow.com/questions/6289646/python-function-as-a-function-argument
• http://code.activestate.com/recipes/578417-bisection-method-in-python/