(algorithm)

**Definition:**
Search a *sorted array* by estimating the next position to check based on the values at the two previous positions checked.

**See also**
*binary search*, *interpolation search*.

*Note:
It is called "secant search" because it uses the secant of the function at two successive points to approximate the derivative in the Newton-Raphson formula. *

To find a *key* k in an array v with indexes from 0 to n-1, begin with x_{0} = 0, x_{1} = n-1, and i = 1. Compute the next position with

x_{i+1} = x_{i} - (v[x_{i}]-k) * (x_{i} - x_{i-1})/(v[x_{i}] - v[x_{i-1}]).

If this lies outside the range, a different method (e.g., midpoint of the range) must be used to get the next position.

Although the theoretical execution time is better than *interpolation search* or *binary search*, coding is tricky, and the gains from faster convergence are offset by higher costs per iteration.

* Richard Harter <cri@tiac.net> January 2001.*

Author: PEB

Go to the Dictionary of Algorithms and Data Structures home page.

If you have suggestions, corrections, or comments, please get in touch with Paul Black.

Entry modified 14 August 2008.

HTML page formatted Fri Feb 23 10:06:08 2018.

Cite this as:

Paul E. Black, "secant search", in
*Dictionary of Algorithms and Data Structures* [online], Vreda Pieterse and Paul E. Black, eds. 14 August 2008. (accessed TODAY)
Available from: https://www.nist.gov/dads/HTML/secantSearch.html