WOLFRAM|DEMONSTRATIONS PROJECT

Finding Roots Using Binary or Interpolation Search

​
quadratic
quadratic 2
cosine
exponential
cubic
steps
1
2
3
4
binary search
interpolation search
|
|
A binary search algorithm is often used to search for a certain element in a sorted sequence. It can also be used to find a point where a function is zero (if the function is monotonic over the interval, there is one such point).
Instead of dividing the interval, an interpolating search (the secant method) uses linear interpolation to guess where the root might be. This method usually converges faster than a binary search (see Details), but each step is computationally more demanding. This Demonstration provides an interactive graphical comparison of the two methods on a set of example functions.