Book Image

Mastering Python for Finance

Book Image

Mastering Python for Finance

Overview of this book

Table of Contents (17 chapters)
Mastering Python for Finance
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The bisection method


The bisection method is considered the simplest one-dimensional root-finding algorithm. The general interest is to find the value of a continuous function such that .

Suppose we know the two points of an interval and , where , and that and lie along the continuous function, taking the midpoint of this interval as , where , the bisection method then evaluates this value as f(c).

Let's illustrate the setup of points along a nonlinear function with the following graph:

Since the value of f(a) is negative and f(b) is positive, the bisection method assumes that the root lies somewhere between a and b and gives .

If or is very close to zero by some predetermined error tolerance value, then a root is declared as found. If , then we may conclude that a root exists along the interval and , or interval and otherwise.

On the next evaluation, is replaced as either or accordingly. With the new interval shortened, the bisection method repeats with the same evaluation to determine...