Bite 4.2.1 · Derivative-based Algorithms

The bisection method in optimization: when the slope points the way

A sequential algorithm that, looking only at the sign of the derivative, halves the interval of uncertainty at each iteration.

Image by Roman · Unsplash

The Bisection Method (also known as Bolzano Search) is one of the simplest and most intuitive algorithms in one-dimensional numerical optimization when the function is differentiable. When, besides evaluating the function, we can compute its derivative, we have a very valuable piece of information: the sign of the slope tells us where the minimum lies. The method exploits this idea to discard exactly half of the interval of uncertainty at each iteration, computing the derivative at a single point: the center of the interval.

The idea rests on a classical result of mathematical analysis. In 1817, Bernard Bolzano published a purely analytic proof that a continuous function taking values of opposite sign at the endpoints of an interval vanishes at some intermediate point (Bolzano, 1817), the result we know today as Bolzano’s theorem. Halving the interval again and again, always keeping the half in which the function changes sign, is the most direct way to trap that point.

In optimization, this same idea is applied to the derivative: the minimum of a differentiable function lies where $f’$ changes from negative to positive.

The bisection algorithm

The goal of the algorithm is to minimize a differentiable function $f(x)$ within an initial interval $[a, b]$. For the sign of the derivative to be a reliable guide, $f$ is further assumed to be pseudoconvex on the interval (for example, convex), so that, if $f’(x) = 0$ at some point, that point is a minimum.

The idea: looking where the slope points

At the midpoint of the current interval $[a_k, b_k]$,

\[x_k = \frac{a_k + b_k}{2}\]

the derivative is computed.

  • If $f’(x_k) > 0$, the function is increasing at $x_k$, so the minimum lies to its left and $[x_k, b_k]$ is discarded.
  • If $f’(x_k) < 0$, the function is decreasing at $x_k$, so the minimum lies to its right and $[a_k, x_k]$ is discarded.
  • If $f’(x_k) = 0$, $x_k$ is the minimum and the algorithm stops.

Since the interval is split exactly in half at each iteration, after $n$ iterations its length is:

\[L_n = \frac{b - a}{2^n}\]

Steps of the algorithm

  1. Choice of $n$: Given a tolerance $\varepsilon > 0$ for the length of the final interval, choose the smallest number of iterations $n$ such that: \(\left(\frac{1}{2}\right)^n \leqslant \frac{\varepsilon}{b - a}\)

  2. Interval reduction rule (for $k = 1, \dots, n$):
    • Compute the midpoint $x_k = \frac{a_k + b_k}{2}$ and the value of the derivative $f’(x_k)$.
    • If $f’(x_k) = 0$, the algorithm stops: $x_k$ is the minimum.
    • If $f’(x_k) > 0$, the new interval is $[a_k, x_k]$.
    • If $f’(x_k) < 0$, the new interval is $[x_k, b_k]$.
  3. Result: After $n$ iterations, the minimum is estimated at the midpoint of the final interval.

Pseudocode

The structured algorithmic formulation is presented below, where \(df\) represents the derivative $f’$ of the function:

\begin{algorithm}
\caption{Bisection Method}
\begin{algorithmic}
\PROCEDURE{Bisection}{$$df, a, b, n$$}
    \STATE $$ak = a$$
    \STATE $$bk = b$$
    \FOR{$$k = 1$$ \TO $$n$$}
        \STATE $$xk = (ak + bk) / 2$$
        \STATE $$d = df(xk)$$
        \IF{$$d = 0$$}
            \RETURN $$xk, [xk, xk]$$
        \ELSIF{$$d > 0$$}
            \STATE $$bk = xk$$
        \ELSE
            \STATE $$ak = xk$$
        \ENDIF
    \ENDFOR
    \STATE $$xopt = (ak + bk) / 2$$
    \RETURN $$xopt, [ak, bk]$$
\ENDPROCEDURE
\end{algorithmic}
\end{algorithm}

Numerical example

To study the behavior of the algorithm, let us consider the nonlinear function:

\[f(x) = x^2 - 3.2x + 3\]

on the interval $[a, b] = [0, 3]$, whose derivative is:

\[f'(x) = 2x - 3.2\]

The function is convex, so the method can be applied. Analytically, the exact minimum is located at $x^* = 1.6$ (where $f’(1.6) = 0$) with $f(1.6) = 0.44$.

We fix a tolerance $\varepsilon = 0.05$ for the length of the final interval. Since $\frac{\varepsilon}{b - a} = \frac{0.05}{3} \approx 0.0167$ and $\left(\frac{1}{2}\right)^6 = 0.015625$ is the first power of $\frac{1}{2}$ that falls below it, $n = 6$ iterations are needed.

Iteration 1:

  • Initial interval: $[a_0, b_0] = [0, 3]$ (Length $L_0 = 3$).
  • Midpoint: $x_1 = \frac{0 + 3}{2} = 1.5 \implies f’(1.5) = -0.2$
  • Decision: Since $f’(x_1) < 0$, the function is decreasing at $x_1$, so we discard the region $[0, 1.5]$.
  • New interval: $[a_1, b_1] = [1.5, 3]$ (Length $L_1 = 1.5$).

Iteration 2:

  • Current interval: $[a_1, b_1] = [1.5, 3]$.
  • Midpoint: $x_2 = \frac{1.5 + 3}{2} = 2.25 \implies f’(2.25) = 1.3$
  • Decision: Since $f’(x_2) > 0$, the function is increasing at $x_2$, so we discard the region $[2.25, 3]$.
  • New interval: $[a_2, b_2] = [1.5, 2.25]$ (Length $L_2 = 0.75$).

Proceeding in the same way, the following iterations are obtained:

Iter. $[a_k, b_k]$ $x_k$ $f’(x_k)$ Discarded region New interval $L_k$
1 $[0, 3]$ $1.5$ $-0.2$ $[0, 1.5]$ $[1.5, 3]$ $1.5$
2 $[1.5, 3]$ $2.25$ $1.3$ $[2.25, 3]$ $[1.5, 2.25]$ $0.75$
3 $[1.5, 2.25]$ $1.875$ $0.55$ $[1.875, 2.25]$ $[1.5, 1.875]$ $0.375$
4 $[1.5, 1.875]$ $1.6875$ $0.175$ $[1.6875, 1.875]$ $[1.5, 1.6875]$ $0.1875$
5 $[1.5, 1.6875]$ $1.59375$ $-0.0125$ $[1.5, 1.59375]$ $[1.59375, 1.6875]$ $0.09375$
6 $[1.59375, 1.6875]$ $1.640625$ $0.08125$ $[1.640625, 1.6875]$ $[1.59375, 1.640625]$ $0.046875$

Note iteration 5: the midpoint $x_5 = 1.59375$ is very close to the optimum, but the derivative, although very small, is still negative. The method does not need to know how large the slope is, only its sign, to correctly decide that the minimum lies to the right.

Result: After 6 iterations, with a single evaluation of the derivative in each one, the initial interval of length $3$ has been reduced to $\frac{3}{2^6} = 0.046875 < \varepsilon$, guaranteeing that the optimum $x^* = 1.6$ lies in $[1.59375, 1.640625]$. The final estimate is the midpoint $x_{opt} = 1.6172$, with $f(1.6172) = 0.4403$.

These iterations can be seen graphically in the following figure, where the tangent line at each midpoint shows the sign of the slope:

Technical analysis

Speed of convergence

At each iteration the length of the interval is multiplied by $\frac{1}{2}$, so the method has linear convergence with ratio $\frac{1}{2}$: each iteration adds one more bit of precision about the location of the optimum. The number of iterations needed depends only on the initial length and the tolerance:

\[n = \left\lceil \log_2 \frac{b - a}{\varepsilon} \right\rceil\]

For example, to reach a tolerance $\varepsilon = 10^{-4}$ on the interval $[0, 3]$ we need $2^n \geqslant 30{,}000$, that is, $n = 15$ iterations ($2^{15} = 32{,}768$), whatever the function.

The cost of the derivative

The method performs a single evaluation per iteration, but it is an evaluation of the derivative, not of the function. If $f’$ is known analytically, as in the example, computing it is usually as simple as computing the function itself. However, when the derivative is not available and has to be approximated numerically, for instance by central differences:

\[f'(x) \approx \frac{f(x + h) - f(x - h)}{2h}\]

each iteration actually requires two function evaluations, and the choice of $h$ introduces an error that may lead to the wrong sign when the slope is very small, precisely near the optimum.

Advantages and Limitations

  • Advantages:
    • Exact halving: The interval is split in two at each iteration, with a single evaluation of the derivative.
    • No parameters: It requires no additional parameter beyond the tolerance, and it can be continued for as long as more precision is desired.
    • Robustness: At each iteration the optimum is guaranteed to remain inside the interval, and the number of iterations needed is known in advance.
  • Limitations:
    • Requires the derivative: The function must be differentiable and $f’$ must be computable, which is not always possible or cheap.
    • Demanding assumptions: For the sign of the derivative to be reliable, the function must be pseudoconvex on the interval. Unimodality is not enough, because $f’$ could vanish at a point that is not the minimum.
    • Wasted information: It only uses the sign of the derivative, not its value. An almost zero slope indicates that the optimum is close, but the method treats it just like a steep slope, which is why its convergence is linear.

The Bisection Method sums up in a single question, which way does the function go down?, all the information it needs to move forward. That an idea born to prove the existence of roots at the beginning of the 19th century is still one of the most reliable algorithms in numerical optimization today shows that, sometimes, knowing where to look is enough to find the way.

References

  1. Book · 1817
    Rein analytischer Beweis des Lehrsatzes, dass zwischen je zwey Werthen, die ein entgegengesetztes Resultat gewähren, wenigstens eine reelle Wurzel der Gleichung liege
    Bernard Bolzano
    Gottlieb Haase

Keep following the series

← Previous · 4.1.4Fibonacci Method Chapter 4 Next · 5.1 →KKT Conditions for Problems with Inequalities

How to cite

Cite this post

Martín-Campo, F. Javier (2026). The bisection method in optimization: when the slope points the way. https://www.fjmartincampo.com/blog/2026/bisection/

As a BibTeX entry:

@misc{martín-campo2026the-bisection-method-in-optimization-when-the-slope-points-the-way,
  title   = {The bisection method in optimization: when the slope points the way},
  author  = {Martín-Campo, F. Javier},
  year    = {2026},
  month   = {nov},
  url     = {https://www.fjmartincampo.com/blog/2026/bisection/}
}

This post is published under a CC BY-NC-SA 4.0 license.