Bisecting Functions with the Bisection Search Algorithm
A bisecting search algorithm is a method for bisecting intervals and searching for input values of a continuous function. Data scientists use a bisection search algorithm as a numerical approach to find a quick approximation of a solution.
The algorithm does this by searching and finding the roots of any continuous mathematical function — it’s the simplest root finding method that’s available. This algorithm also functions as an ideal way to quickly find the midpoint in a dataset.
The bisection search algorithm is particularly relevant in cases in which you’re seeking to generate an approximation for a root of an irrational number — a number that has no finite root. In these situations, the algorithm will compute the minimum degree of accuracy that the root approximation needs in order to be valid.
To illustrate how the bisection method could be used in the real world, imagine the physics that cause a hot air balloon to rise. With a hot air balloon, the balloon’s burner heats the air inside the balloon, resulting in a decrease in air density. Since the air inside the balloon is less dense than the atmospheric air, the less dense air (plus the balloon and its passengers) rises.
Using the bisection method to bisect a function describing balloon altitude as a function of mass lifted, it’s possible for you to predict an approximate balloon altitude based on what you know about the mass of the balloon and its passengers.
To get started using bisection search in R, you’d simply define your function and variables. R’s base package can handle bisection procedures just fine. If you prefer working in Python, you can use the bisect method of the SciPy library to get the job done.